Current work
This commit is contained in:
		| @@ -111,7 +111,6 @@ MonstersIgnoreDisguises: false | |||||||
| # Works only for disguised players when attacked by a entity (arrow, monster. etc) | # Works only for disguised players when attacked by a entity (arrow, monster. etc) | ||||||
| # This will blow all disguises he has on him | # This will blow all disguises he has on him | ||||||
| BlowDisguises: false | BlowDisguises: false | ||||||
| BlownDisguiseMessage: '&cYour disguise was blown!' |  | ||||||
|  |  | ||||||
| #Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected! | #Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected! | ||||||
| StopShulkerDisguisesFromMoving: true | StopShulkerDisguisesFromMoving: true | ||||||
|   | |||||||
| @@ -26,9 +26,8 @@ public class DisguiseConfig { | |||||||
|     private static boolean collectEnabled; |     private static boolean collectEnabled; | ||||||
|     private static boolean colorizeSheep; |     private static boolean colorizeSheep; | ||||||
|     private static boolean colorizeWolf; |     private static boolean colorizeWolf; | ||||||
|     private static HashMap<String, Disguise> customDisguises = new HashMap<String, Disguise>(); |     private static HashMap<String, Disguise> customDisguises = new HashMap<>(); | ||||||
|     private static boolean disableInvisibility; |     private static boolean disableInvisibility; | ||||||
|     private static String disguiseBlownMessage; |  | ||||||
|     private static int disguiseCloneExpire; |     private static int disguiseCloneExpire; | ||||||
|     private static int disguiseEntityExpire; |     private static int disguiseEntityExpire; | ||||||
|     private static boolean displayPlayerDisguisesInTab; |     private static boolean displayPlayerDisguisesInTab; | ||||||
| @@ -52,7 +51,6 @@ public class DisguiseConfig { | |||||||
|     private static boolean stopShulkerDisguisesFromMoving; |     private static boolean stopShulkerDisguisesFromMoving; | ||||||
|     private static boolean targetDisguises; |     private static boolean targetDisguises; | ||||||
|     private static boolean undisguiseSwitchWorlds; |     private static boolean undisguiseSwitchWorlds; | ||||||
|     private static String updateMessage = ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED + "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED + ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"; |  | ||||||
|     private static String updateNotificationPermission; |     private static String updateNotificationPermission; | ||||||
|     private static boolean viewSelfDisguise; |     private static boolean viewSelfDisguise; | ||||||
|     private static boolean witherSkullEnabled; |     private static boolean witherSkullEnabled; | ||||||
| @@ -65,8 +63,8 @@ public class DisguiseConfig { | |||||||
|  |  | ||||||
|     public static Entry<String, Disguise> getCustomDisguise(String disguise) { |     public static Entry<String, Disguise> getCustomDisguise(String disguise) { | ||||||
|         for (Entry<String, Disguise> entry : customDisguises.entrySet()) { |         for (Entry<String, Disguise> entry : customDisguises.entrySet()) { | ||||||
|             if (!entry.getKey().equalsIgnoreCase(disguise) && !entry.getKey().replaceAll("_", "").equalsIgnoreCase( |             if (!entry.getKey().equalsIgnoreCase(disguise) && !entry.getKey().replaceAll("_", "") | ||||||
|                     disguise)) |                     .equalsIgnoreCase(disguise)) | ||||||
|                 continue; |                 continue; | ||||||
|  |  | ||||||
|             return entry; |             return entry; | ||||||
| @@ -109,10 +107,6 @@ public class DisguiseConfig { | |||||||
|         return customDisguises; |         return customDisguises; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static String getDisguiseBlownMessage() { |  | ||||||
|         return disguiseBlownMessage; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static int getDisguiseCloneExpire() { |     public static int getDisguiseCloneExpire() { | ||||||
|         return disguiseCloneExpire; |         return disguiseCloneExpire; | ||||||
|     } |     } | ||||||
| @@ -125,10 +119,6 @@ public class DisguiseConfig { | |||||||
|         return maxClonedDisguises; |         return maxClonedDisguises; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static String getUpdateMessage() { |  | ||||||
|         return updateMessage; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static String getUpdateNotificationPermission() { |     public static String getUpdateNotificationPermission() { | ||||||
|         return updateNotificationPermission; |         return updateNotificationPermission; | ||||||
|     } |     } | ||||||
| @@ -165,7 +155,6 @@ public class DisguiseConfig { | |||||||
|         setModifyBoundingBox(config.getBoolean("ModifyBoundingBox")); |         setModifyBoundingBox(config.getBoolean("ModifyBoundingBox")); | ||||||
|         setMonstersIgnoreDisguises(config.getBoolean("MonstersIgnoreDisguises")); |         setMonstersIgnoreDisguises(config.getBoolean("MonstersIgnoreDisguises")); | ||||||
|         setDisguiseBlownOnAttack(config.getBoolean("BlowDisguises")); |         setDisguiseBlownOnAttack(config.getBoolean("BlowDisguises")); | ||||||
|         setDisguiseBlownMessage(ChatColor.translateAlternateColorCodes('&', config.getString("BlownDisguiseMessage"))); |  | ||||||
|         setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath")); |         setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath")); | ||||||
|         setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving")); |         setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving")); | ||||||
|         setMovementPacketsEnabled(config.getBoolean("PacketsEnabled.Movement")); |         setMovementPacketsEnabled(config.getBoolean("PacketsEnabled.Movement")); | ||||||
| @@ -195,8 +184,8 @@ public class DisguiseConfig { | |||||||
|         setUseTranslations(config.getBoolean("Translations")); |         setUseTranslations(config.getBoolean("Translations")); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             String option = config.getString("SelfDisguisesScoreboard", |             String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name()) | ||||||
|                     DisguisePushing.MODIFY_SCOREBOARD.name()).toUpperCase(); |                     .toUpperCase(); | ||||||
|  |  | ||||||
|             if (!option.endsWith("_SCOREBOARD")) |             if (!option.endsWith("_SCOREBOARD")) | ||||||
|                 option += "_SCOREBOARD"; |                 option += "_SCOREBOARD"; | ||||||
| @@ -204,8 +193,8 @@ public class DisguiseConfig { | |||||||
|             disablePushing = DisguisePushing.valueOf(option); |             disablePushing = DisguisePushing.valueOf(option); | ||||||
|         } |         } | ||||||
|         catch (Exception ex) { |         catch (Exception ex) { | ||||||
|             System.out.println("[LibsDisguises] Cannot parse '" + config.getString( |             System.out.println("[LibsDisguises] Cannot parse '" + config | ||||||
|                     "SelfDisguisesScoreboard") + "' to a valid option for SelfDisguisesTeam"); |                     .getString("SelfDisguisesScoreboard") + "' to a valid option for SelfDisguisesTeam"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         customDisguises.clear(); |         customDisguises.clear(); | ||||||
| @@ -233,8 +222,9 @@ public class DisguiseConfig { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             try { |             try { | ||||||
|                 Disguise disguise = DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), "disguise", |                 Disguise disguise = DisguiseParser | ||||||
|                         toParse.split(" "), DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise")); |                         .parseDisguise(Bukkit.getConsoleSender(), "disguise", toParse.split(" "), | ||||||
|  |                                 DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise")); | ||||||
|  |  | ||||||
|                 customDisguises.put(key, disguise); |                 customDisguises.put(key, disguise); | ||||||
|  |  | ||||||
| @@ -429,10 +419,6 @@ public class DisguiseConfig { | |||||||
|         disableInvisibility = disableInvis; |         disableInvisibility = disableInvis; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void setDisguiseBlownMessage(String newMessage) { |  | ||||||
|         disguiseBlownMessage = newMessage; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void setDisguiseBlownOnAttack(boolean blowDisguise) { |     public static void setDisguiseBlownOnAttack(boolean blowDisguise) { | ||||||
|         blowDisguisesOnAttack = blowDisguise; |         blowDisguisesOnAttack = blowDisguise; | ||||||
|     } |     } | ||||||
| @@ -567,10 +553,6 @@ public class DisguiseConfig { | |||||||
|         undisguiseSwitchWorlds = isUndisguise; |         undisguiseSwitchWorlds = isUndisguise; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void setUpdateMessage(String newMessage) { |  | ||||||
|         updateMessage = newMessage; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void setUpdateNotificationPermission(String newPermission) { |     public static void setUpdateNotificationPermission(String newPermission) { | ||||||
|         updateNotificationPermission = newPermission; |         updateNotificationPermission = newPermission; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ import me.libraryaddict.disguise.utilities.DisguiseParser; | |||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.UpdateChecker; | import me.libraryaddict.disguise.utilities.UpdateChecker; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| @@ -86,15 +87,14 @@ public class DisguiseListener implements Listener { | |||||||
|                                         continue; |                                         continue; | ||||||
|                                     } |                                     } | ||||||
|  |  | ||||||
|                                     p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion, |                                     p.sendMessage(LibsMsg.UPDATE_READY.get(currentVersion, latestVersion)); | ||||||
|                                             latestVersion)); |  | ||||||
|                                 } |                                 } | ||||||
|                             } |                             } | ||||||
|                         }); |                         }); | ||||||
|                     } |                     } | ||||||
|                     catch (Exception ex) { |                     catch (Exception ex) { | ||||||
|                         System.out.print( |                         System.out.print(String | ||||||
|                                 String.format("[LibsDisguises] Failed to check for update: %s", ex.getMessage())); |                                 .format("[LibsDisguises] Failed to check for update: %s", ex.getMessage())); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }, 0, (20 * 60 * 60 * 6)); // Check every 6 hours |             }, 0, (20 * 60 * 60 * 6)); // Check every 6 hours | ||||||
| @@ -138,8 +138,10 @@ public class DisguiseListener implements Listener { | |||||||
|         if (disguises.length > 0) { |         if (disguises.length > 0) { | ||||||
|             DisguiseAPI.undisguiseToAll(entity); |             DisguiseAPI.undisguiseToAll(entity); | ||||||
|  |  | ||||||
|             if (DisguiseConfig.getDisguiseBlownMessage().length() > 0) { |             String blown = LibsMsg.BLOWN_DISGUISE.get(); | ||||||
|                 entity.sendMessage(DisguiseConfig.getDisguiseBlownMessage()); |  | ||||||
|  |             if (blown.length() > 0) { | ||||||
|  |                 entity.sendMessage(blown); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -278,15 +280,15 @@ public class DisguiseListener implements Listener { | |||||||
|         Player p = event.getPlayer(); |         Player p = event.getPlayer(); | ||||||
|  |  | ||||||
|         if (latestVersion != null && p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) { |         if (latestVersion != null && p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) { | ||||||
|             p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion, latestVersion)); |             p.sendMessage(LibsMsg.UPDATE_READY.get(currentVersion, latestVersion)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (DisguiseConfig.isBedPacketsEnabled()) { |         if (DisguiseConfig.isBedPacketsEnabled()) { | ||||||
|             chunkMove(p, p.getLocation(), null); |             chunkMove(p, p.getLocation(), null); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (DisguiseConfig.isSaveGameProfiles() && DisguiseConfig.isUpdateGameProfiles() && DisguiseUtilities.hasGameProfile( |         if (DisguiseConfig.isSaveGameProfiles() && DisguiseConfig.isUpdateGameProfiles() && DisguiseUtilities | ||||||
|                 p.getName())) { |                 .hasGameProfile(p.getName())) { | ||||||
|             WrappedGameProfile profile = WrappedGameProfile.fromPlayer(p); |             WrappedGameProfile profile = WrappedGameProfile.fromPlayer(p); | ||||||
|  |  | ||||||
|             if (!profile.getProperties().isEmpty()) { |             if (!profile.getProperties().isEmpty()) { | ||||||
| @@ -364,9 +366,9 @@ public class DisguiseListener implements Listener { | |||||||
|             Location to = event.getTo(); |             Location to = event.getTo(); | ||||||
|             Location from = event.getFrom(); |             Location from = event.getFrom(); | ||||||
|  |  | ||||||
|             if (DisguiseUtilities.getChunkCord(to.getBlockX()) != DisguiseUtilities.getChunkCord( |             if (DisguiseUtilities.getChunkCord(to.getBlockX()) != DisguiseUtilities | ||||||
|                     from.getBlockX()) || DisguiseUtilities.getChunkCord( |                     .getChunkCord(from.getBlockX()) || DisguiseUtilities | ||||||
|                     to.getBlockZ()) != DisguiseUtilities.getChunkCord(from.getBlockZ())) { |                     .getChunkCord(to.getBlockZ()) != DisguiseUtilities.getChunkCord(from.getBlockZ())) { | ||||||
|                 chunkMove(event.getPlayer(), to, from); |                 chunkMove(event.getPlayer(), to, from); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -375,7 +377,8 @@ public class DisguiseListener implements Listener { | |||||||
|             Disguise disguise; |             Disguise disguise; | ||||||
|  |  | ||||||
|             if ((disguise = DisguiseAPI.getDisguise(event.getPlayer())) != null) { |             if ((disguise = DisguiseAPI.getDisguise(event.getPlayer())) != null) { | ||||||
|                 if (disguise.getType() == DisguiseType.SHULKER) { // Stop Shulker disguises from moving their coordinates |                 if (disguise | ||||||
|  |                         .getType() == DisguiseType.SHULKER) { // Stop Shulker disguises from moving their coordinates | ||||||
|                     Location from = event.getFrom(); |                     Location from = event.getFrom(); | ||||||
|                     Location to = event.getTo(); |                     Location to = event.getTo(); | ||||||
|  |  | ||||||
| @@ -429,8 +432,8 @@ public class DisguiseListener implements Listener { | |||||||
|  |  | ||||||
|     @EventHandler |     @EventHandler | ||||||
|     public void onRightClick(PlayerInteractEntityEvent event) { |     public void onRightClick(PlayerInteractEntityEvent event) { | ||||||
|         if (!disguiseEntity.containsKey(event.getPlayer().getName()) && !disguiseClone.containsKey( |         if (!disguiseEntity.containsKey(event.getPlayer().getName()) && !disguiseClone | ||||||
|                 event.getPlayer().getName())) { |                 .containsKey(event.getPlayer().getName())) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -456,9 +459,9 @@ public class DisguiseListener implements Listener { | |||||||
|             Disguise disguise = disguiseEntity.remove(p.getName()); |             Disguise disguise = disguiseEntity.remove(p.getName()); | ||||||
|  |  | ||||||
|             if (disguise != null) { |             if (disguise != null) { | ||||||
|                 if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { |                 if (disguise.isMiscDisguise() && !DisguiseConfig | ||||||
|                     p.sendMessage( |                         .isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { | ||||||
|                             ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!"); |                     p.sendMessage(LibsMsg.DISABLED_LIVING_TO_MISC.get()); | ||||||
|                 } else { |                 } else { | ||||||
|                     if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { |                     if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { | ||||||
|                         if (disguise.getWatcher() instanceof LivingWatcher) { |                         if (disguise.getWatcher() instanceof LivingWatcher) { | ||||||
| @@ -472,31 +475,62 @@ public class DisguiseListener implements Listener { | |||||||
|  |  | ||||||
|                     DisguiseAPI.disguiseToAll(entity, disguise); |                     DisguiseAPI.disguiseToAll(entity, disguise); | ||||||
|  |  | ||||||
|                     String disguiseName = "a "; |                     String disguiseName; | ||||||
|  |  | ||||||
|                     if (disguise instanceof PlayerDisguise) { |                     if (disguise instanceof PlayerDisguise) { | ||||||
|                         disguiseName = "the player " + ((PlayerDisguise) disguise).getName(); |                         disguiseName = ((PlayerDisguise) disguise).getName(); | ||||||
|                     } else { |                     } else { | ||||||
|                         disguiseName += disguise.getType().toReadable(); |                         disguiseName = disguise.getType().toReadable(); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  |                     // Jeez, maybe I should redo my messages here | ||||||
|                     if (disguise.isDisguiseInUse()) { |                     if (disguise.isDisguiseInUse()) { | ||||||
|                         p.sendMessage(ChatColor.RED + "Disguised " + (entity instanceof Player ? "" : |                         if (disguise.isPlayerDisguise()) { | ||||||
|                                 "the ") + entityName + " as " + disguiseName + "!"); |                             if (entity instanceof Player) { | ||||||
|  |                                 p.sendMessage(LibsMsg.LISTEN_ENTITY_PLAYER_DISG_PLAYER.get(entityName, disguiseName)); | ||||||
|                             } else { |                             } else { | ||||||
|                         p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : |                                 p.sendMessage(LibsMsg.LISTEN_ENTITY_ENTITY_DISG_PLAYER.get(entityName, disguiseName)); | ||||||
|                                 "the ") + entityName + " as " + disguiseName + "!"); |                             } | ||||||
|  |                         } else { | ||||||
|  |                             if (entity instanceof Player) { | ||||||
|  |                                 p.sendMessage(LibsMsg.LISTEN_ENTITY_PLAYER_DISG_ENTITY.get(entityName, disguiseName)); | ||||||
|  |                             } else { | ||||||
|  |                                 p.sendMessage(LibsMsg.LISTEN_ENTITY_ENTITY_DISG_ENTITY.get(entityName, disguiseName)); | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     } else { | ||||||
|  |                         if (disguise.isPlayerDisguise()) { | ||||||
|  |                             if (entity instanceof Player) { | ||||||
|  |                                 p.sendMessage( | ||||||
|  |                                         LibsMsg.LISTEN_ENTITY_PLAYER_DISG_PLAYER_FAIL.get(entityName, disguiseName)); | ||||||
|  |                             } else { | ||||||
|  |                                 p.sendMessage( | ||||||
|  |                                         LibsMsg.LISTEN_ENTITY_ENTITY_DISG_PLAYER_FAIL.get(entityName, disguiseName)); | ||||||
|  |                             } | ||||||
|  |                         } else { | ||||||
|  |                             if (entity instanceof Player) { | ||||||
|  |                                 p.sendMessage( | ||||||
|  |                                         LibsMsg.LISTEN_ENTITY_PLAYER_DISG_ENTITY_FAIL.get(entityName, disguiseName)); | ||||||
|  |                             } else { | ||||||
|  |                                 p.sendMessage( | ||||||
|  |                                         LibsMsg.LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL.get(entityName, disguiseName)); | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 if (DisguiseAPI.isDisguised(entity)) { |                 if (DisguiseAPI.isDisguised(entity)) { | ||||||
|                     DisguiseAPI.undisguiseToAll(entity); |                     DisguiseAPI.undisguiseToAll(entity); | ||||||
|  |  | ||||||
|                     p.sendMessage( |                     if (entity instanceof Player) | ||||||
|                             ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName); |                         p.sendMessage(LibsMsg.LISTEN_UNDISG_PLAYER.get(entityName)); | ||||||
|  |                     else | ||||||
|  |                         p.sendMessage(LibsMsg.LISTEN_UNDISG_ENT.get(entityName)); | ||||||
|                 } else { |                 } else { | ||||||
|                     p.sendMessage( |                     if (entity instanceof Player) | ||||||
|                             ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!"); |                         p.sendMessage(LibsMsg.LISTEN_UNDISG_PLAYER_FAIL.get(entityName)); | ||||||
|  |                     else | ||||||
|  |                         p.sendMessage(LibsMsg.LISTEN_UNDISG_ENT_FAIL.get(entityName)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } else if (disguiseModify.containsKey(p.getName())) { |         } else if (disguiseModify.containsKey(p.getName())) { | ||||||
| @@ -505,22 +539,22 @@ public class DisguiseListener implements Listener { | |||||||
|             Disguise disguise = DisguiseAPI.getDisguise(p, entity); |             Disguise disguise = DisguiseAPI.getDisguise(p, entity); | ||||||
|  |  | ||||||
|             if (disguise == null) { |             if (disguise == null) { | ||||||
|                 p.sendMessage(ChatColor.RED + entityName + " is not disguised!"); |                 p.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityName)); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser.getPermissions(p, |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser | ||||||
|                     "libsdisguises.disguiseentitymodify."); |                     .getPermissions(p, "libsdisguises.disguiseentitymodify."); | ||||||
|  |  | ||||||
|             if (!perms.containsKey(new DisguisePerm(disguise.getType()))) { |             if (!perms.containsKey(new DisguisePerm(disguise.getType()))) { | ||||||
|                 p.sendMessage(ChatColor.RED + "You do not have permission to modify this disguise"); |                 p.sendMessage(LibsMsg.DMODPLAYER_NOPERM.get()); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             try { |             try { | ||||||
|                 DisguiseParser.callMethods(p, disguise, perms.get(new DisguisePerm(disguise.getType())), |                 DisguiseParser.callMethods(p, disguise, perms.get(new DisguisePerm(disguise.getType())), | ||||||
|                         new ArrayList<String>(), options); |                         new ArrayList<String>(), options); | ||||||
|                 p.sendMessage(ChatColor.RED + "Modified the disguise!"); |                 p.sendMessage(LibsMsg.LISTENER_MODIFIED_DISG.get()); | ||||||
|             } |             } | ||||||
|             catch (DisguiseParseException ex) { |             catch (DisguiseParseException ex) { | ||||||
|                 if (ex.getMessage() != null) { |                 if (ex.getMessage() != null) { | ||||||
| @@ -535,8 +569,8 @@ public class DisguiseListener implements Listener { | |||||||
|  |  | ||||||
|     @EventHandler |     @EventHandler | ||||||
|     public void onTarget(EntityTargetEvent event) { |     public void onTarget(EntityTargetEvent event) { | ||||||
|         if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() != null && event.getTarget() instanceof Player && DisguiseAPI.isDisguised( |         if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() != null && event | ||||||
|                 event.getTarget())) { |                 .getTarget() instanceof Player && DisguiseAPI.isDisguised(event.getTarget())) { | ||||||
|             switch (event.getReason()) { |             switch (event.getReason()) { | ||||||
|                 case TARGET_ATTACKED_ENTITY: |                 case TARGET_ATTACKED_ENTITY: | ||||||
|                 case TARGET_ATTACKED_OWNER: |                 case TARGET_ATTACKED_OWNER: | ||||||
| @@ -557,9 +591,9 @@ public class DisguiseListener implements Listener { | |||||||
|         Location from = event.getFrom(); |         Location from = event.getFrom(); | ||||||
|  |  | ||||||
|         if (DisguiseConfig.isBedPacketsEnabled()) { |         if (DisguiseConfig.isBedPacketsEnabled()) { | ||||||
|             if (DisguiseUtilities.getChunkCord(to.getBlockX()) != DisguiseUtilities.getChunkCord( |             if (DisguiseUtilities.getChunkCord(to.getBlockX()) != DisguiseUtilities | ||||||
|                     from.getBlockX()) || DisguiseUtilities.getChunkCord( |                     .getChunkCord(from.getBlockX()) || DisguiseUtilities | ||||||
|                     to.getBlockZ()) != DisguiseUtilities.getChunkCord(from.getBlockZ())) { |                     .getChunkCord(to.getBlockZ()) != DisguiseUtilities.getChunkCord(from.getBlockZ())) { | ||||||
|                 chunkMove(player, null, from); |                 chunkMove(player, null, from); | ||||||
|  |  | ||||||
|                 Bukkit.getScheduler().runTask(plugin, new Runnable() { |                 Bukkit.getScheduler().runTask(plugin, new Runnable() { | ||||||
| @@ -575,7 +609,8 @@ public class DisguiseListener implements Listener { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (DisguiseConfig.isUndisguiseOnWorldChange() && to.getWorld() != null && from.getWorld() != null && to.getWorld() != from.getWorld()) { |         if (DisguiseConfig.isUndisguiseOnWorldChange() && to.getWorld() != null && from.getWorld() != null && to | ||||||
|  |                 .getWorld() != from.getWorld()) { | ||||||
|             for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) { |             for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) { | ||||||
|                 disguise.removeDisguise(); |                 disguise.removeDisguise(); | ||||||
|             } |             } | ||||||
| @@ -584,8 +619,8 @@ public class DisguiseListener implements Listener { | |||||||
|  |  | ||||||
|     @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) |     @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | ||||||
|     public void onVehicleEnter(VehicleEnterEvent event) { |     public void onVehicleEnter(VehicleEnterEvent event) { | ||||||
|         if (event.getEntered() instanceof Player && DisguiseAPI.isDisguised((Player) event.getEntered(), |         if (event.getEntered() instanceof Player && DisguiseAPI | ||||||
|                 event.getEntered())) { |                 .isDisguised((Player) event.getEntered(), event.getEntered())) { | ||||||
|             DisguiseUtilities.removeSelfDisguise((Player) event.getEntered()); |             DisguiseUtilities.removeSelfDisguise((Player) event.getEntered()); | ||||||
|  |  | ||||||
|             ((Player) event.getEntered()).updateInventory(); |             ((Player) event.getEntered()).updateInventory(); | ||||||
|   | |||||||
| @@ -33,7 +33,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor { | |||||||
|             itel.remove(); |             itel.remove(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return new ArrayList<String>(new HashSet<String>(list)); |         return new ArrayList<>(new HashSet<>(list)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected ArrayList<String> getAllowedDisguises( |     protected ArrayList<String> getAllowedDisguises( | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import me.libraryaddict.disguise.DisguiseConfig; | |||||||
| import me.libraryaddict.disguise.LibsDisguises; | import me.libraryaddict.disguise.LibsDisguises; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.apache.commons.lang.StringUtils; | import org.apache.commons.lang.StringUtils; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| @@ -21,8 +22,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -38,8 +38,8 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | |||||||
|  |  | ||||||
|             for (int i = player == null ? 0 : 1; i < args.length; i++) { |             for (int i = player == null ? 0 : 1; i < args.length; i++) { | ||||||
|                 String option = args[i]; |                 String option = args[i]; | ||||||
|                 if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip") || StringUtils.startsWithIgnoreCase(option, |                 if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip") || StringUtils | ||||||
|                         "ignoreEnquip")) { |                         .startsWithIgnoreCase(option, "ignoreEnquip")) { | ||||||
|                     doEquipment = false; |                     doEquipment = false; | ||||||
|                 } else if (option.equalsIgnoreCase("doSneakSprint")) { |                 } else if (option.equalsIgnoreCase("doSneakSprint")) { | ||||||
|                     doSneak = true; |                     doSneak = true; | ||||||
| @@ -49,9 +49,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | |||||||
|                 } else if (option.equalsIgnoreCase("doSprint")) { |                 } else if (option.equalsIgnoreCase("doSprint")) { | ||||||
|                     doSprint = true; |                     doSprint = true; | ||||||
|                 } else { |                 } else { | ||||||
|                     sender.sendMessage(String.format(TranslateType.MESSAGE.get( |                     sender.sendMessage(LibsMsg.INVALID_CLONE.get(option)); | ||||||
|                             ChatColor.DARK_RED + "Unknown " + "option '%s" + "' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' 'DoSneak' 'DoSprint'"), |  | ||||||
|                             option)); |  | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -63,12 +61,10 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | |||||||
|             } else { |             } else { | ||||||
|                 LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), options); |                 LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), options); | ||||||
|  |  | ||||||
|                 sender.sendMessage(String.format(TranslateType.MESSAGE.get( |                 sender.sendMessage(LibsMsg.CLICK_TIMER.get(DisguiseConfig.getDisguiseCloneExpire())); | ||||||
|                         ChatColor.RED + "Right click a entity in the next %s" + " seconds to grab the disguise reference!"), |  | ||||||
|                         DisguiseConfig.getDisguiseCloneExpire())); |  | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
| @@ -100,11 +96,8 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp | |||||||
|     @Override |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, |     protected void sendCommandUsage(CommandSender sender, | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.CLONE_HELP1.get()); | ||||||
|                 ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other " + "disguise commands!")); |         sender.sendMessage(LibsMsg.CLONE_HELP2.get()); | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.CLONE_HELP3.get()); | ||||||
|                 ChatColor.DARK_GREEN + "Security note: Any references you create will be available to all players " + "able to use disguise references.")); |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |  | ||||||
|                 ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")")); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | |||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| @@ -31,8 +32,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (!(sender instanceof Entity)) { |         if (!(sender instanceof Entity)) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -71,11 +71,9 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter | |||||||
|         DisguiseAPI.disguiseToAll((Player) sender, disguise); |         DisguiseAPI.disguiseToAll((Player) sender, disguise); | ||||||
|  |  | ||||||
|         if (disguise.isDisguiseInUse()) { |         if (disguise.isDisguiseInUse()) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Now disguised as a %s"), |             sender.sendMessage(LibsMsg.DISGUISED.get(disguise.getType().toReadable())); | ||||||
|                     disguise.getType().toReadable())); |  | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Failed to disguise as a %s"), |             sender.sendMessage(LibsMsg.FAILED_DISGIUSE.get(disguise.getType().toReadable())); | ||||||
|                     disguise.getType().toReadable())); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
| @@ -143,8 +141,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter | |||||||
|  |  | ||||||
|                     if (addMethods) { |                     if (addMethods) { | ||||||
|                         // If this is a method, add. Else if it can be a param of the previous argument, add. |                         // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                         for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                         for (Method method : ReflectionFlagWatchers | ||||||
|                                 disguiseType.getWatcherClass())) { |                                 .getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { | ||||||
|                             tabs.add(method.getName()); |                             tabs.add(method.getName()); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @@ -162,21 +160,18 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter | |||||||
|     protected void sendCommandUsage(CommandSender sender, |     protected void sendCommandUsage(CommandSender sender, | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|         sender.sendMessage( |         sender.sendMessage(LibsMsg.DISG_HELP1.get()); | ||||||
|                 TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!")); |         sender.sendMessage(LibsMsg.CAN_USE_DISGS | ||||||
|         sender.sendMessage( |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can use the disguises: %s"), |  | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("player")) { |         if (allowedDisguises.contains("player")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguise player " + "<Name>")); |             sender.sendMessage(LibsMsg.DISG_HELP2.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguise <DisguiseType> " + "<Baby>")); |         sender.sendMessage(LibsMsg.DISG_HELP3.get()); | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { |         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DISG_HELP4.get()); | ||||||
|                     ChatColor.DARK_GREEN + "/disguise " + "<Dropped_Item/Falling_Block> <Id> <Durability>")); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; | |||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| @@ -28,13 +29,12 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (!(sender instanceof Player)) { |         if (!(sender instanceof Player)) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (getPermissions(sender).isEmpty()) { |         if (getPermissions(sender).isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -62,8 +62,8 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | |||||||
|  |  | ||||||
|         LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise); |         LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise); | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage( | ||||||
|                 ChatColor.RED + "Right click an entity in the next " + DisguiseConfig.getDisguiseEntityExpire() + " " + "seconds to disguise it as a " + disguise.getType().toReadable() + "!")); |                 LibsMsg.DISG_ENT_CLICK.get(DisguiseConfig.getDisguiseEntityExpire(), disguise.getType().toReadable())); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -135,8 +135,8 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | |||||||
|  |  | ||||||
|                     if (addMethods) { |                     if (addMethods) { | ||||||
|                         // If this is a method, add. Else if it can be a param of the previous argument, add. |                         // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                         for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                         for (Method method : ReflectionFlagWatchers | ||||||
|                                 disguiseType.getWatcherClass())) { |                                 .getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { | ||||||
|                             tabs.add(method.getName()); |                             tabs.add(method.getName()); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @@ -158,21 +158,18 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | |||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DISG_ENT_HELP1.get()); | ||||||
|                 ChatColor.DARK_GREEN + "Choose a disguise then right click an entity to disguise it!")); |         sender.sendMessage(LibsMsg.DISG_ENT_HELP2 | ||||||
|         sender.sendMessage( |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"), |  | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("player")) { |         if (allowedDisguises.contains("player")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguiseentity player <Name>")); |             sender.sendMessage(LibsMsg.DISG_ENT_HELP3.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>")); |         sender.sendMessage(LibsMsg.DISG_ENT_HELP4.get()); | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { |         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DISG_ENT_HELP5.get()); | ||||||
|                     ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> " + "<Durability>")); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | |||||||
| import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| @@ -24,8 +25,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) { |         for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) { | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permMap = DisguiseParser.getPermissions(sender, |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permMap = DisguiseParser | ||||||
|                     "libsdisguises." + node + "."); |                     .getPermissions(sender, "libsdisguises." + node + "."); | ||||||
|  |  | ||||||
|             if (!permMap.isEmpty()) { |             if (!permMap.isEmpty()) { | ||||||
|                 if (args.length == 0) { |                 if (args.length == 0) { | ||||||
| @@ -45,9 +46,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|  |  | ||||||
|                     if (help != null) { |                     if (help != null) { | ||||||
|                         if (help.isEnums()) { |                         if (help.isEnums()) { | ||||||
|                             sender.sendMessage( |                             sender.sendMessage(ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + StringUtils | ||||||
|                                     ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + StringUtils.join( |                                     .join(help.getEnums(""), ChatColor.RED + ", " + ChatColor.GREEN)); | ||||||
|                                             help.getEnums(""), ChatColor.RED + ", " + ChatColor.GREEN)); |  | ||||||
|                         } else { |                         } else { | ||||||
|                             sender.sendMessage( |                             sender.sendMessage( | ||||||
|                                     ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + help.getDescription()); |                                     ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + help.getDescription()); | ||||||
| @@ -58,14 +58,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|                     DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]); |                     DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]); | ||||||
|  |  | ||||||
|                     if (type == null) { |                     if (type == null) { | ||||||
|                         sender.sendMessage( |                         sender.sendMessage(LibsMsg.DHELP_CANTFIND.get(args[0])); | ||||||
|                                 TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the disguise ") + args[0]); |  | ||||||
|                         return true; |                         return true; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     if (!permMap.containsKey(type)) { |                     if (!permMap.containsKey(type)) { | ||||||
|                         sender.sendMessage(TranslateType.MESSAGE.get( |                         sender.sendMessage(LibsMsg.NO_PERM_DISGUISE.get()); | ||||||
|                                 ChatColor.RED + "You do not have permission for " + "that disguise!")); |  | ||||||
|                         return true; |                         return true; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
| @@ -109,12 +107,13 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|  |  | ||||||
|                             if (declaring == LivingWatcher.class) { |                             if (declaring == LivingWatcher.class) { | ||||||
|                                 methodColor = ChatColor.AQUA; |                                 methodColor = ChatColor.AQUA; | ||||||
|                             } else if (!(FlagWatcher.class.isAssignableFrom( |                             } else if (!(FlagWatcher.class | ||||||
|                                     declaring)) || declaring == FlagWatcher.class) { |                                     .isAssignableFrom(declaring)) || declaring == FlagWatcher.class) { | ||||||
|                                 methodColor = ChatColor.GRAY; |                                 methodColor = ChatColor.GRAY; | ||||||
|                             } |                             } | ||||||
|  |  | ||||||
|                             String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")"; |                             String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info | ||||||
|  |                                     .getName() + ChatColor.DARK_RED + ")"; | ||||||
|  |  | ||||||
|                             map.put(str, methodColor); |                             map.put(str, methodColor); | ||||||
|                             methods.add(str); |                             methods.add(str); | ||||||
| @@ -134,13 +133,11 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|                         methods.add(ChatColor.RED + "No options with permission to use"); |                         methods.add(ChatColor.RED + "No options with permission to use"); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     sender.sendMessage(ChatColor.DARK_RED + type.toReadable() + TranslateType.MESSAGE.get( |                     sender.sendMessage(LibsMsg.DHELP_OPTIONS.get(ChatColor.DARK_RED + type.toReadable(), | ||||||
|                             " options: ") + StringUtils.join(methods, ChatColor.DARK_RED + ", ")); |                             StringUtils.join(methods, ChatColor.DARK_RED + ", "))); | ||||||
|  |  | ||||||
|                     if (ignored > 0) { |                     if (ignored > 0) { | ||||||
|                         sender.sendMessage(String.format(TranslateType.MESSAGE.get( |                         sender.sendMessage(LibsMsg.NO_PERMS_USE_OPTIONS.get(ignored)); | ||||||
|                                 ChatColor.RED + "Ignored %s" + " options you do not have permission to use. Add " + "'show' to view unusable options."), |  | ||||||
|                                 ignored)); |  | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     return true; |                     return true; | ||||||
| @@ -148,7 +145,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |         sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -158,8 +155,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|         String[] args = getArgs(origArgs); |         String[] args = getArgs(origArgs); | ||||||
|  |  | ||||||
|         for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) { |         for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) { | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser.getPermissions(sender, |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser | ||||||
|                     "libsdisguises." + node + "."); |                     .getPermissions(sender, "libsdisguises." + node + "."); | ||||||
|  |  | ||||||
|             if (args.length == 0) { |             if (args.length == 0) { | ||||||
|                 for (DisguisePerm type : perms.keySet()) { |                 for (DisguisePerm type : perms.keySet()) { | ||||||
| @@ -186,12 +183,10 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl | |||||||
|     @Override |     @Override | ||||||
|     protected void sendCommandUsage(CommandSender sender, |     protected void sendCommandUsage(CommandSender sender, | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DHELP_HELP1.get()); | ||||||
|                 ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN + "- View the options you can set " + "on a disguise. Add 'show' to reveal the options you don't have permission to use")); |  | ||||||
|  |  | ||||||
|         for (ParamInfo s : ReflectionFlagWatchers.getParamInfos()) { |         for (ParamInfo s : ReflectionFlagWatchers.getParamInfos()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "/disguisehelp " + s.getName().replaceAll(" ", |             sender.sendMessage(LibsMsg.DHELP_HELP2.get(s.getName().replaceAll(" ", ""), s.getDescription())); | ||||||
|                     "") + ChatColor.GREEN + " - " + s.getDescription())); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; | |||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| @@ -27,15 +28,14 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (!(sender instanceof Entity)) { |         if (!(sender instanceof Entity)) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); |         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); | ||||||
|  |  | ||||||
|         if (map.isEmpty()) { |         if (map.isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -47,18 +47,19 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | |||||||
|         Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender); |         Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender); | ||||||
|  |  | ||||||
|         if (disguise == null) { |         if (disguise == null) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are not disguised!")); |             sender.sendMessage(LibsMsg.NOT_DISGUISED.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!map.containsKey(new DisguisePerm(disguise.getType()))) { |         if (!map.containsKey(new DisguisePerm(disguise.getType()))) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "No permission to modify your disguise!")); |             sender.sendMessage(LibsMsg.DMODIFY_NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             DisguiseParser.callMethods(sender, disguise, |             DisguiseParser | ||||||
|                     getPermissions(sender).get(new DisguisePerm(disguise.getType())), new ArrayList<String>(), args); |                     .callMethods(sender, disguise, getPermissions(sender).get(new DisguisePerm(disguise.getType())), | ||||||
|  |                             new ArrayList<String>(), args); | ||||||
|         } |         } | ||||||
|         catch (DisguiseParseException ex) { |         catch (DisguiseParseException ex) { | ||||||
|             if (ex.getMessage() != null) { |             if (ex.getMessage() != null) { | ||||||
| @@ -72,7 +73,7 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Your disguise has been modified!")); |         sender.sendMessage(LibsMsg.DMODIFY_MODIFIED.get()); | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -152,12 +153,9 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom | |||||||
|     protected void sendCommandUsage(CommandSender sender, |     protected void sendCommandUsage(CommandSender sender, | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|         sender.sendMessage( |         sender.sendMessage(LibsMsg.DMODIFY_HELP3.get()); | ||||||
|                 TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "Modify your own disguise as you wear " + "it!")); |         sender.sendMessage(LibsMsg.DMODIFY_HELP3.get()); | ||||||
|         sender.sendMessage( |         sender.sendMessage(LibsMsg.DMODIFY_HELP3 | ||||||
|                 TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguisemodify setBaby true setSprinting true")); |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|         sender.sendMessage( |  | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"), |  | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands; | |||||||
| import me.libraryaddict.disguise.DisguiseConfig; | import me.libraryaddict.disguise.DisguiseConfig; | ||||||
| import me.libraryaddict.disguise.LibsDisguises; | import me.libraryaddict.disguise.LibsDisguises; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| @@ -23,13 +24,12 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (!(sender instanceof Player)) { |         if (!(sender instanceof Player)) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (getPermissions(sender).isEmpty()) { |         if (getPermissions(sender).isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -40,9 +40,7 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements | |||||||
|  |  | ||||||
|         LibsDisguises.getInstance().getListener().setDisguiseModify(sender.getName(), args); |         LibsDisguises.getInstance().getListener().setDisguiseModify(sender.getName(), args); | ||||||
|  |  | ||||||
|         sender.sendMessage(String.format(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DMODIFYENT_CLICK.get(DisguiseConfig.getDisguiseEntityExpire())); | ||||||
|                 ChatColor.RED + "Right click a disguised entity " + "in the next %s seconds to modify their disguise!"), |  | ||||||
|                 DisguiseConfig.getDisguiseEntityExpire())); |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -89,8 +87,8 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements | |||||||
|  |  | ||||||
|             if (addMethods) { |             if (addMethods) { | ||||||
|                 // If this is a method, add. Else if it can be a param of the previous argument, add. |                 // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                 for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                 for (Method method : ReflectionFlagWatchers | ||||||
|                         perm.getType().getWatcherClass())) { |                         .getDisguiseWatcherMethods(perm.getType().getWatcherClass())) { | ||||||
|                     tabs.add(method.getName()); |                     tabs.add(method.getName()); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -110,10 +108,8 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements | |||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DMODENT_HELP1.get()); | ||||||
|                 ChatColor.DARK_GREEN + "Choose the options for a disguise then right click a entity to modify it!")); |         sender.sendMessage(LibsMsg.DMODENT_HELP2 | ||||||
|         sender.sendMessage( |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"), |  | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,9 +5,9 @@ import me.libraryaddict.disguise.disguisetypes.Disguise; | |||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; |  | ||||||
| import org.apache.commons.lang.StringUtils; | import org.apache.commons.lang.StringUtils; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| @@ -28,7 +28,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); |         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); | ||||||
|  |  | ||||||
|         if (map.isEmpty()) { |         if (map.isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -40,9 +40,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|         Player player = Bukkit.getPlayer(args[0]); |         Player player = Bukkit.getPlayer(args[0]); | ||||||
|  |  | ||||||
|         if (player == null) { |         if (player == null) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0])); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the player '%s" + "'"), |  | ||||||
|                             args[0])); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -63,15 +61,12 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|             disguise = DisguiseAPI.getDisguise(player); |             disguise = DisguiseAPI.getDisguise(player); | ||||||
|  |  | ||||||
|         if (disguise == null) { |         if (disguise == null) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.DMODPLAYER_NODISGUISE.get(player.getName())); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "The player '%s' is " + "not disguised"), |  | ||||||
|                             player.getName())); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!map.containsKey(new DisguisePerm(disguise.getType()))) { |         if (!map.containsKey(new DisguisePerm(disguise.getType()))) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DMODPLAYER_NOPERM.get()); | ||||||
|                     ChatColor.RED + "You do not have permission to modify this " + "disguise")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -91,8 +86,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage( |         sender.sendMessage(LibsMsg.DMODPLAYER_MODIFIED.get(player.getName())); | ||||||
|                 TranslateType.MESSAGE.get(ChatColor.RED + "Modified the disguise of " + player.getName() + "!")); |  | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -115,9 +109,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|             Player player = Bukkit.getPlayer(args[0]); |             Player player = Bukkit.getPlayer(args[0]); | ||||||
|  |  | ||||||
|             if (player == null) { |             if (player == null) { | ||||||
|                 sender.sendMessage( |                 sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0])); | ||||||
|                         String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the player '%s'"), |  | ||||||
|                                 args[0])); |  | ||||||
|                 return tabs; |                 return tabs; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -130,9 +122,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|                 disguise = DisguiseAPI.getDisguise(player); |                 disguise = DisguiseAPI.getDisguise(player); | ||||||
|  |  | ||||||
|             if (disguise == null) { |             if (disguise == null) { | ||||||
|                 sender.sendMessage(String.format( |                 sender.sendMessage(LibsMsg.DMODPLAYER_NODISGUISE.get(player.getName())); | ||||||
|                         TranslateType.MESSAGE.get(ChatColor.RED + "The player '%s' " + "is not disguised"), |  | ||||||
|                         player.getName())); |  | ||||||
|                 return tabs; |                 return tabs; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -179,8 +169,8 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|  |  | ||||||
|                 if (addMethods) { |                 if (addMethods) { | ||||||
|                     // If this is a method, add. Else if it can be a param of the previous argument, add. |                     // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                     for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                     for (Method method : ReflectionFlagWatchers | ||||||
|                             disguiseType.getWatcherClass())) { |                             .getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { | ||||||
|                         tabs.add(method.getName()); |                         tabs.add(method.getName()); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -198,9 +188,8 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements | |||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "Modify the disguise of another player!")); |         sender.sendMessage(LibsMsg.DMODPLAYER_HELP1.get()); | ||||||
|         sender.sendMessage( |         sender.sendMessage(LibsMsg.DMODPLAYER_HELP2 | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"), |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,13 +3,10 @@ package me.libraryaddict.disguise.commands; | |||||||
| import me.libraryaddict.disguise.DisguiseAPI; | import me.libraryaddict.disguise.DisguiseAPI; | ||||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||||
| import me.libraryaddict.disguise.utilities.ClassGetter; | import me.libraryaddict.disguise.utilities.*; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; |  | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; |  | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; |  | ||||||
| import org.apache.commons.lang.StringUtils; | import org.apache.commons.lang.StringUtils; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| @@ -53,15 +50,14 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); |         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); | ||||||
|  |  | ||||||
|         if (map.isEmpty()) { |         if (map.isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -79,10 +75,8 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|  |  | ||||||
|             Collections.sort(classes); |             Collections.sort(classes); | ||||||
|  |  | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.DMODRADIUS_USABLE | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "EntityTypes usable " + "are: %s"), |                     .get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN))); | ||||||
|                             ChatColor.GREEN + StringUtils.join(classes, |  | ||||||
|                                     ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + ".")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -107,36 +101,30 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (type == null) { |                 if (type == null) { | ||||||
|                     sender.sendMessage( |                     sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0])); | ||||||
|                             String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Unrecognised " + "EntityType %s"), |  | ||||||
|                                     args[0])); |  | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (args.length == starting + 1) { |         if (args.length == starting + 1) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage( | ||||||
|                     ChatColor.RED + "You need to supply the disguise options as well as the radius" + (starting != 0 ? |                     (starting == 0 ? LibsMsg.DMODRADIUS_NEEDOPTIONS : LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY).get()); | ||||||
|                             " and EntityType" : ""))); |  | ||||||
|             return true; |             return true; | ||||||
|         } else if (args.length < 2) { |         } else if (args.length < 2) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DMODRADIUS_NEEDOPTIONS.get()); | ||||||
|                     ChatColor.RED + "You need to supply a radius as well as " + "the disguise options")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!isNumeric(args[starting])) { |         if (!isNumeric(args[starting])) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get(ChatColor.RED + "%s is not a " + "number"), |             sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting])); | ||||||
|                     args[starting])); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         int radius = Integer.parseInt(args[starting]); |         int radius = Integer.parseInt(args[starting]); | ||||||
|  |  | ||||||
|         if (radius > maxRadius) { |         if (radius > maxRadius) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius)); | ||||||
|                     ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), maxRadius)); |  | ||||||
|             radius = maxRadius; |             radius = maxRadius; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -192,16 +180,13 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (noPermission > 0) { |         if (noPermission > 0) { | ||||||
|             sender.sendMessage(String.format( |             sender.sendMessage(LibsMsg.DMODRADIUS_NOPERM.get(noPermission)); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "No permission to modify " + "%s disguises!"), |  | ||||||
|                     noPermission)); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (modifiedDisguises > 0) { |         if (modifiedDisguises > 0) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DMODRADIUS.get(modifiedDisguises)); | ||||||
|                     ChatColor.RED + "Successfully modified the disguises of %s" + " entities!"), modifiedDisguises)); |  | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Couldn't find any disguised entities!")); |             sender.sendMessage(LibsMsg.DMODRADIUS_NOENTS.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
| @@ -241,8 +226,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|         int radius = Integer.parseInt(args[starting]); |         int radius = Integer.parseInt(args[starting]); | ||||||
|  |  | ||||||
|         if (radius > maxRadius) { |         if (radius > maxRadius) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius)); | ||||||
|                     ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), maxRadius)); |  | ||||||
|             radius = maxRadius; |             radius = maxRadius; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -293,8 +277,8 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|  |  | ||||||
|                 if (addMethods) { |                 if (addMethods) { | ||||||
|                     // If this is a method, add. Else if it can be a param of the previous argument, add. |                     // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                     for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                     for (Method method : ReflectionFlagWatchers | ||||||
|                             disguiseType.getWatcherClass())) { |                             .getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { | ||||||
|                         tabs.add(method.getName()); |                         tabs.add(method.getName()); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -312,31 +296,22 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements | |||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|  |  | ||||||
|         sender.sendMessage(String.format(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DMODRADIUS_HELP1.get(maxRadius)); | ||||||
|                 ChatColor.DARK_GREEN + "Modify the disguises in a radius! Caps at %s blocks!"), maxRadius)); |         sender.sendMessage(LibsMsg.DMODRADIUS_HELP2 | ||||||
|         sender.sendMessage( |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the disguises: %s"), |  | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|  |  | ||||||
|         String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"; |         String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"; | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("player")) { |         if (allowedDisguises.contains("player")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DMODRADIUS_HELP3.get()); | ||||||
|                     (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>").replace( |  | ||||||
|                             "<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"))); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DMODRADIUS_HELP4.get()); | ||||||
|                 (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby" + optional + ">").replace( |  | ||||||
|                         "<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"))); |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { |         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DMODRADIUS_HELP5.get()); | ||||||
|                     (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace( |  | ||||||
|                             "<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"))); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DMODRADIUS_HELP6.get()); | ||||||
|                 ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius " + "EntityTypes")); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | |||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| @@ -32,7 +33,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | |||||||
|         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); |         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); | ||||||
|  |  | ||||||
|         if (map.isEmpty()) { |         if (map.isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -42,16 +43,14 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (args.length == 1) { |         if (args.length == 1) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DPLAYER_SUPPLY.get()); | ||||||
|                     ChatColor.RED + "You need to supply a disguise as well as " + "the player")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Player player = Bukkit.getPlayer(args[0]); |         Player player = Bukkit.getPlayer(args[0]); | ||||||
|  |  | ||||||
|         if (player == null) { |         if (player == null) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0])); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the player '%s'"), args[0])); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -81,8 +80,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) { |         if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DISABLED_LIVING_TO_MISC.get()); | ||||||
|                     ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the" + " config!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -100,13 +98,9 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | |||||||
|         DisguiseAPI.disguiseToAll(player, disguise); |         DisguiseAPI.disguiseToAll(player, disguise); | ||||||
|  |  | ||||||
|         if (disguise.isDisguiseInUse()) { |         if (disguise.isDisguiseInUse()) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG.get(player.getName(), disguise.getType().toReadable())); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Successfully disguised %s as a %s!"), |  | ||||||
|                             player.getName(), disguise.getType().toReadable())); |  | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL.get(player.getName(), disguise.getType().toReadable())); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Failed to disguise %s as a %s!"), |  | ||||||
|                             player.getName(), disguise.getType().toReadable())); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
| @@ -175,8 +169,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | |||||||
|  |  | ||||||
|                     if (addMethods) { |                     if (addMethods) { | ||||||
|                         // If this is a method, add. Else if it can be a param of the previous argument, add. |                         // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                         for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                         for (Method method : ReflectionFlagWatchers | ||||||
|                                 disguiseType.getWatcherClass())) { |                                 .getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { | ||||||
|                             tabs.add(method.getName()); |                             tabs.add(method.getName()); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @@ -195,22 +189,18 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom | |||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|  |  | ||||||
|         sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); |         sender.sendMessage(LibsMsg.D_HELP1.get()); | ||||||
|         sender.sendMessage( |         sender.sendMessage(LibsMsg.D_HELP2 | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"), |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("player")) { |         if (allowedDisguises.contains("player")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.D_HELP3.get()); | ||||||
|                     ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player " + "<Name>")); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.D_HELP4.get()); | ||||||
|                 ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> " + "<DisguiseType> <Baby>")); |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { |         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.D_HELP5.get()); | ||||||
|                     ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> " + "<Durability>")); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,13 +5,10 @@ import me.libraryaddict.disguise.DisguiseConfig; | |||||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||||
| import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | ||||||
| import me.libraryaddict.disguise.utilities.ClassGetter; | import me.libraryaddict.disguise.utilities.*; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; |  | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers; |  | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; |  | ||||||
| import org.apache.commons.lang.StringUtils; | import org.apache.commons.lang.StringUtils; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| @@ -44,15 +41,14 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); |         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); | ||||||
|  |  | ||||||
|         if (map.isEmpty()) { |         if (map.isEmpty()) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -70,10 +66,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|  |  | ||||||
|             Collections.sort(classes); |             Collections.sort(classes); | ||||||
|  |  | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.DRADIUS_ENTITIES | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"), |                     .get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN))); | ||||||
|                             ChatColor.GREEN + StringUtils.join(classes, |  | ||||||
|                                     ChatColor.DARK_GREEN + ", " + ChatColor.GREEN))); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -98,36 +92,30 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (type == null) { |                 if (type == null) { | ||||||
|                     sender.sendMessage( |                     sender.sendMessage(LibsMsg.DRADIUS_UNRECOG.get(args[0])); | ||||||
|                             String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Unrecognised " + "EntityType %s"), |  | ||||||
|                                     args[0])); |  | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (args.length == starting + 1) { |         if (args.length == starting + 1) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage( | ||||||
|                     ChatColor.RED + "You need to supply a disguise as well as the radius" + (starting != 0 ? |                     (starting == 0 ? LibsMsg.DRADIUS_NEEDOPTIONS : LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY).get()); | ||||||
|                             " and EntityType" : ""))); |  | ||||||
|             return true; |             return true; | ||||||
|         } else if (args.length < 2) { |         } else if (args.length < 2) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DRADIUS_NEEDOPTIONS.get()); | ||||||
|                     ChatColor.RED + "You need to supply a radius as well as " + "the disguise")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!isNumeric(args[starting])) { |         if (!isNumeric(args[starting])) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting])); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "%s is not a number"), args[starting])); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         int radius = Integer.parseInt(args[starting]); |         int radius = Integer.parseInt(args[starting]); | ||||||
|  |  | ||||||
|         if (radius > maxRadius) { |         if (radius > maxRadius) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius)); | ||||||
|                     ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), maxRadius)); |  | ||||||
|             radius = maxRadius; |             radius = maxRadius; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -173,7 +161,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) { |             if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) { | ||||||
|                 if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { |                 if (disguise.isMiscDisguise() && !DisguiseConfig | ||||||
|  |                         .isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { | ||||||
|                     miscDisguises++; |                     miscDisguises++; | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
| @@ -198,17 +187,13 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (disguisedEntitys > 0) { |         if (disguisedEntitys > 0) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.DISRADIUS.get(disguisedEntitys)); | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Successfully disguised %s" + " entities!"), |  | ||||||
|                             disguisedEntitys)); |  | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Couldn't find any entities to disguise!")); |             sender.sendMessage(LibsMsg.DISRADIUS_FAIL.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (miscDisguises > 0) { |         if (miscDisguises > 0) { | ||||||
|             sender.sendMessage(String.format(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DRADIUS_MISCDISG.get(miscDisguises)); | ||||||
|                     ChatColor.RED + "Failed to disguise %s entities because the option to disguise a living entity as" + " a non-living has been disabled in the config"), |  | ||||||
|                     miscDisguises)); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
| @@ -299,8 +284,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|  |  | ||||||
|                     if (addMethods) { |                     if (addMethods) { | ||||||
|                         // If this is a method, add. Else if it can be a param of the previous argument, add. |                         // If this is a method, add. Else if it can be a param of the previous argument, add. | ||||||
|                         for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods( |                         for (Method method : ReflectionFlagWatchers | ||||||
|                                 disguiseType.getWatcherClass())) { |                                 .getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { | ||||||
|                             tabs.add(method.getName()); |                             tabs.add(method.getName()); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @@ -319,31 +304,20 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom | |||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) { | ||||||
|         ArrayList<String> allowedDisguises = getAllowedDisguises(map); |         ArrayList<String> allowedDisguises = getAllowedDisguises(map); | ||||||
|  |  | ||||||
|         sender.sendMessage(String.format(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DRADIUS_HELP1.get(maxRadius)); | ||||||
|                 ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"), maxRadius)); |         sender.sendMessage(LibsMsg.DRADIUS_HELP2 | ||||||
|         sender.sendMessage( |                 .get(ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); | ||||||
|                 String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"), |  | ||||||
|                         ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN))); |  | ||||||
|  |  | ||||||
|         String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"; |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("player")) { |         if (allowedDisguises.contains("player")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DRADIUS_HELP3.get()); | ||||||
|                     (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>").replace( |  | ||||||
|                             "<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"))); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DRADIUS_HELP4.get()); | ||||||
|                 (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby" + optional + ">").replace( |  | ||||||
|                         "<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"))); |  | ||||||
|  |  | ||||||
|         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { |         if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.DRADIUS_HELP5.get()); | ||||||
|                     (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace( |  | ||||||
|                             "<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"))); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         sender.sendMessage(TranslateType.MESSAGE.get( |         sender.sendMessage(LibsMsg.DRADIUS_HELP6.get()); | ||||||
|                 ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius " + "EntityTypes")); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package me.libraryaddict.disguise.commands; | package me.libraryaddict.disguise.commands; | ||||||
|  |  | ||||||
|  | import me.libraryaddict.disguise.DisguiseAPI; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.command.Command; | import org.bukkit.command.Command; | ||||||
| @@ -7,8 +9,6 @@ import org.bukkit.command.CommandExecutor; | |||||||
| import org.bukkit.command.CommandSender; | import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.DisguiseAPI; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @author Navid |  * @author Navid | ||||||
|  */ |  */ | ||||||
| @@ -17,8 +17,7 @@ public class DisguiseViewSelfCommand implements CommandExecutor { | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -26,10 +25,10 @@ public class DisguiseViewSelfCommand implements CommandExecutor { | |||||||
|  |  | ||||||
|         if (DisguiseAPI.isViewSelfToggled(player)) { |         if (DisguiseAPI.isViewSelfToggled(player)) { | ||||||
|             DisguiseAPI.setViewDisguiseToggled(player, false); |             DisguiseAPI.setViewDisguiseToggled(player, false); | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.GREEN + "Toggled viewing own disguise off!")); |             sender.sendMessage(LibsMsg.VIEW_SELF_ON.get()); | ||||||
|         } else { |         } else { | ||||||
|             DisguiseAPI.setViewDisguiseToggled(player, true); |             DisguiseAPI.setViewDisguiseToggled(player, true); | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.GREEN + "Toggled viewing own disguise on!")); |             sender.sendMessage(LibsMsg.VIEW_SELF_OFF.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package me.libraryaddict.disguise.commands; | package me.libraryaddict.disguise.commands; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.LibsDisguises; | import me.libraryaddict.disguise.LibsDisguises; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | import me.libraryaddict.disguise.utilities.LibsPremium; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| @@ -35,7 +36,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected String[] getArgs(String[] args) { |     protected String[] getArgs(String[] args) { | ||||||
|         ArrayList<String> newArgs = new ArrayList<String>(); |         ArrayList<String> newArgs = new ArrayList<>(); | ||||||
|  |  | ||||||
|         for (int i = 0; i < args.length - 1; i++) { |         for (int i = 0; i < args.length - 1; i++) { | ||||||
|             String s = args[i]; |             String s = args[i]; | ||||||
| @@ -53,8 +54,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | |||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (args.length == 0) { |         if (args.length == 0) { | ||||||
|             sender.sendMessage( |             sender.sendMessage( | ||||||
|                     ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + Bukkit.getPluginManager().getPlugin( |                     ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + Bukkit.getPluginManager() | ||||||
|                             "LibsDisguises").getDescription().getVersion() + " by libraryaddict, formerly maintained " + "by Byteflux and NavidK0." + ( |                             .getPlugin("LibsDisguises").getDescription() | ||||||
|  |                             .getVersion() + " by libraryaddict, formerly maintained " + "by Byteflux and NavidK0." + ( | ||||||
|                             sender.hasPermission("libsdisguises.reload") ? |                             sender.hasPermission("libsdisguises.reload") ? | ||||||
|                                     "\nUse " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" + "." : |                                     "\nUse " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" + "." : | ||||||
|                                     "")); |                                     "")); | ||||||
| @@ -66,14 +68,13 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | |||||||
|             if (sender.hasPermission("libsdisguises.reload")) { |             if (sender.hasPermission("libsdisguises.reload")) { | ||||||
|                 if (args[0].equalsIgnoreCase("reload")) { |                 if (args[0].equalsIgnoreCase("reload")) { | ||||||
|                     LibsDisguises.getInstance().reload(); |                     LibsDisguises.getInstance().reload(); | ||||||
|                     sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.GREEN + "[LibsDisguises] Reloaded config.")); |                     sender.sendMessage(LibsMsg.RELOADED_CONFIG.get()); | ||||||
|                     return true; |                     return true; | ||||||
|                 } else { |                 } else { | ||||||
|                     sender.sendMessage(TranslateType.MESSAGE.get( |                     sender.sendMessage(LibsMsg.LIBS_RELOAD_WRONG.get()); | ||||||
|                             ChatColor.RED + "[LibsDisguises] Did you mean 'reload'?")); |  | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |                 sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return true; |         return true; | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package me.libraryaddict.disguise.commands; | package me.libraryaddict.disguise.commands; | ||||||
|  |  | ||||||
|  | import me.libraryaddict.disguise.DisguiseAPI; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.command.Command; | import org.bukkit.command.Command; | ||||||
| @@ -8,27 +10,26 @@ import org.bukkit.command.CommandSender; | |||||||
| import org.bukkit.entity.Entity; | import org.bukkit.entity.Entity; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.DisguiseAPI; |  | ||||||
|  |  | ||||||
| public class UndisguiseCommand implements CommandExecutor { | public class UndisguiseCommand implements CommandExecutor { | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (sender.hasPermission("libsdisguises.undisguise")) { |         if (sender.hasPermission("libsdisguises.undisguise")) { | ||||||
|             if (DisguiseAPI.isDisguised((Entity) sender)) { |             if (DisguiseAPI.isDisguised((Entity) sender)) { | ||||||
|                 DisguiseAPI.undisguiseToAll((Player) sender); |                 DisguiseAPI.undisguiseToAll((Player) sender); | ||||||
|                 sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are no longer disguised")); |                 sender.sendMessage(LibsMsg.UNDISG.get()); | ||||||
|             } else { |             } else { | ||||||
|                 sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are not disguised!")); |                 sender.sendMessage(LibsMsg.UNDISG_FAIL.get()); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package me.libraryaddict.disguise.commands; | package me.libraryaddict.disguise.commands; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.LibsDisguises; | import me.libraryaddict.disguise.LibsDisguises; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.command.Command; | import org.bukkit.command.Command; | ||||||
| @@ -12,16 +13,14 @@ public class UndisguiseEntityCommand implements CommandExecutor { | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|         if (sender.hasPermission("libsdisguises.undisguiseentity")) { |         if (sender.hasPermission("libsdisguises.undisguiseentity")) { | ||||||
|             LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), null); |             LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), null); | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get( |             sender.sendMessage(LibsMsg.UND_ENTITY.get()); | ||||||
|                     ChatColor.RED + "Right click a disguised entity to " + "undisguise them!")); |  | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|         } |         } | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,9 +1,8 @@ | |||||||
| package me.libraryaddict.disguise.commands; | package me.libraryaddict.disguise.commands; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.DisguiseAPI; | import me.libraryaddict.disguise.DisguiseAPI; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; |  | ||||||
| import org.bukkit.command.Command; | import org.bukkit.command.Command; | ||||||
| import org.bukkit.command.CommandExecutor; | import org.bukkit.command.CommandExecutor; | ||||||
| import org.bukkit.command.CommandSender; | import org.bukkit.command.CommandSender; | ||||||
| @@ -57,19 +56,18 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { | |||||||
|                 if (p != null) { |                 if (p != null) { | ||||||
|                     if (DisguiseAPI.isDisguised(p)) { |                     if (DisguiseAPI.isDisguised(p)) { | ||||||
|                         DisguiseAPI.undisguiseToAll(p); |                         DisguiseAPI.undisguiseToAll(p); | ||||||
|                         sender.sendMessage( |                         sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(p.getName())); | ||||||
|                                 TranslateType.MESSAGE.get(ChatColor.RED + "The player is no longer disguised")); |  | ||||||
|                     } else { |                     } else { | ||||||
|                         sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "The player is not disguised!")); |                         sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(p.getName())); | ||||||
|                     } |                     } | ||||||
|                 } else { |                 } else { | ||||||
|                     sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Player not found")); |                     sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0])); | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "/undisguiseplayer <Name>")); |                 sender.sendMessage(LibsMsg.UNDISG_PLAYER_HELP.get()); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|         } |         } | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package me.libraryaddict.disguise.commands; | package me.libraryaddict.disguise.commands; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.DisguiseAPI; | import me.libraryaddict.disguise.DisguiseAPI; | ||||||
|  | import me.libraryaddict.disguise.utilities.LibsMsg; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.command.Command; | import org.bukkit.command.Command; | ||||||
| @@ -29,24 +30,20 @@ public class UndisguiseRadiusCommand implements CommandExecutor { | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (sender.getName().equals("CONSOLE")) { | ||||||
|             sender.sendMessage( |             sender.sendMessage(LibsMsg.NO_CONSOLE.get()); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!")); |  | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (sender.hasPermission("libsdisguises.undisguiseradius")) { |         if (sender.hasPermission("libsdisguises.undisguiseradius")) { | ||||||
|             int radius = maxRadius; |             int radius = maxRadius; | ||||||
|             if (args.length > 0) { |             if (args.length > 0) { | ||||||
|                 if (!isNumeric(args[0])) { |                 if (!isNumeric(args[0])) { | ||||||
|                     sender.sendMessage(String.format(TranslateType.MESSAGE.get( |                     sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[0])); | ||||||
|                             ChatColor.RED + "Error! " + ChatColor.GREEN + "%s" + ChatColor.RED + " is not a " + "number!"), |  | ||||||
|                             args[0])); |  | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|                 radius = Integer.parseInt(args[0]); |                 radius = Integer.parseInt(args[0]); | ||||||
|                 if (radius > maxRadius) { |                 if (radius > maxRadius) { | ||||||
|                     sender.sendMessage(String.format(TranslateType.MESSAGE.get( |                     sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius)); | ||||||
|                             ChatColor.RED + "Limited radius to %s" + "! Don't want to make too much lag right?"), |  | ||||||
|                             maxRadius)); |  | ||||||
|                     radius = maxRadius; |                     radius = maxRadius; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -61,11 +58,10 @@ public class UndisguiseRadiusCommand implements CommandExecutor { | |||||||
|                     disguisedEntitys++; |                     disguisedEntitys++; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             sender.sendMessage( |  | ||||||
|                     String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Successfully undisguised %s entities!"), |             sender.sendMessage(LibsMsg.UNDISRADIUS.get(disguisedEntitys)); | ||||||
|                             disguisedEntitys)); |  | ||||||
|         } else { |         } else { | ||||||
|             sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command.")); |             sender.sendMessage(LibsMsg.NO_PERM.get()); | ||||||
|         } |         } | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ public class DisguiseParser { | |||||||
|             super(); |             super(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public DisguiseParseException(LibsMessages message, String... params) { |         public DisguiseParseException(LibsMsg message, String... params) { | ||||||
|             super(message.get(params)); |             super(message.get(params)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -145,9 +145,7 @@ public class DisguiseParser { | |||||||
|             ArrayList<String> usedOptions) throws DisguiseParseException { |             ArrayList<String> usedOptions) throws DisguiseParseException { | ||||||
|  |  | ||||||
|         if (!passesCheck(sender, optionPermissions, usedOptions)) { |         if (!passesCheck(sender, optionPermissions, usedOptions)) { | ||||||
|             throw new DisguiseParseException( |             throw new DisguiseParseException(LibsMsg.D_PARSE_NOPERM, usedOptions.get(usedOptions.size() - 1)); | ||||||
|                     ChatColor.RED + "You do not have permission to use the option " + usedOptions.get( |  | ||||||
|                             usedOptions.size() - 1)); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -201,7 +199,8 @@ public class DisguiseParser { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static DisguisePerm[] getDisguisePerms() { |     public static DisguisePerm[] getDisguisePerms() { | ||||||
|         DisguisePerm[] perms = new DisguisePerm[DisguiseType.values().length + DisguiseConfig.getCustomDisguises().size()]; |         DisguisePerm[] perms = new DisguisePerm[DisguiseType.values().length + DisguiseConfig.getCustomDisguises() | ||||||
|  |                 .size()]; | ||||||
|         int i = 0; |         int i = 0; | ||||||
|  |  | ||||||
|         for (DisguiseType disguiseType : DisguiseType.values()) { |         for (DisguiseType disguiseType : DisguiseType.values()) { | ||||||
| @@ -467,12 +466,11 @@ public class DisguiseParser { | |||||||
|     public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args, |     public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args, | ||||||
|             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException { |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException { | ||||||
|         if (permissionMap.isEmpty()) { |         if (permissionMap.isEmpty()) { | ||||||
|             throw new DisguiseParseException( |             throw new DisguiseParseException(LibsMsg.NO_PERM); | ||||||
|                     TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this " + "command.")); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (args.length == 0) { |         if (args.length == 0) { | ||||||
|             throw new DisguiseParseException(TranslateType.MESSAGE.get("No arguments defined")); |             throw new DisguiseParseException(LibsMsg.PARSE_NO_ARGS); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // How many args to skip due to the disugise being constructed |         // How many args to skip due to the disugise being constructed | ||||||
| @@ -488,13 +486,10 @@ public class DisguiseParser { | |||||||
|                 disguise = DisguiseUtilities.getClonedDisguise(args[0].toLowerCase()); |                 disguise = DisguiseUtilities.getClonedDisguise(args[0].toLowerCase()); | ||||||
|  |  | ||||||
|                 if (disguise == null) { |                 if (disguise == null) { | ||||||
|                     throw new DisguiseParseException(String.format( |                     throw new DisguiseParseException(LibsMsg.PARSE_NO_REF, args[0]); | ||||||
|                             TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find a disguise under the reference %s"), |  | ||||||
|                             args[0])); |  | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 throw new DisguiseParseException(TranslateType.MESSAGE.get( |                 throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_REF); | ||||||
|                         ChatColor.RED + "You do not have perimssion to use disguise references!")); |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             optionPermissions = (permissionMap.containsKey(new DisguisePerm(disguise.getType())) ? |             optionPermissions = (permissionMap.containsKey(new DisguisePerm(disguise.getType())) ? | ||||||
| @@ -509,24 +504,19 @@ public class DisguiseParser { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (disguisePerm == null) { |             if (disguisePerm == null) { | ||||||
|                 throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get( |                 throw new DisguiseParseException(LibsMsg.PARSE_DISG_NO_EXIST, args[0]); | ||||||
|                         ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + "%s" + ChatColor.RED + " " + "doesn't exist!"), |  | ||||||
|                         args[0])); |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (disguisePerm.isUnknown()) { |             if (disguisePerm.isUnknown()) { | ||||||
|                 throw new DisguiseParseException(TranslateType.MESSAGE.get( |                 throw new DisguiseParseException(LibsMsg.PARSE_CANT_DISG_UNKNOWN); | ||||||
|                         ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!")); |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (disguisePerm.getEntityType() == null) { |             if (disguisePerm.getEntityType() == null) { | ||||||
|                 throw new DisguiseParseException( |                 throw new DisguiseParseException(LibsMsg.PARSE_CANT_LOAD); | ||||||
|                         TranslateType.MESSAGE.get(ChatColor.RED + "Error! This disguise " + "couldn't be loaded!")); |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (!permissionMap.containsKey(disguisePerm)) { |             if (!permissionMap.containsKey(disguisePerm)) { | ||||||
|                 throw new DisguiseParseException( |                 throw new DisguiseParseException(LibsMsg.NO_PERM_DISGUISE); | ||||||
|                         TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use " + "this disguise.")); |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             optionPermissions = permissionMap.get(disguisePerm); |             optionPermissions = permissionMap.get(disguisePerm); | ||||||
| @@ -538,13 +528,11 @@ public class DisguiseParser { | |||||||
|                     // If he is doing a player disguise |                     // If he is doing a player disguise | ||||||
|                     if (args.length == 1) { |                     if (args.length == 1) { | ||||||
|                         // He needs to give the player name |                         // He needs to give the player name | ||||||
|                         throw new DisguiseParseException(TranslateType.MESSAGE.get( |                         throw new DisguiseParseException(LibsMsg.PARSE_SUPPLY_PLAYER); | ||||||
|                                 ChatColor.RED + "Error! You need " + "to give a player name!")); |  | ||||||
|                     } else { |                     } else { | ||||||
|                         if (!disguiseOptions.isEmpty() && (!disguiseOptions.containsKey( |                         if (!disguiseOptions.isEmpty() && (!disguiseOptions | ||||||
|                                 args[1].toLowerCase()) || !disguiseOptions.get(args[1].toLowerCase()))) { |                                 .containsKey(args[1].toLowerCase()) || !disguiseOptions.get(args[1].toLowerCase()))) { | ||||||
|                             throw new DisguiseParseException(TranslateType.MESSAGE.get( |                             throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_NAME); | ||||||
|                                     ChatColor.RED + "Error! You don't have permission to use that name!")); |  | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         args[1] = args[1].replace("\\_", " "); |                         args[1] = args[1].replace("\\_", " "); | ||||||
| @@ -587,7 +575,8 @@ public class DisguiseParser { | |||||||
|                         if (isInteger(args[1])) { |                         if (isInteger(args[1])) { | ||||||
|                             miscId = Integer.parseInt(args[1]); |                             miscId = Integer.parseInt(args[1]); | ||||||
|                         } else { |                         } else { | ||||||
|                             if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK || disguisePerm.getType() == DisguiseType.DROPPED_ITEM) { |                             if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK || disguisePerm | ||||||
|  |                                     .getType() == DisguiseType.DROPPED_ITEM) { | ||||||
|                                 for (Material mat : Material.values()) { |                                 for (Material mat : Material.values()) { | ||||||
|                                     if (mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) { |                                     if (mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) { | ||||||
|                                         miscId = mat.getId(); |                                         miscId = mat.getId(); | ||||||
| @@ -611,9 +600,8 @@ public class DisguiseParser { | |||||||
|                                 case WITHER_SKULL: |                                 case WITHER_SKULL: | ||||||
|                                     break; |                                     break; | ||||||
|                                 default: |                                 default: | ||||||
|                                     throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get( |                                     throw new DisguiseParseException(LibsMsg.PARSE_TOO_MANY_ARGS, | ||||||
|                                             ChatColor.RED + "Error! %s doesn't know" + " " + "what to do with %s!"), |                                             disguisePerm.toReadable(), args[1]); | ||||||
|                                             disguisePerm.toReadable(), args[1])); |  | ||||||
|                             } |                             } | ||||||
|                             toSkip++; |                             toSkip++; | ||||||
|                             // If they also defined a data value |                             // If they also defined a data value | ||||||
| @@ -622,11 +610,11 @@ public class DisguiseParser { | |||||||
|                                 toSkip++; |                                 toSkip++; | ||||||
|                             } |                             } | ||||||
|                             if (secondArg != null) { |                             if (secondArg != null) { | ||||||
|                                 if (disguisePerm.getType() != DisguiseType.FALLING_BLOCK && disguisePerm.getType() != DisguiseType.DROPPED_ITEM) { |                                 if (disguisePerm.getType() != DisguiseType.FALLING_BLOCK && disguisePerm | ||||||
|                                     throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get( |                                         .getType() != DisguiseType.DROPPED_ITEM) { | ||||||
|                                             ChatColor.RED + "Error! Only the disguises " + DisguiseType.FALLING_BLOCK.toReadable() + " and " + DisguiseType.DROPPED_ITEM.toReadable() + " uses a second number!"), |                                     throw new DisguiseParseException(LibsMsg.PARSE_USE_SECOND_NUM, | ||||||
|                                             DisguiseType.FALLING_BLOCK.toReadable(), |                                             DisguiseType.FALLING_BLOCK.toReadable(), | ||||||
|                                             DisguiseType.DROPPED_ITEM.toReadable())); |                                             DisguiseType.DROPPED_ITEM.toReadable()); | ||||||
|                                 } |                                 } | ||||||
|                                 miscData = Integer.parseInt(secondArg); |                                 miscData = Integer.parseInt(secondArg); | ||||||
|                             } |                             } | ||||||
| @@ -645,9 +633,8 @@ public class DisguiseParser { | |||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) { |                         if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) { | ||||||
|                             throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get( |                             throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, toCheck, | ||||||
|                                     ChatColor.RED + "Error! You do not have permission to use the parameter %s on the" + " %s disguise!"), |                                     disguisePerm.toReadable()); | ||||||
|                                     toCheck, disguisePerm.toReadable())); |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
| @@ -760,12 +747,7 @@ public class DisguiseParser { | |||||||
|                             } |                             } | ||||||
|                         } else if (param == ItemStack.class) { |                         } else if (param == ItemStack.class) { | ||||||
|                             // Parse to itemstack |                             // Parse to itemstack | ||||||
|                             try { |                             value = parseToItemstack(methodName, valueString); | ||||||
|                                 value = parseToItemstack(valueString); |  | ||||||
|                             } |  | ||||||
|                             catch (Exception ex) { |  | ||||||
|                                 throw new DisguiseParseException(String.format(ex.getMessage(), methodName)); |  | ||||||
|                             } |  | ||||||
|                         } else if (param == ItemStack[].class) { |                         } else if (param == ItemStack[].class) { | ||||||
|                             // Parse to itemstack array |                             // Parse to itemstack array | ||||||
|                             ItemStack[] items = new ItemStack[4]; |                             ItemStack[] items = new ItemStack[4]; | ||||||
| @@ -775,7 +757,7 @@ public class DisguiseParser { | |||||||
|                             if (split.length == 4) { |                             if (split.length == 4) { | ||||||
|                                 for (int a = 0; a < 4; a++) { |                                 for (int a = 0; a < 4; a++) { | ||||||
|                                     try { |                                     try { | ||||||
|                                         items[a] = parseToItemstack(split[a]); |                                         items[a] = parseToItemstack(methodName, split[a]); | ||||||
|                                     } |                                     } | ||||||
|                                     catch (Exception ex) { |                                     catch (Exception ex) { | ||||||
|                                         throw parseToException( |                                         throw parseToException( | ||||||
| @@ -858,8 +840,8 @@ public class DisguiseParser { | |||||||
|                         } else if (param == RabbitType.class) { |                         } else if (param == RabbitType.class) { | ||||||
|                             try { |                             try { | ||||||
|                                 for (RabbitType type : RabbitType.values()) { |                                 for (RabbitType type : RabbitType.values()) { | ||||||
|                                     if (type.name().replace("_", "").equalsIgnoreCase( |                                     if (type.name().replace("_", "") | ||||||
|                                             valueString.replace("_", "").replace(" ", ""))) { |                                             .equalsIgnoreCase(valueString.replace("_", "").replace(" ", ""))) { | ||||||
|                                         value = type; |                                         value = type; | ||||||
|  |  | ||||||
|                                         break; |                                         break; | ||||||
| @@ -927,10 +909,10 @@ public class DisguiseParser { | |||||||
|                     throw storedEx; |                     throw storedEx; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 throw new DisguiseParseException(ChatColor.RED + "Cannot find the option " + methodName); |                 throw new DisguiseParseException(LibsMsg.PARSE_OPTION_NA, methodName); | ||||||
|             } |             } | ||||||
|             if (value == null) { |             if (value == null) { | ||||||
|                 throw new DisguiseParseException(ChatColor.RED + "No value was given for the option " + methodName); |                 throw new DisguiseParseException(LibsMsg.PARSE_NO_OPTION_VALUE, methodName); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (!usedOptions.contains(methodName.toLowerCase())) { |             if (!usedOptions.contains(methodName.toLowerCase())) { | ||||||
| @@ -949,11 +931,10 @@ public class DisguiseParser { | |||||||
|  |  | ||||||
|     private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, |     private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, | ||||||
|             String methodName) { |             String methodName) { | ||||||
|         return new DisguiseParseException( |         return new DisguiseParseException(LibsMsg.PARSE_EXPECTED_RECEIVED, expectedValue, receivedInstead, methodName); | ||||||
|                 ChatColor.RED + "Expected " + ChatColor.GREEN + expectedValue + ChatColor.RED + ", received " + ChatColor.GREEN + receivedInstead + ChatColor.RED + " instead for " + ChatColor.GREEN + methodName); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static ItemStack parseToItemstack(String string) throws Exception { |     private static ItemStack parseToItemstack(String method, String string) throws DisguiseParseException { | ||||||
|         String[] split = string.split(":", -1); |         String[] split = string.split(":", -1); | ||||||
|  |  | ||||||
|         int itemId = -1; |         int itemId = -1; | ||||||
| @@ -1000,13 +981,13 @@ public class DisguiseParser { | |||||||
|             boolean myPerms = true; |             boolean myPerms = true; | ||||||
|  |  | ||||||
|             for (String option : usedOptions) { |             for (String option : usedOptions) { | ||||||
|                 if (!sender.getName().equals("CONSOLE") && option.equalsIgnoreCase( |                 if (!sender.getName().equals("CONSOLE") && option.equalsIgnoreCase("setInvisible") && DisguiseConfig | ||||||
|                         "setInvisible") && DisguiseConfig.isDisabledInvisibility()) { |                         .isDisabledInvisibility()) { | ||||||
|                     myPerms = false; |                     myPerms = false; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (!(theirPermissions.get(list) && list.contains("*")) && (list.contains( |                 if (!(theirPermissions.get(list) && list.contains("*")) && (list.contains(option) != theirPermissions | ||||||
|                         option) != theirPermissions.get(list))) { |                         .get(list))) { | ||||||
|                     myPerms = false; |                     myPerms = false; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -121,12 +121,10 @@ public class DisguiseUtilities { | |||||||
|         if (reference != null && DisguiseUtilities.addClonedDisguise(reference, disguise)) { |         if (reference != null && DisguiseUtilities.addClonedDisguise(reference, disguise)) { | ||||||
|             String entityName = DisguiseType.getType(toClone).toReadable(); |             String entityName = DisguiseType.getType(toClone).toReadable(); | ||||||
|  |  | ||||||
|             player.sendMessage( |             player.sendMessage(LibsMsg.MADE_REF.get(entityName, reference)); | ||||||
|                     ChatColor.RED + "Constructed a " + entityName + " disguise! Your reference is " + reference); |             player.sendMessage(LibsMsg.MADE_REF_EXAMPLE.get(reference)); | ||||||
|             player.sendMessage(ChatColor.RED + "Example usage: /disguise " + reference); |  | ||||||
|         } else { |         } else { | ||||||
|             player.sendMessage( |             player.sendMessage(LibsMsg.REF_TOO_MANY.get()); | ||||||
|                     ChatColor.RED + "Failed to store the reference, too many cloned disguises. Please raise the " + "maximum cloned disguises, or lower the time they last"); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -247,7 +245,8 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|         checkConflicts(disguise, null); |         checkConflicts(disguise, null); | ||||||
|  |  | ||||||
|         if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise.isModifyBoundingBox()) { |         if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise | ||||||
|  |                 .isModifyBoundingBox()) { | ||||||
|             doBoundingBox(disguise); |             doBoundingBox(disguise); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -385,8 +384,8 @@ public class DisguiseUtilities { | |||||||
|             if (entityTrackerEntry == null) |             if (entityTrackerEntry == null) | ||||||
|                 return; |                 return; | ||||||
|  |  | ||||||
|             Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |             Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                     entityTrackerEntry); |                     .get(entityTrackerEntry); | ||||||
|  |  | ||||||
|             // If the tracker exists. Remove himself from his tracker |             // If the tracker exists. Remove himself from his tracker | ||||||
|             trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent |             trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent | ||||||
| @@ -418,7 +417,9 @@ public class DisguiseUtilities { | |||||||
|                 FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); |                 FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); | ||||||
|  |  | ||||||
|                 if (disguiseValues.getBabyBox() != null) { |                 if (disguiseValues.getBabyBox() != null) { | ||||||
|                     if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby()) || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher()).isBaby())) { |                     if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()) | ||||||
|  |                             .isBaby()) || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise | ||||||
|  |                             .getWatcher()).isBaby())) { | ||||||
|                         disguiseBox = disguiseValues.getBabyBox(); |                         disguiseBox = disguiseValues.getBabyBox(); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -430,7 +431,8 @@ public class DisguiseUtilities { | |||||||
|                 FakeBoundingBox entityBox = entityValues.getAdultBox(); |                 FakeBoundingBox entityBox = entityValues.getAdultBox(); | ||||||
|  |  | ||||||
|                 if (entityValues.getBabyBox() != null) { |                 if (entityValues.getBabyBox() != null) { | ||||||
|                     if ((entity instanceof Ageable && !((Ageable) entity).isAdult()) || (entity instanceof Zombie && ((Zombie) entity).isBaby())) { |                     if ((entity instanceof Ageable && !((Ageable) entity) | ||||||
|  |                             .isAdult()) || (entity instanceof Zombie && ((Zombie) entity).isBaby())) { | ||||||
|                         entityBox = entityValues.getBabyBox(); |                         entityBox = entityValues.getBabyBox(); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -622,8 +624,8 @@ public class DisguiseUtilities { | |||||||
|             Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); |             Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); | ||||||
|  |  | ||||||
|             if (entityTrackerEntry != null) { |             if (entityTrackerEntry != null) { | ||||||
|                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                         entityTrackerEntry); |                         .get(entityTrackerEntry); | ||||||
|                 trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent |                 trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent | ||||||
|                 // ConcurrentModificationException |                 // ConcurrentModificationException | ||||||
|                 for (Object p : trackedPlayers) { |                 for (Object p : trackedPlayers) { | ||||||
| @@ -649,9 +651,9 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|             @Override |             @Override | ||||||
|             public void onLookup(WrappedGameProfile gameProfile) { |             public void onLookup(WrappedGameProfile gameProfile) { | ||||||
|                 if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName().equals( |                 if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName() | ||||||
|                         disguise.getSkin() != null ? disguise.getSkin() : |                         .equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) || !gameProfile | ||||||
|                                 disguise.getName()) || !gameProfile.getProperties().isEmpty())) { |                         .getProperties().isEmpty())) { | ||||||
|                     disguise.setGameProfile(gameProfile); |                     disguise.setGameProfile(gameProfile); | ||||||
|  |  | ||||||
|                     DisguiseUtilities.refreshTrackers(disguise); |                     DisguiseUtilities.refreshTrackers(disguise); | ||||||
| @@ -743,8 +745,9 @@ public class DisguiseUtilities { | |||||||
|                         catch (Exception e) { |                         catch (Exception e) { | ||||||
|                             runnables.remove(playerName); |                             runnables.remove(playerName); | ||||||
|  |  | ||||||
|                             System.out.print( |                             System.out | ||||||
|                                     "[LibsDisguises] Error when fetching " + playerName + "'s uuid from mojang: " + e.getMessage()); |                                     .print("[LibsDisguises] Error when fetching " + playerName + "'s uuid from mojang: " + e | ||||||
|  |                                             .getMessage()); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 }); |                 }); | ||||||
| @@ -803,21 +806,22 @@ public class DisguiseUtilities { | |||||||
|             Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null); |             Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null); | ||||||
|             Object world = ((List) server.getClass().getField("worlds").get(server)).get(0); |             Object world = ((List) server.getClass().getField("worlds").get(server)).get(0); | ||||||
|  |  | ||||||
|             Object bedChunk = ReflectionManager.getNmsClass("Chunk").getConstructor( |             Object bedChunk = ReflectionManager.getNmsClass("Chunk") | ||||||
|                     ReflectionManager.getNmsClass("World"), int.class, int.class).newInstance(world, 0, 0); |                     .getConstructor(ReflectionManager.getNmsClass("World"), int.class, int.class) | ||||||
|  |                     .newInstance(world, 0, 0); | ||||||
|  |  | ||||||
|             Field cSection = bedChunk.getClass().getDeclaredField("sections"); |             Field cSection = bedChunk.getClass().getDeclaredField("sections"); | ||||||
|             cSection.setAccessible(true); |             cSection.setAccessible(true); | ||||||
|  |  | ||||||
|             Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, |             Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class) | ||||||
|                     boolean.class).newInstance(0, true); |                     .newInstance(0, true); | ||||||
|  |  | ||||||
|             Object block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class).invoke(null, |             Object block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class) | ||||||
|                     Material.BED_BLOCK.getId()); |                     .invoke(null, Material.BED_BLOCK.getId()); | ||||||
|  |  | ||||||
|             Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class); |             Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class); | ||||||
|             Method setType = chunkSection.getClass().getMethod("setType", int.class, int.class, int.class, |             Method setType = chunkSection.getClass() | ||||||
|                     ReflectionManager.getNmsClass("IBlockData")); |                     .getMethod("setType", int.class, int.class, int.class, ReflectionManager.getNmsClass("IBlockData")); | ||||||
|             Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class); |             Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class); | ||||||
|             Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class); |             Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class); | ||||||
|  |  | ||||||
| @@ -835,8 +839,9 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|             cSection.set(bedChunk, array); |             cSection.set(bedChunk, array); | ||||||
|  |  | ||||||
|             spawnChunk = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, |             spawnChunk = ProtocolLibrary.getProtocolManager() | ||||||
|                     bedChunk, 65535).createPacket(bedChunk, 65535); |                     .createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, 65535) | ||||||
|  |                     .createPacket(bedChunk, 65535); | ||||||
|  |  | ||||||
|             Field threadField = ReflectionManager.getNmsField("MinecraftServer", "primaryThread"); |             Field threadField = ReflectionManager.getNmsField("MinecraftServer", "primaryThread"); | ||||||
|             threadField.setAccessible(true); |             threadField.setAccessible(true); | ||||||
| @@ -863,9 +868,9 @@ public class DisguiseUtilities { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isDisguiseInUse(Disguise disguise) { |     public static boolean isDisguiseInUse(Disguise disguise) { | ||||||
|         return disguise.getEntity() != null && getDisguises().containsKey( |         return disguise.getEntity() != null && getDisguises() | ||||||
|                 disguise.getEntity().getUniqueId()) && getDisguises().get(disguise.getEntity().getUniqueId()).contains( |                 .containsKey(disguise.getEntity().getUniqueId()) && getDisguises() | ||||||
|                 disguise); |                 .get(disguise.getEntity().getUniqueId()).contains(disguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -888,8 +893,8 @@ public class DisguiseUtilities { | |||||||
|         try { |         try { | ||||||
|             PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); |             PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); | ||||||
|  |  | ||||||
|             if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && disguise.getEntity().getName().equalsIgnoreCase( |             if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && disguise.getEntity().getName() | ||||||
|                     player)) { |                     .equalsIgnoreCase(player)) { | ||||||
|                 removeSelfDisguise((Player) disguise.getEntity()); |                 removeSelfDisguise((Player) disguise.getEntity()); | ||||||
|  |  | ||||||
|                 if (disguise.isSelfDisguiseVisible()) { |                 if (disguise.isSelfDisguiseVisible()) { | ||||||
| @@ -915,11 +920,11 @@ public class DisguiseUtilities { | |||||||
|                 if (entityTrackerEntry == null) |                 if (entityTrackerEntry == null) | ||||||
|                     return; |                     return; | ||||||
|  |  | ||||||
|                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                         entityTrackerEntry); |                         .get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                 Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", |                 Method clear = ReflectionManager | ||||||
|                         ReflectionManager.getNmsClass("EntityPlayer")); |                         .getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
|  |  | ||||||
|                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", |                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", | ||||||
|                         ReflectionManager.getNmsClass("EntityPlayer")); |                         ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
| @@ -975,11 +980,11 @@ public class DisguiseUtilities { | |||||||
|                 final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity); |                 final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity); | ||||||
|  |  | ||||||
|                 if (entityTrackerEntry != null) { |                 if (entityTrackerEntry != null) { | ||||||
|                     Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", |                     Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                             "trackedPlayers").get(entityTrackerEntry); |                             .get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                     Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", |                     Method clear = ReflectionManager | ||||||
|                             ReflectionManager.getNmsClass("EntityPlayer")); |                             .getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
|  |  | ||||||
|                     final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", |                     final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", | ||||||
|                             ReflectionManager.getNmsClass("EntityPlayer")); |                             ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
| @@ -1052,11 +1057,11 @@ public class DisguiseUtilities { | |||||||
|             final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); |             final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); | ||||||
|  |  | ||||||
|             if (entityTrackerEntry != null) { |             if (entityTrackerEntry != null) { | ||||||
|                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                         entityTrackerEntry); |                         .get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                 final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", |                 final Method clear = ReflectionManager | ||||||
|                         ReflectionManager.getNmsClass("EntityPlayer")); |                         .getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
|  |  | ||||||
|                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", |                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", | ||||||
|                         ReflectionManager.getNmsClass("EntityPlayer")); |                         ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
| @@ -1100,7 +1105,8 @@ public class DisguiseUtilities { | |||||||
|                 getDisguises().remove(entityId); |                 getDisguises().remove(entityId); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise.isModifyBoundingBox()) { |             if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise | ||||||
|  |                     .isModifyBoundingBox()) { | ||||||
|                 doBoundingBox(disguise); |                 doBoundingBox(disguise); | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -1175,16 +1181,16 @@ public class DisguiseUtilities { | |||||||
|             Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player); |             Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player); | ||||||
|  |  | ||||||
|             if (entityTrackerEntry != null) { |             if (entityTrackerEntry != null) { | ||||||
|                 Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |                 Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                         entityTrackerEntry); |                         .get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                 // If the tracker exists. Remove himself from his tracker |                 // If the tracker exists. Remove himself from his tracker | ||||||
|                 if (isHashSet(trackedPlayersObj)) { |                 if (isHashSet(trackedPlayersObj)) { | ||||||
|                     ((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |                     ((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                             entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); |                             .get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); | ||||||
|                 } else { |                 } else { | ||||||
|                     ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get( |                     ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap") | ||||||
|                             entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); |                             .get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -1194,10 +1200,10 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|         // Resend entity metadata else he will be invisible to himself until its resent |         // Resend entity metadata else he will be invisible to himself until its resent | ||||||
|         try { |         try { | ||||||
|             ProtocolLibrary.getProtocolManager().sendServerPacket(player, |             ProtocolLibrary.getProtocolManager().sendServerPacket(player, ProtocolLibrary.getProtocolManager() | ||||||
|                     ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_METADATA, |                     .createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), | ||||||
|                             player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true).createPacket( |                             WrappedDataWatcher.getEntityWatcher(player), true) | ||||||
|                             player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true)); |                     .createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true)); | ||||||
|         } |         } | ||||||
|         catch (Exception ex) { |         catch (Exception ex) { | ||||||
|             ex.printStackTrace(); |             ex.printStackTrace(); | ||||||
| @@ -1214,8 +1220,8 @@ public class DisguiseUtilities { | |||||||
|             throw new IllegalStateException("Cannot modify disguises on an async thread"); |             throw new IllegalStateException("Cannot modify disguises on an async thread"); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible() || !disguise.canSee( |             if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise | ||||||
|                     player)) { |                     .isSelfDisguiseVisible() || !disguise.canSee(player)) { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -1248,8 +1254,8 @@ public class DisguiseUtilities { | |||||||
|                 String ldTeamName = "LD Pushing"; |                 String ldTeamName = "LD Pushing"; | ||||||
|  |  | ||||||
|                 // If the player is in a team already |                 // If the player is in a team already | ||||||
|                 if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName().endsWith( |                 if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName() | ||||||
|                         "_LDP"))) { |                         .endsWith("_LDP"))) { | ||||||
|                     // If we're creating a scoreboard |                     // If we're creating a scoreboard | ||||||
|                     if (pOption == DisguisePushing.CREATE_SCOREBOARD) { |                     if (pOption == DisguisePushing.CREATE_SCOREBOARD) { | ||||||
|                         // Remember his old team so we can give him it back later |                         // Remember his old team so we can give him it back later | ||||||
| @@ -1300,16 +1306,16 @@ public class DisguiseUtilities { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             // Add himself to his own entity tracker |             // Add himself to his own entity tracker | ||||||
|             Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |             Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                     entityTrackerEntry); |                     .get(entityTrackerEntry); | ||||||
|  |  | ||||||
|             // Check for code differences in PaperSpigot vs Spigot |             // Check for code differences in PaperSpigot vs Spigot | ||||||
|             if (isHashSet(trackedPlayersObj)) { |             if (isHashSet(trackedPlayersObj)) { | ||||||
|                 ((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( |                 ((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") | ||||||
|                         entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player)); |                         .get(entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player)); | ||||||
|             } else { |             } else { | ||||||
|                 ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get( |                 ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap") | ||||||
|                         entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true); |                         .get(entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             ProtocolManager manager = ProtocolLibrary.getProtocolManager(); |             ProtocolManager manager = ProtocolLibrary.getProtocolManager(); | ||||||
| @@ -1320,8 +1326,8 @@ public class DisguiseUtilities { | |||||||
|             WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player); |             WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player); | ||||||
|  |  | ||||||
|             sendSelfPacket(player, |             sendSelfPacket(player, | ||||||
|                     manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, |                     manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true) | ||||||
|                             true).createPacket(player.getEntityId(), dataWatcher, true)); |                             .createPacket(player.getEntityId(), dataWatcher, true)); | ||||||
|  |  | ||||||
|             boolean isMoving = false; |             boolean isMoving = false; | ||||||
|  |  | ||||||
| @@ -1339,64 +1345,68 @@ public class DisguiseUtilities { | |||||||
|                 Vector velocity = player.getVelocity(); |                 Vector velocity = player.getVelocity(); | ||||||
|                 sendSelfPacket(player, |                 sendSelfPacket(player, | ||||||
|                         manager.createPacketConstructor(Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(), |                         manager.createPacketConstructor(Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(), | ||||||
|                                 velocity.getY(), velocity.getZ()).createPacket(player.getEntityId(), velocity.getX(), |                                 velocity.getY(), velocity.getZ()) | ||||||
|                                 velocity.getY(), velocity.getZ())); |                                 .createPacket(player.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ())); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // Why the hell would he even need this. Meh. |             // Why the hell would he even need this. Meh. | ||||||
|             if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) { |             if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) { | ||||||
|                 sendSelfPacket(player, manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player, |                 sendSelfPacket(player, | ||||||
|                         player.getVehicle()).createPacket(0, player, player.getVehicle())); |                         manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player, player.getVehicle()) | ||||||
|  |                                 .createPacket(0, player, player.getVehicle())); | ||||||
|             } else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) { |             } else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) { | ||||||
|                 sendSelfPacket(player, manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player.getPassenger(), |                 sendSelfPacket(player, | ||||||
|                         player).createPacket(0, player.getPassenger(), player)); |                         manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player.getPassenger(), player) | ||||||
|  |                                 .createPacket(0, player.getPassenger(), player)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, |             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), |                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))) | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     .createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                             ReflectionManager.getNmsItem(player.getInventory().getHelmet()))); |                             ReflectionManager.getNmsItem(player.getInventory().getHelmet()))); | ||||||
|             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, |             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), |                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))) | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.CHEST), |                     .createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.CHEST), | ||||||
|                             ReflectionManager.getNmsItem(player.getInventory().getChestplate()))); |                             ReflectionManager.getNmsItem(player.getInventory().getChestplate()))); | ||||||
|             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, |             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), |                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))) | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.LEGS), |                     .createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.LEGS), | ||||||
|                             ReflectionManager.getNmsItem(player.getInventory().getLeggings()))); |                             ReflectionManager.getNmsItem(player.getInventory().getLeggings()))); | ||||||
|             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, |             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), |                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))) | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.FEET), |                     .createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.FEET), | ||||||
|                             ReflectionManager.getNmsItem(player.getInventory().getBoots()))); |                             ReflectionManager.getNmsItem(player.getInventory().getBoots()))); | ||||||
|             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, |             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), |                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))) | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HAND), |                     .createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.HAND), | ||||||
|                             ReflectionManager.getNmsItem(player.getInventory().getItemInMainHand()))); |                             ReflectionManager.getNmsItem(player.getInventory().getItemInMainHand()))); | ||||||
|             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, |             sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), |                     ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), | ||||||
|                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), |                     ReflectionManager.getNmsItem(new ItemStack(Material.STONE))) | ||||||
|                     ReflectionManager.createEnumItemSlot(EquipmentSlot.OFF_HAND), |                     .createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.OFF_HAND), | ||||||
|                             ReflectionManager.getNmsItem(player.getInventory().getItemInOffHand()))); |                             ReflectionManager.getNmsItem(player.getInventory().getItemInOffHand()))); | ||||||
|  |  | ||||||
|             Location loc = player.getLocation(); |             Location loc = player.getLocation(); | ||||||
|  |  | ||||||
|             // If the disguised is sleeping for w/e reason |             // If the disguised is sleeping for w/e reason | ||||||
|             if (player.isSleeping()) { |             if (player.isSleeping()) { | ||||||
|                 sendSelfPacket(player, manager.createPacketConstructor(Server.BED, player, |                 sendSelfPacket(player, | ||||||
|                         ReflectionManager.getBlockPosition(0, 0, 0)).createPacket(player, |                         manager.createPacketConstructor(Server.BED, player, ReflectionManager.getBlockPosition(0, 0, 0)) | ||||||
|                         ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); |                                 .createPacket(player, ReflectionManager | ||||||
|  |                                         .getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // Resend any active potion effects |             // Resend any active potion effects | ||||||
|             for (PotionEffect potionEffect : player.getActivePotionEffects()) { |             for (PotionEffect potionEffect : player.getActivePotionEffects()) { | ||||||
|                 Object mobEffect = ReflectionManager.createMobEffect(potionEffect); |                 Object mobEffect = ReflectionManager.createMobEffect(potionEffect); | ||||||
|                 sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EFFECT, player.getEntityId(), |                 sendSelfPacket(player, | ||||||
|                         mobEffect).createPacket(player.getEntityId(), mobEffect)); |                         manager.createPacketConstructor(Server.ENTITY_EFFECT, player.getEntityId(), mobEffect) | ||||||
|  |                                 .createPacket(player.getEntityId(), mobEffect)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         catch (Exception ex) { |         catch (Exception ex) { | ||||||
| @@ -1449,8 +1459,8 @@ public class DisguiseUtilities { | |||||||
|         Entity e = disguise.getEntity(); |         Entity e = disguise.getEntity(); | ||||||
|  |  | ||||||
|         // If the disguises entity is null, or the disguised entity isn't a player return |         // If the disguises entity is null, or the disguised entity isn't a player return | ||||||
|         if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId()) || !getDisguises().get( |         if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId()) || !getDisguises() | ||||||
|                 e.getUniqueId()).contains(disguise)) { |                 .get(e.getUniqueId()).contains(disguise)) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -1465,7 +1475,8 @@ public class DisguiseUtilities { | |||||||
|         DisguiseUtilities.removeSelfDisguise(player); |         DisguiseUtilities.removeSelfDisguise(player); | ||||||
|  |  | ||||||
|         // If the disguised player can't see himself. Return |         // If the disguised player can't see himself. Return | ||||||
|         if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() || player.getVehicle() != null) { |         if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() || player | ||||||
|  |                 .getVehicle() != null) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,22 +0,0 @@ | |||||||
| package me.libraryaddict.disguise.utilities; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Created by libraryaddict on 15/06/2017. |  | ||||||
|  */ |  | ||||||
| public enum LibsMessages { |  | ||||||
|     // Format being CLASS_STRING. So no perm = DISG_COMMAND_NO_PERM. Or DISG_PARSE_NO_PERM_OPTION |  | ||||||
|     TEST("This is a test string"); |  | ||||||
|  |  | ||||||
|     private String string; |  | ||||||
|  |  | ||||||
|     LibsMessages(String string) { |  | ||||||
|         this.string = string; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public String get(String... strings) { |  | ||||||
|         if (strings.length == 0) |  | ||||||
|             return TranslateType.MESSAGE.get(string); |  | ||||||
|  |  | ||||||
|         return String.format(TranslateType.MESSAGE.get(string), (Object[]) strings); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										180
									
								
								src/me/libraryaddict/disguise/utilities/LibsMsg.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								src/me/libraryaddict/disguise/utilities/LibsMsg.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,180 @@ | |||||||
|  | package me.libraryaddict.disguise.utilities; | ||||||
|  |  | ||||||
|  | import org.bukkit.ChatColor; | ||||||
|  | import org.bukkit.entity.Player; | ||||||
|  |  | ||||||
|  | import java.util.ArrayList; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Created by libraryaddict on 15/06/2017. | ||||||
|  |  */ | ||||||
|  | public enum LibsMsg { | ||||||
|  |     // Format being CLASS_STRING. So no perm = DISG_COMMAND_NO_PERM. Or DISG_PARSE_NO_PERM_OPTION | ||||||
|  |     DHELP_OPTIONS("%s options: %s"), NO_PERMS_USE_OPTIONS( | ||||||
|  |             ChatColor.RED + "Ignored %s" + " options you do not have " + "permission to use. Add " + "'show' to view unusable options."), | ||||||
|  |     DISG_HELP4(ChatColor.DARK_GREEN + "/disguise " + "<Dropped_Item/Falling_Block> <Id> <Durability>"), | ||||||
|  |     DHELP_CANTFIND(ChatColor.RED + "Cannot find the disguise %s"), | ||||||
|  |     NO_PERM_DISGUISE(ChatColor.RED + "You do not have permission for " + "that disguise!"), | ||||||
|  |     DISG_ENT_HELP1(ChatColor.DARK_GREEN + "Choose a disguise then right click an entity to disguise it!"), | ||||||
|  |     DISG_ENT_HELP2(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"), | ||||||
|  |     DISG_ENT_HELP3(ChatColor.DARK_GREEN + "/disguiseentity player <Name>"), | ||||||
|  |     DISG_ENT_HELP4(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>"), | ||||||
|  |     DISG_ENT_HELP5(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> " + "<Durability>"), | ||||||
|  |     DISG_ENT_CLICK(ChatColor.RED + "Right click an entity in the next %s seconds to disguise it as a %s!"), | ||||||
|  |     DISG_HELP3(ChatColor.DARK_GREEN + "/disguise <DisguiseType> " + "<Baby>"), | ||||||
|  |     DMODRADIUS(ChatColor.RED + "Successfully modified the disguises of %s" + " entities!"), | ||||||
|  |     DMODRADIUS_NOENTS(ChatColor.RED + "Couldn't find any disguised entities!"), | ||||||
|  |     DMODRADIUS_NOPERM(ChatColor.RED + "No " + "permission to modify " + "%s disguises!"), | ||||||
|  |     DISG_HELP2(ChatColor.DARK_GREEN + "/disguise player " + "<Name>"), | ||||||
|  |     DISG_HELP1(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"), | ||||||
|  |     CAN_USE_DISGS(ChatColor.DARK_GREEN + "You can use the disguises: %s"), | ||||||
|  |     DISGUISED(ChatColor.RED + "Now " + "disguised as a %s"), | ||||||
|  |     DHELP_HELP2(ChatColor.RED + "/disguisehelp %s" + ChatColor.GREEN + " - %s"), DHELP_HELP1( | ||||||
|  |             ChatColor.RED + "/disguisehelp <DisguiseType>" + " " + ChatColor.GREEN + "- View the options you can set " + "on a disguise. Add 'show' to reveal the options you don't have permission to use"), | ||||||
|  |     FAILED_DISGIUSE(ChatColor.RED + "Failed to disguise as a %s"), CLONE_HELP1( | ||||||
|  |             ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other " + "disguise commands!"), | ||||||
|  |     CLONE_HELP2( | ||||||
|  |             ChatColor.DARK_GREEN + "Security note: Any references you create will be available to all players " + "able to use disguise references."), | ||||||
|  |     CLONE_HELP3( | ||||||
|  |             ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"), | ||||||
|  |     RELOADED_CONFIG(ChatColor.GREEN + "[LibsDisguises] Reloaded config."), | ||||||
|  |     DMODIFY_NO_PERM(ChatColor.RED + "No " + "permission to modify your disguise!"), | ||||||
|  |     DMODIFY_MODIFIED(ChatColor.RED + "Your disguise has been modified!"), | ||||||
|  |     DMODIFY_HELP1(ChatColor.DARK_GREEN + "Modify your own disguise as you wear " + "it!"), | ||||||
|  |     DMODIFY_HELP2(ChatColor.DARK_GREEN + "/disguisemodify setBaby true setSprinting true"), | ||||||
|  |     DMODIFY_HELP3(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"), DMODIFYENT_CLICK( | ||||||
|  |             ChatColor.RED + "Right click a disguised entity " + "in the next %s seconds to modify their disguise!"), | ||||||
|  |     LIBS_RELOAD_WRONG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload'?"), | ||||||
|  |     DMODENT_HELP1(ChatColor.DARK_GREEN + "Choose the options for a disguise then right click a entity to modify it!"), | ||||||
|  |     DMODENT_HELP2(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"), | ||||||
|  |     CANNOT_FIND_PLAYER(ChatColor.RED + "Cannot find the player '%s" + "'"), | ||||||
|  |     PARSE_USE_SECOND_NUM(ChatColor.RED + "Error! Only the disguises %s" + " and %s" + " uses a second number!"), | ||||||
|  |     PARSE_NO_PERM_PARAM( | ||||||
|  |             ChatColor.RED + "Error! You do not have permission to use the parameter %s on the" + " %s " + "disguise!"), | ||||||
|  |     PARSE_NO_OPTION_VALUE(ChatColor.RED + "No value was given for the option %s"), | ||||||
|  |     PARSE_OPTION_NA(ChatColor.RED + "Cannot find the option %s"), UPDATE_READY( | ||||||
|  |             ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED + "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED + ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"), | ||||||
|  |     PARSE_EXPECTED_RECEIVED( | ||||||
|  |             ChatColor.RED + "Expected " + ChatColor.GREEN + "%s" + ChatColor.RED + ", received " + ChatColor.GREEN + "%s" + ChatColor.RED + " instead for " + ChatColor.GREEN + "%s"), | ||||||
|  |     DRADIUS_ENTITIES(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"), | ||||||
|  |     DRADIUS_UNRECOG(ChatColor.RED + "Unrecognised " + "EntityType %s"), | ||||||
|  |     PARSE_TOO_MANY_ARGS(ChatColor.RED + "Error! %s doesn't know" + " " + "what to do with %s!"), | ||||||
|  |     DISG_PLAYER_AS_DISG(ChatColor.RED + "Successfully disguised %s as a %s!"), | ||||||
|  |     PARSE_NO_PERM_NAME(ChatColor.RED + "Error! You don't have permission to use that name!"), | ||||||
|  |     DPLAYER_SUPPLY(ChatColor.RED + "You need to supply a disguise as well as " + "the player"), | ||||||
|  |     PARSE_SUPPLY_PLAYER(ChatColor.RED + "Error! You need " + "to give a player name!"), | ||||||
|  |     DISG_PLAYER_AS_DISG_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"), DISABLED_LIVING_TO_MISC( | ||||||
|  |             ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the" + " config!"), | ||||||
|  |     DMODRADIUS_HELP1(ChatColor.DARK_GREEN + "Modify the disguises in a radius! Caps at %s blocks!"), | ||||||
|  |     DMODRADIUS_HELP2(ChatColor.DARK_GREEN + "You can modify the disguises: %s"), DMODRADIUS_HELP3( | ||||||
|  |             (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + "> <Radius> player <Name>") | ||||||
|  |                     .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")), DMODRADIUS_HELP4( | ||||||
|  |             (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + "> <Radius> <DisguiseType> <Baby" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + ">") | ||||||
|  |                     .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")), DMODRADIUS_HELP5( | ||||||
|  |             (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + ">") | ||||||
|  |                     .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")), DMODRADIUS_HELP6( | ||||||
|  |             ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius " + "EntityTypes"), | ||||||
|  |     UND_ENTITY(ChatColor.RED + "Right click a disguised entity to " + "undisguise them!"), | ||||||
|  |     UNDISG_PLAYER(ChatColor.RED + "%s is no longer disguised"), | ||||||
|  |     LISTEN_ENTITY_PLAYER_DISG_PLAYER(ChatColor.RED + "Disguised the player %s as the player %s!"), | ||||||
|  |     LISTEN_ENTITY_PLAYER_DISG_ENTITY(ChatColor.RED + "Disguised the player %s as a %s!"), | ||||||
|  |     LISTEN_ENTITY_ENTITY_DISG_PLAYER(ChatColor.RED + "Disguised s %s as the player %s!"), | ||||||
|  |     LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised s %s as a %s!"), | ||||||
|  |     LISTEN_ENTITY_PLAYER_DISG_PLAYER_FAIL(ChatColor.RED + "Failed to disguise the player %s as the player %s!"), | ||||||
|  |     LISTEN_ENTITY_PLAYER_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise the player %s as a %s!"), | ||||||
|  |     LISTEN_ENTITY_ENTITY_DISG_PLAYER_FAIL(ChatColor.RED + "Failed to disguise s %s as the player %s!"), | ||||||
|  |     LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise s %s as a %s!"), | ||||||
|  |     LISTEN_UNDISG_PLAYER(ChatColor.RED + "Undisguised %s"), LISTEN_UNDISG_ENT(ChatColor.RED + "Undisguised the %s"), | ||||||
|  |     LISTEN_UNDISG_PLAYER_FAIL(ChatColor.RED + "The %s isn't disguised!"), | ||||||
|  |     MADE_REF(ChatColor.RED + "Constructed a %s disguise! Your reference is %s"), | ||||||
|  |     MADE_REF_EXAMPLE(ChatColor.RED + "Example usage: /disguise %s"), REF_TOO_MANY( | ||||||
|  |             ChatColor.RED + "Failed to store the reference, too many cloned disguises. Please raise the " + "maximum " + "cloned disguises, or lower the time they last"), | ||||||
|  |     LISTEN_UNDISG_ENT_FAIL(ChatColor.RED + "%s isn't disguised!"), | ||||||
|  |     UNDISG_PLAYER_FAIL(ChatColor.RED + "%s not disguised!"), | ||||||
|  |     UNDISG_PLAYER_HELP(ChatColor.RED + "/undisguiseplayer <Name>"), | ||||||
|  |     DMODPLAYER_NODISGUISE(ChatColor.RED + "The " + "player '%s' is " + "not disguised"), | ||||||
|  |     DMODPLAYER_NOPERM(ChatColor.RED + "You do not have permission to modify this " + "disguise"), | ||||||
|  |     DMODPLAYER_MODIFIED(ChatColor.RED + "Modified the disguise of %s!"), | ||||||
|  |     LISTENER_MODIFIED_DISG(ChatColor.RED + "Modified the disguise!"), | ||||||
|  |     DMODPLAYER_HELP1(ChatColor.DARK_GREEN + "Modify the disguise of another player!"), | ||||||
|  |     DMODPLAYER_HELP2(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"), | ||||||
|  |     NO_PERM(ChatColor.RED + "You are forbidden to use this command."), | ||||||
|  |     NOT_DISGUISED(ChatColor.RED + "You are not disguised!"), | ||||||
|  |     DRADIUS_HELP1(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"), | ||||||
|  |     DRADIUS_HELP2(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"), DRADIUS_HELP3( | ||||||
|  |             (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + "> <Radius> player <Name>") | ||||||
|  |                     .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")), DRADIUS_HELP4( | ||||||
|  |             (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + "> <Radius> <DisguiseType> <Baby" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + ">") | ||||||
|  |                     .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")), DRADIUS_HELP5( | ||||||
|  |             (ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")" + ">") | ||||||
|  |                     .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")), DRADIUS_HELP6( | ||||||
|  |             ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius " + "EntityTypes"), | ||||||
|  |     D_PARSE_NOPERM(ChatColor.RED + "You do not have permission to use the option %s"), | ||||||
|  |     PARSE_NO_ARGS("No arguments defined"), | ||||||
|  |     PARSE_NO_REF(ChatColor.RED + "Cannot find a disguise under the reference " + "%s"), | ||||||
|  |     PARSE_NO_PERM_REF(ChatColor.RED + "You do not have perimssion to use disguise references!"), PARSE_DISG_NO_EXIST( | ||||||
|  |             ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + "%s" + ChatColor.RED + " " + "doesn't exist!"), | ||||||
|  |     PARSE_CANT_DISG_UNKNOWN(ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!"), | ||||||
|  |     PARSE_CANT_LOAD(ChatColor.RED + "Error! This disguise " + "couldn't be loaded!"), | ||||||
|  |     D_HELP1(ChatColor.DARK_GREEN + "Disguise another player!"), | ||||||
|  |     D_HELP2(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"), | ||||||
|  |     DMODRADIUS_USABLE(ChatColor.DARK_GREEN + "EntityTypes usable " + "are: %s" + ChatColor.DARK_GREEN + "."), | ||||||
|  |     D_HELP3(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player " + "<Name>"), | ||||||
|  |     D_HELP4(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> " + "<DisguiseType> <Baby>"), | ||||||
|  |     D_HELP5(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> " + "<Durability>"), | ||||||
|  |     DMODRADIUS_UNRECOGNIZED(ChatColor.RED + "Unrecognised " + "EntityType %s"), | ||||||
|  |     DMODRADIUS_NEEDOPTIONS(ChatColor.RED + "You need to supply the disguise options as well as the radius"), | ||||||
|  |     DRADIUS_NEEDOPTIONS(ChatColor.RED + "You need to supply a disguise as well as the radius"), | ||||||
|  |     DRADIUS_NEEDOPTIONS_ENTITY(ChatColor.RED + "You need to supply a disguise as well as the radius and EntityType"), | ||||||
|  |     NOT_NUMBER(ChatColor.RED + "Error! %s is not a " + "number"), DRADIUS_MISCDISG( | ||||||
|  |             ChatColor.RED + "Failed to disguise %s entities because the option to disguise a living entity " + "as" + " a non-living has been disabled in the config"), | ||||||
|  |     LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), | ||||||
|  |     DISRADIUS(ChatColor.RED + "Successfully disguised %s" + " entities!"), | ||||||
|  |     DISRADIUS_FAIL(ChatColor.RED + "Couldn't find any entities to disguise!"), DMODRADIUS_NEEDOPTIONS_ENTITY( | ||||||
|  |             ChatColor.RED + "You need to " + "supply" + " the disguise options as well as the radius" + " and EntityType"), | ||||||
|  |     NO_CONSOLE(ChatColor.RED + "You may not use this command from the console!"), CLICK_TIMER( | ||||||
|  |             ChatColor.RED + "Right click a entity in the next %s" + " " + "seconds " + "to " + "grab " + "the disguise reference!"), | ||||||
|  |     UNDISRADIUS(ChatColor.RED + "Successfully undisguised %s entities!"), | ||||||
|  |     UNDISG(ChatColor.RED + "You are no longer disguised"), UNDISG_FAIL(ChatColor.RED + "You are not disguised!"), | ||||||
|  |     VIEW_SELF_ON(ChatColor.GREEN + "Toggled viewing own disguise off!"), | ||||||
|  |     BLOWN_DISGUISE(ChatColor.RED + "Your disguise" + " was blown!"), | ||||||
|  |     VIEW_SELF_OFF(ChatColor.GREEN + "Toggled viewing own disguise on!"), INVALID_CLONE( | ||||||
|  |             ChatColor.DARK_RED + "Unknown " + "option '%s" + "' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' 'DoSneak' 'DoSprint'"); | ||||||
|  |  | ||||||
|  |     static { | ||||||
|  |         for (LibsMsg msg : values()) { | ||||||
|  |             for (LibsMsg msg1 : values()) { | ||||||
|  |                 if (msg == msg1) | ||||||
|  |                     continue; | ||||||
|  |  | ||||||
|  |                 if (!msg.getRaw().equalsIgnoreCase(msg1.getRaw())) | ||||||
|  |                     continue; | ||||||
|  |  | ||||||
|  |                 System.out.println(msg.name() + " and " + msg1.name() + " conflict"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         System.out.println("Alright dont forget to delete this libraryaddict!!!!!!!!!!!!!!!!!!"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private String string; | ||||||
|  |  | ||||||
|  |     LibsMsg(String string) { | ||||||
|  |         this.string = string; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String getRaw() { | ||||||
|  |         return string; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String get(Object... strings) { | ||||||
|  |         if (strings.length == 0) | ||||||
|  |             return TranslateType.MESSAGE.get(getRaw()); | ||||||
|  |  | ||||||
|  |         return String.format(TranslateType.MESSAGE.get(getRaw()), (Object[]) strings); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String toString() { | ||||||
|  |         throw new RuntimeException("Dont call this"); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -47,5 +47,9 @@ public class TranslateFiller { | |||||||
|                                 "multiple" + " " : "a ") + para.getSimpleName().replace("[]", "s")); |                                 "multiple" + " " : "a ") + para.getSimpleName().replace("[]", "s")); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         for (LibsMsg msg : LibsMsg.values()) { | ||||||
|  |             TranslateType.MESSAGE.get(msg.getRaw()); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ package me.libraryaddict.disguise.utilities; | |||||||
|  |  | ||||||
| import me.libraryaddict.disguise.DisguiseConfig; | import me.libraryaddict.disguise.DisguiseConfig; | ||||||
| import org.apache.commons.lang3.StringEscapeUtils; | import org.apache.commons.lang3.StringEscapeUtils; | ||||||
|  | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.configuration.InvalidConfigurationException; | import org.bukkit.configuration.InvalidConfigurationException; | ||||||
| import org.bukkit.configuration.file.YamlConfiguration; | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
|  |  | ||||||
| @@ -56,7 +57,7 @@ public enum TranslateType { | |||||||
|                 if (value == null) |                 if (value == null) | ||||||
|                     System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'"); |                     System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'"); | ||||||
|                 else |                 else | ||||||
|                     translated.put(key, value); |                     translated.put(key, ChatColor.translateAlternateColorCodes('&', value)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         catch (Exception e) { |         catch (Exception e) { | ||||||
| @@ -74,7 +75,7 @@ public enum TranslateType { | |||||||
|  |  | ||||||
|         translated.put(message, message); |         translated.put(message, message); | ||||||
|  |  | ||||||
|         message = StringEscapeUtils.escapeJava(message); |         message = StringEscapeUtils.escapeJava(message.replaceAll(ChatColor.COLOR_CHAR + "", "&")); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             boolean exists = file.exists(); |             boolean exists = file.exists(); | ||||||
| @@ -112,26 +113,24 @@ public enum TranslateType { | |||||||
|         return translated; |         return translated; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public String get(String message) { |     public String get(String msg) { | ||||||
|         if (this != TranslateType.MESSAGE) |         if (this != TranslateType.MESSAGE) | ||||||
|             throw new IllegalArgumentException("Can't set no comment for '" + message + "'"); |             throw new IllegalArgumentException("Can't set no comment for '" + msg + "'"); | ||||||
|  |  | ||||||
|         return get(message, null); |         return get(msg, null); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public String get(String message, String comment) { |     public String get(String msg, String comment) { | ||||||
|         if (!LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations()) |         if (!LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations()) | ||||||
|             return message; |  | ||||||
|         System.out.println("1"); |  | ||||||
|  |  | ||||||
|         String msg = translated.get(message); |  | ||||||
|  |  | ||||||
|         if (msg != null) |  | ||||||
|             return msg; |             return msg; | ||||||
|         System.out.println("2"); |  | ||||||
|  |  | ||||||
|         save(message, comment); |         String toReturn = translated.get(msg); | ||||||
|  |  | ||||||
|         return message; |         if (toReturn != null) | ||||||
|  |             return toReturn; | ||||||
|  |  | ||||||
|  |         save(msg, comment); | ||||||
|  |  | ||||||
|  |         return msg; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user