Current work
This commit is contained in:
@@ -36,7 +36,7 @@ public class DisguiseParser {
|
||||
super();
|
||||
}
|
||||
|
||||
public DisguiseParseException(LibsMessages message, String... params) {
|
||||
public DisguiseParseException(LibsMsg message, String... params) {
|
||||
super(message.get(params));
|
||||
}
|
||||
}
|
||||
@@ -145,9 +145,7 @@ public class DisguiseParser {
|
||||
ArrayList<String> usedOptions) throws DisguiseParseException {
|
||||
|
||||
if (!passesCheck(sender, optionPermissions, usedOptions)) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "You do not have permission to use the option " + usedOptions.get(
|
||||
usedOptions.size() - 1));
|
||||
throw new DisguiseParseException(LibsMsg.D_PARSE_NOPERM, usedOptions.get(usedOptions.size() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +199,8 @@ public class DisguiseParser {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||
@@ -467,12 +466,11 @@ public class DisguiseParser {
|
||||
public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException {
|
||||
if (permissionMap.isEmpty()) {
|
||||
throw new DisguiseParseException(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this " + "command."));
|
||||
throw new DisguiseParseException(LibsMsg.NO_PERM);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -488,13 +486,10 @@ public class DisguiseParser {
|
||||
disguise = DisguiseUtilities.getClonedDisguise(args[0].toLowerCase());
|
||||
|
||||
if (disguise == null) {
|
||||
throw new DisguiseParseException(String.format(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find a disguise under the reference %s"),
|
||||
args[0]));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_NO_REF, args[0]);
|
||||
}
|
||||
} else {
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You do not have perimssion to use disguise references!"));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_REF);
|
||||
}
|
||||
|
||||
optionPermissions = (permissionMap.containsKey(new DisguisePerm(disguise.getType())) ?
|
||||
@@ -509,24 +504,19 @@ public class DisguiseParser {
|
||||
}
|
||||
|
||||
if (disguisePerm == null) {
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + "%s" + ChatColor.RED + " " + "doesn't exist!"),
|
||||
args[0]));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_DISG_NO_EXIST, args[0]);
|
||||
}
|
||||
|
||||
if (disguisePerm.isUnknown()) {
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!"));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_CANT_DISG_UNKNOWN);
|
||||
}
|
||||
|
||||
if (disguisePerm.getEntityType() == null) {
|
||||
throw new DisguiseParseException(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "Error! This disguise " + "couldn't be loaded!"));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_CANT_LOAD);
|
||||
}
|
||||
|
||||
if (!permissionMap.containsKey(disguisePerm)) {
|
||||
throw new DisguiseParseException(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use " + "this disguise."));
|
||||
throw new DisguiseParseException(LibsMsg.NO_PERM_DISGUISE);
|
||||
}
|
||||
|
||||
optionPermissions = permissionMap.get(disguisePerm);
|
||||
@@ -538,13 +528,11 @@ public class DisguiseParser {
|
||||
// If he is doing a player disguise
|
||||
if (args.length == 1) {
|
||||
// He needs to give the player name
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You need " + "to give a player name!"));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_SUPPLY_PLAYER);
|
||||
} else {
|
||||
if (!disguiseOptions.isEmpty() && (!disguiseOptions.containsKey(
|
||||
args[1].toLowerCase()) || !disguiseOptions.get(args[1].toLowerCase()))) {
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You don't have permission to use that name!"));
|
||||
if (!disguiseOptions.isEmpty() && (!disguiseOptions
|
||||
.containsKey(args[1].toLowerCase()) || !disguiseOptions.get(args[1].toLowerCase()))) {
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_NAME);
|
||||
}
|
||||
|
||||
args[1] = args[1].replace("\\_", " ");
|
||||
@@ -587,7 +575,8 @@ public class DisguiseParser {
|
||||
if (isInteger(args[1])) {
|
||||
miscId = Integer.parseInt(args[1]);
|
||||
} 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()) {
|
||||
if (mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) {
|
||||
miscId = mat.getId();
|
||||
@@ -611,9 +600,8 @@ public class DisguiseParser {
|
||||
case WITHER_SKULL:
|
||||
break;
|
||||
default:
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! %s doesn't know" + " " + "what to do with %s!"),
|
||||
disguisePerm.toReadable(), args[1]));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_TOO_MANY_ARGS,
|
||||
disguisePerm.toReadable(), args[1]);
|
||||
}
|
||||
toSkip++;
|
||||
// If they also defined a data value
|
||||
@@ -622,11 +610,11 @@ public class DisguiseParser {
|
||||
toSkip++;
|
||||
}
|
||||
if (secondArg != null) {
|
||||
if (disguisePerm.getType() != DisguiseType.FALLING_BLOCK && disguisePerm.getType() != DisguiseType.DROPPED_ITEM) {
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! Only the disguises " + DisguiseType.FALLING_BLOCK.toReadable() + " and " + DisguiseType.DROPPED_ITEM.toReadable() + " uses a second number!"),
|
||||
if (disguisePerm.getType() != DisguiseType.FALLING_BLOCK && disguisePerm
|
||||
.getType() != DisguiseType.DROPPED_ITEM) {
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_USE_SECOND_NUM,
|
||||
DisguiseType.FALLING_BLOCK.toReadable(),
|
||||
DisguiseType.DROPPED_ITEM.toReadable()));
|
||||
DisguiseType.DROPPED_ITEM.toReadable());
|
||||
}
|
||||
miscData = Integer.parseInt(secondArg);
|
||||
}
|
||||
@@ -645,9 +633,8 @@ public class DisguiseParser {
|
||||
}
|
||||
|
||||
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You do not have permission to use the parameter %s on the" + " %s disguise!"),
|
||||
toCheck, disguisePerm.toReadable()));
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, toCheck,
|
||||
disguisePerm.toReadable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,12 +747,7 @@ public class DisguiseParser {
|
||||
}
|
||||
} else if (param == ItemStack.class) {
|
||||
// Parse to itemstack
|
||||
try {
|
||||
value = parseToItemstack(valueString);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new DisguiseParseException(String.format(ex.getMessage(), methodName));
|
||||
}
|
||||
value = parseToItemstack(methodName, valueString);
|
||||
} else if (param == ItemStack[].class) {
|
||||
// Parse to itemstack array
|
||||
ItemStack[] items = new ItemStack[4];
|
||||
@@ -775,7 +757,7 @@ public class DisguiseParser {
|
||||
if (split.length == 4) {
|
||||
for (int a = 0; a < 4; a++) {
|
||||
try {
|
||||
items[a] = parseToItemstack(split[a]);
|
||||
items[a] = parseToItemstack(methodName, split[a]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw parseToException(
|
||||
@@ -858,8 +840,8 @@ public class DisguiseParser {
|
||||
} else if (param == RabbitType.class) {
|
||||
try {
|
||||
for (RabbitType type : RabbitType.values()) {
|
||||
if (type.name().replace("_", "").equalsIgnoreCase(
|
||||
valueString.replace("_", "").replace(" ", ""))) {
|
||||
if (type.name().replace("_", "")
|
||||
.equalsIgnoreCase(valueString.replace("_", "").replace(" ", ""))) {
|
||||
value = type;
|
||||
|
||||
break;
|
||||
@@ -927,10 +909,10 @@ public class DisguiseParser {
|
||||
throw storedEx;
|
||||
}
|
||||
|
||||
throw new DisguiseParseException(ChatColor.RED + "Cannot find the option " + methodName);
|
||||
throw new DisguiseParseException(LibsMsg.PARSE_OPTION_NA, methodName);
|
||||
}
|
||||
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())) {
|
||||
@@ -949,11 +931,10 @@ public class DisguiseParser {
|
||||
|
||||
private static DisguiseParseException parseToException(String expectedValue, String receivedInstead,
|
||||
String methodName) {
|
||||
return new DisguiseParseException(
|
||||
ChatColor.RED + "Expected " + ChatColor.GREEN + expectedValue + ChatColor.RED + ", received " + ChatColor.GREEN + receivedInstead + ChatColor.RED + " instead for " + ChatColor.GREEN + methodName);
|
||||
return new DisguiseParseException(LibsMsg.PARSE_EXPECTED_RECEIVED, expectedValue, receivedInstead, methodName);
|
||||
}
|
||||
|
||||
private static ItemStack parseToItemstack(String string) throws Exception {
|
||||
private static ItemStack parseToItemstack(String method, String string) throws DisguiseParseException {
|
||||
String[] split = string.split(":", -1);
|
||||
|
||||
int itemId = -1;
|
||||
@@ -1000,13 +981,13 @@ public class DisguiseParser {
|
||||
boolean myPerms = true;
|
||||
|
||||
for (String option : usedOptions) {
|
||||
if (!sender.getName().equals("CONSOLE") && option.equalsIgnoreCase(
|
||||
"setInvisible") && DisguiseConfig.isDisabledInvisibility()) {
|
||||
if (!sender.getName().equals("CONSOLE") && option.equalsIgnoreCase("setInvisible") && DisguiseConfig
|
||||
.isDisabledInvisibility()) {
|
||||
myPerms = false;
|
||||
}
|
||||
|
||||
if (!(theirPermissions.get(list) && list.contains("*")) && (list.contains(
|
||||
option) != theirPermissions.get(list))) {
|
||||
if (!(theirPermissions.get(list) && list.contains("*")) && (list.contains(option) != theirPermissions
|
||||
.get(list))) {
|
||||
myPerms = false;
|
||||
break;
|
||||
}
|
||||
|
@@ -121,12 +121,10 @@ public class DisguiseUtilities {
|
||||
if (reference != null && DisguiseUtilities.addClonedDisguise(reference, disguise)) {
|
||||
String entityName = DisguiseType.getType(toClone).toReadable();
|
||||
|
||||
player.sendMessage(
|
||||
ChatColor.RED + "Constructed a " + entityName + " disguise! Your reference is " + reference);
|
||||
player.sendMessage(ChatColor.RED + "Example usage: /disguise " + reference);
|
||||
player.sendMessage(LibsMsg.MADE_REF.get(entityName, reference));
|
||||
player.sendMessage(LibsMsg.MADE_REF_EXAMPLE.get(reference));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
ChatColor.RED + "Failed to store the reference, too many cloned disguises. Please raise the " + "maximum cloned disguises, or lower the time they last");
|
||||
player.sendMessage(LibsMsg.REF_TOO_MANY.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +245,8 @@ public class DisguiseUtilities {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -385,8 +384,8 @@ public class DisguiseUtilities {
|
||||
if (entityTrackerEntry == null)
|
||||
return;
|
||||
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry);
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
// If the tracker exists. Remove himself from his tracker
|
||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||
@@ -418,7 +417,9 @@ public class DisguiseUtilities {
|
||||
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -430,7 +431,8 @@ public class DisguiseUtilities {
|
||||
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -622,8 +624,8 @@ public class DisguiseUtilities {
|
||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||
|
||||
if (entityTrackerEntry != null) {
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry);
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||
// ConcurrentModificationException
|
||||
for (Object p : trackedPlayers) {
|
||||
@@ -649,9 +651,9 @@ public class DisguiseUtilities {
|
||||
|
||||
@Override
|
||||
public void onLookup(WrappedGameProfile gameProfile) {
|
||||
if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName().equals(
|
||||
disguise.getSkin() != null ? disguise.getSkin() :
|
||||
disguise.getName()) || !gameProfile.getProperties().isEmpty())) {
|
||||
if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName()
|
||||
.equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) || !gameProfile
|
||||
.getProperties().isEmpty())) {
|
||||
disguise.setGameProfile(gameProfile);
|
||||
|
||||
DisguiseUtilities.refreshTrackers(disguise);
|
||||
@@ -743,8 +745,9 @@ public class DisguiseUtilities {
|
||||
catch (Exception e) {
|
||||
runnables.remove(playerName);
|
||||
|
||||
System.out.print(
|
||||
"[LibsDisguises] Error when fetching " + playerName + "'s uuid from mojang: " + e.getMessage());
|
||||
System.out
|
||||
.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 world = ((List) server.getClass().getField("worlds").get(server)).get(0);
|
||||
|
||||
Object bedChunk = ReflectionManager.getNmsClass("Chunk").getConstructor(
|
||||
ReflectionManager.getNmsClass("World"), int.class, int.class).newInstance(world, 0, 0);
|
||||
Object bedChunk = ReflectionManager.getNmsClass("Chunk")
|
||||
.getConstructor(ReflectionManager.getNmsClass("World"), int.class, int.class)
|
||||
.newInstance(world, 0, 0);
|
||||
|
||||
Field cSection = bedChunk.getClass().getDeclaredField("sections");
|
||||
cSection.setAccessible(true);
|
||||
|
||||
Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class,
|
||||
boolean.class).newInstance(0, true);
|
||||
Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class)
|
||||
.newInstance(0, true);
|
||||
|
||||
Object block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class).invoke(null,
|
||||
Material.BED_BLOCK.getId());
|
||||
Object block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class)
|
||||
.invoke(null, Material.BED_BLOCK.getId());
|
||||
|
||||
Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class);
|
||||
Method setType = chunkSection.getClass().getMethod("setType", int.class, int.class, int.class,
|
||||
ReflectionManager.getNmsClass("IBlockData"));
|
||||
Method setType = chunkSection.getClass()
|
||||
.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 setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class);
|
||||
|
||||
@@ -835,8 +839,9 @@ public class DisguiseUtilities {
|
||||
|
||||
cSection.set(bedChunk, array);
|
||||
|
||||
spawnChunk = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.MAP_CHUNK,
|
||||
bedChunk, 65535).createPacket(bedChunk, 65535);
|
||||
spawnChunk = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, 65535)
|
||||
.createPacket(bedChunk, 65535);
|
||||
|
||||
Field threadField = ReflectionManager.getNmsField("MinecraftServer", "primaryThread");
|
||||
threadField.setAccessible(true);
|
||||
@@ -863,9 +868,9 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
public static boolean isDisguiseInUse(Disguise disguise) {
|
||||
return disguise.getEntity() != null && getDisguises().containsKey(
|
||||
disguise.getEntity().getUniqueId()) && getDisguises().get(disguise.getEntity().getUniqueId()).contains(
|
||||
disguise);
|
||||
return disguise.getEntity() != null && getDisguises()
|
||||
.containsKey(disguise.getEntity().getUniqueId()) && getDisguises()
|
||||
.get(disguise.getEntity().getUniqueId()).contains(disguise);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -888,8 +893,8 @@ public class DisguiseUtilities {
|
||||
try {
|
||||
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||
|
||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && disguise.getEntity().getName().equalsIgnoreCase(
|
||||
player)) {
|
||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && disguise.getEntity().getName()
|
||||
.equalsIgnoreCase(player)) {
|
||||
removeSelfDisguise((Player) disguise.getEntity());
|
||||
|
||||
if (disguise.isSelfDisguiseVisible()) {
|
||||
@@ -915,11 +920,11 @@ public class DisguiseUtilities {
|
||||
if (entityTrackerEntry == null)
|
||||
return;
|
||||
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry);
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
Method clear = ReflectionManager
|
||||
.getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
|
||||
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
@@ -975,11 +980,11 @@ public class DisguiseUtilities {
|
||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity);
|
||||
|
||||
if (entityTrackerEntry != null) {
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry",
|
||||
"trackedPlayers").get(entityTrackerEntry);
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
Method clear = ReflectionManager
|
||||
.getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
|
||||
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
@@ -1052,11 +1057,11 @@ public class DisguiseUtilities {
|
||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||
|
||||
if (entityTrackerEntry != null) {
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry);
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
final Method clear = ReflectionManager
|
||||
.getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
|
||||
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||
@@ -1100,7 +1105,8 @@ public class DisguiseUtilities {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1175,16 +1181,16 @@ public class DisguiseUtilities {
|
||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
|
||||
|
||||
if (entityTrackerEntry != null) {
|
||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry);
|
||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
// If the tracker exists. Remove himself from his tracker
|
||||
if (isHashSet(trackedPlayersObj)) {
|
||||
((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player));
|
||||
((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player));
|
||||
} else {
|
||||
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(
|
||||
entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player));
|
||||
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap")
|
||||
.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
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player,
|
||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_METADATA,
|
||||
player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true).createPacket(
|
||||
player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(),
|
||||
WrappedDataWatcher.getEntityWatcher(player), true)
|
||||
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -1214,8 +1220,8 @@ public class DisguiseUtilities {
|
||||
throw new IllegalStateException("Cannot modify disguises on an async thread");
|
||||
|
||||
try {
|
||||
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible() || !disguise.canSee(
|
||||
player)) {
|
||||
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise
|
||||
.isSelfDisguiseVisible() || !disguise.canSee(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1248,8 +1254,8 @@ public class DisguiseUtilities {
|
||||
String ldTeamName = "LD Pushing";
|
||||
|
||||
// If the player is in a team already
|
||||
if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName().endsWith(
|
||||
"_LDP"))) {
|
||||
if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName()
|
||||
.endsWith("_LDP"))) {
|
||||
// If we're creating a scoreboard
|
||||
if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
||||
// 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
|
||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry);
|
||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
// Check for code differences in PaperSpigot vs Spigot
|
||||
if (isHashSet(trackedPlayersObj)) {
|
||||
((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||
entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player));
|
||||
((Set<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player));
|
||||
} else {
|
||||
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(
|
||||
entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true);
|
||||
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap")
|
||||
.get(entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true);
|
||||
}
|
||||
|
||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||
@@ -1320,8 +1326,8 @@ public class DisguiseUtilities {
|
||||
WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player);
|
||||
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher,
|
||||
true).createPacket(player.getEntityId(), dataWatcher, true));
|
||||
manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true)
|
||||
.createPacket(player.getEntityId(), dataWatcher, true));
|
||||
|
||||
boolean isMoving = false;
|
||||
|
||||
@@ -1339,64 +1345,68 @@ public class DisguiseUtilities {
|
||||
Vector velocity = player.getVelocity();
|
||||
sendSelfPacket(player,
|
||||
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.
|
||||
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player,
|
||||
player.getVehicle()).createPacket(0, player, player.getVehicle()));
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player, player.getVehicle())
|
||||
.createPacket(0, player, player.getVehicle()));
|
||||
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player.getPassenger(),
|
||||
player).createPacket(0, player.getPassenger(), player));
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
|
||||
.createPacket(0, player.getPassenger(), player));
|
||||
}
|
||||
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(),
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getHelmet())));
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getHelmet())));
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(),
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.CHEST),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getChestplate())));
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.CHEST),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getChestplate())));
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(),
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.LEGS),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getLeggings())));
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.LEGS),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getLeggings())));
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(),
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.FEET),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getBoots())));
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.FEET),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getBoots())));
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(),
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HAND),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getItemInMainHand())));
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.HAND),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getItemInMainHand())));
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE))).createPacket(player.getEntityId(),
|
||||
ReflectionManager.createEnumItemSlot(EquipmentSlot.OFF_HAND),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getItemInOffHand())));
|
||||
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
|
||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.OFF_HAND),
|
||||
ReflectionManager.getNmsItem(player.getInventory().getItemInOffHand())));
|
||||
|
||||
Location loc = player.getLocation();
|
||||
|
||||
// If the disguised is sleeping for w/e reason
|
||||
if (player.isSleeping()) {
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.BED, player,
|
||||
ReflectionManager.getBlockPosition(0, 0, 0)).createPacket(player,
|
||||
ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(Server.BED, player, ReflectionManager.getBlockPosition(0, 0, 0))
|
||||
.createPacket(player, ReflectionManager
|
||||
.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
|
||||
}
|
||||
|
||||
// Resend any active potion effects
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
|
||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EFFECT, player.getEntityId(),
|
||||
mobEffect).createPacket(player.getEntityId(), mobEffect));
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(Server.ENTITY_EFFECT, player.getEntityId(), mobEffect)
|
||||
.createPacket(player.getEntityId(), mobEffect));
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -1449,8 +1459,8 @@ public class DisguiseUtilities {
|
||||
Entity e = disguise.getEntity();
|
||||
|
||||
// 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(
|
||||
e.getUniqueId()).contains(disguise)) {
|
||||
if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId()) || !getDisguises()
|
||||
.get(e.getUniqueId()).contains(disguise)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1465,7 +1475,8 @@ public class DisguiseUtilities {
|
||||
DisguiseUtilities.removeSelfDisguise(player);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
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 org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -56,7 +57,7 @@ public enum TranslateType {
|
||||
if (value == null)
|
||||
System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'");
|
||||
else
|
||||
translated.put(key, value);
|
||||
translated.put(key, ChatColor.translateAlternateColorCodes('&', value));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -74,7 +75,7 @@ public enum TranslateType {
|
||||
|
||||
translated.put(message, message);
|
||||
|
||||
message = StringEscapeUtils.escapeJava(message);
|
||||
message = StringEscapeUtils.escapeJava(message.replaceAll(ChatColor.COLOR_CHAR + "", "&"));
|
||||
|
||||
try {
|
||||
boolean exists = file.exists();
|
||||
@@ -112,26 +113,24 @@ public enum TranslateType {
|
||||
return translated;
|
||||
}
|
||||
|
||||
public String get(String message) {
|
||||
public String get(String msg) {
|
||||
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())
|
||||
return message;
|
||||
System.out.println("1");
|
||||
|
||||
String msg = translated.get(message);
|
||||
|
||||
if (msg != null)
|
||||
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