From b999f48fef1511f7101b5f6192ed3498750340b7 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 2 Jun 2014 04:14:35 +1200 Subject: [PATCH] Added options to choose how long a disguise entity and disguise clone command is valid for --- config.yml | 6 ++++++ .../libraryaddict/disguise/DisguiseConfig.java | 18 ++++++++++++++++++ .../disguise/DisguiseListener.java | 4 ++-- .../libraryaddict/disguise/LibsDisguises.java | 2 ++ .../commands/DisguiseCloneCommand.java | 4 +++- .../commands/DisguiseEntityCommand.java | 6 ++++-- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/config.yml b/config.yml index f6593c65..47f46da3 100644 --- a/config.yml +++ b/config.yml @@ -57,6 +57,12 @@ MonstersIgnoreDisguises: false BlowDisguises: false BlownDisguiseMessage: '&cYour disguise was blown!' +# A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring +DisguiseEntityExpire: 10 + +# Another option to choose the same thing for DisguiseClone command +DisguiseCloneExpire: 10 + # This I don't really recommend turning on as it can make a memory leak.. # These disguises, as normal will not persist after a server restart. # There is also no EntityDeath option as entities do not revive after death. diff --git a/src/me/libraryaddict/disguise/DisguiseConfig.java b/src/me/libraryaddict/disguise/DisguiseConfig.java index f000f090..a9ae4bbc 100644 --- a/src/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/me/libraryaddict/disguise/DisguiseConfig.java @@ -8,6 +8,8 @@ public class DisguiseConfig { private static boolean blowDisguisesOnAttack; private static boolean collectEnabled; private static String disguiseBlownMessage; + private static int disguiseCloneExpire; + private static int disguiseEntityExpire; private static boolean enquipmentEnabled; private static boolean entityAnimationsAdded; private static boolean entityStatusEnabled; @@ -34,6 +36,14 @@ public class DisguiseConfig { return disguiseBlownMessage; } + public static int getDisguiseCloneExpire() { + return disguiseCloneExpire; + } + + public static int getDisguiseEntityExpire() { + return disguiseEntityExpire; + } + public static boolean isAnimationPacketsEnabled() { return animationEnabled; } @@ -190,6 +200,14 @@ public class DisguiseConfig { blowDisguisesOnAttack = blowDisguise; } + public static void setDisguiseCloneExpire(int newExpires) { + disguiseCloneExpire = newExpires; + } + + public static void setDisguiseEntityExpire(int newExpires) { + disguiseEntityExpire = newExpires; + } + public static void setEnquipmentPacketsEnabled(boolean enabled) { if (enabled != isEnquipmentPacketsEnabled()) { enquipmentEnabled = enabled; diff --git a/src/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java index 05a5a83a..07916db3 100644 --- a/src/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/me/libraryaddict/disguise/DisguiseListener.java @@ -254,7 +254,7 @@ public class DisguiseListener implements Listener { disguiseRunnable.remove(player); } }; - runnable.runTaskLater(plugin, 20 * 10); + runnable.runTaskLater(plugin, 20 * DisguiseConfig.getDisguiseCloneExpire()); disguiseRunnable.put(player, runnable); disguiseClone.put(player, options); } @@ -271,7 +271,7 @@ public class DisguiseListener implements Listener { disguiseRunnable.remove(player); } }; - runnable.runTaskLater(plugin, 20 * 10); + runnable.runTaskLater(plugin, 20 * DisguiseConfig.getDisguiseEntityExpire()); disguiseRunnable.put(player, runnable); disguiseEntity.put(player, disguise); } diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 80ad8e95..f36a227f 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -117,6 +117,8 @@ public class LibsDisguises extends JavaPlugin { DisguiseConfig.setCollectPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Collect")); DisguiseConfig.setMetadataPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Metadata")); DisguiseConfig.setMaxHealthDeterminedByDisguisedEntity(getConfig().getBoolean("MaxHealthDeterminedByEntity")); + DisguiseConfig.setDisguiseEntityExpire(getConfig().getInt("DisguiseEntityExpire")); + DisguiseConfig.setDisguiseCloneExpire(getConfig().getInt("DisguiseCloneExpire")); 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/commands/DisguiseCloneCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java index e1adeb36..eec01290 100644 --- a/src/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseCloneCommand.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.commands; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseListener; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand; @@ -43,7 +44,8 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand { } } listener.setDisguiseClone(sender.getName(), new Boolean[] { doEnquipment, doSneak, doSprint }); - sender.sendMessage(ChatColor.RED + "Right click a entity in the next 10 seconds to disguise as it!"); + sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseCloneExpire() + + " seconds to disguise as it!"); } else { sender.sendMessage(ChatColor.RED + "There was once a curious little boy," + " he liked to try out these strange sounding commands." diff --git a/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java index 776fef1a..e9148c4a 100644 --- a/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java @@ -1,6 +1,8 @@ package me.libraryaddict.disguise.commands; import java.util.ArrayList; + +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseListener; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand; @@ -36,8 +38,8 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand { return true; } listener.setDisguiseEntity(sender.getName(), disguise); - sender.sendMessage(ChatColor.RED + "Right click a entity in the next 10 seconds to disguise it as a " - + disguise.getType().toReadable() + "!"); + sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire() + + " seconds to disguise it as a " + disguise.getType().toReadable() + "!"); return true; }