Skip to content

Commit

Permalink
Fixed replacements.
Browse files Browse the repository at this point in the history
  • Loading branch information
EazyFTW committed Sep 1, 2020
1 parent 01b07aa commit 2934331
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void onCommand(TextChannel channel, Message message, Member member, Strin
.success()
.addField("Email", showEmail ? preorder.getEmail() : obfuscateEmail(preorder.getEmail()), true)
.addField("Transaction ID", showTransactionId ? preorder.getTransactionId() : obfuscateTransactionId(preorder.getTransactionId()), true)
.addField("Plugin", (query.hasAny() ? query.first() + " " : "") + preorder.getPlugin(), true)
.addField("Plugin", (query.hasAny() ? query.first().getAsMention() + " " : "") + preorder.getPlugin(), true)
.addField("Discord Name", preorder.getDiscordName() + " (" + selectedMember.getAsMention() + ")", true)
.send(channel);
}
Expand All @@ -88,14 +88,21 @@ public String obfuscateEmail(String email) {
int index = email.indexOf("@");
if(index == -1) return email;

StringBuilder length = new StringBuilder();
for(int i = 0; i < index - 1; i++) length.append("*");

StringBuilder sb = new StringBuilder(email);
sb.replace(0, index - 1, "*");
sb.replace(0, index - 1, length.toString());
return sb.toString();
}

public String obfuscateTransactionId(String transactionId) {
StringBuilder sb = new StringBuilder(transactionId);
sb.replace(0, (int)(transactionId.length() / 1.5d), "*");

StringBuilder length = new StringBuilder();
for(int i = 0; i < (int)(transactionId.length() / 1.5d); i++) length.append("*");

sb.replace(0, (int)(transactionId.length() / 1.5d), length.toString());
return sb.toString();
}

Expand Down

0 comments on commit 2934331

Please sign in to comment.