mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 21:15:28 +02:00
Clean up on all of our commands. Abstracted experience commands and
hardcore commands. Moved lots of duplicated code to functions in CommandUtils.java. Split /ptp into individual commands, just like /party. Used ternary logic to simplify some of our /skillname stat displays. Fixed skill guide to not allow for negative pages. Simplified logic for many /skillname data calculations. Use permission checks to prevent calculating data that will never be displayed. Made the skill guide into its own command.
This commit is contained in:
@@ -8,10 +8,14 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
private double originalRate;
|
||||
|
||||
public XprateCommand() {
|
||||
originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -35,8 +39,8 @@ public class XprateCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!StringUtils.isInt(args[0])) {
|
||||
return false;
|
||||
if (CommandUtils.isInvalidInteger(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.xprateSet(sender)) {
|
||||
@@ -44,11 +48,16 @@ public class XprateCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
||||
if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
mcMMO.p.setXPEventEnabled(false);
|
||||
}
|
||||
else if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
mcMMO.p.setXPEventEnabled(true);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||
int newXpRate = Integer.parseInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
|
Reference in New Issue
Block a user