Skip to content

Commit

Permalink
Merge pull request #34 from diademiemi:diademiemi/issue15
Browse files Browse the repository at this point in the history
Handle no arguments on config forget
  • Loading branch information
x86-39 authored Jan 15, 2022
2 parents e3c401c + aafdaed commit 5505aeb
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/main/java/me/diademiemi/lineation/command/CommandExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,36 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
break;
case "maxwins":
if (sender.hasPermission("lineation.maxwins")) {
try {
int i = Integer.parseInt(args[2]);
Config.getPluginConfig().getConfig().set("maxwins", i);
sender.sendMessage(Message.SUCCESS_OPTION_SET);
} catch (Exception e) {
sender.sendMessage(Message.ERROR_UNKNOWN_ARGS);
}
if (args.length > 2) {
try {
int i = Integer.parseInt(args[2]);
Config.getPluginConfig().getConfig().set("maxwins", i);
sender.sendMessage(Message.SUCCESS_OPTION_SET);
} catch (Exception e) {
sender.sendMessage(Message.ERROR_UNKNOWN_ARGS);
}
} else sender.sendMessage(Message.ERROR_UNKNOWN_ARGS);
} else sender.sendMessage(Message.ERROR_NO_PERMS);
break;
case "forget":
if (sender.hasPermission("lineation.forget")) {
try {
if (Config.getData().getConfig().isInt(args[2])) {
Config.getData().getConfig().set(args[2], null);
sender.sendMessage(Message.SUCCESS_PLAYER_FORGOTTEN.replace("$PLAYER$", args[2]));
} else if (args[2].equals("all")) {
Lineation.getInstance().saveResource("data.yml", true);
Config.getData().reloadConfig();
sender.sendMessage(Message.SUCCESS_PLAYER_FORGOTTEN.replace("$PLAYER$", args[2]));
} else if (Config.getData().getConfig().isInt(Bukkit.getPlayer(args[2]).getUniqueId().toString())) {
Config.getData().getConfig().set(Bukkit.getPlayer(args[2]).getUniqueId().toString(), null);
sender.sendMessage(Message.SUCCESS_PLAYER_FORGOTTEN.replace("$PLAYER$", args[2]));
} else sender.sendMessage(Message.ERROR_UNKNOWN_PLAYER.replace("$PLAYER$", args[2]));
} catch (Exception e) {
sender.sendMessage(Message.ERROR_UNKNOWN_PLAYER.replace("$PLAYER$", args[2]));
}
if (args.length > 2) {
try {
if (Config.getData().getConfig().isInt(args[2])) {
Config.getData().getConfig().set(args[2], null);
sender.sendMessage(Message.SUCCESS_PLAYER_FORGOTTEN.replace("$PLAYER$", args[2]));
} else if (args[2].equals("all")) {
Lineation.getInstance().saveResource("data.yml", true);
Config.getData().reloadConfig();
sender.sendMessage(Message.SUCCESS_PLAYER_FORGOTTEN.replace("$PLAYER$", args[2]));
} else if (Config.getData().getConfig().isInt(Bukkit.getPlayer(args[2]).getUniqueId().toString())) {
Config.getData().getConfig().set(Bukkit.getPlayer(args[2]).getUniqueId().toString(), null);
sender.sendMessage(Message.SUCCESS_PLAYER_FORGOTTEN.replace("$PLAYER$", args[2]));
} else sender.sendMessage(Message.ERROR_UNKNOWN_PLAYER.replace("$PLAYER$", args[2]));
} catch (Exception e) {
sender.sendMessage(Message.ERROR_UNKNOWN_PLAYER.replace("$PLAYER$", args[2]));
}
} else sender.sendMessage(Message.ERROR_UNKNOWN_ARGS);
} else sender.sendMessage(Message.ERROR_NO_PERMS);
break;
default:
Expand Down

0 comments on commit 5505aeb

Please sign in to comment.