2013-02-01 19:41:26 +01:00
|
|
|
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 org.bukkit.entity.Player;
|
|
|
|
|
2012-06-07 00:02:22 +02:00
|
|
|
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;
|
2013-02-04 18:47:48 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
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
|
|
|
|
2012-04-04 22:12:13 +02:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
switch (args.length) {
|
|
|
|
case 1:
|
2013-02-04 18:47:48 +01:00
|
|
|
if (!args[0].equalsIgnoreCase("reset")) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-01-30 20:10:19 +01:00
|
|
|
|
2013-02-04 18:47:48 +01:00
|
|
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.xprate.reset")) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
2012-04-04 22:12:13 +02:00
|
|
|
|
2013-02-04 18:47:48 +01:00
|
|
|
if (mcMMO.p.isXPEventEnabled()) {
|
|
|
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
2012-04-04 22:12:13 +02:00
|
|
|
}
|
2013-02-04 18:47:48 +01:00
|
|
|
|
|
|
|
mcMMO.p.toggleXpEventEnabled();
|
2012-04-04 22:12:13 +02:00
|
|
|
}
|
|
|
|
|
2013-02-04 18:47:48 +01:00
|
|
|
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
2012-04-04 22:12:13 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 2:
|
2013-02-04 18:47:48 +01:00
|
|
|
if (!Misc.isInt(args[0])) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-04-04 22:12:13 +02:00
|
|
|
|
2013-02-04 18:47:48 +01:00
|
|
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.xprate.set")) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
2012-04-04 22:12:13 +02:00
|
|
|
|
2013-02-04 18:47:48 +01:00
|
|
|
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()) {
|
|
|
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
2012-04-04 22:12:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-02-04 18:47:48 +01:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
2012-04-04 22:12:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2013-02-04 18:47:48 +01:00
|
|
|
return false;
|
2012-04-04 22:12:13 +02:00
|
|
|
}
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|