mcMMO/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java

69 lines
2.4 KiB
Java
Raw Normal View History

package com.gmail.nossr50.commands.admin;
2012-01-09 20:00:13 +01:00
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
2012-04-26 16:27:57 +02:00
import com.gmail.nossr50.config.Config;
2012-04-27 11:47:11 +02:00
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
2012-01-09 20:00:13 +01:00
public class XprateCommand implements CommandExecutor {
2013-01-26 23:01:55 +01:00
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
2012-04-21 00:09:50 +02:00
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (!args[0].equalsIgnoreCase("reset")) {
return false;
}
2013-02-13 03:06:36 +01:00
if (!sender.hasPermission("mcmmo.commands.xprate.reset")) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (mcMMO.p.isXPEventEnabled()) {
2013-02-13 05:06:31 +01:00
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
mcMMO.p.toggleXpEventEnabled();
}
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
return true;
case 2:
if (!Misc.isInt(args[0])) {
return false;
}
2013-02-13 03:06:36 +01:00
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 = Misc.getInt(args[0]);
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) {
2013-02-13 05:06:31 +01:00
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;
}
}
2012-01-09 20:00:13 +01:00
}