mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
2ad73e9b2c
String-related util functions from Misc.java to StringUtils.java
69 lines
2.4 KiB
Java
69 lines
2.4 KiB
Java
package com.gmail.nossr50.commands.admin;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
import com.gmail.nossr50.util.StringUtils;
|
|
|
|
public class XprateCommand implements CommandExecutor {
|
|
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
|
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
switch (args.length) {
|
|
case 1:
|
|
if (!args[0].equalsIgnoreCase("reset")) {
|
|
return false;
|
|
}
|
|
|
|
if (!sender.hasPermission("mcmmo.commands.xprate.reset")) {
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
return true;
|
|
}
|
|
|
|
if (mcMMO.p.isXPEventEnabled()) {
|
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
|
|
mcMMO.p.toggleXpEventEnabled();
|
|
}
|
|
|
|
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
|
return true;
|
|
|
|
case 2:
|
|
if (!StringUtils.isInt(args[0])) {
|
|
return false;
|
|
}
|
|
|
|
if (!sender.hasPermission("mcmmo.commands.xprate.set")) {
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
return true;
|
|
}
|
|
|
|
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
|
return false;
|
|
}
|
|
|
|
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
|
int newXpRate = Integer.parseInt(args[0]);
|
|
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
|
|
|
if (mcMMO.p.isXPEventEnabled()) {
|
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
|
}
|
|
else {
|
|
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
|
}
|
|
|
|
return true;
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
}
|