2013-04-05 04:11:11 +02:00
|
|
|
package com.gmail.nossr50.commands;
|
|
|
|
|
2013-03-28 17:57:49 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2013-04-05 04:11:11 +02:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2013-03-28 17:57:49 +01:00
|
|
|
import org.bukkit.command.TabExecutor;
|
2013-05-28 19:33:20 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2013-03-28 17:57:49 +01:00
|
|
|
import org.bukkit.util.StringUtil;
|
2013-04-05 04:11:11 +02:00
|
|
|
|
|
|
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
|
|
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
|
2013-03-28 17:57:49 +01:00
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
|
|
|
|
public class MobhealthCommand implements TabExecutor {
|
|
|
|
private static final List<String> MOB_HEALTHBAR_TYPES;
|
|
|
|
|
|
|
|
static {
|
|
|
|
ArrayList<String> types = new ArrayList<String>();
|
|
|
|
|
|
|
|
for (MobHealthbarType type : MobHealthbarType.values()) {
|
|
|
|
types.add(type.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
Collections.sort(types);
|
|
|
|
MOB_HEALTHBAR_TYPES = ImmutableList.copyOf(types);
|
|
|
|
}
|
2013-04-05 04:11:11 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
if (CommandUtils.noConsoleUsage(sender)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (args.length) {
|
|
|
|
case 1:
|
2013-05-28 19:33:20 +02:00
|
|
|
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
2013-04-05 04:11:11 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
|
|
|
playerProfile.setMobHealthbarType(type);
|
|
|
|
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch (IllegalArgumentException ex) {
|
|
|
|
sender.sendMessage("Invalid type!"); //TODO: Localize
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-03-28 17:57:49 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
|
|
switch (args.length) {
|
|
|
|
case 1:
|
|
|
|
return StringUtil.copyPartialMatches(args[0], MOB_HEALTHBAR_TYPES, new ArrayList<String>(MOB_HEALTHBAR_TYPES.size()));
|
|
|
|
default:
|
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
}
|
2013-04-05 04:11:11 +02:00
|
|
|
}
|