From d4ae115d19b3982e4618ba4248da0c08e20e2ab0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 6 Nov 2013 05:05:04 +1300 Subject: [PATCH] Added toReadable to disguisetype --- .../libraryaddict/disguise/commands/DisguiseCommand.java | 9 +-------- .../disguise/commands/DisguiseEntityCommand.java | 8 +------- .../disguise/commands/DisguisePlayerCommand.java | 9 +-------- .../disguise/commands/DisguiseRadiusCommand.java | 2 +- .../disguise/disguisetypes/DisguiseType.java | 8 ++++++++ 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/me/libraryaddict/disguise/commands/DisguiseCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseCommand.java index 92364bb7..8245430e 100644 --- a/src/me/libraryaddict/disguise/commands/DisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseCommand.java @@ -29,7 +29,7 @@ public class DisguiseCommand extends BaseDisguiseCommand { try { Disguise disguise = parseDisguise(sender, args); DisguiseAPI.disguiseToAll((Player) sender, disguise); - sender.sendMessage(ChatColor.RED + "Now disguised as a " + toReadable(disguise.getType().name())); + sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable()); } catch (Exception ex) { if (ex.getMessage() != null) { sender.sendMessage(ex.getMessage()); @@ -52,11 +52,4 @@ public class DisguiseCommand extends BaseDisguiseCommand { if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer "); } - - private String toReadable(String name) { - String[] split = name.split("_"); - for (int i = 0; i < split.length; i++) - split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); - return StringUtils.join(split, " "); - } } diff --git a/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java index 67c97d79..bdde2069 100644 --- a/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java @@ -35,7 +35,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand { Disguise disguise = parseDisguise(sender, args); listener.setSlap(sender.getName(), disguise); sender.sendMessage(ChatColor.RED + "Right click a entity in the next 10 seconds to disguise it as a " - + toReadable(disguise.getType().name()) + "!"); + + disguise.getType().toReadable() + "!"); } catch (Exception ex) { if (ex.getMessage() != null) { sender.sendMessage(ex.getMessage()); @@ -59,10 +59,4 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand { sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity "); } - private String toReadable(String name) { - String[] split = name.split("_"); - for (int i = 0; i < split.length; i++) - split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); - return StringUtils.join(split, " "); - } } diff --git a/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java b/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java index 64f80680..ea47967c 100644 --- a/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java @@ -45,7 +45,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand { Disguise disguise = parseDisguise(sender, newArgs); DisguiseAPI.disguiseToAll(player, disguise); sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a " - + toReadable(disguise.getType().name()) + "!"); + + disguise.getType().toReadable() + "!"); } catch (Exception ex) { if (ex.getMessage() != null) { sender.sendMessage(ex.getMessage()); @@ -69,11 +69,4 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand { sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer "); } - - private String toReadable(String name) { - String[] split = name.split("_"); - for (int i = 0; i < split.length; i++) - split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); - return StringUtils.join(split, " "); - } } diff --git a/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java index 07f8724f..87688cb9 100644 --- a/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java @@ -66,7 +66,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand { for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) { if (entity == sender) continue; - DisguiseAPI.disguiseToAll(entity, disguise.clone()); + DisguiseAPI.disguiseToAll(entity, disguise); disguisedEntitys++; } sender.sendMessage(ChatColor.RED + "Successfully disguised " + disguisedEntitys + " entities!"); diff --git a/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java index c64746f7..f65fc7d2 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java +++ b/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes; +import org.apache.commons.lang.StringUtils; import org.bukkit.entity.EntityType; public enum DisguiseType { @@ -131,6 +132,13 @@ public enum DisguiseType { return DisguiseType.valueOf(entityType.name()); } + public String toReadable() { + String[] split = name().split("_"); + for (int i = 0; i < split.length; i++) + split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); + return StringUtils.join(split, " "); + } + private int defaultData; private int defaultId; private int entityId;