From 29343314bf6e82aa42283b9e5c25459f9913d676 Mon Sep 17 00:00:00 2001 From: EazyFTW Date: Tue, 1 Sep 2020 15:59:21 -0500 Subject: [PATCH] Fixed replacements. --- .../TechDiscordBot/module/cmds/PreorderCommand.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java index 66abf52e..eb581151 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java @@ -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); } @@ -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(); }