From 85077227a2f52692375fe8a935cbb6cb2619559d Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 21 Jan 2014 14:05:32 +1300 Subject: [PATCH] Fixed the disguise blown message not being used --- .../disguise/DisguiseConfig.java | 9 +++++++ .../disguise/DisguiseListener.java | 2 +- .../libraryaddict/disguise/LibsDisguises.java | 4 +++ .../disguise/utilities/DisguiseUtilities.java | 26 +++++++++---------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseConfig.java b/src/me/libraryaddict/disguise/DisguiseConfig.java index 173dd0cd..a3b8858c 100644 --- a/src/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/me/libraryaddict/disguise/DisguiseConfig.java @@ -4,6 +4,7 @@ import me.libraryaddict.disguise.utilities.PacketsManager; public class DisguiseConfig { private static boolean blowDisguisesOnAttack; + private static String disguiseBlownMessage; private static boolean entityAnimationsAdded; private static boolean hearSelfDisguise; private static boolean hidingArmor; @@ -20,6 +21,10 @@ public class DisguiseConfig { return hearSelfDisguise; } + public static String getDisguiseBlownMessage() { + return disguiseBlownMessage; + } + public static boolean isDisguiseBlownOnAttack() { return blowDisguisesOnAttack; } @@ -91,6 +96,10 @@ public class DisguiseConfig { entityAnimationsAdded = isEntityAnimationsAdded; } + public static void setDisguiseBlownMessage(String newMessage) { + disguiseBlownMessage = newMessage; + } + public static void setDisguiseBlownOnAttack(boolean blowDisguise) { blowDisguisesOnAttack = blowDisguise; } diff --git a/src/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java index 256a4b04..5a2827ca 100644 --- a/src/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/me/libraryaddict/disguise/DisguiseListener.java @@ -72,7 +72,7 @@ public class DisguiseListener implements Listener { DisguiseAPI.undisguiseToAll(event.getEntity()); for (Disguise disguise : disguises) { if (DisguiseUtilities.isDisguiseInUse(disguise)) { - ((Player) event.getEntity()).sendMessage(ChatColor.RED + "Your disguise was blown!"); + ((Player) event.getEntity()).sendMessage(DisguiseConfig.getDisguiseBlownMessage()); break; } } diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index c55b448a..ab318167 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -3,6 +3,7 @@ package me.libraryaddict.disguise; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; + import me.libraryaddict.disguise.commands.*; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -20,6 +21,7 @@ import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.DisguiseValues; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Ageable; @@ -70,6 +72,8 @@ public class LibsDisguises extends JavaPlugin { DisguiseConfig.setModifyBoundingBox(getConfig().getBoolean("ModifyBoundingBox")); DisguiseConfig.setMonstersIgnoreDisguises(getConfig().getBoolean("MonstersIgnoreDisguises")); DisguiseConfig.setDisguiseBlownOnAttack(getConfig().getBoolean("BlowDisguises")); + DisguiseConfig.setDisguiseBlownMessage(ChatColor.translateAlternateColorCodes('&', + getConfig().getString("BlownDisguiseMessage"))); try { // Here I use reflection to set the plugin for Disguise.. // Kind of stupid but I don't want open API calls for a commonly used object. diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 6a6fde84..8a2c2307 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -161,19 +161,6 @@ public class DisguiseUtilities { } } - public static TargetedDisguise getMainDisguise(int entityId) { - TargetedDisguise toReturn = null; - if (getDisguises().containsKey(entityId)) { - for (TargetedDisguise disguise : getDisguises().get(entityId)) { - if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { - return disguise; - } - toReturn = disguise; - } - } - return toReturn; - } - public static TargetedDisguise getDisguise(Player observer, int entityId) { if (getDisguises().containsKey(entityId)) { for (TargetedDisguise disguise : getDisguises().get(entityId)) { @@ -196,6 +183,19 @@ public class DisguiseUtilities { return new TargetedDisguise[0]; } + public static TargetedDisguise getMainDisguise(int entityId) { + TargetedDisguise toReturn = null; + if (getDisguises().containsKey(entityId)) { + for (TargetedDisguise disguise : getDisguises().get(entityId)) { + if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + return disguise; + } + toReturn = disguise; + } + } + return toReturn; + } + /** * Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise. */