Added options to choose how long a disguise entity and disguise clone command is valid for

This commit is contained in:
libraryaddict 2014-06-02 04:14:35 +12:00
parent 4262221133
commit b999f48fef
6 changed files with 35 additions and 5 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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);
}

View File

@ -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.

View File

@ -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."

View File

@ -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;
}