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

52 lines
1.2 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User;
2013-06-08 21:31:19 +00:00
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
import org.bukkit.TreeType;
public class Commandbigtree extends EssentialsCommand
{
public Commandbigtree()
{
super("bigtree");
}
@Override
2011-11-18 12:06:59 +00:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
TreeType tree;
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
{
tree = TreeType.TALL_REDWOOD;
}
else if (args.length > 0 && args[0].equalsIgnoreCase("tree"))
{
tree = TreeType.BIG_TREE;
}
2012-03-22 17:25:13 +00:00
else if (args.length > 0 && args[0].equalsIgnoreCase("jungle"))
{
tree = TreeType.JUNGLE;
}
else
{
throw new NotEnoughArgumentsException();
}
2011-11-18 12:06:59 +00:00
2013-07-07 11:11:57 +00:00
final Location loc = LocationUtil.getTarget(user.getBase());
2013-06-08 21:31:19 +00:00
final Location safeLocation = LocationUtil.getSafeDestination(loc);
2011-11-15 21:50:09 +00:00
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(tl("bigTreeSuccess"));
}
else
{
throw new Exception(tl("bigTreeFailure"));
}
}
}