Rewrites a bunch of code to improve the structure as specified in #5, #4, #2, #1

This commit is contained in:
2022-02-18 19:39:20 +01:00
parent d2f152334f
commit 16faa1ddb2
8 changed files with 254 additions and 195 deletions

View File

@ -31,15 +31,14 @@ public class AddCommand implements CommandExecutor {
List<String> arguments = Tokenizer.tokenize(String.join(" ", args));
String id = arguments.get(0);
short line;
double cost;
try {
line = (short) (Short.parseShort(arguments.get(1)) - 1);
cost = Double.parseDouble(arguments.get(2));
} catch (NumberFormatException exception) {
sender.sendMessage("You provided an invalid number");
return false;
}
String permission = arguments.get(2);
OptionState ignoreCase = OptionState.DEFAULT;
OptionState ignoreColor = OptionState.DEFAULT;
if (arguments.size() > 3) {
@ -50,13 +49,14 @@ public class AddCommand implements CommandExecutor {
}
try {
PaidSign sign = new PaidSign(id, line, cost, ignoreCase, ignoreColor);
PaidSign sign = new PaidSign(id, cost, permission, ignoreCase, ignoreColor);
/* TODO: Rewrite the method for comparing if paid signs are duplicated
for (PaidSign similarSign : manager.getPaidSigns(sign.getCleanId(), sign.getLineIndex())) {
if (sign.matches(similarSign)) {
sender.sendMessage("A paid sign with the same id and line already exists");
return false;
}
}
}*/
manager.addPaidSign(sign);
sender.sendMessage("Successfully added new paid sign");
return true;