From c03765803c3620693adce8f0389929907264df4f Mon Sep 17 00:00:00 2001 From: vemacs Date: Wed, 3 Jun 2015 14:03:26 -0600 Subject: [PATCH] Move to switch statement (Java 7 sugar) --- .../essentials/perm/GroupManagerHandler.java | 5 +-- .../essentials/perm/PermissionsHandler.java | 31 ++++++++++++------- .../essentials/utils/SpawnerUtil.java | 1 - 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java b/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java index 472eef037..fd53a3215 100644 --- a/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.perm; import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder; import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -10,8 +11,8 @@ import org.bukkit.plugin.Plugin; public class GroupManagerHandler extends AbstractVaultHandler { private final transient GroupManager groupManager; - public GroupManagerHandler(final Plugin permissionsPlugin) { - groupManager = ((GroupManager) permissionsPlugin); + public GroupManagerHandler() { + groupManager = ((GroupManager) Bukkit.getPluginManager().getPlugin("GroupManager")); } @Override diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java index 5e3c26a78..c26250ad7 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java @@ -110,18 +110,25 @@ public class PermissionsHandler implements IPermissionsHandler { if (!(handler instanceof AbstractVaultHandler)) { AbstractVaultHandler vaultHandler; // No switch statements for Strings, this is Java 6 - if (enabledPermsPlugin.equals("PermissionsEx")) { - vaultHandler = new PermissionsExHandler(); - } else if (enabledPermsPlugin.equals("GroupManager")) { - vaultHandler = new GroupManagerHandler(pluginManager.getPlugin(enabledPermsPlugin)); - } else if (enabledPermsPlugin.equals("SimplyPerms")) { - vaultHandler = new SimplyPermsHandler(); - } else if (enabledPermsPlugin.equals("Privileges")) { - vaultHandler = new PrivilegesHandler(); - } else if (enabledPermsPlugin.equals("bPermissions")) { - vaultHandler = new BPermissions2Handler(); - } else { - vaultHandler = new GenericVaultHandler(); + switch (enabledPermsPlugin) { + case "PermissionsEx": + vaultHandler = new PermissionsExHandler(); + break; + case "GroupManager": + vaultHandler = new GroupManagerHandler(); + break; + case "SimplyPerms": + vaultHandler = new SimplyPermsHandler(); + break; + case "Privileges": + vaultHandler = new PrivilegesHandler(); + break; + case "bPermissions": + vaultHandler = new BPermissions2Handler(); + break; + default: + vaultHandler = new GenericVaultHandler(); + break; } if (enabledPermsPlugin.equals("")) { enabledPermsPlugin = "generic"; diff --git a/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java b/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java index 3dcf41413..a57cd901a 100644 --- a/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java @@ -68,7 +68,6 @@ public class SpawnerUtil { } public EntityType getEntityType(ItemStack is) { - ItemMeta meta = is.getItemMeta(); if (useMeta) { BlockStateMeta bsm = (BlockStateMeta) is.getItemMeta(); CreatureSpawner bs = (CreatureSpawner) bsm.getBlockState();