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.datatypes.player.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
|
|
|
|
public class McabilityCommand implements CommandExecutor {
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
2013-03-03 17:06:05 +01:00
|
|
|
McMMOPlayer mcMMOPlayer;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
switch (args.length) {
|
|
|
|
case 0:
|
|
|
|
if (!Permissions.mcability(sender)) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
if (mcMMOPlayer.getAbilityUse()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
|
|
|
}
|
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
mcMMOPlayer.toggleAbilityUse();
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (!Permissions.mcabilityOthers(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
|
|
|
|
|
|
|
if (mcMMOPlayer == null) {
|
2013-03-03 17:06:05 +01:00
|
|
|
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
if (!playerProfile.isLoaded()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player player = mcMMOPlayer.getPlayer();
|
|
|
|
|
|
|
|
if (!player.isOnline()) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
if (mcMMOPlayer.getAbilityUse()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
|
|
|
}
|
|
|
|
|
2013-03-03 17:06:05 +01:00
|
|
|
mcMMOPlayer.toggleAbilityUse();
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|