Added config option ContactMojangServers which disables player skins, but stops the plugin from pinging Mojang servers.

Added reload command to reload the config.
Tweaked a couple of things.
Fixed isInvulnerable issue.
This commit is contained in:
NavidK0
2015-03-29 22:47:29 -04:00
parent a33bb0b139
commit 15c0141c3d
27 changed files with 174 additions and 236 deletions

View File

@@ -95,7 +95,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
try {
methods[methods.length - i--] = Disguise.class.getMethod(methodName, boolean.class);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
return methods;
@@ -630,7 +630,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
storedEx = ex;
methodToUse = null;
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
methodToUse = null;
}
}

View File

@@ -64,7 +64,7 @@ public class ClassGetter {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}

View File

@@ -113,7 +113,7 @@ public class DisguiseUtilities {
zChunk = bedChunk.getClass().getField("locZ");
zChunk.setAccessible(true);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
@@ -266,7 +266,7 @@ public class DisguiseUtilities {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
@@ -317,7 +317,7 @@ public class DisguiseUtilities {
xChunk.set(bedChunk, chunkX);
zChunk.set(bedChunk, chunkZ);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
// Make unload packets
try {
@@ -448,7 +448,7 @@ public class DisguiseUtilities {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return players;
}
@@ -628,7 +628,7 @@ public class DisguiseUtilities {
try {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}, 2);
@@ -652,7 +652,7 @@ public class DisguiseUtilities {
try {
updatePlayer.invoke(entityTrackerEntry, p);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}, 2);
@@ -662,7 +662,7 @@ public class DisguiseUtilities {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}
@@ -693,7 +693,7 @@ public class DisguiseUtilities {
try {
updatePlayer.invoke(entityTrackerEntry, p);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}, 2);
@@ -701,7 +701,7 @@ public class DisguiseUtilities {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}
@@ -722,7 +722,7 @@ public class DisguiseUtilities {
try {
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}, 2);
@@ -746,7 +746,7 @@ public class DisguiseUtilities {
try {
updatePlayer.invoke(entityTrackerEntry, p);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}, 2);
@@ -754,7 +754,7 @@ public class DisguiseUtilities {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}
@@ -789,7 +789,7 @@ public class DisguiseUtilities {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
// Remove the fake entity ID from the disguise bin
selfDisguised.remove(player.getUniqueId());
@@ -803,7 +803,7 @@ public class DisguiseUtilities {
trackedPlayers.remove(ReflectionManager.getNmsEntity(player));
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
// Resend entity metadata else he will be invisible to himself until its resent
try {
@@ -815,7 +815,7 @@ public class DisguiseUtilities {
WrappedDataWatcher.getEntityWatcher(player), true)
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
player.updateInventory();
}
@@ -864,7 +864,7 @@ public class DisguiseUtilities {
field.setAccessible(true);
isMoving = field.getBoolean(entityTrackerEntry);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
// Send the velocity packets
if (isMoving) {
@@ -920,7 +920,7 @@ public class DisguiseUtilities {
.createPacket(player.getEntityId(), mobEffect));
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
@@ -948,13 +948,13 @@ public class DisguiseUtilities {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
}
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
});
}
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}

View File

@@ -106,7 +106,7 @@ public class PacketsManager {
}
}
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
};
@@ -114,7 +114,7 @@ public class PacketsManager {
// Now I call this and the main listener is registered!
setupMainPacketsListener();
}
/**
* Construct the packets I need to spawn in the disguise
*/
@@ -372,7 +372,7 @@ public class PacketsManager {
newWatcher.setObject(watchableObject.getIndex(), watchableObject.getValue());
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return newWatcher;
}
@@ -571,7 +571,7 @@ public class PacketsManager {
obj = null;
}
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
if (obj == null) {
@@ -587,7 +587,7 @@ public class PacketsManager {
.invoke(nmsEntity, DamageSource.GENERIC);
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
soundType = entitySound.getType(soundName, !hasInvun);
}
@@ -624,7 +624,7 @@ public class PacketsManager {
.invoke(step));
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
// There is no else statement. Because seriously. This should never be null. Unless
// someone is
@@ -704,7 +704,7 @@ public class PacketsManager {
obj = null;
}
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
if (obj == null) {
@@ -745,7 +745,7 @@ public class PacketsManager {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}
@@ -787,7 +787,7 @@ public class PacketsManager {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
if (delayedPackets != null && delayedPackets.length > 0) {
@@ -798,7 +798,7 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
}
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}, 2);
@@ -828,7 +828,7 @@ public class PacketsManager {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
} else if (event.getPacketType() == PacketType.Play.Server.ANIMATION) {
if (event.getPacket().getIntegers().read(1) != 2) {
@@ -886,7 +886,7 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet,
false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}
@@ -905,7 +905,7 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet,
false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}
@@ -930,7 +930,7 @@ public class PacketsManager {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
org.bukkit.inventory.ItemStack newHeld = event.getPlayer().getInventory()
@@ -945,7 +945,7 @@ public class PacketsManager {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}
@@ -986,7 +986,7 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet,
false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
// Else if its a hotbar slot
@@ -1004,7 +1004,7 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet,
false);
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}
@@ -1219,13 +1219,13 @@ public class PacketsManager {
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
}
} catch (InvocationTargetException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
}
}, 2);
}
} catch (InvocationTargetException ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
}
@@ -1493,7 +1493,7 @@ public class PacketsManager {
}
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return packets == null ? null : new PacketContainer[][] { packets, delayedPackets };
}

