Fixed bug where players switching worlds would become invisible.
Fixed bug where arrows wouldn't blow disguises. Added default permission for /libsdisguises reload (only ops can use by default)
This commit is contained in:
@@ -35,6 +35,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
|
||||
public class DisguiseParseException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1276971370793124510L;
|
||||
|
||||
public DisguiseParseException() {
|
||||
@@ -45,7 +46,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
||||
ArrayList<String> allowedDisguises = new ArrayList<>();
|
||||
for (DisguiseType type : hashMap.keySet()) {
|
||||
@@ -61,30 +62,30 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
|
||||
protected HashMap<String, Boolean> getDisguisePermission(CommandSender sender, DisguiseType type) {
|
||||
switch (type) {
|
||||
case PLAYER:
|
||||
case FALLING_BLOCK:
|
||||
case PAINTING:
|
||||
case SPLASH_POTION:
|
||||
case FISHING_HOOK:
|
||||
case DROPPED_ITEM:
|
||||
HashMap<String, Boolean> returns = new HashMap<>();
|
||||
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
|
||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
||||
String lowerPerm = permission.getPermission().toLowerCase();
|
||||
if (lowerPerm.startsWith(beginning)) {
|
||||
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
||||
if (split.length > 1) {
|
||||
if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) {
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
returns.put(split[i], permission.getValue());
|
||||
case PLAYER:
|
||||
case FALLING_BLOCK:
|
||||
case PAINTING:
|
||||
case SPLASH_POTION:
|
||||
case FISHING_HOOK:
|
||||
case DROPPED_ITEM:
|
||||
HashMap<String, Boolean> returns = new HashMap<>();
|
||||
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
|
||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
||||
String lowerPerm = permission.getPermission().toLowerCase();
|
||||
if (lowerPerm.startsWith(beginning)) {
|
||||
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
||||
if (split.length > 1) {
|
||||
if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) {
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
returns.put(split[i], permission.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returns;
|
||||
default:
|
||||
return new HashMap<>();
|
||||
return returns;
|
||||
default:
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +93,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
Method[] methods = watcherClass.getMethods();
|
||||
methods = Arrays.copyOf(methods, methods.length + 4);
|
||||
int i = 4;
|
||||
for (String methodName : new String[] { "setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf",
|
||||
"setHearSelfDisguise" }) {
|
||||
for (String methodName : new String[]{"setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf",
|
||||
"setHearSelfDisguise"}) {
|
||||
try {
|
||||
methods[methods.length - i--] = Disguise.class.getMethod(methodName, boolean.class);
|
||||
} catch (Exception ex) {
|
||||
@@ -105,9 +106,10 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
|
||||
/**
|
||||
* Get perms for the node. Returns a hashmap of allowed disguisetypes and their options
|
||||
*
|
||||
* @param sender
|
||||
* @param permissionNode
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) {
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>();
|
||||
@@ -265,8 +267,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
option = option.substring(1);
|
||||
isRemove = false;
|
||||
}
|
||||
if (option.equals("baby"))
|
||||
if (option.equals("baby")) {
|
||||
option = "setbaby";
|
||||
}
|
||||
list.add(option);
|
||||
}
|
||||
HashMap<ArrayList<String>, Boolean> options = new HashMap<>();
|
||||
@@ -293,16 +296,15 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The
|
||||
* commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the
|
||||
* disguise has been feed a proper disguisetype.
|
||||
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the disguise has been feed a proper disguisetype.
|
||||
*
|
||||
* @param sender
|
||||
* @param args
|
||||
* @param map
|
||||
* @return
|
||||
* @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.reflect.InvocationTargetException
|
||||
* @return
|
||||
* @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.reflect.InvocationTargetException
|
||||
*/
|
||||
protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
@@ -366,7 +368,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
} else {
|
||||
if (!disguiseOptions.isEmpty()
|
||||
&& (!disguiseOptions.containsKey(args[1].toLowerCase()) || !disguiseOptions
|
||||
.get(args[1].toLowerCase()))) {
|
||||
.get(args[1].toLowerCase()))) {
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! You don't have permission to use that name!");
|
||||
}
|
||||
args[1] = args[1].replace("\\_", " ");
|
||||
@@ -415,19 +417,19 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
if (miscId != -1) {
|
||||
switch (disguiseType) {
|
||||
case PAINTING:
|
||||
case FALLING_BLOCK:
|
||||
case SPLASH_POTION:
|
||||
case DROPPED_ITEM:
|
||||
case FISHING_HOOK:
|
||||
case ARROW:
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case WITHER_SKULL:
|
||||
break;
|
||||
default:
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! " + disguiseType.toReadable()
|
||||
+ " doesn't know what to do with " + args[1] + "!");
|
||||
case PAINTING:
|
||||
case FALLING_BLOCK:
|
||||
case SPLASH_POTION:
|
||||
case DROPPED_ITEM:
|
||||
case FISHING_HOOK:
|
||||
case ARROW:
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case WITHER_SKULL:
|
||||
break;
|
||||
default:
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! " + disguiseType.toReadable()
|
||||
+ " doesn't know what to do with " + args[1] + "!");
|
||||
}
|
||||
toSkip++;
|
||||
// If they also defined a data value
|
||||
@@ -577,8 +579,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
if (potionType == null && isNumeric(valueString)) {
|
||||
potionType = PotionEffectType.getById(Integer.parseInt(valueString));
|
||||
}
|
||||
if (potionType == null)
|
||||
if (potionType == null) {
|
||||
throw new DisguiseParseException();
|
||||
}
|
||||
value = potionType;
|
||||
} catch (Exception ex) {
|
||||
throw parseToException("a potioneffect type", valueString, methodName);
|
||||
@@ -597,8 +600,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
} else if (param == BlockFace.class) {
|
||||
try {
|
||||
BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
|
||||
if (face.ordinal() > 4)
|
||||
if (face.ordinal() > 4) {
|
||||
throw new DisguiseParseException();
|
||||
}
|
||||
value = face;
|
||||
} catch (Exception ex) {
|
||||
throw parseToException("a direction (north, east, south, west, up)", valueString, methodName);
|
||||
@@ -661,10 +665,11 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
usedOptions.add(methodName.toLowerCase());
|
||||
}
|
||||
doCheck(optionPermissions, usedOptions);
|
||||
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass()))
|
||||
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {
|
||||
methodToUse.invoke(disguise.getWatcher(), value);
|
||||
else
|
||||
} else {
|
||||
methodToUse.invoke(disguise, value);
|
||||
}
|
||||
}
|
||||
// Alright. We've constructed our disguise.
|
||||
return disguise;
|
||||
|
@@ -13,7 +13,6 @@ import java.util.jar.JarFile;
|
||||
/**
|
||||
* User: Austin Date: 4/22/13 Time: 11:47 PM (c) lazertester
|
||||
*/
|
||||
|
||||
// Code for this taken and slightly modified from
|
||||
// https://github.com/ddopson/java-class-enumerator
|
||||
public class ClassGetter {
|
||||
@@ -59,8 +58,9 @@ public class ClassGetter {
|
||||
}
|
||||
if (className != null) {
|
||||
Class<?> c = loadClass(className);
|
||||
if (c != null)
|
||||
if (c != null) {
|
||||
classes.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@@ -11,107 +11,69 @@ import org.bukkit.Sound;
|
||||
* Only living disguises go in here!
|
||||
*/
|
||||
public enum DisguiseSound {
|
||||
ARROW(null, null, null, null, "random.bowhit"),
|
||||
|
||||
ARROW(null, null, null, null, "random.bowhit"),
|
||||
BAT("mob.bat.hurt", null, "mob.bat.death", "mob.bat.idle", "damage.fallsmall", "mob.bat.loop", "damage.fallbig",
|
||||
"mob.bat.takeoff"),
|
||||
|
||||
BLAZE("mob.blaze.hit", null, "mob.blaze.death", "mob.blaze.breathe", "damage.fallsmall", "damage.fallbig"),
|
||||
|
||||
CAVE_SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
|
||||
|
||||
CHICKEN("mob.chicken.hurt", "mob.chicken.step", "mob.chicken.hurt", "mob.chicken.say", "damage.fallsmall",
|
||||
"mob.chicken.plop", "damage.fallbig"),
|
||||
|
||||
COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
|
||||
|
||||
CREEPER("mob.creeper.say", "step.grass", "mob.creeper.death", null),
|
||||
|
||||
DONKEY("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle", "mob.horse.gallop",
|
||||
"mob.horse.leather", "mob.horse.donkey.angry", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft",
|
||||
"mob.horse.land", "mob.horse.jump", "mob.horse.angry"),
|
||||
|
||||
ELDER_GUARDIAN("mob.guardian.elder.hit", null, "mob.guardian.elder.death", "mob.guardian.elder.death"),
|
||||
|
||||
ENDER_DRAGON("mob.enderdragon.hit", null, "mob.enderdragon.end", "mob.enderdragon.growl", "damage.fallsmall",
|
||||
"mob.enderdragon.wings", "damage.fallbig"),
|
||||
|
||||
ENDERMAN("mob.endermen.hit", "step.grass", "mob.endermen.death", "mob.endermen.idle", "mob.endermen.scream",
|
||||
"mob.endermen.portal", "mob.endermen.stare"),
|
||||
|
||||
ENDERMITE("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
|
||||
|
||||
GHAST("mob.ghast.scream", null, "mob.ghast.death", "mob.ghast.moan", "damage.fallsmall", "mob.ghast.fireball",
|
||||
"damage.fallbig", "mob.ghast.affectionate_scream", "mob.ghast.charge"),
|
||||
|
||||
GIANT("damage.hit", "step.grass", null, null),
|
||||
|
||||
GUARDIAN("mob.guardian.hit", null, "mob.guardian.death", "mob.guardian.death"),
|
||||
|
||||
HORSE("mob.horse.hit", "step.grass", "mob.horse.death", "mob.horse.idle", "mob.horse.gallop", "mob.horse.leather",
|
||||
"mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.angry",
|
||||
"mob.horse.leather"),
|
||||
|
||||
IRON_GOLEM("mob.irongolem.hit", "mob.irongolem.walk", "mob.irongolem.death", "mob.irongolem.throw"),
|
||||
|
||||
MAGMA_CUBE("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
|
||||
|
||||
MULE("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle"),
|
||||
|
||||
MUSHROOM_COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
|
||||
|
||||
OCELOT("mob.cat.hitt", "step.grass", "mob.cat.hitt", "mob.cat.meow", "mob.cat.purreow", "mob.cat.purr"),
|
||||
|
||||
PIG("mob.pig.say", "mob.pig.step", "mob.pig.death", "mob.pig.say"),
|
||||
|
||||
PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
|
||||
|
||||
PLAYER("game.player.hurt", "step.grass", "game.player.hurt", null),
|
||||
|
||||
RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"),
|
||||
|
||||
SHEEP("mob.sheep.say", "mob.sheep.step", null, "mob.sheep.say", "mob.sheep.shear"),
|
||||
|
||||
SILVERFISH("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
|
||||
|
||||
SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
|
||||
|
||||
SKELETON_HORSE("mob.horse.skeleton.hit", "step.grass", "mob.horse.skeleton.death", "mob.horse.skeleton.idle",
|
||||
"mob.horse.gallop", "mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land",
|
||||
"mob.horse.jump", "mob.horse.angry"),
|
||||
|
||||
SLIME("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
|
||||
|
||||
SNOWMAN(),
|
||||
|
||||
SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
|
||||
|
||||
SQUID(),
|
||||
|
||||
UNDEAD_HORSE("mob.horse.zombie.hit", "step.grass", "mob.horse.zombie.death", "mob.horse.zombie.idle", "mob.horse.gallop",
|
||||
"mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump",
|
||||
"mob.horse.angry"),
|
||||
|
||||
VILLAGER("mob.villager.hit", null, "mob.villager.death", "mob.villager.idle", "mob.villager.haggle", "mob.villager.no",
|
||||
"mob.villager.yes"),
|
||||
|
||||
WITCH("mob.witch.hurt", null, "mob.witch.death", "mob.witch.idle"),
|
||||
|
||||
WITHER("mob.wither.hurt", null, "mob.wither.death", "mob.wither.idle", "damage.fallsmall", "mob.wither.spawn",
|
||||
"damage.fallbig", "mob.wither.shoot"),
|
||||
|
||||
WITHER_SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
|
||||
|
||||
WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine",
|
||||
"mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"),
|
||||
|
||||
ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
|
||||
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood"),
|
||||
|
||||
ZOMBIE_VILLAGER("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
|
||||
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood");
|
||||
|
||||
public enum SoundType {
|
||||
|
||||
CANCEL, DEATH, HURT, IDLE, STEP;
|
||||
}
|
||||
|
||||
@@ -131,9 +93,9 @@ public enum DisguiseSound {
|
||||
for (int i = 0; i < sounds.length; i++) {
|
||||
Object obj = sounds[i];
|
||||
String s;
|
||||
if (obj == null)
|
||||
if (obj == null) {
|
||||
continue;
|
||||
else if (obj instanceof String) {
|
||||
} else if (obj instanceof String) {
|
||||
s = (String) obj;
|
||||
} else if (obj instanceof Sound) {
|
||||
s = ReflectionManager.getCraftSound((Sound) obj);
|
||||
@@ -142,21 +104,21 @@ public enum DisguiseSound {
|
||||
throw new RuntimeException("Was given a unknown object " + obj);
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
disguiseSounds.put(SoundType.HURT, s);
|
||||
break;
|
||||
case 1:
|
||||
disguiseSounds.put(SoundType.STEP, s);
|
||||
break;
|
||||
case 2:
|
||||
disguiseSounds.put(SoundType.DEATH, s);
|
||||
break;
|
||||
case 3:
|
||||
disguiseSounds.put(SoundType.IDLE, s);
|
||||
break;
|
||||
default:
|
||||
cancelSounds.add(s);
|
||||
break;
|
||||
case 0:
|
||||
disguiseSounds.put(SoundType.HURT, s);
|
||||
break;
|
||||
case 1:
|
||||
disguiseSounds.put(SoundType.STEP, s);
|
||||
break;
|
||||
case 2:
|
||||
disguiseSounds.put(SoundType.DEATH, s);
|
||||
break;
|
||||
case 3:
|
||||
disguiseSounds.put(SoundType.IDLE, s);
|
||||
break;
|
||||
default:
|
||||
cancelSounds.add(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,8 +128,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
|
||||
public String getSound(SoundType type) {
|
||||
if (type == null || !disguiseSounds.containsKey(type))
|
||||
if (type == null || !disguiseSounds.containsKey(type)) {
|
||||
return null;
|
||||
}
|
||||
return disguiseSounds.get(type);
|
||||
}
|
||||
|
||||
@@ -179,18 +142,22 @@ public enum DisguiseSound {
|
||||
* Used to check if this sound name is owned by this disguise sound.
|
||||
*/
|
||||
public SoundType getType(String sound, boolean ignoreDamage) {
|
||||
if (isCancelSound(sound))
|
||||
if (isCancelSound(sound)) {
|
||||
return SoundType.CANCEL;
|
||||
}
|
||||
if (disguiseSounds.containsKey(SoundType.STEP) && disguiseSounds.get(SoundType.STEP).startsWith("step.")
|
||||
&& sound.startsWith("step."))
|
||||
&& sound.startsWith("step.")) {
|
||||
return SoundType.STEP;
|
||||
}
|
||||
for (SoundType type : SoundType.values()) {
|
||||
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT))
|
||||
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT)) {
|
||||
continue;
|
||||
}
|
||||
String s = disguiseSounds.get(type);
|
||||
if (s != null) {
|
||||
if (s.equals(sound))
|
||||
if (s.equals(sound)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -205,9 +172,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
|
||||
public void removeSound(SoundType type, String sound) {
|
||||
if (type == SoundType.CANCEL)
|
||||
if (type == SoundType.CANCEL) {
|
||||
cancelSounds.remove(sound);
|
||||
else {
|
||||
} else {
|
||||
disguiseSounds.remove(type);
|
||||
}
|
||||
}
|
||||
@@ -221,9 +188,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
|
||||
public void setSound(SoundType type, String sound) {
|
||||
if (type == SoundType.CANCEL)
|
||||
if (type == SoundType.CANCEL) {
|
||||
cancelSounds.add(sound);
|
||||
else {
|
||||
} else {
|
||||
disguiseSounds.put(type, sound);
|
||||
}
|
||||
}
|
||||
|
@@ -51,20 +51,20 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
|
||||
public class DisguiseUtilities {
|
||||
|
||||
/**
|
||||
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of
|
||||
* the plugin to do that.
|
||||
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of the plugin to do that.
|
||||
*/
|
||||
private static HashSet<String> addedByPlugins = new HashSet<>();
|
||||
private static Object bedChunk;
|
||||
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
|
||||
/**
|
||||
* A hashmap of the uuid's of entitys, alive and dead. And their disguises in use
|
||||
**/
|
||||
*
|
||||
*/
|
||||
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>();
|
||||
/**
|
||||
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for
|
||||
* a max of a second.
|
||||
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for a max of a second.
|
||||
*/
|
||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public class DisguiseUtilities {
|
||||
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);
|
||||
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
||||
for (BlockFace face : new BlockFace[]{BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}) {
|
||||
setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal()));
|
||||
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||
@@ -179,8 +179,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the
|
||||
* observers in the disguise don't see any other disguise.
|
||||
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the observers in the disguise don't see any other disguise.
|
||||
*/
|
||||
public static void checkConflicts(TargetedDisguise disguise, String name) {
|
||||
// If the disguise is being used.. Else we may accidentally undisguise something else
|
||||
@@ -237,7 +236,6 @@ public class DisguiseUtilities {
|
||||
|
||||
// System.out.print("Cannot set more than one " + TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS
|
||||
// + " on a entity. Removed the old disguise.");
|
||||
|
||||
disguiseItel.remove();
|
||||
d.removeDisguise();
|
||||
}
|
||||
@@ -258,7 +256,7 @@ public class DisguiseUtilities {
|
||||
entityTrackerEntry);
|
||||
HashSet cloned = (HashSet) trackedPlayers.clone();
|
||||
PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||
destroyPacket.getIntegerArrays().write(0, new int[] { disguise.getEntity().getEntityId() });
|
||||
destroyPacket.getIntegerArrays().write(0, new int[]{disguise.getEntity().getEntityId()});
|
||||
for (Object p : cloned) {
|
||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||
if (player == disguise.getEntity() || disguise.canSee(player)) {
|
||||
@@ -281,7 +279,7 @@ public class DisguiseUtilities {
|
||||
if (disguiseValues.getBabyBox() != null) {
|
||||
if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby())
|
||||
|| (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher())
|
||||
.isBaby())) {
|
||||
.isBaby())) {
|
||||
disguiseBox = disguiseValues.getBabyBox();
|
||||
}
|
||||
}
|
||||
@@ -307,7 +305,7 @@ public class DisguiseUtilities {
|
||||
public static PacketContainer[] getBedChunkPacket(Player player, Location newLoc, Location oldLoc) {
|
||||
int i = 0;
|
||||
PacketContainer[] packets = new PacketContainer[newLoc != null ? 2 + (oldLoc != null ? 1 : 0) : 1];
|
||||
for (Location loc : new Location[] { oldLoc, newLoc }) {
|
||||
for (Location loc : new Location[]{oldLoc, newLoc}) {
|
||||
if (loc == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -360,7 +358,7 @@ public class DisguiseUtilities {
|
||||
ints.write(1, (int) Math.floor(loc.getX() * 32));
|
||||
ints.write(2, (int) Math.floor((PacketsManager.getYModifier(disguise.getEntity(), disguise) + loc.getY()) * 32));
|
||||
ints.write(3, (int) Math.floor(loc.getZ() * 32));
|
||||
return new PacketContainer[] { setBed, teleport };
|
||||
return new PacketContainer[]{setBed, teleport};
|
||||
|
||||
}
|
||||
|
||||
@@ -433,8 +431,9 @@ public class DisguiseUtilities {
|
||||
|
||||
/**
|
||||
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
|
||||
*
|
||||
* @param disguise
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<Player> getPerverts(Disguise disguise) {
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
@@ -469,7 +468,7 @@ public class DisguiseUtilities {
|
||||
if (DisguiseAPI.isDisguiseInUse(disguise)
|
||||
&& (!gameProfile.getName().equals(
|
||||
disguise.getSkin() != null ? disguise.getSkin() : disguise.getName())
|
||||
|| !gameProfile.getProperties().isEmpty())) {
|
||||
|| !gameProfile.getProperties().isEmpty())) {
|
||||
disguise.setGameProfile(gameProfile);
|
||||
DisguiseUtilities.refreshTrackers(disguise);
|
||||
}
|
||||
@@ -478,8 +477,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||
*/
|
||||
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
|
||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
||||
@@ -550,8 +548,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||
*/
|
||||
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
|
||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
|
||||
@@ -582,14 +579,14 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Please note that in the future when 'DualInt' and the like are removed. This should break.. However, that should be negated
|
||||
* in the future as I'd be able to set the watcher index's as per the spigot version. Instead of checking on the player's
|
||||
* version every single packet..
|
||||
* Please note that in the future when 'DualInt' and the like are removed. This should break.. However, that should be negated in the future as I'd be able to set the watcher index's as per the spigot version. Instead of checking on the player's version every single packet..
|
||||
*/
|
||||
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
|
||||
List<WrappedWatchableObject> list) {
|
||||
if (true) // Use for future protocol compatibility
|
||||
{
|
||||
return list;
|
||||
}
|
||||
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>();
|
||||
ArrayList<WrappedWatchableObject> backups = new ArrayList<>();
|
||||
for (WrappedWatchableObject obj : list) {
|
||||
@@ -598,7 +595,7 @@ public class DisguiseUtilities {
|
||||
continue;
|
||||
}
|
||||
switch (obj.getIndex()) {
|
||||
// TODO: Future version support
|
||||
// TODO: Future version support
|
||||
}
|
||||
}
|
||||
Iterator<WrappedWatchableObject> itel = backups.iterator();
|
||||
@@ -625,8 +622,9 @@ public class DisguiseUtilities {
|
||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
|
||||
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
|
||||
removeSelfDisguise((Player) disguise.getEntity());
|
||||
if (disguise.isSelfDisguiseVisible())
|
||||
if (disguise.isSelfDisguiseVisible()) {
|
||||
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||
}
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
@@ -820,10 +818,10 @@ public class DisguiseUtilities {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(
|
||||
player,
|
||||
ProtocolLibrary
|
||||
.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
|
||||
WrappedDataWatcher.getEntityWatcher(player), true)
|
||||
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||
.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
|
||||
WrappedDataWatcher.getEntityWatcher(player), true)
|
||||
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
@@ -891,11 +889,11 @@ public class DisguiseUtilities {
|
||||
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())
|
||||
.createPacket(0, player, player.getVehicle()));
|
||||
.createPacket(0, player, player.getVehicle()));
|
||||
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
|
||||
.createPacket(0, player.getPassenger(), player));
|
||||
.createPacket(0, player.getPassenger(), player));
|
||||
}
|
||||
|
||||
// Resend the armor
|
||||
@@ -928,7 +926,7 @@ public class DisguiseUtilities {
|
||||
Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), mobEffect)
|
||||
.createPacket(player.getEntityId(), mobEffect));
|
||||
.createPacket(player.getEntityId(), mobEffect));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
@@ -944,7 +942,7 @@ public class DisguiseUtilities {
|
||||
final PacketContainer[] delayed = transformed == null ? null : transformed[1];
|
||||
try {
|
||||
if (packets == null) {
|
||||
packets = new PacketContainer[] { packet };
|
||||
packets = new PacketContainer[]{packet};
|
||||
}
|
||||
for (PacketContainer p : packets) {
|
||||
p = p.deepClone();
|
||||
@@ -972,6 +970,7 @@ public class DisguiseUtilities {
|
||||
|
||||
/**
|
||||
* Setup it so he can see himself when disguised
|
||||
*
|
||||
* @param disguise
|
||||
*/
|
||||
public static void setupFakeDisguise(final Disguise disguise) {
|
||||
|
@@ -10,28 +10,28 @@ public class DisguiseValues {
|
||||
|
||||
public static DisguiseValues getDisguiseValues(DisguiseType type) {
|
||||
switch (type) {
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
type = DisguiseType.HORSE;
|
||||
break;
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_TNT:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
type = DisguiseType.MINECART;
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
type = DisguiseType.SKELETON;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
type = DisguiseType.ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
type = DisguiseType.HORSE;
|
||||
break;
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_TNT:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
type = DisguiseType.MINECART;
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
type = DisguiseType.SKELETON;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
type = DisguiseType.ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return values.get(type);
|
||||
}
|
||||
@@ -76,38 +76,38 @@ public class DisguiseValues {
|
||||
double d = paramDouble - (((int) Math.floor(paramDouble)) + 0.5D);
|
||||
|
||||
switch (enumEntitySize) {
|
||||
case 1:
|
||||
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
||||
case 1:
|
||||
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
case 2:
|
||||
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
}
|
||||
case 3:
|
||||
if (d > 0.0D) {
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
case 2:
|
||||
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
case 3:
|
||||
if (d > 0.0D) {
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
case 4:
|
||||
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
}
|
||||
case 4:
|
||||
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
case 5:
|
||||
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
}
|
||||
case 5:
|
||||
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
|
||||
return (int) Math.floor(paramDouble * 32.0D);
|
||||
}
|
||||
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
default:
|
||||
break;
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (d > 0.0D) {
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
public class FakeBoundingBox {
|
||||
|
||||
private double xMod;
|
||||
private double yMod;
|
||||
private double zMod;
|
||||
|
@@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
public interface LibsProfileLookup {
|
||||
|
||||
public void onLookup(WrappedGameProfile gameProfile);
|
||||
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
|
||||
public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
||||
|
||||
private WrappedGameProfile gameProfile;
|
||||
|
||||
public WrappedGameProfile getGameProfile() {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -31,8 +31,10 @@ import org.bukkit.potion.PotionEffect;
|
||||
public class ReflectionManager {
|
||||
|
||||
public enum LibVersion {
|
||||
|
||||
V1_8;
|
||||
private static LibVersion currentVersion;
|
||||
|
||||
static {
|
||||
//String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
||||
currentVersion = V1_8;
|
||||
@@ -59,8 +61,7 @@ public class ReflectionManager {
|
||||
private static Map<String, Map<String, String>> ForgeFieldMappings;
|
||||
|
||||
/**
|
||||
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method
|
||||
* names.
|
||||
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method names.
|
||||
*/
|
||||
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
|
||||
private static final Method ihmGet;
|
||||
@@ -82,7 +83,7 @@ public class ReflectionManager {
|
||||
final String nameseg_class = "a-zA-Z0-9$_";
|
||||
final String fqn_class = nameseg_class + "/";
|
||||
|
||||
primitiveTypes = ImmutableMap.<Class<?>, String> builder().put(boolean.class, "Z").put(byte.class, "B")
|
||||
primitiveTypes = ImmutableMap.<Class<?>, String>builder().put(boolean.class, "Z").put(byte.class, "B")
|
||||
.put(char.class, "C").put(short.class, "S").put(int.class, "I").put(long.class, "J").put(float.class, "F")
|
||||
.put(double.class, "D").put(void.class, "V").build();
|
||||
|
||||
@@ -191,7 +192,7 @@ public class ReflectionManager {
|
||||
trackerField = getNmsField("WorldServer", "tracker");
|
||||
entitiesField = getNmsField("EntityTracker", "trackedEntities");
|
||||
ihmGet = getNmsMethod("IntHashMap", "get", int.class);
|
||||
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB",double.class, double.class, double.class,
|
||||
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class,
|
||||
double.class, double.class, double.class);
|
||||
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
||||
}
|
||||
@@ -208,7 +209,7 @@ public class ReflectionManager {
|
||||
WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
|
||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
||||
gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
||||
gameProfile.getHandle(), playerinteractmanager);
|
||||
gameProfile.getHandle(), playerinteractmanager);
|
||||
} else if (entityName.equals("EnderPearl")) {
|
||||
entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
||||
.newInstance(world, createEntityInstance("Cow"));
|
||||
@@ -249,26 +250,26 @@ public class ReflectionManager {
|
||||
if (field.getType().getSimpleName().equals("double")) {
|
||||
stage++;
|
||||
switch (stage) {
|
||||
case 1:
|
||||
x -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 2:
|
||||
y -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 3:
|
||||
z -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 4:
|
||||
x += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 5:
|
||||
y += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 6:
|
||||
z += field.getDouble(boundingBox);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||
case 1:
|
||||
x -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 2:
|
||||
y -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 3:
|
||||
z -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 4:
|
||||
x += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 5:
|
||||
y += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 6:
|
||||
z += field.getDouble(boundingBox);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,7 +383,7 @@ public class ReflectionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WrappedGameProfile getGameProfile(Player player) {
|
||||
public static WrappedGameProfile getGameProfile(Player player) {
|
||||
return WrappedGameProfile.fromPlayer(player);
|
||||
}
|
||||
|
||||
@@ -519,7 +520,7 @@ public class ReflectionManager {
|
||||
float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
|
||||
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
|
||||
float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
|
||||
return new float[] { length, width, height };
|
||||
return new float[]{length, width, height};
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
@@ -573,7 +574,7 @@ public class ReflectionManager {
|
||||
.getClass()
|
||||
.getMethod("findProfilesByNames", String[].class, agent.getClass(),
|
||||
Class.forName("com.mojang.authlib.ProfileLookupCallback"))
|
||||
.invoke(profileRepo, new String[] { playername }, agent, callback);
|
||||
.invoke(profileRepo, new String[]{playername}, agent, callback);
|
||||
if (callback.getGameProfile() != null) {
|
||||
return callback.getGameProfile();
|
||||
}
|
||||
@@ -607,10 +608,8 @@ public class ReflectionManager {
|
||||
public static void setAllowSleep(Player player) {
|
||||
try {
|
||||
/**
|
||||
Object nmsEntity = getNmsEntity(player);
|
||||
Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity);
|
||||
Field check = getNmsField(connection.getClass(), "checkMovement");
|
||||
check.setBoolean(connection, true); **/
|
||||
* Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); *
|
||||
*/
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import java.net.URL;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UpdateChecker {
|
||||
|
||||
private String latestVersion;
|
||||
|
||||
private boolean checkHigher(String currentVersion, String newVersion) {
|
||||
@@ -51,8 +52,9 @@ public class UpdateChecker {
|
||||
private String toReadable(String version) {
|
||||
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
||||
version = "";
|
||||
for (String s : split)
|
||||
for (String s : split) {
|
||||
version += String.format("%4s", s);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user