improve + fit to my needs
This commit is contained in:
parent
dc6c159db3
commit
08137109f4
3 changed files with 20 additions and 14 deletions
|
@ -25,15 +25,8 @@ public class ValidateCommand extends Command {
|
|||
|
||||
final String hash = fullArgs[0];
|
||||
|
||||
if (
|
||||
hash.equals(bot.hashing.getHash(context.splitInput[0], context.sender, true)) ||
|
||||
hash.equals(bot.hashing.getHash(context.splitInput[0], context.sender, false))
|
||||
) return Component.text("Valid hash").color(NamedTextColor.GREEN);
|
||||
|
||||
else if (
|
||||
hash.equals(bot.hashing.getOwnerHash(context.splitInput[0], context.sender, true)) ||
|
||||
hash.equals(bot.hashing.getOwnerHash(context.splitInput[0], context.sender, false))
|
||||
) return Component.text("Valid OwnerHash").color(NamedTextColor.GREEN);
|
||||
if (bot.hashing.isCorrectHash(hash, context.splitInput[0], context.sender)) return Component.text("Valid hash").color(NamedTextColor.GREEN);
|
||||
else if (bot.hashing.isCorrectOwnerHash(hash, context.splitInput[0], context.sender)) return Component.text("Valid OwnerHash").color(NamedTextColor.GREEN);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -143,11 +143,8 @@ public class CommandHandlerPlugin {
|
|||
} else {
|
||||
if (
|
||||
command.trustLevel == TrustLevel.TRUSTED &&
|
||||
// mess?
|
||||
!userHash.equals(bot.hashing.getHash(splitInput[0], context.sender, true)) &&
|
||||
!userHash.equals(bot.hashing.getOwnerHash(splitInput[0], context.sender, true)) &&
|
||||
!userHash.equals(bot.hashing.getHash(splitInput[0], context.sender, false)) &&
|
||||
!userHash.equals(bot.hashing.getOwnerHash(splitInput[0], context.sender, false))
|
||||
!bot.hashing.isCorrectHash(userHash, splitInput[0], context.sender) &&
|
||||
!bot.hashing.isCorrectOwnerHash(userHash, splitInput[0], context.sender)
|
||||
) return Component.text("Invalid hash").color(NamedTextColor.RED);
|
||||
|
||||
if (
|
||||
|
|
|
@ -55,4 +55,20 @@ public class HashingPlugin {
|
|||
) :
|
||||
hash;
|
||||
}
|
||||
|
||||
public boolean isCorrectHash (String hash, String prefix, PlayerEntry sender) {
|
||||
// removes reset section sign
|
||||
if (hash.length() == (16 * 2 /* <-- don't forget, we have the section signs */) + 2 && hash.endsWith("§r")) hash = hash.substring(0, hash.length() - 2);
|
||||
|
||||
return hash.equals(getHash(prefix, sender, true)) ||
|
||||
hash.equals(getHash(prefix, sender, false));
|
||||
}
|
||||
|
||||
public boolean isCorrectOwnerHash (String hash, String prefix, PlayerEntry sender) {
|
||||
// removes reset section sign
|
||||
if (hash.length() == (16 * 2 /* <-- don't forget, we have the section signs */) + 2 && hash.endsWith("§r")) hash = hash.substring(0, hash.length() - 2);
|
||||
|
||||
return hash.equals(getOwnerHash(prefix, sender, true)) ||
|
||||
hash.equals(getOwnerHash(prefix, sender, false));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue