2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands;
|
|
|
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2013-03-12 21:25:42 +01:00
|
|
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
|
|
|
|
public class McgodCommand implements CommandExecutor {
|
2013-03-12 21:25:42 +01:00
|
|
|
private McMMOPlayer mcMMOPlayer;
|
|
|
|
private Player player;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
switch (args.length) {
|
|
|
|
case 0:
|
2013-03-12 21:25:42 +01:00
|
|
|
if (CommandUtils.noConsoleUsage(sender)) {
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
if (!Permissions.mcgod(sender)) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
|
|
|
player = mcMMOPlayer.getPlayer();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
toggleGodMode();
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (!Permissions.mcgodOthers(sender)) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-22 19:08:10 +01:00
|
|
|
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
player = mcMMOPlayer.getPlayer();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
if (CommandUtils.isOffline(sender, player)) {
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
toggleGodMode();
|
|
|
|
sender.sendMessage("God mode has been toggled for" + args[0]); // TODO: Localize
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-03-12 21:25:42 +01:00
|
|
|
|
|
|
|
private void toggleGodMode() {
|
|
|
|
if (mcMMOPlayer.getGodMode()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
|
|
|
}
|
|
|
|
|
|
|
|
mcMMOPlayer.toggleGodMode();
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|