Fix compile, avoid hardcoding tree values

This commit is contained in:
vemacs 2015-06-03 08:05:38 -06:00
parent d63e342f78
commit 0c8695a888
2 changed files with 11 additions and 31 deletions

View File

@ -148,7 +148,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
getLogger().warning(tl("versionMismatch", plugin.getDescription().getName())); getLogger().warning(tl("versionMismatch", plugin.getDescription().getName()));
} }
} }
execTimer.mark("BukkitCheck");
for (Method method : Server.class.getDeclaredMethods()) { for (Method method : Server.class.getDeclaredMethods()) {
if (method.getName().endsWith("getOnlinePlayers") && method.getReturnType() == Player[].class) { if (method.getName().endsWith("getOnlinePlayers") && method.getReturnType() == Player[].class) {

View File

@ -1,6 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.LocationUtil; import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location; import org.bukkit.Location;
@ -9,7 +8,6 @@ import org.bukkit.TreeType;
import static com.earth2me.essentials.I18n.tl; import static com.earth2me.essentials.I18n.tl;
public class Commandtree extends EssentialsCommand { public class Commandtree extends EssentialsCommand {
public Commandtree() { public Commandtree() {
super("tree"); super("tree");
@ -17,36 +15,19 @@ public class Commandtree extends EssentialsCommand {
@Override @Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
TreeType tree = TreeType.BIRCH; TreeType tree = null;
try // update check if (args.length < 1) {
{ throw new NotEnoughArgumentsException();
if (args.length < 1) { } else {
throw new NotEnoughArgumentsException(); for (TreeType type : TreeType.values()) {
} else if (args[0].equalsIgnoreCase("birch")) { if (type.name().replace("_", "").equalsIgnoreCase(args[0])) {
tree = TreeType.BIRCH; tree = type;
} else if (args[0].equalsIgnoreCase("redwood")) { break;
tree = TreeType.REDWOOD; }
} else if (args[0].equalsIgnoreCase("tree")) { }
tree = TreeType.TREE; if (tree == null) {
} else if (args[0].equalsIgnoreCase("redmushroom")) {
tree = TreeType.RED_MUSHROOM;
} else if (args[0].equalsIgnoreCase("brownmushroom")) {
tree = TreeType.BROWN_MUSHROOM;
} else if (args[0].equalsIgnoreCase("jungle")) {
tree = TreeType.SMALL_JUNGLE;
} else if (args[0].equalsIgnoreCase("junglebush")) {
tree = TreeType.JUNGLE_BUSH;
} else if (args[0].equalsIgnoreCase("swamp")) {
tree = TreeType.SWAMP;
} else if (args[0].equalsIgnoreCase("acacia")) {
tree = TreeType.ACACIA;
} else if (args[0].equalsIgnoreCase("darkoak")) {
tree = TreeType.DARK_OAK;
} else {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
} catch (java.lang.NoSuchFieldError e) {
Essentials.wrongVersion();
} }
final Location loc = LocationUtil.getTarget(user.getBase()); final Location loc = LocationUtil.getTarget(user.getBase());