View File

@@ -162,11 +162,11 @@ public class ReflectionManager {
System.out.println("[LibsDisguises] Loaded " + ForgeFieldMappings.size() + " Cauldron field mappings");
System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings");
} catch (ClassNotFoundException e) {
e.printStackTrace();
e.printStackTrace(System.out);
System.err
.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace(System.out);
System.err
.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
}
@@ -187,7 +187,7 @@ public class ReflectionManager {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
craftItemClass = getCraftClass("inventory.CraftItemStack");
@@ -221,7 +221,7 @@ public class ReflectionManager {
}
return entityObject;
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -231,7 +231,7 @@ public class ReflectionManager {
return getNmsClass("MobEffect").getConstructor(int.class, int.class, int.class, boolean.class, boolean.class)
.newInstance(id, duration, amplification, ambient, particles);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -279,7 +279,7 @@ public class ReflectionManager {
return new FakeBoundingBox(x, y, z);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -288,7 +288,7 @@ public class ReflectionManager {
try {
return (Entity) getNmsMethod("Entity", "getBukkitEntity").invoke(nmsEntity);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -297,7 +297,7 @@ public class ReflectionManager {
try {
return (ItemStack) craftItemClass.getMethod("asBukkitCopy", getNmsClass("ItemStack")).invoke(null, nmsItem);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -310,7 +310,7 @@ public class ReflectionManager {
try {
return Class.forName("org.bukkit.craftbukkit." + getBukkitVersion() + "." + className);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -319,7 +319,7 @@ public class ReflectionManager {
try {
return (String) getCraftClass("CraftSound").getMethod("getSound", Sound.class).invoke(null, sound);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -340,7 +340,7 @@ public class ReflectionManager {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -349,7 +349,7 @@ public class ReflectionManager {
try {
return getNmsClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(x, y, z);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -358,7 +358,7 @@ public class ReflectionManager {
try {
return (Enum) getNmsMethod("EnumDirection", "fromType2", int.class).invoke(null, direction);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -367,7 +367,7 @@ public class ReflectionManager {
try {
return (Enum) getNmsClass("PacketPlayOutPlayerInfo$EnumPlayerInfoAction").getEnumConstants()[action];
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -381,7 +381,7 @@ public class ReflectionManager {
.newInstance(playerInfoPacket, gameProfile.getHandle(), 0,
getNmsClass("WorldSettings$EnumGamemode").getEnumConstants()[1], playerListName);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -394,7 +394,7 @@ public class ReflectionManager {
try {
return new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -405,7 +405,7 @@ public class ReflectionManager {
gameProfile.getProperties().putAll(profileWithSkin.getProperties());
return gameProfile;
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -426,7 +426,7 @@ public class ReflectionManager {
try {
return Class.forName("net.minecraft.server." + getBukkitVersion() + "." + className);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -435,7 +435,7 @@ public class ReflectionManager {
try {
return clazz.getConstructor(parameters);
} catch (NoSuchMethodException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -448,7 +448,7 @@ public class ReflectionManager {
try {
return getCraftClass("entity.CraftEntity").getMethod("getHandle").invoke(entity);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -458,14 +458,14 @@ public class ReflectionManager {
try {
return clazz.getField(ForgeFieldMappings.get(clazz.getName()).get(fieldName));
} catch (NoSuchFieldException ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
} catch (NullPointerException ignored) {
}
}
try {
return clazz.getField(fieldName);
} catch (NoSuchFieldException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -478,7 +478,7 @@ public class ReflectionManager {
try {
return craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(null, itemstack);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -493,14 +493,14 @@ public class ReflectionManager {
}
return clazz.getMethod(innerMap.get(sb.toString()), parameters);
} catch (NoSuchMethodException e) {
e.printStackTrace();
e.printStackTrace(System.out);
} catch (NullPointerException ignored) {
}
}
try {
return clazz.getMethod(methodName, parameters);
} catch (NoSuchMethodException e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -513,7 +513,7 @@ public class ReflectionManager {
try {
return (double) pingField.getInt(ReflectionManager.getNmsEntity(player));
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return 0D;
}
@@ -525,7 +525,7 @@ public class ReflectionManager {
float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
return new float[] { length, width, height };
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -542,7 +542,7 @@ public class ReflectionManager {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -560,7 +560,7 @@ public class ReflectionManager {
try {
return getCraftClass("CraftWorld").getMethod("getHandle").invoke(world);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(System.out);
}
return null;
}
@@ -585,7 +585,7 @@ public class ReflectionManager {
}
}
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
return null;
}
@@ -615,7 +615,7 @@ public class ReflectionManager {
Field check = getNmsField(connection.getClass(), "checkMovement");
check.setBoolean(connection, true);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}
@@ -626,7 +626,7 @@ public class ReflectionManager {
loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(), loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ());
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
} catch (Exception ex) {
ex.printStackTrace();
ex.printStackTrace(System.out);
}
}