TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
snowleo 117d938ac5 Several bug fixes and cleanup.
Found using PMD and FindBugs.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1553 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-01 10:40:12 +00:00

39 lines
985 B
Java

package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandpowertool extends EssentialsCommand
{
public Commandpowertool()
{
super("powertool");
}
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
ItemStack is = user.getItemInHand();
if (is == null || is.getType() == Material.AIR)
{
user.sendMessage(Util.i18n("powerToolAir"));
return;
}
String command = getFinalArg(args, 0);
if (command != null && !command.isEmpty())
{
user.sendMessage(Util.format("powerToolAttach",is.getType().toString().toLowerCase().replaceAll("_", " ")));
}
else
{
user.sendMessage(Util.format("powerToolRemove", is.getType().toString().toLowerCase().replaceAll("_", " ")));
}
charge(user);
user.setPowertool(is, command);
}
}