TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandtree.java

55 lines
1.1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
2011-11-18 17:42:26 +00:00
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.TreeType;
public class Commandtree extends EssentialsCommand
{
public Commandtree()
{
super("tree");
}
@Override
2011-11-18 19:30:05 +00:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
2011-11-15 21:50:09 +00:00
TreeType tree;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
else if (args[0].equalsIgnoreCase("birch"))
{
tree = TreeType.BIRCH;
}
else if (args[0].equalsIgnoreCase("redwood"))
{
tree = TreeType.REDWOOD;
}
else if (args[0].equalsIgnoreCase("tree"))
{
tree = TreeType.TREE;
}
else
{
throw new NotEnoughArgumentsException();
}
2011-11-15 21:50:09 +00:00
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
2011-11-15 21:50:09 +00:00
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(Util.i18n("treeSpawned"));
}
else
{
user.sendMessage(Util.i18n("treeFailure"));
}
}
}