diff --git a/.classpath b/.classpath new file mode 100644 index 00000000..149cb3c9 --- /dev/null +++ b/.classpath @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 00000000..d9784440 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + LibsDisguises + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..7a531392 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/src=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..672496e1 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/bin/main/java/me/libraryaddict/disguise/DisguiseAPI.class b/bin/main/java/me/libraryaddict/disguise/DisguiseAPI.class new file mode 100644 index 00000000..8e626477 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/DisguiseAPI.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/DisguiseConfig.class b/bin/main/java/me/libraryaddict/disguise/DisguiseConfig.class new file mode 100644 index 00000000..93422639 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/DisguiseConfig.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/DisguiseListener.class b/bin/main/java/me/libraryaddict/disguise/DisguiseListener.class new file mode 100644 index 00000000..c9e3de03 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/DisguiseListener.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/LibsDisguises.class b/bin/main/java/me/libraryaddict/disguise/LibsDisguises.class new file mode 100644 index 00000000..823abc02 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/LibsDisguises.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand$DisguiseParseException.class b/bin/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand$DisguiseParseException.class new file mode 100644 index 00000000..1029d632 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand$DisguiseParseException.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand.class new file mode 100644 index 00000000..86745086 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/CloneDisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/CloneDisguiseCommand.class new file mode 100644 index 00000000..c806016d Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/CloneDisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.class new file mode 100644 index 00000000..172bcff8 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/DisguiseViewSelf.class b/bin/main/java/me/libraryaddict/disguise/commands/DisguiseViewSelf.class new file mode 100644 index 00000000..f2e59047 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/DisguiseViewSelf.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/EntityDisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/EntityDisguiseCommand.class new file mode 100644 index 00000000..fe4c3a42 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/EntityDisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand$EnumHelp.class b/bin/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand$EnumHelp.class new file mode 100644 index 00000000..c73600ee Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand$EnumHelp.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand.class new file mode 100644 index 00000000..b2bbef17 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.class new file mode 100644 index 00000000..940a7015 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.class new file mode 100644 index 00000000..9a2a36f9 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.class new file mode 100644 index 00000000..3e21ccb4 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseCommand.class new file mode 100644 index 00000000..16bd0f80 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.class new file mode 100644 index 00000000..a48c6564 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.class new file mode 100644 index 00000000..75f7592e Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.class b/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.class new file mode 100644 index 00000000..92a18478 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.class new file mode 100644 index 00000000..343e6851 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.class new file mode 100644 index 00000000..8d061b0f Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.class new file mode 100644 index 00000000..2b7d5136 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.class new file mode 100644 index 00000000..71ca1d18 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.class new file mode 100644 index 00000000..73859d78 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.class new file mode 100644 index 00000000..94404cba Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.class new file mode 100644 index 00000000..adc5b27e Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/RabbitType.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/RabbitType.class new file mode 100644 index 00000000..c7a18a8a Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/RabbitType.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise$TargetType.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise$TargetType.class new file mode 100644 index 00000000..823ccba3 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise$TargetType.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.class new file mode 100644 index 00000000..49dbefdc Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.class new file mode 100644 index 00000000..fa8c0fe0 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.class new file mode 100644 index 00000000..32a27b81 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.class new file mode 100644 index 00000000..0289b7f5 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.class new file mode 100644 index 00000000..7372acbe Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.class new file mode 100644 index 00000000..8cc668fa Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.class new file mode 100644 index 00000000..20cc552e Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.class new file mode 100644 index 00000000..6caa59d8 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.class new file mode 100644 index 00000000..948dc9ed Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.class new file mode 100644 index 00000000..dc1dfb44 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.class new file mode 100644 index 00000000..dfff2a24 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.class new file mode 100644 index 00000000..7ca8b1e1 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.class new file mode 100644 index 00000000..08c6e588 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.class new file mode 100644 index 00000000..9d653f14 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.class new file mode 100644 index 00000000..322981d9 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.class new file mode 100644 index 00000000..1e74f646 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.class new file mode 100644 index 00000000..df794235 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.class new file mode 100644 index 00000000..43ceab57 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.class new file mode 100644 index 00000000..663cbabd Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.class new file mode 100644 index 00000000..f9bc45b9 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.class new file mode 100644 index 00000000..8555d676 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.class new file mode 100644 index 00000000..d7a6154a Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.class new file mode 100644 index 00000000..a25f4543 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.class new file mode 100644 index 00000000..526de3f5 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.class new file mode 100644 index 00000000..63818b42 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.class new file mode 100644 index 00000000..f2a3ce53 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.class new file mode 100644 index 00000000..50d65544 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.class new file mode 100644 index 00000000..15699834 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.class new file mode 100644 index 00000000..077aa964 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.class new file mode 100644 index 00000000..9e2f7d29 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.class new file mode 100644 index 00000000..da817276 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.class new file mode 100644 index 00000000..3f72b838 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.class new file mode 100644 index 00000000..f919fd13 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.class new file mode 100644 index 00000000..96db1e8b Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.class new file mode 100644 index 00000000..2258953d Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.class new file mode 100644 index 00000000..535980d6 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.class new file mode 100644 index 00000000..0735c627 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.class b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.class new file mode 100644 index 00000000..6a75bb19 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/events/DisguiseEvent.class b/bin/main/java/me/libraryaddict/disguise/events/DisguiseEvent.class new file mode 100644 index 00000000..9d520900 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/events/DisguiseEvent.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.class b/bin/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.class new file mode 100644 index 00000000..433bb78f Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/ClassGetter.class b/bin/main/java/me/libraryaddict/disguise/utilities/ClassGetter.class new file mode 100644 index 00000000..09adae03 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/ClassGetter.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseSound$SoundType.class b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseSound$SoundType.class new file mode 100644 index 00000000..7c61187c Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseSound$SoundType.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.class b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.class new file mode 100644 index 00000000..8e91393a Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.class b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.class new file mode 100644 index 00000000..8d4d52da Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.class b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.class new file mode 100644 index 00000000..d32e04e9 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/FakeBoundingBox.class b/bin/main/java/me/libraryaddict/disguise/utilities/FakeBoundingBox.class new file mode 100644 index 00000000..1ef02954 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/FakeBoundingBox.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookup.class b/bin/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookup.class new file mode 100644 index 00000000..009ca94f Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookup.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.class b/bin/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.class new file mode 100644 index 00000000..21ffc755 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/Metrics$Graph.class b/bin/main/java/me/libraryaddict/disguise/utilities/Metrics$Graph.class new file mode 100644 index 00000000..5e6174e0 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/Metrics$Graph.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/Metrics$Plotter.class b/bin/main/java/me/libraryaddict/disguise/utilities/Metrics$Plotter.class new file mode 100644 index 00000000..fdb5e56f Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/Metrics$Plotter.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/Metrics.class b/bin/main/java/me/libraryaddict/disguise/utilities/Metrics.class new file mode 100644 index 00000000..c6ecf4d2 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/Metrics.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/PacketsManager.class b/bin/main/java/me/libraryaddict/disguise/utilities/PacketsManager.class new file mode 100644 index 00000000..7037d2a9 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/PacketsManager.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.class b/bin/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.class new file mode 100644 index 00000000..55eac426 Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.class differ diff --git a/bin/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.class b/bin/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.class new file mode 100644 index 00000000..8cb614ba Binary files /dev/null and b/bin/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.class differ diff --git a/src/main/resources/config.yml b/bin/main/resources/config.yml similarity index 100% rename from src/main/resources/config.yml rename to bin/main/resources/config.yml diff --git a/src/main/resources/plugin.yml b/bin/main/resources/plugin.yml similarity index 100% rename from src/main/resources/plugin.yml rename to bin/main/resources/plugin.yml diff --git a/build.gradle b/build.gradle deleted file mode 100644 index dd33abce..00000000 --- a/build.gradle +++ /dev/null @@ -1,95 +0,0 @@ -plugins { - id 'java' - id 'maven-publish' -} - -println 'Compiling LibsDisguises via Gradle ver. ' + gradle.gradleVersion - -sourceCompatibility = '1.7' -ext.spigotVersion = '1.9-R0.1-SNAPSHOT' - -ext.disguisesVersion = '9.0.3' - -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' - -repositories { - mavenCentral() - - maven { - name 'Spigot' - url 'https://hub.spigotmc.org/nexus/content/groups/public/' - } - - maven { - url 'https://oss.sonatype.org/content/groups/public/' - } - - maven { - name 'dmulloy2-repo' - url 'http://repo.dmulloy2.net/content/groups/public/' - } - - flatDir { - dir 'libs' - } -} - -task sourceJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -jar { - baseName "LibsDisguises" -} - -processResources { - expand projectVersion: disguisesVersion -} - -artifacts { - archives sourceJar - archives javadocJar - archives jar -} - -publishing { - publications { - mavenJava(MavenPublication) { - groupId 'LibsDisguises' - artifactId 'LibsDisguises' - version disguisesVersion + '-SNAPSHOT' - from components.java - artifact sourceJar { - classifier = 'sources' - } - artifact javadocJar { - classifier = 'javadoc' - } - } - } - repositories { - maven { - url "http://repo.md-5.net/content/repositories/releases/" - } - maven { - url "http://repo.md-5.net/content/repositories/snapshots/" - } - } -} - -file('libs').mkdirs() - -ant.get src: 'http://server.o2gaming.com/downloads/spigot-1.9.jar', dest: file('libs'), verbose: false, skipexisting: true - -dependencies { - compile "org.spigotmc:spigot-api:$project.ext.spigotVersion" - compile 'com.comphenix.protocol:ProtocolLib:3.7.0-SNAPSHOT' - compile group: "spigot", name: 'spigot-1.9', version: "1.9" - testCompile group: 'junit', name: 'junit', version: '4.10' -} diff --git a/config.yml b/config.yml new file mode 100644 index 00000000..282c1e11 --- /dev/null +++ b/config.yml @@ -0,0 +1,130 @@ +# Shall I notify people of a LibsDisguises update? +NotifyUpdate: true +# Whats the permission to get the notification? +Permission: 'libsdisguises.update' +# Whats the max size allowed for command disguiseradius +DisguiseRadiusMax: 50 +# Whats the max size allowed for command undisguiseradius +UndisguiseRadiusMax: 50 +# Shall the players view their disguises? +# Best used when viewing yourself in 3rd person +ViewSelfDisguises: true +# Shall I disguise the sounds? +# This turns your damage sound into a MOOOO +DisguiseSounds: true +# Shall the disguised hear their disguise sounds or their damage sounds. +# I disable this as it can be a little confusing when not used with self disguises +HearSelfDisguise: true +# Shall I send the velocity packets? I REALLY recommend you don't disable. +# This is the only thing allowing the mobs to fly without glitching out. +SendVelocity: true +# For self disguises, they need to have the armor and the held item removed +# Else they see floating armor, floating held items. +# This turns the items invisible in the disguised players inventory. It does not actually remove them! +RemoveArmor: true +RemoveHeldItem: false +# If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible. +# Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking +# This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise. +AddEntityAnimations: true +# When a sheep or wolf is right clicked with dye. The client automatically assumes it was successful and displays the sheeps wool or the wolfs collar as dyed. +# This is a option that either prevents that happening, or it changes their color officially in the plugin so that everyone sees it changed. +# Its currently set to false which means that the color is not changed and will refresh itself to the player. +# Please note that this will not remove the dye from their hands. This also does not check if the disguised entity is actually a sheep/wolf and wants a say in its color. +DyeableSheep: false +DyeableWolf: false +# This is only called into action when the disguise is constructed using the commands. +# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance. +# Such as prophunt. Its also false because its kind of a retarded feature. +# This is pretty simple. It shows the players displayname (Name as it appears in chat) above their head. +# This also overrides any custom name they have set in their disguise options. +ShowNamesAboveDisguises: false +# This supports the above option. +# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not. +NameAboveHeadAlwaysVisible: true +# This modifys the bounding box, This is stuff like can a arrow hit them. +# If you turn this to true, arrows will act like they hit the disguise in the right place! +# So someone disguised as a enderdragon will easily get shot down by arrows! +# This WILL conflict with NoCheatPlus. Other plugins may also get problems. +# This shouldn't really be enabled for players as it also interferes with their movement because the server thinks the player is larger than he really is. +# That makes the player unable to approach this building because the server thinks he is trying to glitch inside blocks. +ModifyBoundingBox: false +# This prevents disguised players from being targeted by monsters. +# This doesn't prevent their targeting you if already targeting when disguised +# They will just ignore you unless provoked. +MonstersIgnoreDisguises: false +# Sigh. People are going to want this. +# So lets make your disguise blown if you are attacked.. +# Works only for disguised players when attacked by a entity (arrow, monster. etc) +# This will blow all disguises he has on him +BlowDisguises: false +BlownDisguiseMessage: '&cYour disguise was blown!' + +#Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected! +StopShulkerDisguisesFromMoving: true + +# A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring +DisguiseEntityExpire: 10 + +# Another option to choose the same thing for DisguiseClone command +DisguiseCloneExpire: 10 +# Max disguises to store at a time with the DisguiseClone command +DisguiseCloneSize: 3 + +# This I don't really recommend turning on as it can make a memory leak.. +# These disguises, as normal will not persist after a server restart. +# There is also no EntityDeath option as entities do not revive after death. +KeepDisguises: + EntityDespawn: false + PlayerDeath: false + PlayerLogout: false + +# This controls if a entitys max health is determined by the entity, or by the disguise. +# Wither is 200, a player is 20. With this enabled, a player disguised as a wither will have the boss bar health accurate to the players health. +# Else it will be 1/20 of the boss bar when he is full health. +# Setting this in LivingWatcher overrides both values. +MaxHealthDeterminedByEntity: true + +# This here is a option to turn off misc disguises. +# This means you can not have a living entity disguise as a non-living entity. +# This disables the Attributes packet, Non-living entities can still disguise as other non-living +# This means that the above option will not work as it uses the attribute packet. +MiscDisguisesForLiving: true + +# Turn this to true to have players undisguised when switching worlds +UndisguiseOnWorldChange: false + +# Contact Mojang's servers? Disabling this option will disable player skin disguises! +ContactMojangServers: true + +# This will help performance, especially with CPU +# Due to safety reasons, self disguises can never have their packets disabled. +PacketsEnabled: + # This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash. + # Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash + Animation: true + # Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player + # This also sends a chunk packet at key positions else it doesn't work for 1.8. Lazyness means it does it for older versions too currently. + Bed: true + # This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it + # This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well + Collect: true + # This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching. + EntityStatus: true + # Entity equipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item. + # Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing. + Equipment: true + # This doesn't actually disable the packet. It would introduce problems. Instead it does the next best thing and caches the data. + # This means that entity metadata will not change, and will only be sent in the spawn packet. + # This is good if performance is extremely in need. + # This is bad to disable unless you are ONLY going to use the disguises for decorations. + # To be honest. This is basically "Disable entity animations". That option is called 'AddEntityAnimations' in the config but unlike that, this is always in effect. + # Animations set by use of the api or through the disguise command are still in effect. + Metadata: true + # Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up. + # If you are using the Item_Frame disguise, when a packet is sent (Roughly every 2min) the disguise will bug up until they move. + Movement: true + # Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity + Riding: true + # When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way. + WitherSkull: true diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 00000000..bb923226 --- /dev/null +++ b/plugin.yml @@ -0,0 +1,103 @@ +name: LibsDisguises +main: me.libraryaddict.disguise.LibsDisguises +description: A disguise plugin with various disguises. +version: ${project.version} +author: libraryaddict +authors: [Byteflux, Navid K.] +softdepend: [ProtocolLib] +commands: + libsdisguises: + permission: libsdisguises.seecmd.libsdisguises + description: Main command for libsdisguises. + disguise: + aliases: [d, dis] + permission: libsdisguises.seecmd.disguise + description: Disguise yourself as an entity. + disguiseentity: + aliases: [dentity, disentity] + permission: libsdisguises.seecmd.disguiseentity + description: Disguise an entity as another entity. + disguisehelp: + aliases: [dhelp, dishelp] + permission: libsdisguises.seecmd.disguisehelp + description: Help command for LibsDisguises. + disguiseplayer: + aliases: [dplayer, displayer] + permission: libsdisguises.seecmd.disguiseplayer + description: Disguise another player as an entity. + disguiseradius: + aliases: [disradius, dradius] + permission: libsdisguises.seecmd.disguiseradius + description: Disguise all entities within a radius as an entity. + undisguise: + aliases: [u, und, undis] + permission: libsdisguises.seecmd.undisguise + description: Undisguise yourself. + undisguiseentity: + aliases: [undisentity, undentity] + permission: libsdisguises.seecmd.undisguiseentity + description: Undisguise an entity. + undisguiseplayer: + aliases: [undisplayer, undplayer] + permission: libsdisguises.seecmd.undisguiseplayer + description: Undisguise a player. + undisguiseradius: + aliases: [undisradius, undradius] + permission: libsdisguises.seecmd.undisguiseradius + description: Undisguise all entities within a radius. + disguiseclone: + aliases: [disguisec, disc, disclone, dclone, clonedisguise, clonedis, cdisguise, cdis] + permission: libsdisguises.seecmd.disguiseclone + description: Copy a disguise (or entity) and use it later. + disguiseviewself: + aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd] + permission: libsdisguises.seecmd.viewself + description: Toggle seeing your own disguise on or off. + +permissions: + libsdisguises.reload: + description: Allows the user to reload LibsDisguises. + default: op + libsdisguises.seethrough: + description: Allows player to see through disguises. + default: false + libsdisguises.seecmd: + description: See all commands in tab-completion + default: true + children: + libsdisguises.seecmd.libsdisguises: true + libsdisguises.seecmd.disguise: true + libsdisguises.seecmd.disguiseentity: true + libsdisguises.seecmd.disguisehelp: true + libsdisguises.seecmd.disguiseplayer: true + libsdisguises.seecmd.disguiseradius: true + libsdisguises.seecmd.undisguise: true + libsdisguises.seecmd.undisguiseentity: true + libsdisguises.seecmd.undisguiseplayer: true + libsdisguises.seecmd.undisguiseradius: true + libsdisguises.seecmd.disguiseclone: true + libsdisguises.seecmd.disguiseviewself: true + libsdisguises.seecmd.libsdisguises: + description: See the /libsdisguises command in tab-completion + libsdisguises.seecmd.disguiseviewself: + description: See the /disguiseviewself command in tab-completion + libsdisguises.seecmd.disguise: + description: See the /disguise command in tab-completion + libsdisguises.seecmd.disguiseentity: + description: See the /disguiseentity command in tab-completion + libsdisguises.seecmd.disguisehelp: + description: See the /disguisehelp command in tab-completion + libsdisguises.seecmd.disguiseplayer: + description: See the /disguiseplayer command in tab-completion + libsdisguises.seecmd.disguiseradius: + description: See the /disguiseradius command in tab-completion + libsdisguises.seecmd.undisguise: + description: See the /undisguise command in tab-completion + libsdisguises.seecmd.undisguiseentity: + description: See the /undisguiseentity command in tab-completion + libsdisguises.seecmd.undisguiseplayer: + description: See the /undisguiseplayer command in tab-completion + libsdisguises.seecmd.undisguiseradius: + description: See the /undisguiseradius command in tab-completion + libsdisguises.seecmd.disguiseclone: + description: See the /disguiseclone command in tab-completion diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..dea38eac --- /dev/null +++ b/pom.xml @@ -0,0 +1,74 @@ + + 4.0.0 + LibsDisguises + LibsDisguises + 0.0.1-SNAPSHOT + + + src + clean install + target + LibsDisguises + + + + . + true + ${project.basedir} + + plugin.yml + config.yml + README.md + + + + + + + + 1.8 + 1.8 + UTF-8 + + + + + dmulloy2-repo + http://repo.dmulloy2.net/content/groups/public/ + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + + com.comphenix.protocol + ProtocolLib + 4.0.0-SNAPSHOT + + + org.spigotmc + spigot-api + 1.9.2-R0.1-SNAPSHOT + + + org.spigotmc + spigot + 1.9.2-R0.1-SNAPSHOT + + + + + + md_5-releases + http://repo.md-5.net/content/repositories/releases/ + + + md_5-snapshots + http://repo.md-5.net/content/repositories/snapshots/ + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index f0b731cb..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'LibsDisguises' diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java deleted file mode 100644 index 16659ad3..00000000 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java +++ /dev/null @@ -1,290 +0,0 @@ -package me.libraryaddict.disguise.disguisetypes; - -import org.apache.commons.lang.StringUtils; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Guardian; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Zombie; - -import java.lang.reflect.Method; - -public enum DisguiseType { - - AREA_EFFECT_CLOUD(3, 0), - ARMOR_STAND(78), - ARROW(60, 0), - BAT, - BLAZE, - BOAT(1), - CAVE_SPIDER, - CHICKEN, - COW, - CREEPER, - DONKEY, - DRAGON_FIREBALL(93), - DROPPED_ITEM(2, 1), - EGG(62), - ELDER_GUARDIAN, - ENDER_CRYSTAL(51), - ENDER_DRAGON, - ENDER_PEARL(65), - ENDER_SIGNAL(72), - ENDERMAN, - ENDERMITE, - EXPERIENCE_ORB, - FALLING_BLOCK(70, 1), - FIREBALL(63), - FIREWORK(76), - FISHING_HOOK(90), - GHAST, - GIANT, - GUARDIAN, - HORSE, - IRON_GOLEM, - ITEM_FRAME(71), - LEASH_HITCH(77), - MAGMA_CUBE, - MINECART(10), - MINECART_CHEST(10, 1), - MINECART_COMMAND(10, 6), - MINECART_FURNACE(10, 2), - MINECART_HOPPER(10, 5), - MINECART_MOB_SPAWNER(10, 4), - MINECART_TNT(10, 3), - MULE, - MUSHROOM_COW, - OCELOT, - PAINTING, - PIG, - PIG_ZOMBIE, - PLAYER, - PRIMED_TNT(50), - RABBIT, - SHEEP, - SHULKER, - SHULKER_BULLET(67), - SILVERFISH, - SKELETON, - SKELETON_HORSE, - SLIME, - SMALL_FIREBALL(63), - SNOWBALL(61), - SNOWMAN, - SPECTRAL_ARROW(91), - SPIDER, - SPLASH_POTION(73, 0), - SQUID, - TIPPED_ARROW(92), - THROWN_EXP_BOTTLE(75), - UNDEAD_HORSE, - VILLAGER, - WITCH, - WITHER, - WITHER_SKELETON, - WITHER_SKULL(66), - WOLF, - ZOMBIE, - ZOMBIE_VILLAGER, - UNKNOWN; - - private static Method isVillager, getVariant, getSkeletonType, isElder; - - static { - // We set the entity type in this so that we can safely ignore disguisetypes which don't exist in older versions of MC. - // Without erroring up everything. - for (DisguiseType type : values()) { - try { - DisguiseType toUse = type; - String name; - switch (type) { - // Disguise item frame isn't supported. So we don't give it a entity type which should prevent it from being.. - // Usable. - case ITEM_FRAME: - break; - case DONKEY: - case MULE: - case UNDEAD_HORSE: - case SKELETON_HORSE: - toUse = DisguiseType.HORSE; - break; - case ZOMBIE_VILLAGER: - toUse = DisguiseType.ZOMBIE; - break; - case WITHER_SKELETON: - toUse = DisguiseType.SKELETON; - break; - case ELDER_GUARDIAN: - toUse = DisguiseType.GUARDIAN; - break; - default: - break; - } - name = toUse.name(); - type.setEntityType(EntityType.valueOf(name)); - } catch (Throwable ex) { - // This version of Spigot doesn't have the disguise. - } - } - try { - isVillager = Zombie.class.getMethod("isVillager"); - } catch (Throwable ignored) { - } - try { - getVariant = Horse.class.getMethod("getVariant"); - } catch (Throwable ignored) { - // Pre-1.6, but that isn't even supported - } - try { - getSkeletonType = Skeleton.class.getMethod("getSkeletonType"); - } catch (Throwable ignored) { - } - try { - isElder = Guardian.class.getMethod("isElder"); - } catch (Throwable ignored) { - } - } - - public static DisguiseType getType(Entity entity) { - DisguiseType disguiseType = getType(entity.getType()); - switch (disguiseType) { - case ZOMBIE: - try { - if ((Boolean) isVillager.invoke(entity)) { - disguiseType = DisguiseType.ZOMBIE_VILLAGER; - } - } catch (Exception ex) { - ex.printStackTrace(System.out); - } - break; - case HORSE: - try { - Object variant = getVariant.invoke(entity); - disguiseType = DisguiseType.valueOf(((Enum) variant).name()); - } catch (Exception ex) { - ex.printStackTrace(System.out); - } - break; - case SKELETON: - try { - Object type = getSkeletonType.invoke(entity); - if (type == Skeleton.SkeletonType.WITHER) { - disguiseType = DisguiseType.WITHER_SKELETON; - } - } catch (Exception ex) { - ex.printStackTrace(System.out); - } - break; - case GUARDIAN: - try { - if ((Boolean) isElder.invoke(entity)) { - disguiseType = DisguiseType.ELDER_GUARDIAN; - } - } catch (Exception ex) { - ex.printStackTrace(System.out); - } - break; - default: - break; - } - return disguiseType; - } - - public static DisguiseType getType(EntityType entityType) { - try { - return valueOf(entityType.name().toUpperCase()); - } catch (Throwable ex) { - return DisguiseType.UNKNOWN; - } - } - - private int objectId = -1, defaultData = 0; - private EntityType entityType; - private Class watcherClass; - - DisguiseType(int... ints) { - for (int i = 0; i < ints.length; i++) { - int value = ints[i]; - switch (i) { - case 0: - objectId = value; - break; - case 1: - defaultData = value; - break; - default: - break; - } - } - } - - public int getDefaultData() { - return defaultData; - } - - public Class getEntityClass() { - if (entityType != null) { - return getEntityType().getEntityClass(); - } - return Entity.class; - } - - public EntityType getEntityType() { - return entityType; - } - - /** - * The TYPE id of this entity. Different from the Object Id - * send in spawn packets when spawning miscs. - * @return - */ - public int getTypeId() { - return (int) getEntityType().getTypeId(); - } - - /** - * The object type send in packets when spawning a misc entity. - * Otherwise, -1. - * @return - */ - public int getObjectId() { - return objectId; - } - - public Class getWatcherClass() { - return watcherClass; - } - - public boolean isMisc() { - return getEntityType() != null && !getEntityType().isAlive(); - } - - public boolean isMob() { - return getEntityType() != null && getEntityType().isAlive() && !isPlayer(); - } - - public boolean isPlayer() { - return this == DisguiseType.PLAYER; - } - - public boolean isUnknown() { - return this == DisguiseType.UNKNOWN; - } - - private void setEntityType(EntityType entityType) { - this.entityType = entityType; - } - - public void setWatcherClass(Class c) { - watcherClass = c; - } - - public String toReadable() { - String[] split = name().split("_"); - for (int i = 0; i < split.length; i++) { - split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); - } - return StringUtils.join(split, " "); - } -} diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java similarity index 69% rename from src/main/java/me/libraryaddict/disguise/DisguiseAPI.java rename to src/me/libraryaddict/disguise/DisguiseAPI.java index 34802a75..2d73871c 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -1,5 +1,24 @@ package me.libraryaddict.disguise; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.UUID; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.HorseInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; @@ -13,120 +32,158 @@ import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Horse; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.EntityEquipment; -import org.bukkit.inventory.HorseInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.UUID; - -public class DisguiseAPI { - - public static Disguise constructDisguise(Entity entity) { +public class DisguiseAPI +{ + public static Disguise constructDisguise(Entity entity) + { return constructDisguise(entity, true, true, true); } - public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint) { + public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint) + { DisguiseType disguiseType = DisguiseType.getType(entity); Disguise disguise; - if (disguiseType.isMisc()) { + + if (disguiseType.isMisc()) + { disguise = new MiscDisguise(disguiseType); - } else if (disguiseType.isMob()) { + } + else if (disguiseType.isMob()) + { disguise = new MobDisguise(disguiseType); - } else { + } + else + { disguise = new PlayerDisguise(entity.getName()); } + FlagWatcher watcher = disguise.getWatcher(); - if (entity instanceof LivingEntity) { - for (PotionEffect effect : ((LivingEntity) entity).getActivePotionEffects()) { + + if (entity instanceof LivingEntity) + { + for (PotionEffect effect : ((LivingEntity) entity).getActivePotionEffects()) + { ((LivingWatcher) watcher).addPotionEffect(effect.getType()); - if (effect.getType() == PotionEffectType.INVISIBILITY) { + + if (effect.getType() == PotionEffectType.INVISIBILITY) + { watcher.setInvisible(true); - } else if (effect.getType() == PotionEffectType.GLOWING) { + } + else if (effect.getType() == PotionEffectType.GLOWING) + { watcher.setGlowing(true); } } } - if (entity.getFireTicks() > 0) { + + if (entity.getFireTicks() > 0) + { watcher.setBurning(true); } - if (doEquipment && entity instanceof LivingEntity) { + + if (doEquipment && entity instanceof LivingEntity) + { EntityEquipment equip = ((LivingEntity) entity).getEquipment(); + watcher.setArmor(equip.getArmorContents()); watcher.setItemInMainHand(equip.getItemInMainHand()); - if (disguiseType.getEntityType() == EntityType.HORSE) { + + if (disguiseType.getEntityType() == EntityType.HORSE) + { Horse horse = (Horse) entity; HorseInventory horseInventory = horse.getInventory(); ItemStack saddle = horseInventory.getSaddle(); - if (saddle != null && saddle.getType() == Material.SADDLE) { + + if (saddle != null && saddle.getType() == Material.SADDLE) + { ((HorseWatcher) watcher).setSaddled(true); } + ((HorseWatcher) watcher).setHorseArmor(horseInventory.getArmor()); } } - for (Method method : entity.getClass().getMethods()) { + for (Method method : entity.getClass().getMethods()) + { if ((doSneak || !method.getName().equals("setSneaking")) && (doSprint || !method.getName().equals("setSprinting")) - && method.getParameterTypes().length == 0 && method.getReturnType() != void.class) { + && method.getParameterTypes().length == 0 && method.getReturnType() != void.class) + { Class methodReturn = method.getReturnType(); - if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) { + + if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) + { methodReturn = double.class; } + int firstCapitalMethod = firstCapital(method.getName()); - if (firstCapitalMethod > 0) { - for (Method watcherMethod : watcher.getClass().getMethods()) { + + if (firstCapitalMethod > 0) + { + for (Method watcherMethod : watcher.getClass().getMethods()) + { if (!watcherMethod.getName().startsWith("get") && watcherMethod.getReturnType() == void.class - && watcherMethod.getParameterTypes().length == 1) { + && watcherMethod.getParameterTypes().length == 1) + { int firstCapitalWatcher = firstCapital(watcherMethod.getName()); - if (firstCapitalWatcher > 0 - && method.getName().substring(firstCapitalMethod) - .equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) { + + if (firstCapitalWatcher > 0 && method.getName().substring(firstCapitalMethod) + .equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) + { Class methodParam = watcherMethod.getParameterTypes()[0]; - if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) { + + if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) + { methodParam = double.class; - } else if (methodParam == AnimalColor.class) { + } + else if (methodParam == AnimalColor.class) + { methodParam = DyeColor.class; } - if (methodReturn == methodParam) { - try { + if (methodReturn == methodParam) + { + try + { Object value = method.invoke(entity); - if (value != null) { + if (value != null) + { Class toCast = watcherMethod.getParameterTypes()[0]; - if (!(toCast.isInstance(value))) { - if (toCast == float.class) { - if (value instanceof Float) { + if (!(toCast.isInstance(value))) + { + if (toCast == float.class) + { + if (value instanceof Float) + { value = value; - } else { + } + else + { double d = (Double) value; value = (float) d; } - } else if (toCast == double.class) { - if (!(value instanceof Double)) { + } + else if (toCast == double.class) + { + if (!(value instanceof Double)) + { float d = (Float) value; value = (double) d; } - } else if (toCast == AnimalColor.class) { + } + else if (toCast == AnimalColor.class) + { value = AnimalColor.valueOf(((DyeColor) value).name()); } } if (value instanceof Boolean && !(Boolean) value - && watcherMethod.getDeclaringClass() == FlagWatcher.class) { + && watcherMethod.getDeclaringClass() == FlagWatcher.class) + { continue; } } watcherMethod.invoke(watcher, value); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -139,54 +196,73 @@ public class DisguiseAPI { return disguise; } - public static void disguiseEntity(Entity entity, Disguise disguise) { + public static void disguiseEntity(Entity entity, Disguise disguise) + { // If they are trying to disguise a null entity or use a null disguise // Just return. - if (entity == null || disguise == null) { + if (entity == null || disguise == null) + { return; } // The event wasn't cancelled. // If the disguise entity isn't the same as the one we are disguising - if (disguise.getEntity() != entity) { + if (disguise.getEntity() != entity) + { // If the disguise entity actually exists - if (disguise.getEntity() != null) { + if (disguise.getEntity() != null) + { // Clone the disguise disguise = disguise.clone(); } // Set the disguise's entity disguise.setEntity(entity); } - if (Disguise.getViewSelf().contains(disguise.getEntity().getUniqueId())) { + + if (Disguise.getViewSelf().contains(disguise.getEntity().getUniqueId())) + { disguise.setViewSelfDisguise(true); } + disguise.startDisguise(); } - public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise) { - if (disguise.getEntity() != null) { + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise) + { + if (disguise.getEntity() != null) + { disguise = disguise.clone(); } + ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS); - for (Object obj : playersToNotSeeDisguise) { - if (obj instanceof String) { + + for (Object obj : playersToNotSeeDisguise) + { + if (obj instanceof String) + { ((TargetedDisguise) disguise).addPlayer((String) obj); - } else if (obj instanceof Player) { + } + else if (obj instanceof Player) + { ((TargetedDisguise) disguise).addPlayer(((Player) obj).getName()); } } + disguiseEntity(entity, disguise); } @Deprecated - public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List playersToNotSeeDisguise) { + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List playersToNotSeeDisguise) + { disguiseIgnorePlayers(entity, disguise, (Collection) playersToNotSeeDisguise); } - public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) { + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) + { disguiseIgnorePlayers(entity, disguise, (Collection) Arrays.asList(playersToNotSeeDisguise)); } - public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, String... playersToNotSeeDisguise) { + public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, String... playersToNotSeeDisguise) + { disguiseIgnorePlayers(entity, disguise, (Collection) Arrays.asList(playersToNotSeeDisguise)); } @@ -196,20 +272,29 @@ public class DisguiseAPI { * @param disguise * @return */ - public static int disguiseNextEntity(Disguise disguise) { - if (disguise == null) { + public static int disguiseNextEntity(Disguise disguise) + { + if (disguise == null) + { return -1; } - if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) { + + if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) + { disguise = disguise.clone(); } - try { + + try + { int id = ReflectionManager.getNmsField("Entity", "entityCount").getInt(null); DisguiseUtilities.addFutureDisguise(id, (TargetedDisguise) disguise); return id; - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { e.printStackTrace(); } + return -1; } @@ -219,52 +304,73 @@ public class DisguiseAPI { * @param entity * @param disguise */ - public static void disguiseToAll(Entity entity, Disguise disguise) { - if (disguise.getEntity() != null) { + public static void disguiseToAll(Entity entity, Disguise disguise) + { + if (disguise.getEntity() != null) + { disguise = disguise.clone(); } + // You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!! ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS); - for (String observer : ((TargetedDisguise) disguise).getObservers()) { + + for (String observer : ((TargetedDisguise) disguise).getObservers()) + { ((TargetedDisguise) disguise).removePlayer(observer); } disguiseEntity(entity, disguise); } - public static void disguiseToPlayers(Entity entity, Disguise disguise, Collection playersToViewDisguise) { - if (disguise.getEntity() != null) { + public static void disguiseToPlayers(Entity entity, Disguise disguise, Collection playersToViewDisguise) + { + if (disguise.getEntity() != null) + { disguise = disguise.clone(); } + ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS); - for (Object obj : playersToViewDisguise) { - if (obj instanceof String) { + + for (Object obj : playersToViewDisguise) + { + if (obj instanceof String) + { ((TargetedDisguise) disguise).addPlayer((String) obj); - } else if (obj instanceof Player) { + } + else if (obj instanceof Player) + { ((TargetedDisguise) disguise).addPlayer(((Player) obj).getName()); } } + disguiseEntity(entity, disguise); } @Deprecated - public static void disguiseToPlayers(Entity entity, Disguise disguise, List playersToViewDisguise) { + public static void disguiseToPlayers(Entity entity, Disguise disguise, List playersToViewDisguise) + { disguiseToPlayers(entity, disguise, (Collection) playersToViewDisguise); } - public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) { + public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) + { disguiseToPlayers(entity, disguise, (Collection) Arrays.asList(playersToViewDisguise)); } - public static void disguiseToPlayers(Entity entity, Disguise disguise, String... playersToViewDisguise) { + public static void disguiseToPlayers(Entity entity, Disguise disguise, String... playersToViewDisguise) + { disguiseToPlayers(entity, disguise, (Collection) Arrays.asList(playersToViewDisguise)); } - private static int firstCapital(String str) { - for (int i = 0; i < str.length(); i++) { - if (Character.isUpperCase(str.charAt(i))) { + private static int firstCapital(String str) + { + for (int i = 0; i < str.length(); i++) + { + if (Character.isUpperCase(str.charAt(i))) + { return i; } } + return -1; } @@ -274,10 +380,13 @@ public class DisguiseAPI { * @param disguised * @return */ - public static Disguise getDisguise(Entity disguised) { - if (disguised == null) { + public static Disguise getDisguise(Entity disguised) + { + if (disguised == null) + { return null; } + return DisguiseUtilities.getMainDisguise(disguised.getUniqueId()); } @@ -288,10 +397,13 @@ public class DisguiseAPI { * @param disguised * @return */ - public static Disguise getDisguise(Player observer, Entity disguised) { - if (disguised == null || observer == null) { + public static Disguise getDisguise(Player observer, Entity disguised) + { + if (disguised == null || observer == null) + { return null; } + return DisguiseUtilities.getDisguise(observer, disguised); } @@ -301,10 +413,13 @@ public class DisguiseAPI { * @param disguised * @return */ - public static Disguise[] getDisguises(Entity disguised) { - if (disguised == null) { + public static Disguise[] getDisguises(Entity disguised) + { + if (disguised == null) + { return null; } + return DisguiseUtilities.getDisguises(disguised.getUniqueId()); } @@ -315,11 +430,13 @@ public class DisguiseAPI { * @return */ @Deprecated - public static int getFakeDisguise(UUID entityId) { + public static int getFakeDisguise(UUID entityId) + { return -10; } - public static int getSelfDisguiseId() { + public static int getSelfDisguiseId() + { return -10; } @@ -329,7 +446,8 @@ public class DisguiseAPI { * @param disguised * @return */ - public static boolean isDisguised(Entity disguised) { + public static boolean isDisguised(Entity disguised) + { return getDisguise(disguised) != null; } @@ -340,15 +458,18 @@ public class DisguiseAPI { * @param disguised * @return */ - public static boolean isDisguised(Player observer, Entity disguised) { + public static boolean isDisguised(Player observer, Entity disguised) + { return getDisguise(observer, disguised) != null; } - public static boolean isDisguiseInUse(Disguise disguise) { + public static boolean isDisguiseInUse(Disguise disguise) + { return disguise.isDisguiseInUse(); } - public static boolean isSelfDisguised(Player player) { + public static boolean isSelfDisguised(Player player) + { return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()); } @@ -358,18 +479,24 @@ public class DisguiseAPI { * @param entity * @return */ - public static boolean isViewSelfToggled(Entity entity) { - return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() : Disguise.getViewSelf().contains(entity.getUniqueId()); + public static boolean isViewSelfToggled(Entity entity) + { + return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() + : Disguise.getViewSelf().contains(entity.getUniqueId()); } /** - * Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from the world. + * Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from + * the world. * * @param entity */ - public static void undisguiseToAll(Entity entity) { + public static void undisguiseToAll(Entity entity) + { Disguise[] disguises = getDisguises(entity); - for (Disguise disguise : disguises) { + + for (Disguise disguise : disguises) + { disguise.removeDisguise(); } } @@ -380,20 +507,28 @@ public class DisguiseAPI { * @param entity * @param toggled */ - public static void setViewDisguiseToggled(Entity entity, boolean toggled) { - if (isDisguised(entity)) { + public static void setViewDisguiseToggled(Entity entity, boolean toggled) + { + if (isDisguised(entity)) + { Disguise disguise = getDisguise(entity); disguise.setViewSelfDisguise(toggled); } - if (toggled) { - if (!Disguise.getViewSelf().contains(entity.getUniqueId())) { + + if (toggled) + { + if (!Disguise.getViewSelf().contains(entity.getUniqueId())) + { Disguise.getViewSelf().add(entity.getUniqueId()); } - } else { + } + else + { Disguise.getViewSelf().remove(entity.getUniqueId()); } } - private DisguiseAPI() { + private DisguiseAPI() + { } } diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/me/libraryaddict/disguise/DisguiseConfig.java similarity index 75% rename from src/main/java/me/libraryaddict/disguise/DisguiseConfig.java rename to src/me/libraryaddict/disguise/DisguiseConfig.java index e34afe6c..47f733a3 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/me/libraryaddict/disguise/DisguiseConfig.java @@ -1,10 +1,12 @@ package me.libraryaddict.disguise; -import me.libraryaddict.disguise.utilities.PacketsManager; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; -public class DisguiseConfig { +import me.libraryaddict.disguise.utilities.PacketsManager; + +public class DisguiseConfig +{ private static boolean animationEnabled; private static boolean bedEnabled; @@ -43,34 +45,43 @@ public class DisguiseConfig { private static String updateNotificationPermission; private static boolean witherSkullEnabled; - public static String getDisguiseBlownMessage() { + public static String getDisguiseBlownMessage() + { return disguiseBlownMessage; } - public static int getDisguiseCloneExpire() { + public static int getDisguiseCloneExpire() + { return disguiseCloneExpire; } - public static int getDisguiseEntityExpire() { + public static int getDisguiseEntityExpire() + { return disguiseEntityExpire; } - public static int getMaxClonedDisguises() { + public static int getMaxClonedDisguises() + { return maxClonedDisguises; } - public static String getUpdateMessage() { + public static String getUpdateMessage() + { return updateMessage; } - public static String getUpdateNotificationPermission() { + public static String getUpdateNotificationPermission() + { return updateNotificationPermission; } - public static void initConfig(ConfigurationSection config) { + public static void initConfig(ConfigurationSection config) + { + setSoundsEnabled(config.getBoolean("DisguiseSounds")); setVelocitySent(config.getBoolean("SendVelocity")); - setViewDisguises(config.getBoolean("ViewSelfDisguises")); //Since we can now toggle, the view disguises listener must always be on + setViewDisguises(config.getBoolean("ViewSelfDisguises")); // Since we can now toggle, the view disguises listener must + // always be on PacketsManager.setViewDisguisesListener(true); setHearSelfDisguise(config.getBoolean("HearSelfDisguise")); setHideArmorFromSelf(config.getBoolean("RemoveArmor")); @@ -105,19 +116,23 @@ public class DisguiseConfig { setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true)); } - public static boolean isAnimationPacketsEnabled() { + public static boolean isAnimationPacketsEnabled() + { return animationEnabled; } - public static boolean isBedPacketsEnabled() { + public static boolean isBedPacketsEnabled() + { return bedEnabled; } - public static boolean isCollectPacketsEnabled() { + public static boolean isCollectPacketsEnabled() + { return collectEnabled; } - public static boolean isDisguiseBlownOnAttack() { + public static boolean isDisguiseBlownOnAttack() + { return blowDisguisesOnAttack; } @@ -125,96 +140,117 @@ public class DisguiseConfig { * @deprecated Spelling mistake. */ @Deprecated - public static boolean isEnquipmentPacketsEnabled() { + public static boolean isEnquipmentPacketsEnabled() + { return equipmentEnabled; } - public static boolean isEntityAnimationsAdded() { + public static boolean isEntityAnimationsAdded() + { return entityAnimationsAdded; } - public static boolean isEntityStatusPacketsEnabled() { + public static boolean isEntityStatusPacketsEnabled() + { return entityStatusEnabled; } - public static boolean isEquipmentPacketsEnabled() { + public static boolean isEquipmentPacketsEnabled() + { return equipmentEnabled; } /** * Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around */ - public static boolean isHidingArmorFromSelf() { + public static boolean isHidingArmorFromSelf() + { return hidingArmor; } /** * Does the plugin appear to remove the item they are holding, to prevent a floating sword when they are viewing self disguise */ - public static boolean isHidingHeldItemFromSelf() { + public static boolean isHidingHeldItemFromSelf() + { return hidingHeldItem; } - public static boolean isKeepDisguiseOnEntityDespawn() { + public static boolean isKeepDisguiseOnEntityDespawn() + { return keepDisguiseEntityDespawn; } - public static boolean isKeepDisguiseOnPlayerDeath() { + public static boolean isKeepDisguiseOnPlayerDeath() + { return keepDisguisePlayerDeath; } - public static boolean isKeepDisguiseOnPlayerLogout() { + public static boolean isKeepDisguiseOnPlayerLogout() + { return keepDisguisePlayerLogout; } - public static boolean isMaxHealthDeterminedByDisguisedEntity() { + public static boolean isMaxHealthDeterminedByDisguisedEntity() + { return maxHealthIsDisguisedEntity; } - public static boolean isMetadataPacketsEnabled() { + public static boolean isMetadataPacketsEnabled() + { return sendsEntityMetadata; } - public static boolean isMiscDisguisesForLivingEnabled() { + public static boolean isMiscDisguisesForLivingEnabled() + { return miscDisguisesForLivingEnabled; } - public static boolean isModifyBoundingBox() { + public static boolean isModifyBoundingBox() + { return modifyBoundingBox; } - public static boolean isMonstersIgnoreDisguises() { + public static boolean isMonstersIgnoreDisguises() + { return targetDisguises; } - public static boolean isMovementPacketsEnabled() { + public static boolean isMovementPacketsEnabled() + { return movementEnabled; } - public static boolean isNameAboveHeadAlwaysVisible() { + public static boolean isNameAboveHeadAlwaysVisible() + { return showNameAboveHeadAlwaysVisible; } - public static boolean isNameOfPlayerShownAboveDisguise() { + public static boolean isNameOfPlayerShownAboveDisguise() + { return showNameAboveHead; } - public static boolean isSelfDisguisesSoundsReplaced() { + public static boolean isSelfDisguisesSoundsReplaced() + { return hearSelfDisguise; } - public static boolean isSheepDyeable() { + public static boolean isSheepDyeable() + { return colorizeSheep; } /** * Is the sound packets caught and modified */ - public static boolean isSoundEnabled() { + public static boolean isSoundEnabled() + { return PacketsManager.isHearDisguisesEnabled(); } - public static boolean isUndisguiseOnWorldChange() { + public static boolean isUndisguiseOnWorldChange() + { return undisguiseSwitchWorlds; } @@ -223,7 +259,8 @@ public class DisguiseConfig { * * @return */ - public static boolean isVelocitySent() { + public static boolean isVelocitySent() + { return sendVelocity; } @@ -232,74 +269,98 @@ public class DisguiseConfig { * * @return */ - public static boolean isViewDisguises() { + public static boolean isViewDisguises() + { return viewSelfDisguise; } - public static boolean isWitherSkullPacketsEnabled() { + public static boolean isWitherSkullPacketsEnabled() + { return witherSkullEnabled; } - public static boolean isWolfDyeable() { + public static boolean isWolfDyeable() + { return colorizeWolf; } - public static void setAddEntityAnimations(boolean isEntityAnimationsAdded) { + public static void setAddEntityAnimations(boolean isEntityAnimationsAdded) + { entityAnimationsAdded = isEntityAnimationsAdded; } - public static void setAnimationPacketsEnabled(boolean enabled) { - if (enabled != isAnimationPacketsEnabled()) { + public static void setAnimationPacketsEnabled(boolean enabled) + { + if (enabled != isAnimationPacketsEnabled()) + { animationEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } - public static void setBedPacketsEnabled(boolean enabled) { - if (enabled != isBedPacketsEnabled()) { + public static void setBedPacketsEnabled(boolean enabled) + { + if (enabled != isBedPacketsEnabled()) + { bedEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } - public static void setCollectPacketsEnabled(boolean enabled) { - if (enabled != isCollectPacketsEnabled()) { + public static void setCollectPacketsEnabled(boolean enabled) + { + if (enabled != isCollectPacketsEnabled()) + { collectEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } - public static void setDisguiseBlownMessage(String newMessage) { + public static void setDisguiseBlownMessage(String newMessage) + { disguiseBlownMessage = newMessage; } - public static void setDisguiseBlownOnAttack(boolean blowDisguise) { + public static void setDisguiseBlownOnAttack(boolean blowDisguise) + { blowDisguisesOnAttack = blowDisguise; } - public static void setDisguiseCloneExpire(int newExpires) { + public static void setDisguiseCloneExpire(int newExpires) + { disguiseCloneExpire = newExpires; } - public static void setDisguiseEntityExpire(int newExpires) { + public static void setDisguiseEntityExpire(int newExpires) + { disguiseEntityExpire = newExpires; } @Deprecated - public static void setEnquipmentPacketsEnabled(boolean enabled) { + public static void setEnquipmentPacketsEnabled(boolean enabled) + { setEquipmentPacketsEnabled(enabled); } - public static void setEntityStatusPacketsEnabled(boolean enabled) { - if (enabled != isEntityStatusPacketsEnabled()) { + public static void setEntityStatusPacketsEnabled(boolean enabled) + { + if (enabled != isEntityStatusPacketsEnabled()) + { entityStatusEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } - public static void setEquipmentPacketsEnabled(boolean enabled) { - if (enabled != isEquipmentPacketsEnabled()) { + public static void setEquipmentPacketsEnabled(boolean enabled) + { + if (enabled != isEquipmentPacketsEnabled()) + { equipmentEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } @@ -307,8 +368,10 @@ public class DisguiseConfig { /** * Can players hear their own disguises */ - public static void setHearSelfDisguise(boolean replaceSound) { - if (hearSelfDisguise != replaceSound) { + public static void setHearSelfDisguise(boolean replaceSound) + { + if (hearSelfDisguise != replaceSound) + { hearSelfDisguise = replaceSound; } } @@ -316,9 +379,12 @@ public class DisguiseConfig { /** * Set the plugin to hide self disguises armor from theirselves */ - public static void setHideArmorFromSelf(boolean hideArmor) { - if (hidingArmor != hideArmor) { + public static void setHideArmorFromSelf(boolean hideArmor) + { + if (hidingArmor != hideArmor) + { hidingArmor = hideArmor; + PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf()); } } @@ -326,95 +392,121 @@ public class DisguiseConfig { /** * Does the plugin appear to remove the item they are holding, to prevent a floating sword when they are viewing self disguise */ - public static void setHideHeldItemFromSelf(boolean hideHelditem) { - if (hidingHeldItem != hideHelditem) { + public static void setHideHeldItemFromSelf(boolean hideHelditem) + { + if (hidingHeldItem != hideHelditem) + { hidingHeldItem = hideHelditem; + PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf()); } } - public static void setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { + public static void setKeepDisguiseOnEntityDespawn(boolean keepDisguise) + { keepDisguiseEntityDespawn = keepDisguise; } - public static void setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { + public static void setKeepDisguiseOnPlayerDeath(boolean keepDisguise) + { keepDisguisePlayerDeath = keepDisguise; } - public static void setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { + public static void setKeepDisguiseOnPlayerLogout(boolean keepDisguise) + { keepDisguisePlayerLogout = keepDisguise; } - public static void setMaxClonedDisguises(int newMax) { + public static void setMaxClonedDisguises(int newMax) + { maxClonedDisguises = newMax; } - public static void setMaxHealthDeterminedByDisguisedEntity(boolean isDetermined) { + public static void setMaxHealthDeterminedByDisguisedEntity(boolean isDetermined) + { maxHealthIsDisguisedEntity = isDetermined; } - public static void setMetadataPacketsEnabled(boolean enabled) { + public static void setMetadataPacketsEnabled(boolean enabled) + { sendsEntityMetadata = enabled; } - public static void setMiscDisguisesForLivingEnabled(boolean enabled) { - if (enabled != isMiscDisguisesForLivingEnabled()) { + public static void setMiscDisguisesForLivingEnabled(boolean enabled) + { + if (enabled != isMiscDisguisesForLivingEnabled()) + { miscDisguisesForLivingEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } - public static void setModifyBoundingBox(boolean modifyBounding) { + public static void setModifyBoundingBox(boolean modifyBounding) + { modifyBoundingBox = modifyBounding; } - public static void setMonstersIgnoreDisguises(boolean ignore) { + public static void setMonstersIgnoreDisguises(boolean ignore) + { targetDisguises = ignore; } - public static void setMovementPacketsEnabled(boolean enabled) { - if (enabled != isMovementPacketsEnabled()) { + public static void setMovementPacketsEnabled(boolean enabled) + { + if (enabled != isMovementPacketsEnabled()) + { movementEnabled = enabled; + PacketsManager.setupMainPacketsListener(); } } - public static void setNameAboveHeadAlwaysVisible(boolean alwaysVisible) { + public static void setNameAboveHeadAlwaysVisible(boolean alwaysVisible) + { showNameAboveHeadAlwaysVisible = alwaysVisible; } - public static void setNameOfPlayerShownAboveDisguise(boolean showNames) { + public static void setNameOfPlayerShownAboveDisguise(boolean showNames) + { showNameAboveHead = showNames; } - public static void setSheepDyeable(boolean color) { + public static void setSheepDyeable(boolean color) + { colorizeSheep = color; } /** * Set if the disguises play sounds when hurt */ - public static void setSoundsEnabled(boolean isSoundsEnabled) { + public static void setSoundsEnabled(boolean isSoundsEnabled) + { PacketsManager.setHearDisguisesListener(isSoundsEnabled); } - public static void setUndisguiseOnWorldChange(boolean isUndisguise) { + public static void setUndisguiseOnWorldChange(boolean isUndisguise) + { undisguiseSwitchWorlds = isUndisguise; } - public static void setUpdateMessage(String newMessage) { + public static void setUpdateMessage(String newMessage) + { updateMessage = newMessage; } - public static void setUpdateNotificationPermission(String newPermission) { + public static void setUpdateNotificationPermission(String newPermission) + { updateNotificationPermission = newPermission; } - public static void setStopShulkerDisguisesFromMoving(boolean stopShulkerDisguisesFromMoving) { + public static void setStopShulkerDisguisesFromMoving(boolean stopShulkerDisguisesFromMoving) + { DisguiseConfig.stopShulkerDisguisesFromMoving = stopShulkerDisguisesFromMoving; } - public static boolean isStopShulkerDisguisesFromMoving() { + public static boolean isStopShulkerDisguisesFromMoving() + { return stopShulkerDisguisesFromMoving; } @@ -423,22 +515,27 @@ public class DisguiseConfig { * * @param sendVelocityPackets */ - public static void setVelocitySent(boolean sendVelocityPackets) { + public static void setVelocitySent(boolean sendVelocityPackets) + { sendVelocity = sendVelocityPackets; } - public static void setViewDisguises(boolean seeOwnDisguise) { + public static void setViewDisguises(boolean seeOwnDisguise) + { viewSelfDisguise = seeOwnDisguise; } - public static void setWitherSkullPacketsEnabled(boolean enabled) { + public static void setWitherSkullPacketsEnabled(boolean enabled) + { witherSkullEnabled = enabled; } - public static void setWolfDyeable(boolean color) { + public static void setWolfDyeable(boolean color) + { colorizeWolf = color; } - private DisguiseConfig() { + private DisguiseConfig() + { } } diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/DisguiseListener.java rename to src/me/libraryaddict/disguise/DisguiseListener.java index f50b7b8a..75713120 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/me/libraryaddict/disguise/DisguiseListener.java @@ -1,15 +1,9 @@ package me.libraryaddict.disguise; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketContainer; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; -import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import me.libraryaddict.disguise.utilities.ReflectionManager; -import me.libraryaddict.disguise.utilities.UpdateChecker; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.HashSet; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -33,9 +27,17 @@ import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.HashSet; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; + +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.ReflectionManager; +import me.libraryaddict.disguise.utilities.UpdateChecker; public class DisguiseListener implements Listener { diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java similarity index 61% rename from src/main/java/me/libraryaddict/disguise/LibsDisguises.java rename to src/me/libraryaddict/disguise/LibsDisguises.java index 8158e9b4..32dd54dc 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -1,8 +1,22 @@ package me.libraryaddict.disguise; +import java.io.IOException; +import java.lang.reflect.Field; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Tameable; +import org.bukkit.entity.Zombie; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedWatchableObject; + import me.libraryaddict.disguise.commands.CloneDisguiseCommand; import me.libraryaddict.disguise.commands.DisguiseCommand; import me.libraryaddict.disguise.commands.DisguiseViewSelf; @@ -33,37 +47,30 @@ import me.libraryaddict.disguise.utilities.FakeBoundingBox; import me.libraryaddict.disguise.utilities.Metrics; import me.libraryaddict.disguise.utilities.PacketsManager; import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Ageable; -import org.bukkit.entity.Damageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Tameable; -import org.bukkit.entity.Zombie; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.IOException; -import java.lang.reflect.Field; - - -public class LibsDisguises extends JavaPlugin { +public class LibsDisguises extends JavaPlugin +{ private static LibsDisguises instance; private DisguiseListener listener; @Override - public void onEnable() { + public void onEnable() + { getLogger().info("Discovered MC version: " + ReflectionManager.getBukkitVersion()); + saveDefaultConfig(); PacketsManager.init(this); DisguiseUtilities.init(this); + DisguiseConfig.initConfig(getConfig()); PacketsManager.addPacketListeners(); + listener = new DisguiseListener(this); + Bukkit.getPluginManager().registerEvents(listener, this); + getCommand("disguise").setExecutor(new DisguiseCommand()); getCommand("undisguise").setExecutor(new UndisguiseCommand()); getCommand("disguiseplayer").setExecutor(new PlayerDisguiseCommand()); @@ -76,228 +83,304 @@ public class LibsDisguises extends JavaPlugin { getCommand("disguiseclone").setExecutor(new CloneDisguiseCommand()); getCommand("libsdisguises").setExecutor(new LibsDisguisesCommand()); getCommand("disguiseviewself").setExecutor(new DisguiseViewSelf()); + registerValues(); + instance = this; - try { + + try + { Metrics metrics = new Metrics(this); metrics.start(); - } catch (IOException e) { + } + catch (IOException e) + { } } /** * Reloads the config with new config options. */ - public void reload() { + public void reload() + { HandlerList.unregisterAll(listener); + reloadConfig(); DisguiseConfig.initConfig(getConfig()); } /** - * Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume for mob noises. As well as setting their watcher class and entity size. + * Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume + * for mob noises. As well as setting their watcher class and entity size. */ - private void registerValues() { - for (DisguiseType disguiseType : DisguiseType.values()) { - if (disguiseType.getEntityType() == null) { + private void registerValues() + { + for (DisguiseType disguiseType : DisguiseType.values()) + { + if (disguiseType.getEntityType() == null) + { continue; } + Class watcherClass = null; - try { - switch (disguiseType) { - case ITEM_FRAME: //Not really supported... - break; - case MINECART_CHEST: - case MINECART_COMMAND: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - watcherClass = MinecartWatcher.class; - break; - case DONKEY: - case MULE: - case UNDEAD_HORSE: - case SKELETON_HORSE: - watcherClass = HorseWatcher.class; - break; - case ZOMBIE_VILLAGER: - case PIG_ZOMBIE: - watcherClass = ZombieWatcher.class; - break; - case MAGMA_CUBE: - watcherClass = SlimeWatcher.class; - break; - case ELDER_GUARDIAN: - watcherClass = GuardianWatcher.class; - break; - case ENDERMITE: - watcherClass = LivingWatcher.class; - break; - case WITHER_SKELETON: - watcherClass = SkeletonWatcher.class; - break; - default: - watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers." - + toReadable(disguiseType.name()) + "Watcher"); - break; - } - } catch (ClassNotFoundException ex) { - // There is no explicit watcher for this entity. - Class entityClass = disguiseType.getEntityType().getEntityClass(); - if (entityClass != null) { - if (Tameable.class.isAssignableFrom(entityClass)) { - watcherClass = TameableWatcher.class; - } else if (Ageable.class.isAssignableFrom(entityClass)) { - watcherClass = AgeableWatcher.class; - } else if (LivingEntity.class.isAssignableFrom(entityClass)) { - watcherClass = LivingWatcher.class; - } else { - watcherClass = FlagWatcher.class; - } - } else { - watcherClass = FlagWatcher.class; //Disguise is unknown type - } - } - disguiseType.setWatcherClass(watcherClass); - if (DisguiseValues.getDisguiseValues(disguiseType) != null) { - continue; - } - String nmsEntityName = toReadable(disguiseType.name()); - switch (disguiseType) { - case WITHER_SKELETON: - case ZOMBIE_VILLAGER: + + try + { + switch (disguiseType) + { + case ITEM_FRAME: // Not really supported... + break; + case MINECART_CHEST: + case MINECART_COMMAND: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + watcherClass = MinecartWatcher.class; + break; case DONKEY: case MULE: case UNDEAD_HORSE: case SKELETON_HORSE: - continue; - case PRIMED_TNT: - nmsEntityName = "TNTPrimed"; + watcherClass = HorseWatcher.class; break; - case MINECART_TNT: - nmsEntityName = "MinecartTNT"; + case ZOMBIE_VILLAGER: + case PIG_ZOMBIE: + watcherClass = ZombieWatcher.class; break; - case MINECART: - nmsEntityName = "MinecartRideable"; - break; - case FIREWORK: - nmsEntityName = "Fireworks"; - break; - case SPLASH_POTION: - nmsEntityName = "Potion"; - break; - case GIANT: - nmsEntityName = "GiantZombie"; - break; - case DROPPED_ITEM: - nmsEntityName = "Item"; - break; - case FIREBALL: - nmsEntityName = "LargeFireball"; - break; - case LEASH_HITCH: - nmsEntityName = "Leash"; + case MAGMA_CUBE: + watcherClass = SlimeWatcher.class; break; case ELDER_GUARDIAN: - nmsEntityName = "Guardian"; + watcherClass = GuardianWatcher.class; + break; + case ENDERMITE: + watcherClass = LivingWatcher.class; + break; + case WITHER_SKELETON: + watcherClass = SkeletonWatcher.class; break; - case ARROW: - nmsEntityName = "TippedArrow"; default: + watcherClass = Class.forName( + "me.libraryaddict.disguise.disguisetypes.watchers." + toReadable(disguiseType.name()) + "Watcher"); break; + } } - try { - if (nmsEntityName.equalsIgnoreCase("Unknown")) { + catch (ClassNotFoundException ex) + { + // There is no explicit watcher for this entity. + Class entityClass = disguiseType.getEntityType().getEntityClass(); + + if (entityClass != null) + { + if (Tameable.class.isAssignableFrom(entityClass)) + { + watcherClass = TameableWatcher.class; + } + else if (Ageable.class.isAssignableFrom(entityClass)) + { + watcherClass = AgeableWatcher.class; + } + else if (LivingEntity.class.isAssignableFrom(entityClass)) + { + watcherClass = LivingWatcher.class; + } + else + { + watcherClass = FlagWatcher.class; + } + } + else + { + watcherClass = FlagWatcher.class; // Disguise is unknown type + } + } + + disguiseType.setWatcherClass(watcherClass); + + if (DisguiseValues.getDisguiseValues(disguiseType) != null) + { + continue; + } + + String nmsEntityName = toReadable(disguiseType.name()); + + switch (disguiseType) + { + case WITHER_SKELETON: + case ZOMBIE_VILLAGER: + case DONKEY: + case MULE: + case UNDEAD_HORSE: + case SKELETON_HORSE: + continue; + case PRIMED_TNT: + nmsEntityName = "TNTPrimed"; + break; + case MINECART_TNT: + nmsEntityName = "MinecartTNT"; + break; + case MINECART: + nmsEntityName = "MinecartRideable"; + break; + case FIREWORK: + nmsEntityName = "Fireworks"; + break; + case SPLASH_POTION: + nmsEntityName = "Potion"; + break; + case GIANT: + nmsEntityName = "GiantZombie"; + break; + case DROPPED_ITEM: + nmsEntityName = "Item"; + break; + case FIREBALL: + nmsEntityName = "LargeFireball"; + break; + case LEASH_HITCH: + nmsEntityName = "Leash"; + break; + case ELDER_GUARDIAN: + nmsEntityName = "Guardian"; + break; + case ARROW: + nmsEntityName = "TippedArrow"; + default: + break; + } + + try + { + if (nmsEntityName.equalsIgnoreCase("Unknown")) + { DisguiseValues disguiseValues = new DisguiseValues(disguiseType, null, 0, 0); + disguiseValues.setAdultBox(new FakeBoundingBox(0, 0, 0)); + DisguiseSound sound = DisguiseSound.getType(disguiseType.name()); - if (sound != null) { + + if (sound != null) + { sound.setDamageAndIdleSoundVolume(1f); } + continue; } + Object nmsEntity = ReflectionManager.createEntityInstance(nmsEntityName); - if (nmsEntity == null) { + + if (nmsEntity == null) + { getLogger().warning("Entity not found! (" + nmsEntityName + ")"); + continue; } + Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity); int entitySize = 0; - for (Field field : ReflectionManager.getNmsClass("Entity").getFields()) { - if (field.getType().getName().equals("EnumEntitySize")) { + + for (Field field : ReflectionManager.getNmsClass("Entity").getFields()) + { + if (field.getType().getName().equals("EnumEntitySize")) + { Enum enumEntitySize = (Enum) field.get(nmsEntity); + entitySize = enumEntitySize.ordinal(); + break; } } + DisguiseValues disguiseValues = new DisguiseValues(disguiseType, nmsEntity.getClass(), entitySize, bukkitEntity instanceof Damageable ? ((Damageable) bukkitEntity).getMaxHealth() : 0); + WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity); - for (WrappedWatchableObject watch : watcher.getWatchableObjects()) { + + for (WrappedWatchableObject watch : watcher.getWatchableObjects()) + { disguiseValues.setMetaValue(watch.getIndex(), watch.getValue()); // Uncomment when I need to find the new datawatcher values for a class.. -// int id = watch.getIndex(); -// Object val = watch.getValue(); -// Class valClazz = val != null ? watch.getValue().getClass() : null; -// try { -// val = val.toString(); -// } catch (Exception e) { -// val = val != null ? val.getClass() : "null"; -// } -// System.out.println("Disguise: " + disguiseType + ", ID: " + id + ", Class: " + (val == null ? "null" : valClazz) + ", Value: " + val); + // int id = watch.getIndex(); + // Object val = watch.getValue(); + // Class valClazz = val != null ? watch.getValue().getClass() : null; + // try { + // val = val.toString(); + // } catch (Exception e) { + // val = val != null ? val.getClass() : "null"; + // } + // System.out.println("Disguise: " + disguiseType + ", ID: " + id + ", Class: " + (val == null ? "null" : + // valClazz) + ", Value: " + val); } + DisguiseSound sound = DisguiseSound.getType(disguiseType.name()); - if (sound != null) { + + if (sound != null) + { Float soundStrength = ReflectionManager.getSoundModifier(nmsEntity); - if (soundStrength != null) { + + if (soundStrength != null) + { sound.setDamageAndIdleSoundVolume(soundStrength); } } // Get the bounding box disguiseValues.setAdultBox(ReflectionManager.getBoundingBox(bukkitEntity)); - if (bukkitEntity instanceof Ageable) { + + if (bukkitEntity instanceof Ageable) + { ((Ageable) bukkitEntity).setBaby(); - disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity)); - } else if (bukkitEntity instanceof Zombie) { - ((Zombie) bukkitEntity).setBaby(true); + disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity)); } + else if (bukkitEntity instanceof Zombie) + { + ((Zombie) bukkitEntity).setBaby(true); + + disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity)); + } + disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity)); - } catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) { - System.out.print("[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name() - + "!"); + } + catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) + { + System.out.print( + "[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name() + "!"); System.out.print("[LibsDisguises] Before reporting this error, " + "please make sure you are using the latest version of LibsDisguises and ProtocolLib."); - System.out - .print("[LibsDisguises] Development builds are available at (ProtocolLib) " - + "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/"); + System.out.print("[LibsDisguises] Development builds are available at (ProtocolLib) " + + "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/"); ex.printStackTrace(System.out); } } } - private String toReadable(String string) { + private String toReadable(String string) + { StringBuilder builder = new StringBuilder(); - for (String s : string.split("_")) { + + for (String s : string.split("_")) + { builder.append(s.substring(0, 1)).append(s.substring(1).toLowerCase()); } + return builder.toString(); } - public DisguiseListener getListener() { + public DisguiseListener getListener() + { return listener; } /** - * External APIs shouldn't actually need this instance. - * DisguiseAPI should be enough to handle most cases. + * External APIs shouldn't actually need this instance. DisguiseAPI should be enough to handle most cases. * * @return The instance of this plugin */ - public static LibsDisguises getInstance() { + public static LibsDisguises getInstance() + { return instance; } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand.java b/src/me/libraryaddict/disguise/commands/BaseDisguiseCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/BaseDisguiseCommand.java index ff883be6..9e9c500a 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/BaseDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/BaseDisguiseCommand.java @@ -1,14 +1,13 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.disguisetypes.AnimalColor; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import me.libraryaddict.disguise.disguisetypes.MiscDisguise; -import me.libraryaddict.disguise.disguisetypes.MobDisguise; -import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; -import me.libraryaddict.disguise.disguisetypes.RabbitType; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map.Entry; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.BlockFace; @@ -21,13 +20,15 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.potion.PotionEffectType; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map.Entry; +import me.libraryaddict.disguise.disguisetypes.AnimalColor; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.FlagWatcher; +import me.libraryaddict.disguise.disguisetypes.MiscDisguise; +import me.libraryaddict.disguise.disguisetypes.MobDisguise; +import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; +import me.libraryaddict.disguise.disguisetypes.RabbitType; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; /** diff --git a/src/main/java/me/libraryaddict/disguise/commands/CloneDisguiseCommand.java b/src/me/libraryaddict/disguise/commands/CloneDisguiseCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/CloneDisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/CloneDisguiseCommand.java index fd77c87e..8d570966 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/CloneDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/CloneDisguiseCommand.java @@ -1,15 +1,16 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.LibsDisguises; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import java.util.ArrayList; +import java.util.HashMap; + import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import java.util.ArrayList; -import java.util.HashMap; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; public class CloneDisguiseCommand extends BaseDisguiseCommand { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/DisguiseCommand.java index 5b94874b..1cdba6a9 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseCommand.java @@ -1,18 +1,19 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import java.util.ArrayList; +import java.util.HashMap; + import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.HashMap; +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; public class DisguiseCommand extends BaseDisguiseCommand { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseViewSelf.java b/src/me/libraryaddict/disguise/commands/DisguiseViewSelf.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/DisguiseViewSelf.java rename to src/me/libraryaddict/disguise/commands/DisguiseViewSelf.java index b735645c..a1098f22 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseViewSelf.java +++ b/src/me/libraryaddict/disguise/commands/DisguiseViewSelf.java @@ -1,12 +1,13 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import me.libraryaddict.disguise.DisguiseAPI; + /** * * @author Navid diff --git a/src/main/java/me/libraryaddict/disguise/commands/EntityDisguiseCommand.java b/src/me/libraryaddict/disguise/commands/EntityDisguiseCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/EntityDisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/EntityDisguiseCommand.java index 7a7d64a6..6ce182dc 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/EntityDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/EntityDisguiseCommand.java @@ -1,17 +1,18 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.LibsDisguises; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; + import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; public class EntityDisguiseCommand extends BaseDisguiseCommand { diff --git a/src/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand.java b/src/me/libraryaddict/disguise/commands/HelpDisguiseCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/HelpDisguiseCommand.java index 2656a21f..c6b78d7f 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/HelpDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/HelpDisguiseCommand.java @@ -1,10 +1,11 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.disguisetypes.AnimalColor; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import me.libraryaddict.disguise.disguisetypes.RabbitType; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; + import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.block.BlockFace; @@ -13,11 +14,11 @@ import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; +import me.libraryaddict.disguise.disguisetypes.AnimalColor; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.FlagWatcher; +import me.libraryaddict.disguise.disguisetypes.RabbitType; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; public class HelpDisguiseCommand extends BaseDisguiseCommand { diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java rename to src/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java index 8b79763f..840bd78b 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java +++ b/src/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java @@ -1,12 +1,13 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.LibsDisguises; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import me.libraryaddict.disguise.LibsDisguises; + public class LibsDisguisesCommand implements CommandExecutor { @Override diff --git a/src/main/java/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.java b/src/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.java index e373cde5..d986af6b 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.java @@ -1,10 +1,8 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import java.util.ArrayList; +import java.util.HashMap; + import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -12,8 +10,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.HashMap; +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; public class PlayerDisguiseCommand extends BaseDisguiseCommand { diff --git a/src/main/java/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.java b/src/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.java similarity index 74% rename from src/main/java/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.java index 92feb477..d80a7337 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.java @@ -1,11 +1,9 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; -import me.libraryaddict.disguise.utilities.ClassGetter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; + import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -15,135 +13,207 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import me.libraryaddict.disguise.utilities.ClassGetter; -public class RadiusDisguiseCommand extends BaseDisguiseCommand { +public class RadiusDisguiseCommand extends BaseDisguiseCommand +{ private int maxRadius = 30; private ArrayList validClasses = new ArrayList<>(); - public RadiusDisguiseCommand(int maxRadius) { + public RadiusDisguiseCommand(int maxRadius) + { this.maxRadius = maxRadius; - for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) { - if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) { + + for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) + { + if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) + { validClasses.add(c); } } } @Override - public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - if (sender.getName().equals("CONSOLE")) { + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) + { + if (sender.getName().equals("CONSOLE")) + { sender.sendMessage(ChatColor.RED + "You may not use this command from the console!"); return true; } + HashMap, Boolean>> map = getPermissions(sender); - if (map.isEmpty()) { + + if (map.isEmpty()) + { sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); return true; } - if (args.length == 0) { + + if (args.length == 0) + { sendCommandUsage(sender, map); return true; } - if (args[0].equalsIgnoreCase("entitytype") || args[0].equalsIgnoreCase("entitytypes")) { + + if (args[0].equalsIgnoreCase("entitytype") || args[0].equalsIgnoreCase("entitytypes")) + { ArrayList classes = new ArrayList<>(); - for (Class c : validClasses) { + + for (Class c : validClasses) + { classes.add(c.getSimpleName()); } + Collections.sort(classes); + sender.sendMessage(ChatColor.DARK_GREEN + "EntityTypes usable are: " + ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + "."); return true; } + Class entityClass = Entity.class; EntityType type = null; int starting = 0; - if (!isNumeric(args[0])) { - for (Class c : validClasses) { - if (c.getSimpleName().equalsIgnoreCase(args[0])) { + + if (!isNumeric(args[0])) + { + for (Class c : validClasses) + { + if (c.getSimpleName().equalsIgnoreCase(args[0])) + { entityClass = c; starting = 1; break; } } - if (starting == 0) { - try { + + if (starting == 0) + { + try + { type = EntityType.valueOf(args[0].toUpperCase()); - } catch (Exception ex) { } - if (type == null) { + catch (Exception ex) + { + } + + if (type == null) + { sender.sendMessage(ChatColor.RED + "Unrecognised EntityType " + args[0]); return true; } } } - if (args.length == starting + 1) { + + if (args.length == starting + 1) + { sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the radius" + (starting != 0 ? " and EntityType" : "")); return true; } - if (!isNumeric(args[starting])) { + + if (!isNumeric(args[starting])) + { sender.sendMessage(ChatColor.RED + args[starting] + " is not a number"); return true; } + int radius = Integer.parseInt(args[starting]); - if (radius > maxRadius) { + + if (radius > maxRadius) + { sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?"); radius = maxRadius; } + String[] newArgs = new String[args.length - (starting + 1)]; System.arraycopy(args, starting + 1, newArgs, 0, newArgs.length); Disguise disguise; - try { + + try + { disguise = parseDisguise(sender, newArgs, map); - } catch (DisguiseParseException ex) { - if (ex.getMessage() != null) { + } + catch (DisguiseParseException ex) + { + if (ex.getMessage() != null) + { sender.sendMessage(ex.getMessage()); } + return true; - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); return true; - } // Time to use it! + } + + // Time to use it! int disguisedEntitys = 0; int miscDisguises = 0; - for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) { - if (entity == sender) { + + for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) + { + if (entity == sender) + { continue; } - if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) { + + if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) + { if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() - && entity instanceof LivingEntity) { + && entity instanceof LivingEntity) + { miscDisguises++; continue; } + disguise = disguise.clone(); - if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { - if (disguise.getWatcher() instanceof LivingWatcher) { + + if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) + { + if (disguise.getWatcher() instanceof LivingWatcher) + { disguise.getWatcher().setCustomName(((Player) entity).getDisplayName()); - if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { + if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) + { disguise.getWatcher().setCustomNameVisible(true); } } } + DisguiseAPI.disguiseToAll(entity, disguise); - if (disguise.isDisguiseInUse()) { + + if (disguise.isDisguiseInUse()) + { disguisedEntitys++; } } } - if (disguisedEntitys > 0) { + + if (disguisedEntitys > 0) + { sender.sendMessage(ChatColor.RED + "Successfully disguised " + disguisedEntitys + " entities!"); - } else { + } + else + { sender.sendMessage(ChatColor.RED + "Couldn't find any entities to disguise!"); } - if (miscDisguises > 0) { + + if (miscDisguises > 0) + { sender.sendMessage(ChatColor.RED + "Failed to disguise " + miscDisguises + " entities because the option to disguise a living entity as a non-living has been disabled in the config"); } + return true; } @@ -151,25 +221,34 @@ public class RadiusDisguiseCommand extends BaseDisguiseCommand { * Send the player the information */ @Override - protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) { + protected void sendCommandUsage(CommandSender sender, HashMap, Boolean>> map) + { ArrayList allowedDisguises = getAllowedDisguises(map); + sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at 30 blocks!"); sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"; - if (allowedDisguises.contains("player")) { + + if (allowedDisguises.contains("player")) + { sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius player ") .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")); } + sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius ").replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")); - if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { + + if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) + { sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius ").replace("<", - "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")); + + "> ") + .replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")); } - sender.sendMessage(ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN - + "/disguiseradius EntityTypes"); + + sender.sendMessage( + ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius EntityTypes"); } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseCommand.java b/src/me/libraryaddict/disguise/commands/UndisguiseCommand.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/commands/UndisguiseCommand.java rename to src/me/libraryaddict/disguise/commands/UndisguiseCommand.java index 25fe14c4..f2be148b 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseCommand.java +++ b/src/me/libraryaddict/disguise/commands/UndisguiseCommand.java @@ -1,7 +1,5 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; - import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -9,6 +7,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import me.libraryaddict.disguise.DisguiseAPI; + public class UndisguiseCommand implements CommandExecutor { @Override diff --git a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java b/src/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java rename to src/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java index 98ad3190..1f42f994 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java +++ b/src/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.java @@ -1,11 +1,12 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.LibsDisguises; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import me.libraryaddict.disguise.LibsDisguises; + public class UndisguiseEntityCommand implements CommandExecutor { @Override diff --git a/src/main/java/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.java b/src/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.java rename to src/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.java index 82b9a6b0..22844f41 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.java +++ b/src/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.java @@ -1,7 +1,5 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -9,6 +7,8 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import me.libraryaddict.disguise.DisguiseAPI; + public class UndisguisePlayerCommand implements CommandExecutor { @Override diff --git a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java b/src/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java rename to src/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java index a22269c6..37580860 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java +++ b/src/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java @@ -1,7 +1,5 @@ package me.libraryaddict.disguise.commands; -import me.libraryaddict.disguise.DisguiseAPI; - import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -9,6 +7,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import me.libraryaddict.disguise.DisguiseAPI; + public class UndisguiseRadiusCommand implements CommandExecutor { private int maxRadius = 30; diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java b/src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java similarity index 65% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java rename to src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java index 20ad534d..7382c816 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/AnimalColor.java +++ b/src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java @@ -1,29 +1,35 @@ package me.libraryaddict.disguise.disguisetypes; -public enum AnimalColor { - +public enum AnimalColor +{ BLACK(15), BLUE(11), BROWN(12), CYAN(9), GRAY(7), GREEN(13), LIGHT_BLUE(3), LIME(5), MAGENTA(2), ORANGE(1), PINK(6), PURPLE( 10), RED(14), SILVER(8), WHITE(0), YELLOW(4); - public static AnimalColor getColor(int nmsId) { - for (AnimalColor color : values()) { - if (color.getId() == nmsId) { + public static AnimalColor getColor(int nmsId) + { + for (AnimalColor color : values()) + { + if (color.getId() == nmsId) + { return color; } } + return null; } private int value; - AnimalColor(int newValue) { + AnimalColor(int newValue) + { value = newValue; } /** * The color ID as defined by nms internals. */ - public int getId() { + public int getId() + { return value; } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java similarity index 67% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java rename to src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 18baec28..0cfb3003 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -1,9 +1,29 @@ package me.libraryaddict.disguise.disguisetypes; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.scheduler.BukkitTask; +import org.bukkit.util.Vector; + import com.comphenix.protocol.PacketType.Play.Server; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; + import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; @@ -20,27 +40,9 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseValues; import me.libraryaddict.disguise.utilities.PacketsManager; import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Horse.Variant; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.entity.Villager.Profession; -import org.bukkit.scheduler.BukkitTask; -import org.bukkit.util.Vector; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -public abstract class Disguise { +public abstract class Disguise +{ private boolean disguiseInUse; private DisguiseType disguiseType; private Entity entity; @@ -67,252 +69,363 @@ public abstract class Disguise { /** * Seems I do this method so I can make cleaner constructors on disguises.. * - * @param newType The disguise + * @param newType + * The disguise */ - protected void createDisguise(DisguiseType newType) { - if (getWatcher() != null) { + protected void createDisguise(DisguiseType newType) + { + if (getWatcher() != null) + { return; } - if (newType.getEntityType() == null) { - throw new RuntimeException( - "DisguiseType " - + newType + + if (newType.getEntityType() == null) + { + throw new RuntimeException("DisguiseType " + newType + " was used in a futile attempt to construct a disguise, but this version of Spigot does not have that entity"); } + // Set the disguise type disguiseType = newType; // Get if they are a adult now.. + boolean isAdult = true; - if (isMobDisguise()) { + + if (isMobDisguise()) + { isAdult = ((MobDisguise) this).isAdult(); } - try { + + try + { // Construct the FlagWatcher from the stored class setWatcher((FlagWatcher) getType().getWatcherClass().getConstructor(Disguise.class).newInstance(this)); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } + // Set the disguise if its a baby or not - if (!isAdult) { - if (getWatcher() instanceof AgeableWatcher) { + if (!isAdult) + { + if (getWatcher() instanceof AgeableWatcher) + { ((AgeableWatcher) getWatcher()).setBaby(true); - } else if (getWatcher() instanceof ZombieWatcher) { + } + else if (getWatcher() instanceof ZombieWatcher) + { ((ZombieWatcher) getWatcher()).setBaby(true); } } + // If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton - if (getType() == DisguiseType.WITHER_SKELETON) { - ((SkeletonWatcher)getWatcher()).setType(SkeletonType.WITHER); + if (getType() == DisguiseType.WITHER_SKELETON) + { + ((SkeletonWatcher) getWatcher()).setType(SkeletonType.WITHER); } // Else if its a zombie, but the disguise type is a zombie villager. Set the value. - else if (getType() == DisguiseType.ZOMBIE_VILLAGER) { - ((ZombieWatcher)getWatcher()).setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]); - } else if (getType() == DisguiseType.ELDER_GUARDIAN) { - ((GuardianWatcher)getWatcher()).setElder(true); + else if (getType() == DisguiseType.ZOMBIE_VILLAGER) + { + ((ZombieWatcher) getWatcher()) + .setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]); + } + else if (getType() == DisguiseType.ELDER_GUARDIAN) + { + ((GuardianWatcher) getWatcher()).setElder(true); } // Else if its a horse. Set the horse watcher type - else if (getWatcher() instanceof HorseWatcher) { - try { + else if (getWatcher() instanceof HorseWatcher) + { + try + { Variant horseType = Variant.valueOf(getType().name()); - ((HorseWatcher)getWatcher()).setVariant(horseType); - } catch (Exception ex) { + ((HorseWatcher) getWatcher()).setVariant(horseType); + } + catch (Exception ex) + { // Ok.. So it aint a horse } } + final boolean alwaysSendVelocity; - switch (getType()) { - case EGG: - case ENDER_PEARL: - case BAT: - case EXPERIENCE_ORB: - case FIREBALL: - case SMALL_FIREBALL: - case SNOWBALL: - case SPLASH_POTION: - case THROWN_EXP_BOTTLE: - case WITHER_SKULL: - case FIREWORK: - alwaysSendVelocity = true; - break; - default: - alwaysSendVelocity = false; - break; + + switch (getType()) + { + case EGG: + case ENDER_PEARL: + case BAT: + case EXPERIENCE_ORB: + case FIREBALL: + case SMALL_FIREBALL: + case SNOWBALL: + case SPLASH_POTION: + case THROWN_EXP_BOTTLE: + case WITHER_SKULL: + case FIREWORK: + alwaysSendVelocity = true; + break; + default: + alwaysSendVelocity = false; + break; } + double velocitySpeed = 0.0005; - switch (getType()) { - case FIREWORK: - velocitySpeed = -0.040; - break; - case WITHER_SKULL: - velocitySpeed = 0.000001D; - break; - case ARROW: - case TIPPED_ARROW: - case SPECTRAL_ARROW: - case BOAT: - case ENDER_CRYSTAL: - case ENDER_DRAGON: - case GHAST: - case ITEM_FRAME: - case MINECART: - case MINECART_CHEST: - case MINECART_COMMAND: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - case PAINTING: - case PLAYER: - case SQUID: - velocitySpeed = 0; - break; - case DROPPED_ITEM: - case PRIMED_TNT: - case WITHER: - case FALLING_BLOCK: - velocitySpeed = 0.04; - break; - case EXPERIENCE_ORB: - velocitySpeed = 0.0221; - break; - case SPIDER: - case BAT: - case CAVE_SPIDER: - velocitySpeed = 0.004; - break; - default: - break; + + switch (getType()) + { + case FIREWORK: + velocitySpeed = -0.040; + break; + case WITHER_SKULL: + velocitySpeed = 0.000001D; + break; + case ARROW: + case TIPPED_ARROW: + case SPECTRAL_ARROW: + case BOAT: + case ENDER_CRYSTAL: + case ENDER_DRAGON: + case GHAST: + case ITEM_FRAME: + case MINECART: + case MINECART_CHEST: + case MINECART_COMMAND: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + case PAINTING: + case PLAYER: + case SQUID: + velocitySpeed = 0; + break; + case DROPPED_ITEM: + case PRIMED_TNT: + case WITHER: + case FALLING_BLOCK: + velocitySpeed = 0.04; + break; + case EXPERIENCE_ORB: + velocitySpeed = 0.0221; + break; + case SPIDER: + case BAT: + case CAVE_SPIDER: + velocitySpeed = 0.004; + break; + default: + break; } + final double vectorY = velocitySpeed; + final TargetedDisguise disguise = (TargetedDisguise) this; + // A scheduler to clean up any unused disguises. - velocityRunnable = new Runnable() { + velocityRunnable = new Runnable() + { private int blockX, blockY, blockZ, facing; private int deadTicks = 0; private int refreshDisguise = 0; @Override - public void run() { + public void run() + { // If entity is no longer valid. Remove it. - if (!getEntity().isValid()) { + if (!getEntity().isValid()) + { // If it has been dead for 30+ ticks // This is to ensure that this disguise isn't removed while clients think its the real entity // The delay is because if it sends the destroy entity packets straight away, then it means no death animation // This is probably still a problem for wither and enderdragon deaths. - if (deadTicks++ > (getType() == DisguiseType.ENDER_DRAGON ? 200 : 20)) { + if (deadTicks++ > (getType() == DisguiseType.ENDER_DRAGON ? 200 : 20)) + { deadTicks = 0; - if (isRemoveDisguiseOnDeath()) { + + if (isRemoveDisguiseOnDeath()) + { removeDisguise(); - } else { + } + else + { entity = null; watcher = getWatcher().clone(disguise); task.cancel(); task = null; } } - } else { + } + else + { deadTicks = 0; + // If the disguise type is tnt, we need to resend the entity packet else it will turn invisible - if (getType() == DisguiseType.PRIMED_TNT || getType() == DisguiseType.FIREWORK) { + if (getType() == DisguiseType.PRIMED_TNT || getType() == DisguiseType.FIREWORK) + { refreshDisguise++; - if (refreshDisguise % 40 == 0) { + + if (refreshDisguise % 40 == 0) + { refreshDisguise = 0; + DisguiseUtilities.refreshTrackers(disguise); } } - if (getType() == DisguiseType.ITEM_FRAME) { + + if (getType() == DisguiseType.ITEM_FRAME) + { Location loc = getEntity().getLocation(); + int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4; + if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc.getBlockZ() != blockZ - || newFacing != facing) { + || newFacing != facing) + { blockX = loc.getBlockX(); blockY = loc.getBlockY(); blockZ = loc.getBlockZ(); facing = newFacing; + DisguiseUtilities.refreshTrackers(disguise); } } - if (isModifyBoundingBox()) { + + if (isModifyBoundingBox()) + { DisguiseUtilities.doBoundingBox(disguise); } - if (getType() == DisguiseType.BAT && !((BatWatcher) getWatcher()).isHanging()) { + + if (getType() == DisguiseType.BAT && !((BatWatcher) getWatcher()).isHanging()) + { return; } + // If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors. // If this disguise has velocity sending enabled and the entity is flying. - if (isVelocitySent() && vectorY != 0 && (alwaysSendVelocity || !getEntity().isOnGround())) { + if (isVelocitySent() && vectorY != 0 && (alwaysSendVelocity || !getEntity().isOnGround())) + { Vector vector = getEntity().getVelocity(); + // If the entity doesn't have velocity changes already - You know. I really can't wrap my head about the // if statement. // But it doesn't seem to do anything wrong.. - if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround())) { + if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround())) + { return; } + // If disguise isn't a experience orb, or the entity isn't standing on the ground - if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) { + if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) + { PacketContainer lookPacket = null; - if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) { + + if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) + { lookPacket = new PacketContainer(Server.ENTITY_LOOK); + StructureModifier mods = lookPacket.getModifier(); lookPacket.getIntegers().write(0, getEntity().getEntityId()); Location loc = getEntity().getLocation(); - mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); - mods.write(5, PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); - if (isSelfDisguiseVisible() && getEntity() instanceof Player) { + + mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(), + (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); + mods.write(5, PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()), + (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); + + if (isSelfDisguiseVisible() && getEntity() instanceof Player) + { PacketContainer selfLookPacket = lookPacket.shallowClone(); + selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfLookPacket, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } } - try { + + try + { PacketContainer velocityPacket = new PacketContainer(Server.ENTITY_VELOCITY); + StructureModifier mods = velocityPacket.getIntegers(); + mods.write(1, (int) (vector.getX() * 8000)); mods.write(3, (int) (vector.getZ() * 8000)); - for (Player player : DisguiseUtilities.getPerverts(disguise)) { - if (getEntity() == player) { - if (!isSelfDisguiseVisible()) { + + for (Player player : DisguiseUtilities.getPerverts(disguise)) + { + if (getEntity() == player) + { + if (!isSelfDisguiseVisible()) + { continue; } + mods.write(0, DisguiseAPI.getSelfDisguiseId()); - } else { + } + else + { mods.write(0, getEntity().getEntityId()); } + mods.write(2, (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D)); - if (lookPacket != null && player != getEntity()) { + + if (lookPacket != null && player != getEntity()) + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false); } + ProtocolLibrary.getProtocolManager().sendServerPacket(player, velocityPacket.shallowClone(), false); } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } } // If we need to send a packet to update the exp position as it likes to gravitate client sided to // players. } - if (getType() == DisguiseType.EXPERIENCE_ORB) { + if (getType() == DisguiseType.EXPERIENCE_ORB) + { PacketContainer packet = new PacketContainer(Server.REL_ENTITY_MOVE); + packet.getIntegers().write(0, getEntity().getEntityId()); - try { - for (Player player : DisguiseUtilities.getPerverts(disguise)) { - if (getEntity() != player) { + try + { + for (Player player : DisguiseUtilities.getPerverts(disguise)) + { + if (getEntity() != player) + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); - } else if (isSelfDisguiseVisible()) { + } + else if (isSelfDisguiseVisible()) + { PacketContainer selfPacket = packet.shallowClone(); + selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId()); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfPacket, false); - } catch (InvocationTargetException e) { + + try + { + ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfPacket, + false); + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } } - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } @@ -326,7 +439,8 @@ public abstract class Disguise { * * @return entity */ - public Entity getEntity() { + public Entity getEntity() + { return entity; } @@ -335,7 +449,8 @@ public abstract class Disguise { * * @return disguiseType */ - public DisguiseType getType() { + public DisguiseType getType() + { return disguiseType; } @@ -344,63 +459,79 @@ public abstract class Disguise { * * @return flagWatcher */ - public FlagWatcher getWatcher() { + public FlagWatcher getWatcher() + { return watcher; } /** - * In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. getEntity() can still return null if this disguise is active after despawn, logout, etc. + * In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. + * getEntity() can still return null if this disguise is active after despawn, logout, etc. * * @return isDisguiseInUse */ - public boolean isDisguiseInUse() { + public boolean isDisguiseInUse() + { return disguiseInUse; } - public boolean isHidingArmorFromSelf() { + public boolean isHidingArmorFromSelf() + { return hideArmorFromSelf; } - public boolean isHidingHeldItemFromSelf() { + public boolean isHidingHeldItemFromSelf() + { return hideHeldItemFromSelf; } - public boolean isKeepDisguiseOnEntityDespawn() { + public boolean isKeepDisguiseOnEntityDespawn() + { return this.keepDisguiseEntityDespawn; } - public boolean isKeepDisguiseOnPlayerDeath() { + public boolean isKeepDisguiseOnPlayerDeath() + { return this.keepDisguisePlayerDeath; } - public boolean isKeepDisguiseOnPlayerLogout() { + public boolean isKeepDisguiseOnPlayerLogout() + { return this.keepDisguisePlayerLogout; } - public boolean isMiscDisguise() { + public boolean isMiscDisguise() + { return false; } - public boolean isMobDisguise() { + public boolean isMobDisguise() + { return false; } - public boolean isModifyBoundingBox() { + public boolean isModifyBoundingBox() + { return modifyBoundingBox; } - public boolean isPlayerDisguise() { + public boolean isPlayerDisguise() + { return false; } /** * Internal use */ - public boolean isRemoveDisguiseOnDeath() { - return getEntity() == null || (getEntity() instanceof Player ? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath()) : (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead())); + public boolean isRemoveDisguiseOnDeath() + { + return getEntity() == null || (getEntity() instanceof Player + ? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath()) + : (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead())); } - public boolean isSelfDisguiseSoundsReplaced() { + public boolean isSelfDisguiseSoundsReplaced() + { return hearSelfDisguise; } @@ -409,15 +540,18 @@ public abstract class Disguise { * * @return viewSelfDisguise */ - public boolean isSelfDisguiseVisible() { + public boolean isSelfDisguiseVisible() + { return viewSelfDisguise; } - public boolean isSoundsReplaced() { + public boolean isSoundsReplaced() + { return replaceSounds; } - public boolean isVelocitySent() { + public boolean isVelocitySent() + { return velocitySent; } @@ -426,7 +560,8 @@ public abstract class Disguise { * * @return */ - public boolean isShowName() { + public boolean isShowName() + { return showName; } @@ -435,58 +570,88 @@ public abstract class Disguise { * * @return removeDiguise */ - public boolean removeDisguise() { - if (disguiseInUse) { + public boolean removeDisguise() + { + if (disguiseInUse) + { UndisguiseEvent event = new UndisguiseEvent(entity, this); + Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { + + if (!event.isCancelled()) + { disguiseInUse = false; - if (task != null) { + + if (task != null) + { task.cancel(); task = null; } + HashMap> disguises = DisguiseUtilities.getDisguises(); + // If this disguise has a entity set - if (getEntity() != null) { + if (getEntity() != null) + { // If this disguise is active // Remove the disguise from the current disguises. - if (DisguiseUtilities.removeDisguise((TargetedDisguise) this)) { - if (getEntity() instanceof Player) { + if (DisguiseUtilities.removeDisguise((TargetedDisguise) this)) + { + if (getEntity() instanceof Player) + { DisguiseUtilities.removeSelfDisguise((Player) getEntity()); } // Better refresh the entity to undisguise it - if (getEntity().isValid()) { + if (getEntity().isValid()) + { DisguiseUtilities.refreshTrackers((TargetedDisguise) this); - } else { + } + else + { DisguiseUtilities.destroyEntity((TargetedDisguise) this); } } - } else { + } + else + { // Loop through the disguises because it could be used with a unknown entity id. HashMap> future = DisguiseUtilities.getFutureDisguises(); + Iterator itel = DisguiseUtilities.getFutureDisguises().keySet().iterator(); - while (itel.hasNext()) { + + while (itel.hasNext()) + { int id = itel.next(); - if (future.get(id).remove(this) && future.get(id).isEmpty()) { + + if (future.get(id).remove(this) && future.get(id).isEmpty()) + { itel.remove(); } } } - if (isPlayerDisguise()) { + if (isPlayerDisguise()) + { String name = ((PlayerDisguise) this).getName(); - if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase())) { - for (HashSet disguise : disguises.values()) { - for (Disguise d : disguise) { - if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) { + + if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase())) + { + for (HashSet disguise : disguises.values()) + { + for (Disguise d : disguise) + { + if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) + { return true; } } } + DisguiseUtilities.getGameProfiles().remove(name.toLowerCase()); } } + return true; } } @@ -499,135 +664,195 @@ public abstract class Disguise { * @param entity * @return disguise */ - public Disguise setEntity(Entity entity) { - if (this.getEntity() != null) { - if (getEntity() == entity) { + public Disguise setEntity(Entity entity) + { + if (this.getEntity() != null) + { + if (getEntity() == entity) + { return this; } + throw new RuntimeException("This disguise is already in use! Try .clone()"); } - if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { + + if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) + { throw new RuntimeException( "Cannot disguise a living entity with a misc disguise. Reenable MiscDisguisesForLiving in the config to do this"); } + this.entity = entity; + setupWatcher(); + return this; } - public Disguise setShowName(boolean showName) { + public Disguise setShowName(boolean showName) + { this.showName = showName; + return this; } - public Disguise setHearSelfDisguise(boolean hearSelfDisguise) { + public Disguise setHearSelfDisguise(boolean hearSelfDisguise) + { this.hearSelfDisguise = hearSelfDisguise; + return this; } - public Disguise setHideArmorFromSelf(boolean hideArmor) { + public Disguise setHideArmorFromSelf(boolean hideArmor) + { this.hideArmorFromSelf = hideArmor; - if (getEntity() instanceof Player) { + + if (getEntity() instanceof Player) + { ((Player) getEntity()).updateInventory(); } + return this; } - public Disguise setHideHeldItemFromSelf(boolean hideHeldItem) { + public Disguise setHideHeldItemFromSelf(boolean hideHeldItem) + { this.hideHeldItemFromSelf = hideHeldItem; - if (getEntity() instanceof Player) { + + if (getEntity() instanceof Player) + { ((Player) getEntity()).updateInventory(); } + return this; } - public Disguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { + public Disguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) + { this.keepDisguiseEntityDespawn = keepDisguise; + return this; } - public Disguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { + public Disguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) + { this.keepDisguisePlayerDeath = keepDisguise; + return this; } - public Disguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { + public Disguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) + { this.keepDisguisePlayerLogout = keepDisguise; + return this; } - public Disguise setModifyBoundingBox(boolean modifyBox) { - if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + public Disguise setModifyBoundingBox(boolean modifyBox) + { + if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) + { throw new RuntimeException( "Cannot modify the bounding box of a disguise which is not TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS"); } - if (isModifyBoundingBox() != modifyBox) { + + if (isModifyBoundingBox() != modifyBox) + { this.modifyBoundingBox = modifyBox; - if (DisguiseUtilities.isDisguiseInUse(this)) { + + if (DisguiseUtilities.isDisguiseInUse(this)) + { DisguiseUtilities.doBoundingBox((TargetedDisguise) this); } } + return this; } - public Disguise setReplaceSounds(boolean areSoundsReplaced) { + public Disguise setReplaceSounds(boolean areSoundsReplaced) + { replaceSounds = areSoundsReplaced; + return this; } /** - * Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the datawatcher. + * Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the + * datawatcher. */ - private void setupWatcher() { + private void setupWatcher() + { HashMap disguiseValues = DisguiseValues.getMetaValues(getType()); HashMap entityValues = DisguiseValues.getMetaValues(DisguiseType.getType(getEntity().getType())); + // Start from 2 as they ALL share 0 and 1 - for (int dataNo = 0; dataNo <= 31; dataNo++) { + for (int dataNo = 0; dataNo <= 31; dataNo++) + { // STEP 1. Find out if the watcher has set data on it. // If the watcher already set a metadata on this - if (getWatcher().hasValue(dataNo)) { + if (getWatcher().hasValue(dataNo)) + { // Better check that the value is stable. // To check this, I'm going to check if there exists a default value // Then I'm going to check if the watcher value is the same as the default value. - if (disguiseValues.containsKey(dataNo)) { + if (disguiseValues.containsKey(dataNo)) + { // Now check if they are the same class, or both null. - if (disguiseValues.get(dataNo) == null || getWatcher().getValue(dataNo, null) == null) { - if (disguiseValues.get(dataNo) == null && getWatcher().getValue(dataNo, null) == null) { + if (disguiseValues.get(dataNo) == null || getWatcher().getValue(dataNo, null) == null) + { + if (disguiseValues.get(dataNo) == null && getWatcher().getValue(dataNo, null) == null) + { // They are both null. Idk what this means really. continue; } - } else if (getWatcher().getValue(dataNo, null).getClass() == disguiseValues.get(dataNo).getClass()) { + } + else if (getWatcher().getValue(dataNo, null).getClass() == disguiseValues.get(dataNo).getClass()) + { // The classes are the same. The client "shouldn't" crash. continue; } } } + // STEP 2. As the watcher has not set data on it, check if I need to set the default data. // If neither of them touch it - if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) { + if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) + { continue; } + // If the disguise has this, but not the entity. Then better set it! - if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) { + if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) + { getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo)); continue; } + // Else if the disguise doesn't have it. But the entity does. Better remove it! - if (entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) { + if (entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) + { getWatcher().setBackupValue(dataNo, null); continue; } + Object eObj = entityValues.get(dataNo); Object dObj = disguiseValues.get(dataNo); - if (eObj == null || dObj == null) { - if (eObj == null && dObj == null) { + + if (eObj == null || dObj == null) + { + if (eObj == null && dObj == null) + { continue; - } else { + } + else + { getWatcher().setBackupValue(dataNo, dObj); continue; } } - if (eObj.getClass() != dObj.getClass()) { + + if (eObj.getClass() != dObj.getClass()) + { getWatcher().setBackupValue(dataNo, dObj); continue; } @@ -640,29 +865,35 @@ public abstract class Disguise { // EntityLiving is 5 & 6 & 7 & 8 & 9 // Lets use switch Class baseClass = null; - switch (dataNo) { - case 5: - case 6: - case 7: - case 8: - case 9: - baseClass = ReflectionManager.getNmsClass("EntityLiving"); - break; - case 10: - baseClass = ReflectionManager.getNmsClass("EntityInsentient"); - break; - case 11: - baseClass = ReflectionManager.getNmsClass("EntityAgeable"); - break; - default: - break; + + switch (dataNo) + { + case 5: + case 6: + case 7: + case 8: + case 9: + baseClass = ReflectionManager.getNmsClass("EntityLiving"); + break; + case 10: + baseClass = ReflectionManager.getNmsClass("EntityInsentient"); + break; + case 11: + baseClass = ReflectionManager.getNmsClass("EntityAgeable"); + break; + default: + break; } + Class nmsEntityClass = ReflectionManager.getNmsEntity(getEntity()).getClass(); Class nmsDisguiseClass = DisguiseValues.getNmsEntityClass(getType()); - if (nmsDisguiseClass != null) { + + if (nmsDisguiseClass != null) + { // If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..? if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass) - && baseClass.isAssignableFrom(nmsEntityClass)) { + && baseClass.isAssignableFrom(nmsEntityClass)) + { continue; } @@ -670,18 +901,22 @@ public abstract class Disguise { // Maybe if I check that they extend each other.. // Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared // datawatchers. - if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass)) { + if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass)) + { continue; } } + // Well I can't find a reason I should leave it alone. They will probably conflict. // Time to set the value to the disguises value so no conflicts! getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo)); } } - public Disguise setVelocitySent(boolean sendVelocity) { + public Disguise setVelocitySent(boolean sendVelocity) + { this.velocitySent = sendVelocity; + return this; } @@ -691,58 +926,88 @@ public abstract class Disguise { * @param viewSelfDisguise * @return */ - public Disguise setViewSelfDisguise(boolean viewSelfDisguise) { - if (isSelfDisguiseVisible() != viewSelfDisguise) { + public Disguise setViewSelfDisguise(boolean viewSelfDisguise) + { + if (isSelfDisguiseVisible() != viewSelfDisguise) + { this.viewSelfDisguise = viewSelfDisguise; - if (getEntity() != null && getEntity() instanceof Player) { - if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) { - if (isSelfDisguiseVisible()) { + + if (getEntity() != null && getEntity() instanceof Player) + { + if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) + { + if (isSelfDisguiseVisible()) + { DisguiseUtilities.setupFakeDisguise(this); - } else { + } + else + { DisguiseUtilities.removeSelfDisguise((Player) getEntity()); } } } } + return this; } - public Disguise setWatcher(FlagWatcher newWatcher) { - if (!getType().getWatcherClass().isInstance(newWatcher)) { + public Disguise setWatcher(FlagWatcher newWatcher) + { + if (!getType().getWatcherClass().isInstance(newWatcher)) + { throw new IllegalArgumentException(newWatcher.getClass().getSimpleName() + " is not a instance of " + getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); } + watcher = newWatcher; - if (getEntity() != null) { + + if (getEntity() != null) + { setupWatcher(); } + return this; } - public boolean startDisguise() { - if (!isDisguiseInUse()) { - if (getEntity() == null) { + public boolean startDisguise() + { + if (!isDisguiseInUse()) + { + if (getEntity() == null) + { throw new RuntimeException("No entity is assigned to this disguise!"); } + // Fire a disguise event DisguiseEvent event = new DisguiseEvent(entity, this); + Bukkit.getPluginManager().callEvent(event); + // If they cancelled this disguise event. No idea why. // Just return. - if (!event.isCancelled()) { + if (!event.isCancelled()) + { disguiseInUse = true; + task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1); + // Stick the disguise in the disguises bin DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this); - if (isSelfDisguiseVisible() && getEntity() instanceof Player) { + + if (isSelfDisguiseVisible() && getEntity() instanceof Player) + { DisguiseUtilities.removeSelfDisguise((Player) getEntity()); } + // Resend the disguised entity's packet DisguiseUtilities.refreshTrackers((TargetedDisguise) this); + // If he is a player, then self disguise himself - Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() { + Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() + { @Override - public void run() { + public void run() + { DisguiseUtilities.setupFakeDisguise(Disguise.this); } }, 2); @@ -752,7 +1017,8 @@ public abstract class Disguise { return false; } - public boolean stopDisguise() { + public boolean stopDisguise() + { return removeDisguise(); } @@ -761,7 +1027,8 @@ public abstract class Disguise { * * @return */ - public static List getViewSelf() { + public static List getViewSelf() + { return viewSelf; } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java new file mode 100644 index 00000000..d37e5337 --- /dev/null +++ b/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java @@ -0,0 +1,389 @@ +package me.libraryaddict.disguise.disguisetypes; + +import java.lang.reflect.Method; + +import org.apache.commons.lang.StringUtils; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Guardian; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Zombie; + +public enum DisguiseType +{ + + AREA_EFFECT_CLOUD(3, 0), + + ARMOR_STAND(78), + + ARROW(60, 0), + + BAT, + + BLAZE, + + BOAT(1), + + CAVE_SPIDER, + + CHICKEN, + + COW, + + CREEPER, + + DONKEY, + + DRAGON_FIREBALL(93), + + DROPPED_ITEM(2, 1), + + EGG(62), + + ELDER_GUARDIAN, + + ENDER_CRYSTAL(51), + + ENDER_DRAGON, + + ENDER_PEARL(65), + + ENDER_SIGNAL(72), + + ENDERMAN, + + ENDERMITE, + + EXPERIENCE_ORB, + + FALLING_BLOCK(70, 1), + + FIREBALL(63), + + FIREWORK(76), + + FISHING_HOOK(90), + + GHAST, + + GIANT, + + GUARDIAN, + + HORSE, + + IRON_GOLEM, + + ITEM_FRAME(71), + + LEASH_HITCH(77), + + MAGMA_CUBE, + + MINECART(10), + + MINECART_CHEST(10, 1), + + MINECART_COMMAND(10, 6), + + MINECART_FURNACE(10, 2), + + MINECART_HOPPER(10, 5), + + MINECART_MOB_SPAWNER(10, 4), + + MINECART_TNT(10, 3), + + MULE, + + MUSHROOM_COW, + + OCELOT, + + PAINTING, + + PIG, + + PIG_ZOMBIE, + + PLAYER, + + PRIMED_TNT(50), + + RABBIT, + + SHEEP, + + SHULKER, + + SHULKER_BULLET(67), + + SILVERFISH, + + SKELETON, + + SKELETON_HORSE, + + SLIME, + + SMALL_FIREBALL(63), + + SNOWBALL(61), + + SNOWMAN, + + SPECTRAL_ARROW(91), + + SPIDER, + + SPLASH_POTION(73, 0), + + SQUID, + + TIPPED_ARROW(92), + + THROWN_EXP_BOTTLE(75), + + UNDEAD_HORSE, + + VILLAGER, + + WITCH, + + WITHER, + + WITHER_SKELETON, + + WITHER_SKULL(66), + + WOLF, + + ZOMBIE, + + ZOMBIE_VILLAGER, + + UNKNOWN; + + static + { + // We set the entity type in this so that we can safely ignore disguisetypes which don't exist in older versions of MC. + // Without erroring up everything. + + for (DisguiseType type : values()) + { + + try + { + DisguiseType toUse = type; + String name; + + switch (type) + { + // Disguise item frame isn't supported. So we don't give it a entity type which should prevent it from being.. + // Usable. + case ITEM_FRAME: + break; + case DONKEY: + case MULE: + case UNDEAD_HORSE: + case SKELETON_HORSE: + toUse = DisguiseType.HORSE; + break; + case ZOMBIE_VILLAGER: + toUse = DisguiseType.ZOMBIE; + break; + case WITHER_SKELETON: + toUse = DisguiseType.SKELETON; + break; + case ELDER_GUARDIAN: + toUse = DisguiseType.GUARDIAN; + break; + default: + break; + } + + name = toUse.name(); + + type.setEntityType(EntityType.valueOf(name)); + } + catch (Throwable ex) + { + // This version of Spigot doesn't have the disguise. + } + } + } + + public static DisguiseType getType(Entity entity) + { + DisguiseType disguiseType = getType(entity.getType()); + + switch (disguiseType) + { + case ZOMBIE: + + if (((Zombie) entity).isVillager()) + { + disguiseType = DisguiseType.ZOMBIE_VILLAGER; + } + + break; + + case HORSE: + + disguiseType = DisguiseType.valueOf(((Horse) entity).getVariant().name()); + + break; + + case SKELETON: + + if (((Skeleton) entity).getSkeletonType() == SkeletonType.WITHER) + { + disguiseType = DisguiseType.WITHER_SKELETON; + } + + break; + case GUARDIAN: + + if (((Guardian) entity).isElder()) + { + disguiseType = DisguiseType.ELDER_GUARDIAN; + } + + break; + default: + break; + } + + return disguiseType; + + } + + public static DisguiseType getType(EntityType entityType) + { + try + { + return valueOf(entityType.name().toUpperCase()); + } + catch (Throwable ex) + { + return DisguiseType.UNKNOWN; + } + } + + private int objectId = -1, defaultData = 0; + + private EntityType entityType; + + private Class watcherClass; + + DisguiseType(int... ints) + { + for (int i = 0; i < ints.length; i++) + { + int value = ints[i]; + + switch (i) + { + case 0: + objectId = value; + + break; + case 1: + defaultData = value; + + break; + default: + break; + } + } + } + + public int getDefaultData() + { + return defaultData; + } + + public Class getEntityClass() + { + if (entityType != null) + { + return getEntityType().getEntityClass(); + } + + return Entity.class; + } + + public EntityType getEntityType() + { + return entityType; + } + + /** + * The TYPE id of this entity. Different from the Object Id send in spawn packets when spawning miscs. + * + * @return + */ + public int getTypeId() + { + return (int) getEntityType().getTypeId(); + } + + /** + * The object type send in packets when spawning a misc entity. Otherwise, -1. + * + * @return + */ + public int getObjectId() + { + return objectId; + } + + public Class getWatcherClass() + { + return watcherClass; + } + + public boolean isMisc() + { + return getEntityType() != null && !getEntityType().isAlive(); + } + + public boolean isMob() + { + return getEntityType() != null && getEntityType().isAlive() && !isPlayer(); + } + + public boolean isPlayer() + { + return this == DisguiseType.PLAYER; + } + + public boolean isUnknown() + { + return this == DisguiseType.UNKNOWN; + } + + private void setEntityType(EntityType entityType) + { + this.entityType = entityType; + } + + public void setWatcherClass(Class c) + { + watcherClass = c; + } + + public String toReadable() + { + String[] split = name().split("_"); + + for (int i = 0; i < split.length; i++) + { + split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); + } + + return StringUtils.join(split, " "); + } +} diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java similarity index 62% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index 6e1d3638..359f186d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -1,29 +1,32 @@ package me.libraryaddict.disguise.disguisetypes; -import com.comphenix.protocol.PacketType.Play.Server; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.WrappedDataWatcher; -import com.comphenix.protocol.wrappers.WrappedWatchableObject; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import me.libraryaddict.disguise.utilities.PacketsManager; -import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.EntityEquipment; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; - import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -public class FlagWatcher { +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; + +import com.comphenix.protocol.PacketType.Play.Server; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; +import com.comphenix.protocol.wrappers.WrappedWatchableObject; + +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.PacketsManager; +import me.libraryaddict.disguise.utilities.ReflectionManager; + +public class FlagWatcher +{ private boolean addEntityAnimations = DisguiseConfig.isEntityAnimationsAdded(); /** @@ -37,305 +40,445 @@ public class FlagWatcher { private HashSet modifiedEntityAnimations = new HashSet<>(); private List watchableObjects; - public FlagWatcher(Disguise disguise) { + public FlagWatcher(Disguise disguise) + { this.disguise = (TargetedDisguise) disguise; equipment = ReflectionManager.createEntityEquipment(disguise.getEntity()); } - private byte addEntityAnimations(byte originalValue, byte entityValue) { + private byte addEntityAnimations(byte originalValue, byte entityValue) + { byte valueByte = originalValue; - for (int i = 0; i < 6; i++) { - if ((entityValue & 1 << i) != 0 && !modifiedEntityAnimations.contains(i)) { + + for (int i = 0; i < 6; i++) + { + if ((entityValue & 1 << i) != 0 && !modifiedEntityAnimations.contains(i)) + { valueByte = (byte) (valueByte | 1 << i); } } + originalValue = valueByte; + return originalValue; } - public FlagWatcher clone(Disguise owningDisguise) { + public FlagWatcher clone(Disguise owningDisguise) + { FlagWatcher cloned; - try { + + try + { cloned = getClass().getConstructor(Disguise.class).newInstance(getDisguise()); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); cloned = new FlagWatcher(getDisguise()); } + cloned.entityValues = (HashMap) entityValues.clone(); cloned.equipment = ReflectionManager.createEntityEquipment(cloned.getDisguise().getEntity()); cloned.modifiedEntityAnimations = (HashSet) modifiedEntityAnimations.clone(); cloned.addEntityAnimations = addEntityAnimations; + return cloned; } - public List convert(List list) { + public List convert(List list) + { List newList = new ArrayList<>(); HashSet sentValues = new HashSet<>(); boolean sendAllCustom = false; - for (WrappedWatchableObject watch : list) { + + for (WrappedWatchableObject watch : list) + { int id = watch.getIndex(); sentValues.add(id); + // Its sending the air metadata. This is the least commonly sent metadata which all entitys still share. // I send my custom values if I see this! - if (id == 1) { + if (id == 1) + { sendAllCustom = true; } + Object value = null; - if (entityValues.containsKey(id)) { - if (entityValues.get(id) == null) { + + if (entityValues.containsKey(id)) + { + if (entityValues.get(id) == null) + { continue; } + value = entityValues.get(id); - } else if (backupEntityValues.containsKey(id)) { - if (backupEntityValues.get(id) == null) { + } + else if (backupEntityValues.containsKey(id)) + { + if (backupEntityValues.get(id) == null) + { continue; } + value = backupEntityValues.get(id); } - if (value != null) { - if (isEntityAnimationsAdded() && id == 0) { + + if (value != null) + { + if (isEntityAnimationsAdded() && id == 0) + { value = this.addEntityAnimations((byte) value, (byte) watch.getValue()); } + boolean isDirty = watch.getDirtyState(); + watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, value)); - if (!isDirty) { - watch.setDirtyState(false); - } - } else { - boolean isDirty = watch.getDirtyState(); - watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, watch.getValue())); - if (!isDirty) { + + if (!isDirty) + { watch.setDirtyState(false); } } + else + { + boolean isDirty = watch.getDirtyState(); + + watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, watch.getValue())); + + if (!isDirty) + { + watch.setDirtyState(false); + } + } + newList.add(watch); } - if (sendAllCustom) { + + if (sendAllCustom) + { // Its sending the entire meta data. Better add the custom meta - for (int id : entityValues.keySet()) { - if (sentValues.contains(id)) { + for (int id : entityValues.keySet()) + { + if (sentValues.contains(id)) + { continue; } + Object value = entityValues.get(id); - if (value == null) { + + if (value == null) + { continue; } + WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, value)); + newList.add(watch); } } // Here we check for if there is a health packet that says they died. - if (getDisguise().isSelfDisguiseVisible() && getDisguise().getEntity() != null && getDisguise().getEntity() instanceof Player) { - for (WrappedWatchableObject watch : newList) { + if (getDisguise().isSelfDisguiseVisible() && getDisguise().getEntity() != null + && getDisguise().getEntity() instanceof Player) + { + for (WrappedWatchableObject watch : newList) + { // Its a health packet - if (watch.getIndex() == 6) { + if (watch.getIndex() == 6) + { Object value = watch.getValue(); - if (value != null && value instanceof Float) { + + if (value != null && value instanceof Float) + { float newHealth = (Float) value; - if (newHealth > 0 && hasDied) { + + if (newHealth > 0 && hasDied) + { hasDied = false; DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity(), disguise); - } else if (newHealth <= 0 && !hasDied) { + } + else if (newHealth <= 0 && !hasDied) + { hasDied = true; } } } } } + return newList; } - public ItemStack[] getArmor() { + public ItemStack[] getArmor() + { ItemStack[] armor = new ItemStack[4]; System.arraycopy(armor, 0, armor, 0, 4); + return armor; } - public String getCustomName() { + public String getCustomName() + { return (String) getValue(2, null); } - protected TargetedDisguise getDisguise() { + protected TargetedDisguise getDisguise() + { return disguise; } - private boolean getEntityFlag(int byteValue) { + private boolean getEntityFlag(int byteValue) + { return ((byte) getValue(0, (byte) 0) & 1 << byteValue) != 0; } - public ItemStack getItemInMainHand() { - if (equipment == null) return null; + public ItemStack getItemInMainHand() + { + if (equipment == null) + return null; + return equipment.getItemInMainHand(); } - public ItemStack getItemInOffHand() { - if (equipment == null) return null; + public ItemStack getItemInOffHand() + { + if (equipment == null) + return null; + return equipment.getItemInOffHand(); } - public EntityEquipment getEquipment() { + public EntityEquipment getEquipment() + { return equipment; } - protected Object getValue(int no, Object backup) { - if (entityValues.containsKey(no)) { - return entityValues.get(no); + protected Y getValue(int no, Y backup) + { + if (entityValues.containsKey(no)) + { + return (Y) entityValues.get(no); } + return backup; } - public List getWatchableObjects() { - if (watchableObjects == null) { + public List getWatchableObjects() + { + if (watchableObjects == null) + { rebuildWatchableObjects(); } + return watchableObjects; } - public boolean hasCustomName() { + public boolean hasCustomName() + { return getCustomName() != null; } - protected boolean hasValue(int no) { + protected boolean hasValue(int no) + { return entityValues.containsKey(no); } - public boolean isCustomNameVisible() { + public boolean isCustomNameVisible() + { return (boolean) getValue(3, false); } - public boolean isEntityAnimationsAdded() { + public boolean isEntityAnimationsAdded() + { return addEntityAnimations; } - public boolean isBurning() { + public boolean isBurning() + { return getEntityFlag(0); } - public boolean isSneaking() { + public boolean isSneaking() + { return getEntityFlag(1); } - public boolean isSprinting() { + public boolean isSprinting() + { return getEntityFlag(3); } - public boolean isRightClicking() { + public boolean isRightClicking() + { return getEntityFlag(4); } - public boolean isInvisible() { + public boolean isInvisible() + { return getEntityFlag(5); } - public boolean isGlowing() { + public boolean isGlowing() + { return getEntityFlag(6); } - public boolean isFlyingWithElytra() { + public boolean isFlyingWithElytra() + { return getEntityFlag(7); } - public void rebuildWatchableObjects() { + public void rebuildWatchableObjects() + { watchableObjects = new ArrayList<>(); - for (int i = 0; i <= 31; i++) { + + for (int i = 0; i <= 31; i++) + { WrappedWatchableObject watchable = null; - if (this.entityValues.containsKey(i) && this.entityValues.get(i) != null) { - watchable = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(i, entityValues.get(i))); - } else if (this.backupEntityValues.containsKey(i) && this.backupEntityValues.get(i) != null) { + + if (this.entityValues.containsKey(i) && this.entityValues.get(i) != null) + { watchable = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(i, entityValues.get(i))); } - if (watchable != null) { + else if (this.backupEntityValues.containsKey(i) && this.backupEntityValues.get(i) != null) + { + watchable = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(i, entityValues.get(i))); + } + + if (watchable != null) + { watchableObjects.add(watchable); } } } - protected void sendData(int... dataValues) { - if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) { + protected void sendData(int... dataValues) + { + if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) + { return; } + List list = new ArrayList<>(); - for (int data : dataValues) { - if (!entityValues.containsKey(data) || entityValues.get(data) == null) { + + for (int data : dataValues) + { + if (!entityValues.containsKey(data) || entityValues.get(data) == null) + { continue; } + Object value = entityValues.get(data); - if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) { + + if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) + { if (!PacketsManager.isStaticMetadataDisguiseType(disguise)) - value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); + { + value = addEntityAnimations((byte) value, + WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); + } } + WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(data, value)); + list.add(watch); } - if (!list.isEmpty()) { + + if (!list.isEmpty()) + { PacketContainer packet = new PacketContainer(Server.ENTITY_METADATA); + StructureModifier mods = packet.getModifier(); mods.write(0, getDisguise().getEntity().getEntityId()); + packet.getWatchableCollectionModifier().write(0, list); - for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { - try { + + for (Player player : DisguiseUtilities.getPerverts(getDisguise())) + { + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } } } - public void setAddEntityAnimations(boolean isEntityAnimationsAdded) { + public void setAddEntityAnimations(boolean isEntityAnimationsAdded) + { this.addEntityAnimations = isEntityAnimationsAdded; } - public void setArmor(ItemStack[] itemstack) { + public void setArmor(ItemStack[] itemstack) + { setItemStack(EquipmentSlot.HEAD, itemstack[0]); setItemStack(EquipmentSlot.CHEST, itemstack[1]); setItemStack(EquipmentSlot.LEGS, itemstack[2]); setItemStack(EquipmentSlot.FEET, itemstack[3]); } - protected void setBackupValue(int no, Object value) { + protected void setBackupValue(int no, Object value) + { backupEntityValues.put(no, value); } - public void setBurning(boolean setBurning) { + public void setBurning(boolean setBurning) + { setEntityFlag(0, setBurning); + sendData(0); } - public void setCustomName(String name) { - if (name != null && name.length() > 64) { + public void setCustomName(String name) + { + if (name != null && name.length() > 64) + { name = name.substring(0, 64); } + setValue(2, name); sendData(2); } - public void setCustomNameVisible(boolean display) { + public void setCustomNameVisible(boolean display) + { setValue(3, display); sendData(3); } - private void setEntityFlag(int byteValue, boolean flag) { + private void setEntityFlag(int byteValue, boolean flag) + { modifiedEntityAnimations.add(byteValue); + byte b0 = (byte) getValue(0, (byte) 0); - if (flag) { + + if (flag) + { setValue(0, (byte) (b0 | 1 << byteValue)); - } else { + } + else + { setValue(0, (byte) (b0 & ~(1 << byteValue))); } } - public void setInvisible(boolean setInvis) { + public void setInvisible(boolean setInvis) + { setEntityFlag(5, setInvis); sendData(0); } - public void setGlowing(boolean glowing) { + public void setGlowing(boolean glowing) + { setEntityFlag(6, glowing); sendData(0); } - public void setFlyingWithElytra(boolean flying) { + public void setFlyingWithElytra(boolean flying) + { setEntityFlag(7, flying); sendData(0); } @@ -346,110 +489,146 @@ public class FlagWatcher { * @param itemstack */ @Deprecated - public void setItemInHand(ItemStack itemstack) { + public void setItemInHand(ItemStack itemstack) + { setItemInMainHand(itemstack); } - public void setItemInMainHand(ItemStack itemstack) { + public void setItemInMainHand(ItemStack itemstack) + { setItemStack(EquipmentSlot.HAND, itemstack); } - public void setItemInOffHand(ItemStack itemstack) { + public void setItemInOffHand(ItemStack itemstack) + { setItemStack(EquipmentSlot.OFF_HAND, itemstack); } - public void setItemStack(EquipmentSlot slot, ItemStack itemStack) { - if (equipment == null) return; + public void setItemStack(EquipmentSlot slot, ItemStack itemStack) + { + if (equipment == null) + return; + // Itemstack which is null means that its not replacing the disguises itemstack. - if (itemStack == null) { + if (itemStack == null) + { // Find the item to replace it with - if (getDisguise().getEntity() instanceof LivingEntity) { + if (getDisguise().getEntity() instanceof LivingEntity) + { EntityEquipment equipment = ((LivingEntity) getDisguise().getEntity()).getEquipment(); setItemStack(equipment, slot, itemStack); } } + Object itemToSend = null; - if (itemStack != null && itemStack.getTypeId() != 0) { + + if (itemStack != null && itemStack.getTypeId() != 0) + { itemToSend = ReflectionManager.getNmsItem(itemStack); } + setItemStack(equipment, slot, itemStack); - if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { + + if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) + { PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT); + StructureModifier mods = packet.getModifier(); + mods.write(0, getDisguise().getEntity().getEntityId()); mods.write(1, ReflectionManager.createEnumItemSlot(slot)); mods.write(2, itemToSend); - for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { - try { + + for (Player player : DisguiseUtilities.getPerverts(getDisguise())) + { + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } } } - private void setItemStack(EntityEquipment equipment, EquipmentSlot slot, ItemStack itemStack) { - if (equipment == null) return; - switch (slot) { - case CHEST: - equipment.setChestplate(itemStack); - break; - case FEET: - equipment.setBoots(itemStack); - break; - case HAND: - equipment.setItemInMainHand(itemStack); - break; - case HEAD: - equipment.setHelmet(itemStack); - break; - case LEGS: - equipment.setLeggings(itemStack); - break; - case OFF_HAND: - equipment.setItemInOffHand(itemStack); - break; + private void setItemStack(EntityEquipment equipment, EquipmentSlot slot, ItemStack itemStack) + { + if (equipment == null) + return; + + switch (slot) + { + case CHEST: + equipment.setChestplate(itemStack); + break; + case FEET: + equipment.setBoots(itemStack); + break; + case HAND: + equipment.setItemInMainHand(itemStack); + break; + case HEAD: + equipment.setHelmet(itemStack); + break; + case LEGS: + equipment.setLeggings(itemStack); + break; + case OFF_HAND: + equipment.setItemInOffHand(itemStack); + break; } } - public ItemStack getItemStack(EquipmentSlot slot) { - if (equipment == null) return null; - switch (slot) { - case CHEST: - return equipment.getChestplate(); - case FEET: - return equipment.getBoots(); - case HAND: - return equipment.getItemInMainHand(); - case HEAD: - return equipment.getHelmet(); - case LEGS: - return equipment.getLeggings(); - case OFF_HAND: - return equipment.getItemInOffHand(); + public ItemStack getItemStack(EquipmentSlot slot) + { + if (equipment == null) + return null; + + switch (slot) + { + case CHEST: + return equipment.getChestplate(); + case FEET: + return equipment.getBoots(); + case HAND: + return equipment.getItemInMainHand(); + case HEAD: + return equipment.getHelmet(); + case LEGS: + return equipment.getLeggings(); + case OFF_HAND: + return equipment.getItemInOffHand(); } + return null; } - public void setRightClicking(boolean setRightClicking) { + public void setRightClicking(boolean setRightClicking) + { setEntityFlag(4, setRightClicking); sendData(0); } - public void setSneaking(boolean setSneaking) { + public void setSneaking(boolean setSneaking) + { setEntityFlag(1, setSneaking); sendData(0); } - public void setSprinting(boolean setSprinting) { + public void setSprinting(boolean setSprinting) + { setEntityFlag(3, setSprinting); sendData(0); } - protected void setValue(int id, Object value) { + protected void setValue(int id, Object value) + { entityValues.put(id, value); - if (!DisguiseConfig.isMetadataPacketsEnabled()) { + + if (!DisguiseConfig.isMetadataPacketsEnabled()) + { this.rebuildWatchableObjects(); } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java rename to src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java index ccdbfc5a..9d0c792d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java @@ -1,15 +1,16 @@ package me.libraryaddict.disguise.disguisetypes; -import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher; +import java.security.InvalidParameterException; + import org.bukkit.Art; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.security.InvalidParameterException; +import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher; public class MiscDisguise extends TargetedDisguise { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java rename to src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java index 7c430d99..63b1f8e7 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/MobDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java @@ -2,14 +2,14 @@ package me.libraryaddict.disguise.disguisetypes; import java.security.InvalidParameterException; -import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; - import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; + public class MobDisguise extends TargetedDisguise { private boolean isAdult; diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java rename to src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java index dcf287b7..6cb6a812 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.java @@ -1,14 +1,16 @@ package me.libraryaddict.disguise.disguisetypes; +import org.apache.commons.lang.Validate; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + import com.comphenix.protocol.wrappers.WrappedGameProfile; + import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsProfileLookup; import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.apache.commons.lang.Validate; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; public class PlayerDisguise extends TargetedDisguise { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/RabbitType.java b/src/me/libraryaddict/disguise/disguisetypes/RabbitType.java similarity index 55% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/RabbitType.java rename to src/me/libraryaddict/disguise/disguisetypes/RabbitType.java index 143748a8..0f74e5bf 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/RabbitType.java +++ b/src/me/libraryaddict/disguise/disguisetypes/RabbitType.java @@ -1,25 +1,32 @@ package me.libraryaddict.disguise.disguisetypes; -public enum RabbitType { +public enum RabbitType +{ BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1); - public static RabbitType getType(int id) { - for (RabbitType type : values()) { - if (type.getTypeId() == id) { + public static RabbitType getType(int id) + { + for (RabbitType type : values()) + { + if (type.getTypeId() == id) + { return type; } } + return null; } private int type; - RabbitType(int type) { + RabbitType(int type) + { this.type = type; } - public int getTypeId() { + public int getTypeId() + { return type; } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java similarity index 66% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java rename to src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java index 1a21b577..357632c2 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.java @@ -1,93 +1,127 @@ package me.libraryaddict.disguise.disguisetypes; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import org.bukkit.entity.Player; - import java.util.ArrayList; import java.util.Collections; import java.util.List; -public abstract class TargetedDisguise extends Disguise { +import org.bukkit.entity.Player; - public enum TargetType { +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; + +public abstract class TargetedDisguise extends Disguise +{ + + public enum TargetType + { HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS } private List disguiseViewers = new ArrayList<>(); private TargetType targetType = TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; - public TargetedDisguise addPlayer(Player player) { + public TargetedDisguise addPlayer(Player player) + { addPlayer(player.getName()); + return this; } - public TargetedDisguise addPlayer(String playername) { - if (!disguiseViewers.contains(playername)) { + public TargetedDisguise addPlayer(String playername) + { + if (!disguiseViewers.contains(playername)) + { disguiseViewers.add(playername); - if (DisguiseAPI.isDisguiseInUse(this)) { + + if (DisguiseAPI.isDisguiseInUse(this)) + { DisguiseUtilities.checkConflicts(this, playername); DisguiseUtilities.refreshTracker(this, playername); } } + return this; } - public boolean canSee(Player player) { + public boolean canSee(Player player) + { return canSee(player.getName()); } - public boolean canSee(String playername) { + public boolean canSee(String playername) + { boolean hasPlayer = disguiseViewers.contains(playername); - if (targetType == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + + if (targetType == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) + { return !hasPlayer; } + return hasPlayer; } - public TargetType getDisguiseTarget() { + public TargetType getDisguiseTarget() + { return targetType; } - public List getObservers() { + public List getObservers() + { return Collections.unmodifiableList(disguiseViewers); } - public TargetedDisguise removePlayer(Player player) { + public TargetedDisguise removePlayer(Player player) + { removePlayer(player.getName()); + return this; } - public TargetedDisguise removePlayer(String playername) { - if (disguiseViewers.contains(playername)) { + public TargetedDisguise removePlayer(String playername) + { + if (disguiseViewers.contains(playername)) + { disguiseViewers.remove(playername); - if (DisguiseAPI.isDisguiseInUse(this)) { + + if (DisguiseAPI.isDisguiseInUse(this)) + { DisguiseUtilities.checkConflicts(this, playername); DisguiseUtilities.refreshTracker(this, playername); } } + return this; } - public TargetedDisguise setDisguiseTarget(TargetType newTargetType) { - if (DisguiseUtilities.isDisguiseInUse(this)) { + public TargetedDisguise setDisguiseTarget(TargetType newTargetType) + { + if (DisguiseUtilities.isDisguiseInUse(this)) + { throw new RuntimeException("Cannot set the disguise target after the entity has been disguised"); } + targetType = newTargetType; + return this; } - public TargetedDisguise silentlyAddPlayer(String playername) { - if (!disguiseViewers.contains(playername)) { + public TargetedDisguise silentlyAddPlayer(String playername) + { + if (!disguiseViewers.contains(playername)) + { disguiseViewers.add(playername); } + return this; } - public TargetedDisguise silentlyRemovePlayer(String playername) { - if (disguiseViewers.contains(playername)) { + public TargetedDisguise silentlyRemovePlayer(String playername) + { + if (disguiseViewers.contains(playername)) + { disguiseViewers.remove(playername); } + return this; } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java index e5a1d9f9..bca9192e 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import me.libraryaddict.disguise.disguisetypes.Disguise; import org.bukkit.entity.Entity; +import me.libraryaddict.disguise.disguisetypes.Disguise; + public class AgeableWatcher extends LivingWatcher { public AgeableWatcher(Disguise disguise) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java similarity index 97% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java index 66f721dd..acfee458 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java @@ -1,10 +1,10 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import java.awt.Color; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import java.awt.*; - /** * @author Navid */ diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java similarity index 53% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java index d5562d85..32b7f894 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java @@ -2,68 +2,85 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -public class ArmorStandWatcher extends LivingWatcher { +public class ArmorStandWatcher extends LivingWatcher +{ - public ArmorStandWatcher(Disguise disguise) { + public ArmorStandWatcher(Disguise disguise) + { super(disguise); } - private boolean getArmorStandFlag(int value) { - return ((byte) getValue(10, 0) & value) != 0; + private boolean getArmorStandFlag(int value) + { + return (getValue(10, 0) & value) != 0; } - public boolean isNoBasePlate() { + public boolean isNoBasePlate() + { return getArmorStandFlag(8); } - public boolean isNoGravity() { + public boolean isNoGravity() + { return getArmorStandFlag(2); } - public boolean isShowArms() { + public boolean isShowArms() + { return getArmorStandFlag(4); } - public boolean isSmall() { + public boolean isSmall() + { return getArmorStandFlag(1); } - public boolean isMarker() { + public boolean isMarker() + { return getArmorStandFlag(10); } - private void setArmorStandFlag(int value, boolean isTrue) { + private void setArmorStandFlag(int value, boolean isTrue) + { byte b1 = (byte) getValue(10, (byte) 0); - if (isTrue) { + if (isTrue) + { b1 = (byte) (b1 | value); - } else { + } + else + { b1 = (byte) (b1 & value); } setValue(10, b1); sendData(10); } - public void setNoBasePlate(boolean noBasePlate) { + public void setNoBasePlate(boolean noBasePlate) + { setArmorStandFlag(8, noBasePlate); sendData(10); } - public void setNoGravity(boolean noGravity) { + public void setNoGravity(boolean noGravity) + { setArmorStandFlag(2, noGravity); sendData(10); } - public void setShowArms(boolean showArms) { + public void setShowArms(boolean showArms) + { setArmorStandFlag(4, showArms); sendData(10); } - public void setSmall(boolean isSmall) { + public void setSmall(boolean isSmall) + { setArmorStandFlag(1, isSmall); sendData(10); } - public void setMarker(boolean isMarker) { + public void setMarker(boolean isMarker) + { setArmorStandFlag(10, isMarker); sendData(10); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java similarity index 58% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java index 675c7378..6e8d4f57 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java @@ -2,17 +2,20 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -public class BlazeWatcher extends LivingWatcher { - - public BlazeWatcher(Disguise disguise) { +public class BlazeWatcher extends LivingWatcher +{ + public BlazeWatcher(Disguise disguise) + { super(disguise); } - public boolean isBlazing() { + public boolean isBlazing() + { return (boolean) getValue(11, false); } - public void setBlazing(boolean isBlazing) { + public void setBlazing(boolean isBlazing) + { setValue(11, isBlazing); sendData(11); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java similarity index 52% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java index e848e5ad..2eca213b 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java @@ -3,22 +3,25 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -public class BoatWatcher extends FlagWatcher { +public class BoatWatcher extends FlagWatcher +{ - //TODO: Add stuff for new boat values + // TODO: Add stuff for new boat values - public BoatWatcher(Disguise disguise) { + public BoatWatcher(Disguise disguise) + { super(disguise); } - public int getDamage() { - return (int) getValue(7, 40F); + public float getDamage() + { + return getValue(7, 40F); } - public void setDamage(float dmg) { + public void setDamage(float dmg) + { setValue(7, dmg); sendData(7); } - } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java index 236a100e..04b28ccf 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.inventory.ItemStack; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import org.bukkit.inventory.ItemStack; //TODO: Add support for custom items instead of just stone public class DroppedItemWatcher extends FlagWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java similarity index 64% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java index 4ca31e66..2666d2e3 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java @@ -2,35 +2,40 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import com.comphenix.protocol.wrappers.BlockPosition; import com.google.common.base.Optional; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; /** * @author Navid */ -public class EnderCrystalWatcher extends FlagWatcher { - - public EnderCrystalWatcher(Disguise disguise) { +public class EnderCrystalWatcher extends FlagWatcher +{ + public EnderCrystalWatcher(Disguise disguise) + { super(disguise); } - public void setBeamTarget(BlockPosition position) { + public void setBeamTarget(BlockPosition position) + { setValue(5, Optional.of(position)); sendData(5); } - public Optional getBeamTarget() { + public Optional getBeamTarget() + { return (Optional) getValue(5, Optional.absent()); } - public void setShowBottom(boolean bool) { + public void setShowBottom(boolean bool) + { setValue(6, bool); sendData(6); } - public boolean isShowBottom() { + public boolean isShowBottom() + { return (boolean) getValue(6, false); } - } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java index 7f49b2a3..20daf454 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java @@ -1,11 +1,13 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import com.google.common.base.Optional; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.utilities.ReflectionManager; import org.apache.commons.lang3.tuple.Pair; import org.bukkit.inventory.ItemStack; +import com.google.common.base.Optional; + +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.utilities.ReflectionManager; + public class EndermanWatcher extends LivingWatcher { public EndermanWatcher(Disguise disguise) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java index 31faa748..b71ab1ab 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java @@ -1,11 +1,12 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class FallingBlockWatcher extends FlagWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java index e0a45591..b8a3629c 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java @@ -1,9 +1,10 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import me.libraryaddict.disguise.disguisetypes.Disguise; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import me.libraryaddict.disguise.disguisetypes.Disguise; + public class GuardianWatcher extends LivingWatcher { public GuardianWatcher(Disguise disguise) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java similarity index 52% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java index d1fec1fa..3e8fe68d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java @@ -1,177 +1,222 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import com.google.common.base.Optional; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import java.util.UUID; + import org.bukkit.Material; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; import org.bukkit.inventory.ItemStack; -import java.util.UUID; +import com.google.common.base.Optional; -public class HorseWatcher extends AgeableWatcher { +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; - public HorseWatcher(Disguise disguise) { +public class HorseWatcher extends AgeableWatcher +{ + + public HorseWatcher(Disguise disguise) + { super(disguise); setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]); setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]); } - public Variant getVariant() { + public Variant getVariant() + { return Variant.values()[(int) getValue(13, 0)]; } - public void setVariant(Variant variant) { + public void setVariant(Variant variant) + { setVariant(variant.ordinal()); } - public void setVariant(int variant) { - if (variant < 0 || variant > 4) { - variant = 0; //Crashing people is mean + public void setVariant(int variant) + { + if (variant < 0 || variant > 4) + { + variant = 0; // Crashing people is mean } setValue(13, variant); sendData(13); } - public Color getColor() { + public Color getColor() + { return Color.values()[((Integer) getValue(14, 0) & 0xFF)]; } - public ItemStack getHorseArmor() { + public ItemStack getHorseArmor() + { int horseValue = getHorseArmorAsInt(); - switch (horseValue) { - case 1: - return new ItemStack(Material.getMaterial("IRON_BARDING")); - case 2: - return new ItemStack(Material.getMaterial("GOLD_BARDING")); - case 3: - return new ItemStack(Material.getMaterial("DIAMOND_BARDING")); - default: - break; + switch (horseValue) + { + case 1: + return new ItemStack(Material.getMaterial("IRON_BARDING")); + case 2: + return new ItemStack(Material.getMaterial("GOLD_BARDING")); + case 3: + return new ItemStack(Material.getMaterial("DIAMOND_BARDING")); + default: + break; } return null; } - protected int getHorseArmorAsInt() { + protected int getHorseArmorAsInt() + { return (int) getValue(16, 0); } - public Optional getOwner() { - return (Optional) getValue(15, Optional.absent()); + public Optional getOwner() + { + return getValue(15, Optional. absent()); } - public Style getStyle() { + public Style getStyle() + { return Style.values()[((int) getValue(14, 0) >>> 8)]; } - public boolean hasChest() { + public boolean hasChest() + { return isHorseFlag(8); } - public boolean isBreedable() { + public boolean isBreedable() + { return isHorseFlag(16); } - public boolean isGrazing() { + public boolean isGrazing() + { return isHorseFlag(32); } - public boolean isMouthOpen() { + public boolean isMouthOpen() + { return isHorseFlag(128); } - public boolean isRearing() { + public boolean isRearing() + { return isHorseFlag(64); } - public boolean isSaddled() { + public boolean isSaddled() + { return isHorseFlag(4); } - public boolean isTamed() { + public boolean isTamed() + { return isHorseFlag(2); } - private boolean isHorseFlag(int i) { + private boolean isHorseFlag(int i) + { return (getHorseFlag() & i) != 0; } - private byte getHorseFlag() { + private byte getHorseFlag() + { return (byte) getValue(12, (byte) 0); } - public void setCanBreed(boolean breed) { + public void setCanBreed(boolean breed) + { setHorseFlag(16, breed); } - public void setCarryingChest(boolean chest) { + public void setCarryingChest(boolean chest) + { setHorseFlag(8, chest); } - public void setColor(Color color) { + public void setColor(Color color) + { setValue(14, color.ordinal() & 0xFF | getStyle().ordinal() << 8); sendData(14); } - private void setHorseFlag(int i, boolean flag) { + private void setHorseFlag(int i, boolean flag) + { byte j = (byte) getValue(12, (byte) 0); - if (flag) { + if (flag) + { setValue(12, (byte) (j | i)); - } else { + } + else + { setValue(12, (byte) (j & ~i)); } sendData(12); } - public void setGrazing(boolean grazing) { + public void setGrazing(boolean grazing) + { setHorseFlag(32, grazing); } - protected void setHorseArmor(int armor) { + protected void setHorseArmor(int armor) + { setValue(16, armor); sendData(16); } - public void setHorseArmor(ItemStack item) { + public void setHorseArmor(ItemStack item) + { int value = 0; - if (item != null) { + if (item != null) + { Material mat = item.getType(); - if (mat == Material.IRON_BARDING) { + if (mat == Material.IRON_BARDING) + { value = 1; - } else if (mat == Material.GOLD_BARDING) { + } + else if (mat == Material.GOLD_BARDING) + { value = 2; - } else if (mat == Material.DIAMOND_BARDING) { + } + else if (mat == Material.DIAMOND_BARDING) + { value = 3; } } setHorseArmor(value); } - public void setMouthOpen(boolean mouthOpen) { + public void setMouthOpen(boolean mouthOpen) + { setHorseFlag(128, mouthOpen); } - public void setOwner(UUID uuid) { + public void setOwner(UUID uuid) + { setValue(15, Optional.of(uuid)); sendData(15); } - public void setRearing(boolean rear) { + public void setRearing(boolean rear) + { setHorseFlag(64, rear); } - public void setSaddled(boolean saddled) { + public void setSaddled(boolean saddled) + { setHorseFlag(4, saddled); } - public void setStyle(Style style) { + public void setStyle(Style style) + { setValue(14, getColor().ordinal() & 0xFF | style.ordinal() << 8); sendData(14); } - public void setTamed(boolean tamed) { + public void setTamed(boolean tamed) + { setHorseFlag(2, tamed); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java index a6483d51..cccd5881 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.inventory.ItemStack; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import org.bukkit.inventory.ItemStack; public class ItemFrameWatcher extends FlagWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java similarity index 73% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index b0a3609b..b237018c 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -1,19 +1,5 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import com.comphenix.protocol.PacketType.Play.Server; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.WrappedAttribute; -import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -22,64 +8,98 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -public class LivingWatcher extends FlagWatcher { +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; + +import com.comphenix.protocol.PacketType.Play.Server; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedAttribute; +import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; + +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.FlagWatcher; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.ReflectionManager; + +public class LivingWatcher extends FlagWatcher +{ static Map list = new HashMap<>(); static Method getId; - static { - try { + static + { + try + { getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList")); Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null); - for (Object next: ((Iterable)REGISTRY)) { + for (Object next : ((Iterable) REGISTRY)) + { int id = (int) getId.invoke(null, next); list.put(id, next); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } + private double maxHealth; private boolean maxHealthSet; private HashSet potionEffects = new HashSet<>(); - public LivingWatcher(Disguise disguise) { + public LivingWatcher(Disguise disguise) + { super(disguise); } - public void addPotionEffect(PotionEffectType potionEffect) { - if (!hasPotionEffect(potionEffect)) { + public void addPotionEffect(PotionEffectType potionEffect) + { + if (!hasPotionEffect(potionEffect)) + { removePotionEffect(potionEffect); potionEffects.add(potionEffect.getId()); + sendPotionEffects(); } } @Override - public LivingWatcher clone(Disguise disguise) { + public LivingWatcher clone(Disguise disguise) + { LivingWatcher clone = (LivingWatcher) super.clone(disguise); clone.potionEffects = (HashSet) potionEffects.clone(); clone.maxHealth = maxHealth; clone.maxHealthSet = maxHealthSet; + return clone; } - public float getHealth() { + public float getHealth() + { return (float) getValue(6, 0F); } - public double getMaxHealth() { + public double getMaxHealth() + { return maxHealth; } - public boolean isPotionParticlesAmbient() { + public boolean isPotionParticlesAmbient() + { return (boolean) getValue(8, false); } - private int getPotions() { + private int getPotions() + { int m = 3694022; - if (potionEffects.isEmpty()) { + if (potionEffects.isEmpty()) + { return m; } @@ -87,15 +107,19 @@ public class LivingWatcher extends FlagWatcher { float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; - try { - for (int localMobEffect : potionEffects) { + try + { + for (int localMobEffect : potionEffects) + { int n = (Integer) getId.invoke(list.get(localMobEffect)); f1 += (n >> 16 & 0xFF) / 255.0F; f2 += (n >> 8 & 0xFF) / 255.0F; f3 += (n & 0xFF) / 255.0F; f4 += 1.0F; } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } @@ -106,64 +130,86 @@ public class LivingWatcher extends FlagWatcher { return (int) f1 << 16 | (int) f2 << 8 | (int) f3; } - public boolean hasPotionEffect(PotionEffectType type) { + public boolean hasPotionEffect(PotionEffectType type) + { return potionEffects.contains(type.getId()); } - public boolean isMaxHealthSet() { + public boolean isMaxHealthSet() + { return maxHealthSet; } - public void removePotionEffect(PotionEffectType type) { - if (potionEffects.contains(type.getId())) { + public void removePotionEffect(PotionEffectType type) + { + if (potionEffects.contains(type.getId())) + { potionEffects.remove(type.getId()); sendPotionEffects(); } } - public void setPotionParticlesAmbient(boolean particles) { + public void setPotionParticlesAmbient(boolean particles) + { setValue(8, particles); sendData(8); } - private void sendPotionEffects() { + private void sendPotionEffects() + { setValue(7, getPotions()); sendData(7); } - public void setHealth(float health) { + public void setHealth(float health) + { setValue(6, health); sendData(6); } - public int getArrowsSticking() { + public int getArrowsSticking() + { return (int) getValue(9, 0); } - public void setArrowsSticking(int arrowsNo) { + public void setArrowsSticking(int arrowsNo) + { setValue(9, arrowsNo); sendData(9); } - public void setMaxHealth(double newHealth) { + public void setMaxHealth(double newHealth) + { this.maxHealth = newHealth; this.maxHealthSet = true; - if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { + + if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) + { PacketContainer packet = new PacketContainer(Server.UPDATE_ATTRIBUTES); + List attributes = new ArrayList<>(); + Builder builder; builder = WrappedAttribute.newBuilder(); builder.attributeKey("generic.maxHealth"); builder.baseValue(getMaxHealth()); builder.packet(packet); + attributes.add(builder.build()); + Entity entity = getDisguise().getEntity(); + packet.getIntegers().write(0, entity.getEntityId()); packet.getAttributeCollectionModifier().write(0, attributes); - for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { - try { + + for (Player player : DisguiseUtilities.getPerverts(getDisguise())) + { + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java index 8cf490d9..58a13562 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.inventory.ItemStack; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import org.bukkit.inventory.ItemStack; public class MinecartWatcher extends FlagWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java index 70450436..83a71d1d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java @@ -1,9 +1,10 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import me.libraryaddict.disguise.disguisetypes.Disguise; import org.bukkit.entity.Ocelot; import org.bukkit.entity.Ocelot.Type; +import me.libraryaddict.disguise.disguisetypes.Disguise; + public class OcelotWatcher extends TameableWatcher { public OcelotWatcher(Disguise disguise) { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java index 944c66cb..9d72b060 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java @@ -1,9 +1,10 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.Art; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import org.bukkit.Art; public class PaintingWatcher extends FlagWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 348b218d..3e9ab94c 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -1,17 +1,19 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + import com.comphenix.protocol.PacketType.Play.Server; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.WrappedGameProfile; + import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; public class PlayerWatcher extends LivingWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java index 6231a3e4..204ef3c3 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.DyeColor; + import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import org.bukkit.DyeColor; public class SheepWatcher extends AgeableWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java index b41add41..a5e7fb5a 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java @@ -1,9 +1,11 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.block.BlockFace; + import com.comphenix.protocol.wrappers.BlockPosition; import com.google.common.base.Optional; + import me.libraryaddict.disguise.disguisetypes.Disguise; -import org.bukkit.block.BlockFace; /** * @author Navid diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java index ad010ad5..26910584 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import me.libraryaddict.disguise.disguisetypes.Disguise; import org.bukkit.entity.Skeleton.SkeletonType; +import me.libraryaddict.disguise.disguisetypes.Disguise; + /** * @author Navid */ diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java similarity index 54% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java index dfeb5344..1135d890 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java @@ -1,52 +1,66 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import com.google.common.base.Optional; -import me.libraryaddict.disguise.disguisetypes.Disguise; - import java.util.UUID; -public class TameableWatcher extends AgeableWatcher { +import com.google.common.base.Optional; - public TameableWatcher(Disguise disguise) { +import me.libraryaddict.disguise.disguisetypes.Disguise; + +public class TameableWatcher extends AgeableWatcher +{ + + public TameableWatcher(Disguise disguise) + { super(disguise); } - public Optional getOwner() { - return (Optional) getValue(13, Optional.absent()); + public Optional getOwner() + { + return getValue(13, Optional. absent()); } - public boolean isSitting() { + public boolean isSitting() + { return isTameableFlag(1); } - public boolean isTamed() { + public boolean isTamed() + { return isTameableFlag(4); } - protected boolean isTameableFlag(int no) { + protected boolean isTameableFlag(int no) + { return ((byte) getValue(12, (byte) 0) & no) != 0; } - protected void setTameableFlag(int no, boolean flag) { + protected void setTameableFlag(int no, boolean flag) + { byte value = (byte) getValue(12, (byte) 0); - if (flag) { + if (flag) + { setValue(12, (byte) (value | no)); - } else { + } + else + { setValue(12, (byte) (value & -(no + 1))); } sendData(12); } - public void setOwner(UUID owner) { + public void setOwner(UUID owner) + { setValue(13, Optional.of(owner)); sendData(13); } - public void setSitting(boolean sitting) { + public void setSitting(boolean sitting) + { setTameableFlag(1, sitting); } - public void setTamed(boolean tamed) { + public void setTamed(boolean tamed) + { setTameableFlag(4, tamed); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java index 953b54e2..121e5fb0 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.Color; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import org.bukkit.Color; /** * @author Navid diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java index 91f46e85..96ab0f89 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.entity.Villager.Profession; + import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import org.bukkit.entity.Villager.Profession; public class VillagerWatcher extends AgeableWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java index fb482c34..3414f15e 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java @@ -1,9 +1,10 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import me.libraryaddict.disguise.disguisetypes.Disguise; +import java.security.InvalidParameterException; + import org.bukkit.ChatColor; -import java.security.InvalidParameterException; +import me.libraryaddict.disguise.disguisetypes.Disguise; public class WitherWatcher extends LivingWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java index 1f35bc01..b881df27 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import org.bukkit.DyeColor; + import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import org.bukkit.DyeColor; public class WolfWatcher extends TameableWatcher { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java rename to src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java index 09ca4537..039db9ea 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java @@ -1,8 +1,9 @@ package me.libraryaddict.disguise.disguisetypes.watchers; -import me.libraryaddict.disguise.disguisetypes.Disguise; import org.bukkit.entity.Villager.Profession; +import me.libraryaddict.disguise.disguisetypes.Disguise; + public class ZombieWatcher extends LivingWatcher { public ZombieWatcher(Disguise disguise) { diff --git a/src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java b/src/me/libraryaddict/disguise/events/DisguiseEvent.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java rename to src/me/libraryaddict/disguise/events/DisguiseEvent.java index 1f6ea041..c8d99951 100644 --- a/src/main/java/me/libraryaddict/disguise/events/DisguiseEvent.java +++ b/src/me/libraryaddict/disguise/events/DisguiseEvent.java @@ -1,12 +1,12 @@ package me.libraryaddict.disguise.events; -import me.libraryaddict.disguise.disguisetypes.Disguise; - import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import me.libraryaddict.disguise.disguisetypes.Disguise; + public class DisguiseEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); diff --git a/src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java b/src/me/libraryaddict/disguise/events/UndisguiseEvent.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java rename to src/me/libraryaddict/disguise/events/UndisguiseEvent.java index 1ae228d6..4296f55f 100644 --- a/src/main/java/me/libraryaddict/disguise/events/UndisguiseEvent.java +++ b/src/me/libraryaddict/disguise/events/UndisguiseEvent.java @@ -1,12 +1,12 @@ package me.libraryaddict.disguise.events; -import me.libraryaddict.disguise.disguisetypes.Disguise; - import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import me.libraryaddict.disguise.disguisetypes.Disguise; + public class UndisguiseEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java b/src/me/libraryaddict/disguise/utilities/ClassGetter.java similarity index 78% rename from src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java rename to src/me/libraryaddict/disguise/utilities/ClassGetter.java index a05dd781..f1018a63 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/ClassGetter.java +++ b/src/me/libraryaddict/disguise/utilities/ClassGetter.java @@ -1,7 +1,5 @@ package me.libraryaddict.disguise.utilities; -import org.bukkit.entity.Entity; - import java.net.URL; import java.net.URLDecoder; import java.security.CodeSource; @@ -10,60 +8,81 @@ import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import org.bukkit.entity.Entity; + /** * 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 { +public class ClassGetter +{ - public static ArrayList> getClassesForPackage(String pkgname) { + public static ArrayList> getClassesForPackage(String pkgname) + { ArrayList> classes = new ArrayList<>(); // String relPath = pkgname.replace('.', '/'); // Get a File object for the package CodeSource src = Entity.class.getProtectionDomain().getCodeSource(); - if (src != null) { + + if (src != null) + { URL resource = src.getLocation(); resource.getPath(); processJarfile(resource, pkgname, classes); } + return classes; } - private static Class loadClass(String className) { - try { + private static Class loadClass(String className) + { + try + { return Class.forName(className); - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) + { throw new RuntimeException("Unexpected ClassNotFoundException loading class '" + className + "'"); - } catch (NoClassDefFoundError e) { + } + catch (NoClassDefFoundError e) + { return null; } } - private static void processJarfile(URL resource, String pkgname, ArrayList> classes) { - try { + private static void processJarfile(URL resource, String pkgname, ArrayList> classes) + { + try + { String relPath = pkgname.replace('.', '/'); String resPath = URLDecoder.decode(resource.getPath(), "UTF-8"); String jarPath = resPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", ""); JarFile jarFile = new JarFile(jarPath); Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { + while (entries.hasMoreElements()) + { JarEntry entry = entries.nextElement(); String entryName = entry.getName(); String className = null; if (entryName.endsWith(".class") && entryName.startsWith(relPath) - && entryName.length() > (relPath.length() + "/".length())) { + && entryName.length() > (relPath.length() + "/".length())) + { className = entryName.replace('/', '.').replace('\\', '.').replace(".class", ""); } - if (className != null) { + if (className != null) + { Class c = loadClass(className); - if (c != null) { + if (c != null) + { classes.add(c); } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java b/src/me/libraryaddict/disguise/utilities/DisguiseSound.java similarity index 52% rename from src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java rename to src/me/libraryaddict/disguise/utilities/DisguiseSound.java index 82a3a561..cf9a17b8 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseSound.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseSound.java @@ -1,87 +1,145 @@ package me.libraryaddict.disguise.utilities; -import org.bukkit.Sound; - import java.util.HashMap; import java.util.HashSet; +import org.bukkit.Sound; + /** * Only living disguises go in here! */ -public enum DisguiseSound { +public enum DisguiseSound +{ ARROW(null, null, null, null, Sound.ENTITY_ARROW_HIT, Sound.ENTITY_ARROW_SHOOT), - BAT(Sound.ENTITY_BAT_HURT, null, Sound.ENTITY_BAT_DEATH, Sound.ENTITY_BAT_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_BAT_LOOP, Sound.ENTITY_PLAYER_BIG_FALL, - Sound.ENTITY_BAT_TAKEOFF), - BLAZE(Sound.ENTITY_BLAZE_HURT, null, Sound.ENTITY_BLAZE_DEATH, Sound.ENTITY_BLAZE_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_PLAYER_BIG_FALL), + + BAT(Sound.ENTITY_BAT_HURT, null, Sound.ENTITY_BAT_DEATH, Sound.ENTITY_BAT_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, + Sound.ENTITY_BAT_LOOP, Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_BAT_TAKEOFF), + + BLAZE(Sound.ENTITY_BLAZE_HURT, null, Sound.ENTITY_BLAZE_DEATH, Sound.ENTITY_BLAZE_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, + Sound.ENTITY_PLAYER_BIG_FALL), + CAVE_SPIDER(Sound.ENTITY_SPIDER_AMBIENT, Sound.ENTITY_SPIDER_STEP, Sound.ENTITY_SPIDER_DEATH, Sound.ENTITY_SPIDER_AMBIENT), - CHICKEN(Sound.ENTITY_CHICKEN_HURT, Sound.ENTITY_CHICKEN_STEP, Sound.ENTITY_CHICKEN_HURT, Sound.ENTITY_CHICKEN_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, - Sound.ENTITY_CHICKEN_EGG, Sound.ENTITY_PLAYER_BIG_FALL), + + CHICKEN(Sound.ENTITY_CHICKEN_HURT, Sound.ENTITY_CHICKEN_STEP, Sound.ENTITY_CHICKEN_HURT, Sound.ENTITY_CHICKEN_AMBIENT, + Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_CHICKEN_EGG, Sound.ENTITY_PLAYER_BIG_FALL), + COW(Sound.ENTITY_COW_HURT, Sound.ENTITY_COW_STEP, Sound.ENTITY_COW_DEATH, Sound.ENTITY_COW_AMBIENT), + CREEPER(Sound.ENTITY_CREEPER_HURT, "step.grass", Sound.ENTITY_CREEPER_DEATH, null), - DONKEY(Sound.ENTITY_DONKEY_HURT, "step.grass", Sound.ENTITY_DONKEY_DEATH, Sound.ENTITY_DONKEY_AMBIENT, Sound.ENTITY_HORSE_GALLOP, - Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, - Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY), - ELDER_GUARDIAN(Sound.ENTITY_ELDER_GUARDIAN_HURT, null, Sound.ENTITY_ELDER_GUARDIAN_DEATH, Sound.ENTITY_ELDER_GUARDIAN_AMBIENT), - ENDER_DRAGON(Sound.ENTITY_ENDERDRAGON_HURT, null, Sound.ENTITY_ENDERDRAGON_DEATH, Sound.ENTITY_ENDERDRAGON_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, - Sound.ENTITY_ENDERDRAGON_FLAP, Sound.ENTITY_PLAYER_BIG_FALL), - ENDERMAN(Sound.ENTITY_ENDERMEN_HURT, "step.grass", Sound.ENTITY_ENDERMEN_DEATH, Sound.ENTITY_ENDERMEN_AMBIENT, Sound.ENTITY_ENDERMEN_SCREAM, - Sound.ENTITY_ENDERMEN_TELEPORT, Sound.ENTITY_ENDERMEN_STARE), - ENDERMITE(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_ENDERMITE_STEP, Sound.ENTITY_ENDERMITE_DEATH, Sound.ENTITY_ENDERMITE_AMBIENT), - GHAST(Sound.ENTITY_GHAST_HURT, null, Sound.ENTITY_GHAST_DEATH, Sound.ENTITY_GHAST_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_GHAST_SHOOT, - Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_GHAST_SCREAM, Sound.ENTITY_GHAST_WARN), + + DONKEY(Sound.ENTITY_DONKEY_HURT, "step.grass", Sound.ENTITY_DONKEY_DEATH, Sound.ENTITY_DONKEY_AMBIENT, + Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, + Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY), + + ELDER_GUARDIAN(Sound.ENTITY_ELDER_GUARDIAN_HURT, null, Sound.ENTITY_ELDER_GUARDIAN_DEATH, + Sound.ENTITY_ELDER_GUARDIAN_AMBIENT), + + ENDER_DRAGON(Sound.ENTITY_ENDERDRAGON_HURT, null, Sound.ENTITY_ENDERDRAGON_DEATH, Sound.ENTITY_ENDERDRAGON_AMBIENT, + Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_ENDERDRAGON_FLAP, Sound.ENTITY_PLAYER_BIG_FALL), + + ENDERMAN(Sound.ENTITY_ENDERMEN_HURT, "step.grass", Sound.ENTITY_ENDERMEN_DEATH, Sound.ENTITY_ENDERMEN_AMBIENT, + Sound.ENTITY_ENDERMEN_SCREAM, Sound.ENTITY_ENDERMEN_TELEPORT, Sound.ENTITY_ENDERMEN_STARE), + + ENDERMITE(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_ENDERMITE_STEP, Sound.ENTITY_ENDERMITE_DEATH, + Sound.ENTITY_ENDERMITE_AMBIENT), + + GHAST(Sound.ENTITY_GHAST_HURT, null, Sound.ENTITY_GHAST_DEATH, Sound.ENTITY_GHAST_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, + Sound.ENTITY_GHAST_SHOOT, Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_GHAST_SCREAM, Sound.ENTITY_GHAST_WARN), + GIANT(Sound.ENTITY_PLAYER_HURT, "step.grass", null, null), + GUARDIAN(Sound.ENTITY_GUARDIAN_HURT, null, Sound.ENTITY_GUARDIAN_DEATH, Sound.ENTITY_ELDER_GUARDIAN_AMBIENT), + HORSE(Sound.ENTITY_HORSE_HURT, "step.grass", Sound.ENTITY_HORSE_DEATH, Sound.ENTITY_HORSE_AMBIENT, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY), - IRON_GOLEM(Sound.ENTITY_IRONGOLEM_HURT, Sound.ENTITY_IRONGOLEM_STEP, Sound.ENTITY_IRONGOLEM_DEATH, Sound.ENTITY_IRONGOLEM_ATTACK), + + IRON_GOLEM(Sound.ENTITY_IRONGOLEM_HURT, Sound.ENTITY_IRONGOLEM_STEP, Sound.ENTITY_IRONGOLEM_DEATH, + Sound.ENTITY_IRONGOLEM_ATTACK), + MAGMA_CUBE(Sound.ENTITY_MAGMACUBE_HURT, Sound.ENTITY_MAGMACUBE_JUMP, null, null), + MULE(Sound.ENTITY_MULE_HURT, "step.grass", Sound.ENTITY_MULE_DEATH, Sound.ENTITY_MULE_AMBIENT), + MUSHROOM_COW(Sound.ENTITY_COW_HURT, Sound.ENTITY_COW_STEP, Sound.ENTITY_COW_HURT, Sound.ENTITY_COW_AMBIENT), - OCELOT(Sound.ENTITY_CAT_HURT, "step.grass", Sound.ENTITY_CAT_HURT, Sound.ENTITY_CAT_AMBIENT, Sound.ENTITY_CAT_PURR, Sound.ENTITY_CAT_PURREOW), + + OCELOT(Sound.ENTITY_CAT_HURT, "step.grass", Sound.ENTITY_CAT_HURT, Sound.ENTITY_CAT_AMBIENT, Sound.ENTITY_CAT_PURR, + Sound.ENTITY_CAT_PURREOW), + PIG(Sound.ENTITY_PIG_HURT, Sound.ENTITY_PIG_STEP, Sound.ENTITY_PIG_DEATH, Sound.ENTITY_PIG_AMBIENT), - PIG_ZOMBIE(Sound.ENTITY_ZOMBIE_PIG_HURT, null, Sound.ENTITY_ZOMBIE_PIG_DEATH, Sound.ENTITY_ZOMBIE_PIG_AMBIENT, Sound.ENTITY_ZOMBIE_PIG_ANGRY), + + PIG_ZOMBIE(Sound.ENTITY_ZOMBIE_PIG_HURT, null, Sound.ENTITY_ZOMBIE_PIG_DEATH, Sound.ENTITY_ZOMBIE_PIG_AMBIENT, + Sound.ENTITY_ZOMBIE_PIG_ANGRY), + PLAYER(Sound.ENTITY_PLAYER_HURT, "step.grass", Sound.ENTITY_PLAYER_DEATH, null), + RABBIT(Sound.ENTITY_RABBIT_HURT, Sound.ENTITY_RABBIT_JUMP, Sound.ENTITY_RABBIT_DEATH, Sound.ENTITY_RABBIT_AMBIENT), + SHEEP(Sound.ENTITY_SHEEP_HURT, Sound.ENTITY_SHEEP_STEP, null, Sound.ENTITY_SHEEP_AMBIENT, Sound.ENTITY_SHEEP_SHEAR), + SHULKER(Sound.ENTITY_SHULKER_HURT, null, Sound.ENTITY_SHULKER_DEATH, Sound.ENTITY_SHULKER_AMBIENT, Sound.ENTITY_SHULKER_OPEN, Sound.ENTITY_SHULKER_CLOSE, Sound.ENTITY_SHULKER_HURT_CLOSED, Sound.ENTITY_SHULKER_TELEPORT), - SILVERFISH(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_SILVERFISH_STEP, Sound.ENTITY_SILVERFISH_DEATH, Sound.ENTITY_SILVERFISH_AMBIENT), - SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH, Sound.ENTITY_SKELETON_AMBIENT), - SKELETON_HORSE(Sound.ENTITY_SKELETON_HORSE_HURT, "step.grass", Sound.ENTITY_SKELETON_HORSE_DEATH, Sound.ENTITY_SKELETON_HORSE_AMBIENT, - Sound.ENTITY_HORSE_GALLOP, - Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, - Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY), - SLIME(Sound.ENTITY_SLIME_HURT, Sound.ENTITY_SLIME_JUMP, Sound.ENTITY_SLIME_DEATH, null), - SNOWMAN(Sound.ENTITY_SNOWMAN_HURT, null, Sound.ENTITY_SNOWMAN_DEATH, Sound.ENTITY_SNOWMAN_AMBIENT, Sound.ENTITY_SNOWMAN_SHOOT), - SPIDER(Sound.ENTITY_SPIDER_AMBIENT, Sound.ENTITY_SPIDER_STEP, Sound.ENTITY_SPIDER_DEATH, Sound.ENTITY_SPIDER_AMBIENT), - SQUID(Sound.ENTITY_SQUID_HURT, null, Sound.ENTITY_SQUID_DEATH, Sound.ENTITY_SQUID_AMBIENT), - UNDEAD_HORSE(Sound.ENTITY_ZOMBIE_HORSE_HURT, "step.grass", Sound.ENTITY_ZOMBIE_HORSE_DEATH, Sound.ENTITY_ZOMBIE_HORSE_AMBIENT, Sound.ENTITY_HORSE_GALLOP, - Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, - Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY), - VILLAGER(Sound.ENTITY_VILLAGER_HURT, null, Sound.ENTITY_VILLAGER_DEATH, Sound.ENTITY_VILLAGER_AMBIENT, Sound.ENTITY_VILLAGER_TRADING, Sound.ENTITY_VILLAGER_NO, - Sound.ENTITY_VILLAGER_YES), - WITCH(Sound.ENTITY_WITCH_HURT, null, Sound.ENTITY_WITCH_DEATH, Sound.ENTITY_WITCH_AMBIENT), - WITHER(Sound.ENTITY_WITHER_HURT, null, Sound.ENTITY_WITHER_DEATH, Sound.ENTITY_WITHER_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_WITHER_SPAWN, - Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_WITHER_SHOOT), - WITHER_SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH, Sound.ENTITY_SKELETON_AMBIENT), - WOLF(Sound.ENTITY_WOLF_HURT, Sound.ENTITY_WOLF_STEP, Sound.ENTITY_WOLF_DEATH, Sound.ENTITY_WOLF_AMBIENT, Sound.ENTITY_WOLF_GROWL, Sound.ENTITY_WOLF_PANT, - Sound.ENTITY_WOLF_HOWL, Sound.ENTITY_WOLF_SHAKE, Sound.ENTITY_WOLF_WHINE), - ZOMBIE(Sound.ENTITY_ZOMBIE_HURT, Sound.ENTITY_ZOMBIE_STEP, Sound.ENTITY_ZOMBIE_DEATH, Sound.ENTITY_ZOMBIE_AMBIENT, - Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR), - ZOMBIE_VILLAGER(Sound.ENTITY_ZOMBIE_VILLAGER_HURT, Sound.ENTITY_ZOMBIE_VILLAGER_STEP, Sound.ENTITY_ZOMBIE_VILLAGER_DEATH, Sound.ENTITY_ZOMBIE_VILLAGER_AMBIENT, - Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR); - public enum SoundType { + SILVERFISH(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_SILVERFISH_STEP, Sound.ENTITY_SILVERFISH_DEATH, + Sound.ENTITY_SILVERFISH_AMBIENT), + + SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH, Sound.ENTITY_SKELETON_AMBIENT), + + SKELETON_HORSE(Sound.ENTITY_SKELETON_HORSE_HURT, "step.grass", Sound.ENTITY_SKELETON_HORSE_DEATH, + Sound.ENTITY_SKELETON_HORSE_AMBIENT, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, + Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, + Sound.ENTITY_HORSE_ANGRY), + + SLIME(Sound.ENTITY_SLIME_HURT, Sound.ENTITY_SLIME_JUMP, Sound.ENTITY_SLIME_DEATH, null), + + SNOWMAN(Sound.ENTITY_SNOWMAN_HURT, null, Sound.ENTITY_SNOWMAN_DEATH, Sound.ENTITY_SNOWMAN_AMBIENT, + Sound.ENTITY_SNOWMAN_SHOOT), + + SPIDER(Sound.ENTITY_SPIDER_AMBIENT, Sound.ENTITY_SPIDER_STEP, Sound.ENTITY_SPIDER_DEATH, Sound.ENTITY_SPIDER_AMBIENT), + + SQUID(Sound.ENTITY_SQUID_HURT, null, Sound.ENTITY_SQUID_DEATH, Sound.ENTITY_SQUID_AMBIENT), + + UNDEAD_HORSE(Sound.ENTITY_ZOMBIE_HORSE_HURT, "step.grass", Sound.ENTITY_ZOMBIE_HORSE_DEATH, Sound.ENTITY_ZOMBIE_HORSE_AMBIENT, + Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, + Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY), + + VILLAGER(Sound.ENTITY_VILLAGER_HURT, null, Sound.ENTITY_VILLAGER_DEATH, Sound.ENTITY_VILLAGER_AMBIENT, + Sound.ENTITY_VILLAGER_TRADING, Sound.ENTITY_VILLAGER_NO, Sound.ENTITY_VILLAGER_YES), + + WITCH(Sound.ENTITY_WITCH_HURT, null, Sound.ENTITY_WITCH_DEATH, Sound.ENTITY_WITCH_AMBIENT), + + WITHER(Sound.ENTITY_WITHER_HURT, null, Sound.ENTITY_WITHER_DEATH, Sound.ENTITY_WITHER_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, + Sound.ENTITY_WITHER_SPAWN, Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_WITHER_SHOOT), + + WITHER_SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH, + Sound.ENTITY_SKELETON_AMBIENT), + + WOLF(Sound.ENTITY_WOLF_HURT, Sound.ENTITY_WOLF_STEP, Sound.ENTITY_WOLF_DEATH, Sound.ENTITY_WOLF_AMBIENT, + Sound.ENTITY_WOLF_GROWL, Sound.ENTITY_WOLF_PANT, Sound.ENTITY_WOLF_HOWL, Sound.ENTITY_WOLF_SHAKE, + Sound.ENTITY_WOLF_WHINE), + + ZOMBIE(Sound.ENTITY_ZOMBIE_HURT, Sound.ENTITY_ZOMBIE_STEP, Sound.ENTITY_ZOMBIE_DEATH, Sound.ENTITY_ZOMBIE_AMBIENT, + Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD, + Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR), ZOMBIE_VILLAGER(Sound.ENTITY_ZOMBIE_VILLAGER_HURT, + Sound.ENTITY_ZOMBIE_VILLAGER_STEP, Sound.ENTITY_ZOMBIE_VILLAGER_DEATH, Sound.ENTITY_ZOMBIE_VILLAGER_AMBIENT, + Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD, + Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR); + + public enum SoundType + { CANCEL, DEATH, HURT, IDLE, STEP } - public static DisguiseSound getType(String name) { - //TODO: FIX the disguise sounds - try { + public static DisguiseSound getType(String name) + { + // TODO: FIX the disguise sounds + try + { return valueOf(name); - } catch (Exception ex) { + } + catch (Exception ex) + { return null; } } @@ -90,115 +148,160 @@ public enum DisguiseSound { private float damageSoundVolume = 1F; private HashMap disguiseSounds = new HashMap<>(); - DisguiseSound(Object hurt, Object step, Object death, Object idle, Object... sounds) { + DisguiseSound(Object hurt, Object step, Object death, Object idle, Object... sounds) + { addSound(hurt, SoundType.HURT); addSound(step, SoundType.STEP); addSound(death, SoundType.DEATH); addSound(idle, SoundType.IDLE); - for (Object obj : sounds) { + + for (Object obj : sounds) + { addSound(obj, SoundType.CANCEL); } } - private void addSound(Object sound, SoundType type) { + private void addSound(Object sound, SoundType type) + { String s; - if (sound == null) { + + if (sound == null) + { return; - } else if (sound instanceof String) { + } + else if (sound instanceof String) + { s = (String) sound; - } else if (sound instanceof Sound) { + } + else if (sound instanceof Sound) + { s = ReflectionManager.getCraftSound((Sound) sound); - } else { + } + else + { throw new RuntimeException("Was given a unknown object " + sound); } - switch (type) { - case HURT: - disguiseSounds.put(SoundType.HURT, s); - break; - case STEP: - disguiseSounds.put(SoundType.STEP, s); - break; - case DEATH: - disguiseSounds.put(SoundType.DEATH, s); - break; - case IDLE: - disguiseSounds.put(SoundType.IDLE, s); - break; - case CANCEL: - cancelSounds.add(s); + + switch (type) + { + case HURT: + disguiseSounds.put(SoundType.HURT, s); + break; + case STEP: + disguiseSounds.put(SoundType.STEP, s); + break; + case DEATH: + disguiseSounds.put(SoundType.DEATH, s); + break; + case IDLE: + disguiseSounds.put(SoundType.IDLE, s); + break; + case CANCEL: + cancelSounds.add(s); } } - public float getDamageAndIdleSoundVolume() { + public float getDamageAndIdleSoundVolume() + { return damageSoundVolume; } - public String getSound(SoundType type) { - if (type == null || !disguiseSounds.containsKey(type)) { + public String getSound(SoundType type) + { + if (type == null || !disguiseSounds.containsKey(type)) + { return null; } + return disguiseSounds.get(type); } - public HashSet getSoundsToCancel() { + public HashSet getSoundsToCancel() + { return cancelSounds; } /** * Used to check if this sound name is owned by this disguise sound. */ - public SoundType getType(String sound, boolean ignoreDamage) { - if (sound == null) return SoundType.CANCEL; - if (isCancelSound(sound)) { + public SoundType getType(String sound, boolean ignoreDamage) + { + if (sound == null) + return SoundType.CANCEL; + + 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)) { + + for (SoundType type : SoundType.values()) + { + 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 != null) + { + if (s.equals(sound)) + { return type; } } } + return null; } - public boolean isCancelSound(String sound) { + public boolean isCancelSound(String sound) + { return getSoundsToCancel().contains(sound); } - public void removeSound(SoundType type, Sound sound) { + public void removeSound(SoundType type, Sound sound) + { removeSound(type, ReflectionManager.getCraftSound(sound)); } - public void removeSound(SoundType type, String sound) { - if (type == SoundType.CANCEL) { + public void removeSound(SoundType type, String sound) + { + if (type == SoundType.CANCEL) + { cancelSounds.remove(sound); - } else { + } + else + { disguiseSounds.remove(type); } } - public void setDamageAndIdleSoundVolume(float strength) { + public void setDamageAndIdleSoundVolume(float strength) + { this.damageSoundVolume = strength; } - public void setSound(SoundType type, Sound sound) { + public void setSound(SoundType type, Sound sound) + { setSound(type, ReflectionManager.getCraftSound(sound)); } - public void setSound(SoundType type, String sound) { - if (type == SoundType.CANCEL) { + public void setSound(SoundType type, String sound) + { + if (type == SoundType.CANCEL) + { cancelSounds.add(sound); - } else { + } + else + { disguiseSounds.put(type, sound); } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java similarity index 64% rename from src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java rename to src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 63a80266..03a50b44 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -1,23 +1,21 @@ package me.libraryaddict.disguise.utilities; -import com.comphenix.protocol.PacketType.Play.Server; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.WrappedDataWatcher; -import com.comphenix.protocol.wrappers.WrappedGameProfile; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.LibsDisguises; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; -import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; -import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; -import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.UUID; +import java.util.regex.Pattern; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -37,27 +35,33 @@ import org.bukkit.scoreboard.Team.Option; import org.bukkit.scoreboard.Team.OptionStatus; import org.bukkit.util.Vector; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.UUID; -import java.util.regex.Pattern; +import com.comphenix.protocol.PacketType.Play.Server; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; +import com.comphenix.protocol.wrappers.WrappedGameProfile; -public class DisguiseUtilities { +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; +import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; + +public class DisguiseUtilities +{ public static final Random random = new Random(); /** - * 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 addedByPlugins = new HashSet<>(); private static Object bedChunk; @@ -67,7 +71,8 @@ public class DisguiseUtilities { */ private static HashMap> 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> futureDisguises = new HashMap<>(); /** @@ -79,158 +84,240 @@ public class DisguiseUtilities { private static HashSet selfDisguised = new HashSet<>(); private static Field xChunk, zChunk; - static { - try { + static + { + try + { Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null); Object world = ((List) server.getClass().getField("worlds").get(server)).get(0); + 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 block; - try { - block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class) - .invoke(null, Material.BED_BLOCK.getId()); - } catch (Exception ex) { - block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"), "byId").get(null))[Material.BED_BLOCK.getId()]; + + try + { + block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class).invoke(null, + Material.BED_BLOCK.getId()); } + catch (Exception ex) + { + block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"), "byId") + .get(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 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}) { - setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal())); + + 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); } Object[] array = (Object[]) Array.newInstance(chunkSection.getClass(), 16); array[0] = chunkSection; + cSection.set(bedChunk, array); + xChunk = bedChunk.getClass().getField("locX"); xChunk.setAccessible(true); zChunk = bedChunk.getClass().getField("locZ"); zChunk.setAccessible(true); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } - public static boolean addClonedDisguise(String key, Disguise disguise) { - if (DisguiseConfig.getMaxClonedDisguises() > 0) { - if (clonedDisguises.containsKey(key)) { + public static boolean addClonedDisguise(String key, Disguise disguise) + { + if (DisguiseConfig.getMaxClonedDisguises() > 0) + { + if (clonedDisguises.containsKey(key)) + { clonedDisguises.remove(key); - } else if (DisguiseConfig.getMaxClonedDisguises() == clonedDisguises.size()) { + } + else if (DisguiseConfig.getMaxClonedDisguises() == clonedDisguises.size()) + { clonedDisguises.remove(clonedDisguises.keySet().iterator().next()); } - if (DisguiseConfig.getMaxClonedDisguises() > clonedDisguises.size()) { + + if (DisguiseConfig.getMaxClonedDisguises() > clonedDisguises.size()) + { clonedDisguises.put(key, disguise); return true; } } + return false; } - public static void addDisguise(UUID entityId, TargetedDisguise disguise) { - if (!getDisguises().containsKey(entityId)) { + public static void addDisguise(UUID entityId, TargetedDisguise disguise) + { + if (!getDisguises().containsKey(entityId)) + { getDisguises().put(entityId, new HashSet()); } + getDisguises().get(entityId).add(disguise); + 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); } } - public static void addFutureDisguise(final int entityId, final TargetedDisguise disguise) { - if (!futureDisguises.containsKey(entityId)) { + public static void addFutureDisguise(final int entityId, final TargetedDisguise disguise) + { + if (!futureDisguises.containsKey(entityId)) + { futureDisguises.put(entityId, new HashSet()); } + futureDisguises.get(entityId).add(disguise); - final BukkitRunnable runnable = new BukkitRunnable() { + + final BukkitRunnable runnable = new BukkitRunnable() + { @Override - public void run() { - if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getEntityId() == entityId) { + public void run() + { + if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) + { + for (World world : Bukkit.getWorlds()) + { + for (Entity entity : world.getEntities()) + { + if (entity.getEntityId() == entityId) + { UUID uniqueId = entity.getUniqueId(); - for (TargetedDisguise disguise : futureDisguises.remove(entityId)) { + + for (TargetedDisguise disguise : futureDisguises.remove(entityId)) + { addDisguise(uniqueId, disguise); } + return; } } } + futureDisguises.get(entityId).remove(disguise); - if (futureDisguises.get(entityId).isEmpty()) { + + if (futureDisguises.get(entityId).isEmpty()) + { futureDisguises.remove(entityId); } } } }; + runnable.runTaskLater(libsDisguises, 20); } - public static void addGameProfile(String string, WrappedGameProfile gameProfile) { + public static void addGameProfile(String string, WrappedGameProfile gameProfile) + { getGameProfiles().put(string, gameProfile); getAddedByPlugins().add(string.toLowerCase()); } /** - * 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) { + public static void checkConflicts(TargetedDisguise disguise, String name) + { // If the disguise is being used.. Else we may accidentally undisguise something else - if (DisguiseAPI.isDisguiseInUse(disguise)) { + if (DisguiseAPI.isDisguiseInUse(disguise)) + { Iterator disguiseItel = getDisguises().get(disguise.getEntity().getUniqueId()).iterator(); // Iterate through the disguises - while (disguiseItel.hasNext()) { + while (disguiseItel.hasNext()) + { TargetedDisguise d = disguiseItel.next(); // Make sure the disguise isn't the same thing - if (d != disguise) { + if (d != disguise) + { // If the loop'd disguise is hiding the disguise to everyone in its list - if (d.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) { + if (d.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) + { // If player is a observer in the loop - if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) { + if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) + { // If player is a observer in the disguise // Remove them from the loop - if (name != null) { + if (name != null) + { d.removePlayer(name); - } else { - for (String playername : disguise.getObservers()) { + } + else + { + for (String playername : disguise.getObservers()) + { d.silentlyRemovePlayer(playername); } } - } else if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + } + else if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) + { // If player is not a observer in the loop - if (name != null) { - if (!disguise.getObservers().contains(name)) { + if (name != null) + { + if (!disguise.getObservers().contains(name)) + { d.removePlayer(name); } - } else { - for (String playername : new ArrayList<>(d.getObservers())) { - if (!disguise.getObservers().contains(playername)) { + } + else + { + for (String playername : new ArrayList<>(d.getObservers())) + { + if (!disguise.getObservers().contains(playername)) + { d.silentlyRemovePlayer(playername); } } } } - } else if (d.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + } + else if (d.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) + { // Here you add it to the loop if they see the disguise - if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) { + if (disguise.getDisguiseTarget() == TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS) + { // Everyone who is in the disguise needs to be added to the loop - if (name != null) { + if (name != null) + { d.addPlayer(name); - } else { - for (String playername : disguise.getObservers()) { + } + else + { + for (String playername : disguise.getObservers()) + { d.silentlyAddPlayer(playername); } } - } else if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + } + else if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) + { // This here is a paradox. // If fed a name. I can do this. // But the rest of the time.. Its going to conflict. @@ -250,187 +337,278 @@ public class DisguiseUtilities { /** * Sends entity removal packets, as this disguise was removed */ - public static void destroyEntity(TargetedDisguise disguise) { - try { + public static void destroyEntity(TargetedDisguise disguise) + { + try + { Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); - if (entityTrackerEntry != null) { - Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); + + if (entityTrackerEntry != null) + { + 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 ConcurrentModificationException + trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent + // ConcurrentModificationException + PacketContainer destroyPacket = new PacketContainer(Server.ENTITY_DESTROY); - destroyPacket.getIntegerArrays().write(0, new int[]{disguise.getEntity().getEntityId()}); - for (Object p : trackedPlayers) { + + destroyPacket.getIntegerArrays().write(0, new int[] + { + disguise.getEntity().getEntityId() + }); + + for (Object p : trackedPlayers) + { Player player = (Player) ReflectionManager.getBukkitEntity(p); - if (player == disguise.getEntity() || disguise.canSee(player)) { + + if (player == disguise.getEntity() || disguise.canSee(player)) + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } - public static void doBoundingBox(TargetedDisguise disguise) { + public static void doBoundingBox(TargetedDisguise disguise) + { Entity entity = disguise.getEntity(); - if (entity != null) { - if (isDisguiseInUse(disguise)) { + + if (entity != null) + { + if (isDisguiseInUse(disguise)) + { DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType()); FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); - if (disguiseValues.getBabyBox() != null) { + + if (disguiseValues.getBabyBox() != null) + { if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby()) - || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher()) - .isBaby())) { + || (disguise.getWatcher() instanceof ZombieWatcher + && ((ZombieWatcher) disguise.getWatcher()).isBaby())) + { disguiseBox = disguiseValues.getBabyBox(); } } + ReflectionManager.setBoundingBox(entity, disguiseBox); - } else { + } + else + { DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType())); + FakeBoundingBox entityBox = entityValues.getAdultBox(); - if (entityValues.getBabyBox() != null) { + + if (entityValues.getBabyBox() != null) + { if ((entity instanceof Ageable && !((Ageable) entity).isAdult()) - || (entity instanceof Zombie && ((Zombie) entity).isBaby())) { + || (entity instanceof Zombie && ((Zombie) entity).isBaby())) + { entityBox = entityValues.getBabyBox(); } } + ReflectionManager.setBoundingBox(entity, entityBox); } } } - public static HashSet getAddedByPlugins() { + public static HashSet getAddedByPlugins() + { return addedByPlugins; } - public static PacketContainer[] getBedChunkPacket(Location newLoc, Location oldLoc) { + public static PacketContainer[] getBedChunkPacket(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}) { - if (loc == null) { + + for (Location loc : new Location[] + { + oldLoc, newLoc + }) + { + if (loc == null) + { continue; } - try { + try + { int chunkX = (int) Math.floor(loc.getX() / 16D) - 17, chunkZ = (int) Math.floor(loc.getZ() / 16D) - 17; + chunkX -= chunkX % 8; chunkZ -= chunkZ % 8; xChunk.set(bedChunk, chunkX); zChunk.set(bedChunk, chunkZ); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } // Make unload packets - try { - packets[i] = ProtocolLibrary.getProtocolManager() - .createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0, 40) + try + { + packets[i] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0, 40) .createPacket(bedChunk, true, 0, 48); - } catch (IllegalArgumentException ex) { - packets[i] = ProtocolLibrary.getProtocolManager() - .createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0) + } + catch (IllegalArgumentException ex) + { + packets[i] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0) .createPacket(bedChunk, true, 0); } + i++; // Make load packets - if (oldLoc == null || i > 1) { - //MAP_CHUNK_BULK was replaced in 1.9 with several seperated chunk packets -// packets[i] = ProtocolLibrary.getProtocolManager() -// .createPacketConstructor(Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk)) -// .createPacket(Arrays.asList(bedChunk)); - packets[i] = ProtocolLibrary.getProtocolManager() - .createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0) + if (oldLoc == null || i > 1) + { + // MAP_CHUNK_BULK was replaced in 1.9 with several seperated chunk packets + // packets[i] = ProtocolLibrary.getProtocolManager() + // .createPacketConstructor(Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk)) + // .createPacket(Arrays.asList(bedChunk)); + packets[i] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0) .createPacket(bedChunk, true, 0); i++; } } + return packets; } - public static PacketContainer[] getBedPackets(Player player, Location loc, Location playerLocation, PlayerDisguise disguise) { + public static PacketContainer[] getBedPackets(Player player, Location loc, Location playerLocation, PlayerDisguise disguise) + { Entity entity = disguise.getEntity(); + PacketContainer setBed = new PacketContainer(Server.BED); - StructureModifier bedInts = setBed.getIntegers(); - bedInts.write(0, entity.getEntityId()); - PlayerWatcher watcher = disguise.getWatcher(); - int chunkX = (int) Math.floor(playerLocation.getX() / 16D) - 17, chunkZ = (int) Math - .floor(playerLocation.getZ() / 16D) - 17; + + int chunkX = (int) Math.floor(playerLocation.getX() / 16D) - 17, + chunkZ = (int) Math.floor(playerLocation.getZ() / 16D) - 17; chunkX -= chunkX % 8; chunkZ -= chunkZ % 8; + + PlayerWatcher watcher = disguise.getWatcher(); + + StructureModifier bedInts = setBed.getIntegers(); + bedInts.write(0, entity.getEntityId()); + bedInts.write(1, (chunkX * 16) + 1 + watcher.getSleepingDirection().getModX()); bedInts.write(3, (chunkZ * 16) + 1 + watcher.getSleepingDirection().getModZ()); + PacketContainer teleport = new PacketContainer(Server.ENTITY_TELEPORT); + StructureModifier ints = teleport.getIntegers(); ints.write(0, entity.getEntityId()); 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 + }; } - public static Disguise getClonedDisguise(String key) { - if (clonedDisguises.containsKey(key)) { + public static Disguise getClonedDisguise(String key) + { + if (clonedDisguises.containsKey(key)) + { return clonedDisguises.get(key).clone(); } + return null; } - public static PacketContainer getDestroyPacket(int... ids) { + public static PacketContainer getDestroyPacket(int... ids) + { PacketContainer destroyPacket = new PacketContainer(Server.ENTITY_DESTROY); + destroyPacket.getIntegerArrays().write(0, ids); + return destroyPacket; } - public static TargetedDisguise getDisguise(Player observer, Entity entity) { + public static TargetedDisguise getDisguise(Player observer, Entity entity) + { UUID entityId = entity.getUniqueId(); - if (futureDisguises.containsKey(entity.getEntityId())) { - for (TargetedDisguise disguise : futureDisguises.remove(entity.getEntityId())) { + + if (futureDisguises.containsKey(entity.getEntityId())) + { + for (TargetedDisguise disguise : futureDisguises.remove(entity.getEntityId())) + { addDisguise(entityId, disguise); } } - if (getDisguises().containsKey(entityId)) { - for (TargetedDisguise disguise : getDisguises().get(entityId)) { - if (disguise.canSee(observer)) { + + if (getDisguises().containsKey(entityId)) + { + for (TargetedDisguise disguise : getDisguises().get(entityId)) + { + if (disguise.canSee(observer)) + { return disguise; } } } + return null; } - public static HashMap> getDisguises() { + public static HashMap> getDisguises() + { return disguisesInUse; } - public static TargetedDisguise[] getDisguises(UUID entityId) { - if (getDisguises().containsKey(entityId)) { + public static TargetedDisguise[] getDisguises(UUID entityId) + { + if (getDisguises().containsKey(entityId)) + { HashSet disguises = getDisguises().get(entityId); + return disguises.toArray(new TargetedDisguise[disguises.size()]); } + return new TargetedDisguise[0]; } - public static HashMap> getFutureDisguises() { + public static HashMap> getFutureDisguises() + { return futureDisguises; } - public static WrappedGameProfile getGameProfile(String playerName) { + public static WrappedGameProfile getGameProfile(String playerName) + { return gameProfiles.get(playerName.toLowerCase()); } - public static HashMap getGameProfiles() { + public static HashMap getGameProfiles() + { return gameProfiles; } - public static TargetedDisguise getMainDisguise(UUID entityId) { + public static TargetedDisguise getMainDisguise(UUID entityId) + { TargetedDisguise toReturn = null; - if (getDisguises().containsKey(entityId)) { - for (TargetedDisguise disguise : getDisguises().get(entityId)) { - if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + + if (getDisguises().containsKey(entityId)) + { + for (TargetedDisguise disguise : getDisguises().get(entityId)) + { + if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) + { return disguise; } + toReturn = disguise; } } + return toReturn; } @@ -440,41 +618,60 @@ public class DisguiseUtilities { * @param disguise * @return */ - public static List getPerverts(Disguise disguise) { + public static List getPerverts(Disguise disguise) + { List players = new ArrayList<>(); - try { + + try + { Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); - if (entityTrackerEntry != null) { - 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) { + + if (entityTrackerEntry != null) + { + 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) + { Player player = (Player) ReflectionManager.getBukkitEntity(p); - if (((TargetedDisguise) disguise).canSee(player)) { + if (((TargetedDisguise) disguise).canSee(player)) + { players.add(player); } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return players; } - public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) { + public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) + { final String nameToFetch = disguise.getSkin() != null ? disguise.getSkin() : disguise.getName(); final boolean remove = getAddedByPlugins().contains(nameToFetch.toLowerCase()); - return getProfileFromMojang(nameToFetch, new LibsProfileLookup() { + + return getProfileFromMojang(nameToFetch, new LibsProfileLookup() + { @Override - public void onLookup(WrappedGameProfile gameProfile) { - if (remove) { + public void onLookup(WrappedGameProfile gameProfile) + { + if (remove) + { getAddedByPlugins().remove(nameToFetch.toLowerCase()); } + if (DisguiseAPI.isDisguiseInUse(disguise) - && (!gameProfile.getName().equals( - disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) - || !gameProfile.getProperties().isEmpty())) { + && (!gameProfile.getName().equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) + || !gameProfile.getProperties().isEmpty())) + { disguise.setGameProfile(gameProfile); + DisguiseUtilities.refreshTrackers(disguise); } } @@ -482,61 +679,93 @@ public class DisguiseUtilities { } /** - * Pass in a set, check if it's a hashset. - * If it's not, return false. - * If you pass in something else, you failed. + * Pass in a set, check if it's a hashset. If it's not, return false. If you pass in something else, you failed. * * @param obj * @return */ - private static boolean isHashSet(Object obj) { - if (obj instanceof HashSet) return true; //It's Spigot/Bukkit - if (obj instanceof Set) return false; //It's PaperSpigot/SportsBukkit + private static boolean isHashSet(Object obj) + { + if (obj instanceof HashSet) + return true; // It's Spigot/Bukkit + + if (obj instanceof Set) + return false; // It's PaperSpigot/SportsBukkit + throw new IllegalArgumentException("Object passed was not either a hashset or set!"); } /** - * 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) { + public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) + { return getProfileFromMojang(playerName, (Object) runnableIfCantReturn); } - private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable) { + private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable) + { final String playerName = origName.toLowerCase(); - if (gameProfiles.containsKey(playerName)) { - if (gameProfiles.get(playerName) != null) { + + if (gameProfiles.containsKey(playerName)) + { + if (gameProfiles.get(playerName) != null) + { return gameProfiles.get(playerName); } - } else if (Pattern.matches("([A-Za-z0-9_]){1,16}", origName)) { + } + else if (Pattern.matches("([A-Za-z0-9_]){1,16}", origName)) + { getAddedByPlugins().add(playerName); + Player player = Bukkit.getPlayerExact(playerName); - if (player != null) { + + if (player != null) + { WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player); - if (!gameProfile.getProperties().isEmpty()) { + + if (!gameProfile.getProperties().isEmpty()) + { gameProfiles.put(playerName, gameProfile); return gameProfile; } } + // Add null so that if this is called again. I already know I'm doing something about it gameProfiles.put(playerName, null); - Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() { + + Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() + { @Override - public void run() { - try { + public void run() + { + try + { final WrappedGameProfile gameProfile = lookupGameProfile(origName); - Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { + + Bukkit.getScheduler().runTask(libsDisguises, new Runnable() + { @Override - public void run() { - if (!gameProfile.getProperties().isEmpty()) { - if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { + public void run() + { + if (!gameProfile.getProperties().isEmpty()) + { + if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) + { gameProfiles.put(playerName, gameProfile); } - if (runnables.containsKey(playerName)) { - for (Object obj : runnables.remove(playerName)) { - if (obj instanceof Runnable) { + + if (runnables.containsKey(playerName)) + { + for (Object obj : runnables.remove(playerName)) + { + if (obj instanceof Runnable) + { ((Runnable) obj).run(); - } else if (obj instanceof LibsProfileLookup) { + } + else if (obj instanceof LibsProfileLookup) + { ((LibsProfileLookup) obj).onLookup(gameProfile); } } @@ -544,48 +773,64 @@ public class DisguiseUtilities { } } }); - } catch (Exception e) { - if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { + } + catch (Exception e) + { + if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) + { gameProfiles.remove(playerName); getAddedByPlugins().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()); } } }); - } else { + } + else + { return ReflectionManager.getGameProfile(null, origName); } - if (runnable != null) { - if (!runnables.containsKey(playerName)) { + + if (runnable != null) + { + if (!runnables.containsKey(playerName)) + { runnables.put(playerName, new ArrayList<>()); } runnables.get(playerName).add(runnable); } + return ReflectionManager.getGameProfile(null, origName); } /** - * 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) { + public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) + { return getProfileFromMojang(playerName, (Object) runnableIfCantReturn); } - public static HashSet getSelfDisguised() { + public static HashSet getSelfDisguised() + { return selfDisguised; } - public static boolean hasGameProfile(String playerName) { + public static boolean hasGameProfile(String playerName) + { return getGameProfile(playerName) != null; } - public static void init(LibsDisguises disguises) { + public static void init(LibsDisguises disguises) + { libsDisguises = disguises; } - public static boolean isDisguiseInUse(Disguise disguise) { + public static boolean isDisguiseInUse(Disguise disguise) + { return disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getUniqueId()) && getDisguises().get(disguise.getEntity().getUniqueId()).contains(disguise); } @@ -593,55 +838,88 @@ public class DisguiseUtilities { /** * This is called on a thread as it is thread blocking */ - public static WrappedGameProfile lookupGameProfile(String playerName) { + public static WrappedGameProfile lookupGameProfile(String playerName) + { return ReflectionManager.getSkullBlob(ReflectionManager.grabProfileAddUUID(playerName)); } /** * Resends the entity to this specific player */ - public static void refreshTracker(final TargetedDisguise disguise, String player) { - if (disguise.getEntity() != null && disguise.getEntity().isValid()) { - try { + public static void refreshTracker(final TargetedDisguise disguise, String player) + { + if (disguise.getEntity() != null && disguise.getEntity().isValid()) + { + try + { PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); + if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player - && disguise.getEntity().getName().equalsIgnoreCase(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() { + + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { @Override - public void run() { - try { + public void run() + { + try + { DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } }, 2); - } else { + } + else + { final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); - if (entityTrackerEntry != null) { + + if (entityTrackerEntry != null) + { Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") .get(entityTrackerEntry); + Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer")); + final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", ReflectionManager.getNmsClass("EntityPlayer")); - trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); //Copy before iterating to prevent ConcurrentModificationException - for (final Object p : trackedPlayers) { + + trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent + // ConcurrentModificationException + for (final Object p : trackedPlayers) + { Player pl = (Player) ReflectionManager.getBukkitEntity(p); - if (player.equalsIgnoreCase((pl).getName())) { + + if (player.equalsIgnoreCase((pl).getName())) + { clear.invoke(entityTrackerEntry, p); + ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket); - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { @Override - public void run() { - try { + public void run() + { + try + { updatePlayer.invoke(entityTrackerEntry, p); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -651,7 +929,9 @@ public class DisguiseUtilities { } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -660,30 +940,50 @@ public class DisguiseUtilities { /** * A convenience method for me to refresh trackers in other plugins */ - public static void refreshTrackers(Entity entity) { - if (entity.isValid()) { - try { + public static void refreshTrackers(Entity entity) + { + if (entity.isValid()) + { + try + { PacketContainer destroyPacket = getDestroyPacket(entity.getEntityId()); + final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity); - if (entityTrackerEntry != null) { - Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get( - entityTrackerEntry); + + if (entityTrackerEntry != null) + { + Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") + .get(entityTrackerEntry); + Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer")); + final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", ReflectionManager.getNmsClass("EntityPlayer")); - trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); //Copy before iterating to prevent ConcurrentModificationException - for (final Object p : trackedPlayers) { + + trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent + // ConcurrentModificationException + for (final Object p : trackedPlayers) + { Player player = (Player) ReflectionManager.getBukkitEntity(p); - if (player != entity) { + + if (player != entity) + { clear.invoke(entityTrackerEntry, p); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { @Override - public void run() { - try { + public void run() + { + try + { updatePlayer.invoke(entityTrackerEntry, p); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -691,7 +991,9 @@ public class DisguiseUtilities { } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -700,42 +1002,74 @@ public class DisguiseUtilities { /** * Resends the entity to all the watching players, which is where the magic begins */ - public static void refreshTrackers(final TargetedDisguise disguise) { - if (disguise.getEntity().isValid()) { + public static void refreshTrackers(final TargetedDisguise disguise) + { + if (disguise.getEntity().isValid()) + { PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); - try { - if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) { + try + { + if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) + { removeSelfDisguise((Player) disguise.getEntity()); + selfDisguised.add(disguise.getEntity().getUniqueId()); + ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { @Override - public void run() { - try { + public void run() + { + try + { DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } }, 2); } + final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity()); - if (entityTrackerEntry != null) { - Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); - final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer")); - final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", ReflectionManager.getNmsClass("EntityPlayer")); + + if (entityTrackerEntry != null) + { + Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") + .get(entityTrackerEntry); + + final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear", + ReflectionManager.getNmsClass("EntityPlayer")); + + final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer", + ReflectionManager.getNmsClass("EntityPlayer")); + trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); - for (final Object p : trackedPlayers) { + + for (final Object p : trackedPlayers) + { Player player = (Player) ReflectionManager.getBukkitEntity(p); - if (disguise.getEntity() != player && disguise.canSee(player)) { + + if (disguise.getEntity() != player && disguise.canSee(player)) + { clear.invoke(entityTrackerEntry, p); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket); - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { @Override - public void run() { - try { + public void run() + { + try + { updatePlayer.invoke(entityTrackerEntry, p); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -743,78 +1077,115 @@ public class DisguiseUtilities { } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } } - public static boolean removeDisguise(TargetedDisguise disguise) { + public static boolean removeDisguise(TargetedDisguise disguise) + { UUID entityId = disguise.getEntity().getUniqueId(); - if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) { - if (getDisguises().get(entityId).isEmpty()) { + + if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) + { + if (getDisguises().get(entityId).isEmpty()) + { 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); } + return true; } + return false; } - public static void removeGameProfile(String string) { + public static void removeGameProfile(String string) + { gameProfiles.remove(string.toLowerCase()); } - public static void removeSelfDisguise(Player player) { - if (selfDisguised.contains(player.getUniqueId())) { + public static void removeSelfDisguise(Player player) + { + if (selfDisguised.contains(player.getUniqueId())) + { // Send a packet to destroy the fake entity PacketContainer packet = getDestroyPacket(DisguiseAPI.getSelfDisguiseId()); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } - //Code to stop player pushing in 1.9 + + // Code to stop player pushing in 1.9 Scoreboard scoreboard = player.getScoreboard(); Team t; - if ((t = scoreboard.getTeam("LDPushing")) != null) { + + if ((t = scoreboard.getTeam("LDPushing")) != null) + { t.setOption(Option.COLLISION_RULE, OptionStatus.ALWAYS); t.removeEntry(player.getName()); t.unregister(); } -// player.spigot().setCollidesWithEntities(true); - //Finish up + + // player.spigot().setCollidesWithEntities(true); + // Finish up // Remove the fake entity ID from the disguise bin selfDisguised.remove(player.getUniqueId()); // Get the entity tracker - try { + + try + { Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player); - if (entityTrackerEntry != null) { - Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); + + if (entityTrackerEntry != null) + { + Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") + .get(entityTrackerEntry); + // If the tracker exists. Remove himself from his tracker - if (isHashSet(trackedPlayersObj)) { - ((Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); - } else { - ((Map) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); + if (isHashSet(trackedPlayersObj)) + { + ((Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") + .get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); + } + else + { + ((Map) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap") + .get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player)); } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + // Resend entity metadata else he will be invisible to himself until its resent - try { - ProtocolLibrary.getProtocolManager().sendServerPacket( - player, - ProtocolLibrary - .getProtocolManager() + try + { + 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) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + player.updateInventory(); } } @@ -822,142 +1193,159 @@ public class DisguiseUtilities { /** * Sends the self disguise to the player */ - public static void sendSelfDisguise(final Player player, final TargetedDisguise disguise) { - try { + public static void sendSelfDisguise(final Player player, final TargetedDisguise disguise) + { + try + { if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible() - || !disguise.canSee(player)) { + || !disguise.canSee(player)) + { return; } + Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player); - if (entityTrackerEntry == null) { + + if (entityTrackerEntry == null) + { // A check incase the tracker is null. // If it is, then this method will be run again in one tick. Which is when it should be constructed. // Else its going to run in a infinite loop hue hue hue.. // At least until this disguise is discarded - Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { + Bukkit.getScheduler().runTask(libsDisguises, new Runnable() + { @Override - public void run() { - if (DisguiseAPI.getDisguise(player, player) == disguise) { + public void run() + { + if (DisguiseAPI.getDisguise(player, player) == disguise) + { sendSelfDisguise(player, disguise); } } }); + return; } + // Add himself to his own entity tracker - Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); - //Check for code differences in PaperSpigot vs Spigot - if (isHashSet(trackedPlayersObj)) { - ((Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player)); - } else { - ((Map) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true); + Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") + .get(entityTrackerEntry); + + // Check for code differences in PaperSpigot vs Spigot + if (isHashSet(trackedPlayersObj)) + { + ((Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry)) + .add(ReflectionManager.getNmsEntity(player)); + } + else + { + ((Map) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap") + .get(entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true); } ProtocolManager manager = ProtocolLibrary.getProtocolManager(); // Send the player a packet with himself being spawned - manager.sendServerPacket(player, manager.createPacketConstructor(Server.NAMED_ENTITY_SPAWN, player) - .createPacket(player)); + manager.sendServerPacket(player, + manager.createPacketConstructor(Server.NAMED_ENTITY_SPAWN, player).createPacket(player)); + WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player); - sendSelfPacket( - player, - manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, - true).createPacket(player.getEntityId(), dataWatcher, true)); + + sendSelfPacket(player, + manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true) + .createPacket(player.getEntityId(), dataWatcher, true)); boolean isMoving = false; - try { + + try + { Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField("isMoving"); field.setAccessible(true); isMoving = field.getBoolean(entityTrackerEntry); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + // Send the velocity packets - if (isMoving) { + if (isMoving) + { 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())); + sendSelfPacket(player, + manager.createPacketConstructor(Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(), + 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())); - } 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)); + 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())); + } + 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.ENTITY_EQUIPMENT, - 0, + 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(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), + ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD), ReflectionManager.getNmsItem(player.getInventory().getHelmet()))); sendSelfPacket(player, - manager.createPacketConstructor( - Server.ENTITY_EQUIPMENT, - 0, + 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(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), + ReflectionManager.createEnumItemSlot(EquipmentSlot.CHEST), ReflectionManager.getNmsItem(player.getInventory().getChestplate()))); sendSelfPacket(player, - manager.createPacketConstructor( - Server.ENTITY_EQUIPMENT, - 0, + 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(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), + ReflectionManager.createEnumItemSlot(EquipmentSlot.LEGS), ReflectionManager.getNmsItem(player.getInventory().getLeggings()))); sendSelfPacket(player, - manager.createPacketConstructor( - Server.ENTITY_EQUIPMENT, - 0, + 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(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), + ReflectionManager.createEnumItemSlot(EquipmentSlot.FEET), ReflectionManager.getNmsItem(player.getInventory().getBoots()))); sendSelfPacket(player, - manager.createPacketConstructor( - Server.ENTITY_EQUIPMENT, - 0, + 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(new ItemStack(Material.STONE))).createPacket(player.getEntityId(), + ReflectionManager.createEnumItemSlot(EquipmentSlot.HAND), ReflectionManager.getNmsItem(player.getInventory().getItemInMainHand()))); sendSelfPacket(player, - manager.createPacketConstructor( - Server.ENTITY_EQUIPMENT, - 0, + 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(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, + 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()))); + .createPacket(player, + ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); } // Resend any active potion effects - for (PotionEffect potionEffect : player.getActivePotionEffects()) { + 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) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } @@ -965,34 +1353,55 @@ public class DisguiseUtilities { /** * Method to send a packet to the self disguise, translate his entity ID to the fake id. */ - private static void sendSelfPacket(final Player player, PacketContainer packet) { + private static void sendSelfPacket(final Player player, PacketContainer packet) + { PacketContainer[][] transformed = PacketsManager.transformPacket(packet, player, player); + PacketContainer[] packets = transformed == null ? null : transformed[0]; + final PacketContainer[] delayed = transformed == null ? null : transformed[1]; - try { - if (packets == null) { - packets = new PacketContainer[]{packet}; + + try + { + if (packets == null) + { + packets = new PacketContainer[] + { + packet + }; } - for (PacketContainer p : packets) { + + for (PacketContainer p : packets) + { p = p.deepClone(); p.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); ProtocolLibrary.getProtocolManager().sendServerPacket(player, p, false); } - if (delayed != null && delayed.length > 0) { - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + + if (delayed != null && delayed.length > 0) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { @Override - public void run() { - try { - for (PacketContainer packet : delayed) { + public void run() + { + try + { + for (PacketContainer packet : delayed) + { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); } - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } }); } - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(System.out); } } @@ -1002,40 +1411,60 @@ public class DisguiseUtilities { * * @param disguise */ - public static void setupFakeDisguise(final Disguise disguise) { + public static void setupFakeDisguise(final Disguise disguise) + { 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)) { + || !getDisguises().get(e.getUniqueId()).contains(disguise)) + { return; } + Player player = (Player) e; + // Check if he can even see this.. - if (!((TargetedDisguise) disguise).canSee(player)) { + if (!((TargetedDisguise) disguise).canSee(player)) + { return; } + // Remove the old disguise, else we have weird disguises around the place 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; } - //Code to stop player pushing in 1.9 + + // Code to stop player pushing in 1.9 Scoreboard scoreboard = player.getScoreboard(); Team t; - if ((t = scoreboard.getTeam("LDPushing")) != null) { + + if ((t = scoreboard.getTeam("LDPushing")) != null) + { t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); - } else { + } + else + { t = scoreboard.registerNewTeam("LDPushing"); + t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); t.addEntry(player.getName()); } -// player.spigot().setCollidesWithEntities(false); - //Finish up + + // player.spigot().setCollidesWithEntities(false); + // Finish up selfDisguised.add(player.getUniqueId()); + sendSelfDisguise(player, (TargetedDisguise) disguise); - if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) { - if (PacketsManager.isInventoryListenerEnabled()) { + + if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) + { + if (PacketsManager.isInventoryListenerEnabled()) + { player.updateInventory(); } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java b/src/me/libraryaddict/disguise/utilities/DisguiseValues.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java rename to src/me/libraryaddict/disguise/utilities/DisguiseValues.java index bb428de0..70296a5e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseValues.java @@ -1,9 +1,9 @@ package me.libraryaddict.disguise.utilities; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; - import java.util.HashMap; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; + public class DisguiseValues { private static HashMap values = new HashMap<>(); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/FakeBoundingBox.java b/src/me/libraryaddict/disguise/utilities/FakeBoundingBox.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/utilities/FakeBoundingBox.java rename to src/me/libraryaddict/disguise/utilities/FakeBoundingBox.java diff --git a/src/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookup.java b/src/me/libraryaddict/disguise/utilities/LibsProfileLookup.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookup.java rename to src/me/libraryaddict/disguise/utilities/LibsProfileLookup.java diff --git a/src/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.java b/src/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.java similarity index 99% rename from src/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.java rename to src/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.java index cee46e8d..d904b4f9 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.java +++ b/src/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.java @@ -1,7 +1,6 @@ package me.libraryaddict.disguise.utilities; import com.comphenix.protocol.wrappers.WrappedGameProfile; - import com.mojang.authlib.GameProfile; import com.mojang.authlib.ProfileLookupCallback; diff --git a/src/main/java/me/libraryaddict/disguise/utilities/Metrics.java b/src/me/libraryaddict/disguise/utilities/Metrics.java similarity index 74% rename from src/main/java/me/libraryaddict/disguise/utilities/Metrics.java rename to src/me/libraryaddict/disguise/utilities/Metrics.java index b31601f3..f32a325d 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/Metrics.java +++ b/src/me/libraryaddict/disguise/utilities/Metrics.java @@ -27,13 +27,6 @@ */ package me.libraryaddict.disguise.utilities; -import org.bukkit.Bukkit; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.scheduler.BukkitTask; - import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; @@ -53,7 +46,15 @@ import java.util.UUID; import java.util.logging.Level; import java.util.zip.GZIPOutputStream; -public class Metrics { +import org.bukkit.Bukkit; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.scheduler.BukkitTask; + +public class Metrics +{ /** * The current revision number @@ -104,8 +105,10 @@ public class Metrics { */ private volatile BukkitTask task = null; - public Metrics(final Plugin plugin) throws IOException { - if (plugin == null) { + public Metrics(final Plugin plugin) throws IOException + { + if (plugin == null) + { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin = plugin; @@ -117,7 +120,8 @@ public class Metrics { configuration.addDefault("guid", UUID.randomUUID().toString()); configuration.addDefault("debug", false); // Do we need to create the file? - if (configuration.get("guid", null) == null) { + if (configuration.get("guid", null) == null) + { configuration.options().header("http://mcstats.org").copyDefaults(true); configuration.save(configurationFile); } @@ -127,13 +131,17 @@ public class Metrics { } /** - * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics website. Plotters can be added to the graph object returned. + * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics website. + * Plotters can be added to the graph object returned. * - * @param name The name of the graph + * @param name + * The name of the graph * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given */ - public Graph createGraph(final String name) { - if (name == null) { + public Graph createGraph(final String name) + { + if (name == null) + { throw new IllegalArgumentException("Graph name cannot be null"); } // Construct the graph object @@ -147,45 +155,59 @@ public class Metrics { /** * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend * - * @param graph The name of the graph + * @param graph + * The name of the graph */ - public void addGraph(final Graph graph) { - if (graph == null) { + public void addGraph(final Graph graph) + { + if (graph == null) + { throw new IllegalArgumentException("Graph cannot be null"); } graphs.add(graph); } /** - * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 ticks. + * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the initial data to + * the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 ticks. * * @return True if statistics measuring is running, otherwise false. */ - public boolean start() { - synchronized (optOutLock) { + public boolean start() + { + synchronized (optOutLock) + { // Did we opt out? - if (isOptOut()) { + if (isOptOut()) + { return false; } // Is metrics already running? - if (task != null) { + if (task != null) + { return true; } // Begin hitting the server with glorious data - task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { + task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() + { private boolean firstPost = true; @Override - public void run() { - try { + public void run() + { + try + { // This has to be synchronized or it can collide with the disable method. - synchronized (optOutLock) { + synchronized (optOutLock) + { // Disable Task, if it is running and the server owner decided to opt-out - if (isOptOut() && task != null) { + if (isOptOut() && task != null) + { task.cancel(); task = null; // Tell all plotters to stop gathering information. - for (Graph graph : graphs) { + for (Graph graph : graphs) + { graph.onOptOut(); } } @@ -197,8 +219,11 @@ public class Metrics { // After the first post we set firstPost to false // Each post thereafter will be a ping firstPost = false; - } catch (IOException e) { - if (debug) { + } + catch (IOException e) + { + if (debug) + { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); } } @@ -213,13 +238,19 @@ public class Metrics { * * @return true if metrics should be opted out of it */ - public boolean isOptOut() { - synchronized (optOutLock) { - try { + public boolean isOptOut() + { + synchronized (optOutLock) + { + try + { // Reload the metrics file configuration.load(getConfigFile()); - } catch (IOException | InvalidConfigurationException ex) { - if (debug) { + } + catch (IOException | InvalidConfigurationException ex) + { + if (debug) + { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); } return true; @@ -233,16 +264,20 @@ public class Metrics { * * @throws java.io.IOException */ - public void enable() throws IOException { + public void enable() throws IOException + { // This has to be synchronized or it can collide with the check in the task. - synchronized (optOutLock) { + synchronized (optOutLock) + { // Check if the server owner has already set opt-out, if not, set it. - if (isOptOut()) { + if (isOptOut()) + { configuration.set("opt-out", false); configuration.save(configurationFile); } // Enable Task, if it is not running - if (task == null) { + if (task == null) + { start(); } } @@ -253,16 +288,20 @@ public class Metrics { * * @throws java.io.IOException */ - public void disable() throws IOException { + public void disable() throws IOException + { // This has to be synchronized or it can collide with the check in the task. - synchronized (optOutLock) { + synchronized (optOutLock) + { // Check if the server owner has already set opt-out, if not, set it. - if (!isOptOut()) { + if (!isOptOut()) + { configuration.set("opt-out", true); configuration.save(configurationFile); } // Disable Task, if it is running - if (task != null) { + if (task != null) + { task.cancel(); task = null; } @@ -274,7 +313,8 @@ public class Metrics { * * @return the File object for the config file */ - public File getConfigFile() { + public File getConfigFile() + { // I believe the easiest way to get the base folder (e.g Spigot set via -P) for plugins to use // is to abuse the plugin object we already have // plugin.getDataFolder() => base/plugins/PluginA/ @@ -288,7 +328,8 @@ public class Metrics { /** * Generic method that posts a plugin to the metrics website */ - private void postPlugin(final boolean isPing) throws IOException { + private void postPlugin(final boolean isPing) throws IOException + { // Server software specific section PluginDescriptionFile description = plugin.getDescription(); String pluginName = description.getName(); @@ -312,7 +353,8 @@ public class Metrics { String java_version = System.getProperty("java.version"); int coreCount = Runtime.getRuntime().availableProcessors(); // normalize os arch .. amd64 -> x86_64 - if (osarch.equals("amd64")) { + if (osarch.equals("amd64")) + { osarch = "x86_64"; } appendJSONPair(json, "osname", osname); @@ -322,11 +364,14 @@ public class Metrics { appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0"); appendJSONPair(json, "java_version", java_version); // If we're pinging, append it - if (isPing) { + if (isPing) + { appendJSONPair(json, "ping", "1"); } - if (graphs.size() > 0) { - synchronized (graphs) { + if (graphs.size() > 0) + { + synchronized (graphs) + { json.append(','); json.append('"'); json.append("graphs"); @@ -334,14 +379,17 @@ public class Metrics { json.append(':'); json.append('{'); boolean firstGraph = true; - for (Graph graph : graphs) { + for (Graph graph : graphs) + { StringBuilder graphJson = new StringBuilder(); graphJson.append('{'); - for (Plotter plotter : graph.getPlotters()) { + for (Plotter plotter : graph.getPlotters()) + { appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue())); } graphJson.append('}'); - if (!firstGraph) { + if (!firstGraph) + { json.append(','); } json.append(escapeJSON(graph.getName())); @@ -360,9 +408,12 @@ public class Metrics { URLConnection connection; // Mineshafter creates a socks proxy, so we can safely bypass it // It does not reroute POST requests so we need to go around it - if (isMineshafterPresent()) { + if (isMineshafterPresent()) + { connection = url.openConnection(Proxy.NO_PROXY); - } else { + } + else + { connection = url.openConnection(); } byte[] uncompressed = json.toString().getBytes(); @@ -375,8 +426,10 @@ public class Metrics { connection.addRequestProperty("Accept", "application/json"); connection.addRequestProperty("Connection", "close"); connection.setDoOutput(true); - if (debug) { - System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); + if (debug) + { + System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + + " compressed=" + compressed.length); } // Write the data OutputStream os = connection.getOutputStream(); @@ -384,24 +437,35 @@ public class Metrics { os.flush(); String response; try ( // Now read the response - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) + { response = reader.readLine(); // close resources os.close(); } - if (response == null || response.startsWith("ERR") || response.startsWith("7")) { - if (response == null) { + if (response == null || response.startsWith("ERR") || response.startsWith("7")) + { + if (response == null) + { response = "null"; - } else if (response.startsWith("7")) { + } + else if (response.startsWith("7")) + { response = response.substring(response.startsWith("7,") ? 2 : 1); } throw new IOException(response); - } else { + } + else + { // Is this the first update this hour? - if (response.equals("1") || response.contains("This is your first update this hour")) { - synchronized (graphs) { - for (Graph graph : graphs) { - for (Plotter plotter : graph.getPlotters()) { + if (response.equals("1") || response.contains("This is your first update this hour")) + { + synchronized (graphs) + { + for (Graph graph : graphs) + { + for (Plotter plotter : graph.getPlotters()) + { plotter.reset(); } } @@ -416,19 +480,29 @@ public class Metrics { * @param input * @return byte[] */ - public static byte[] gzip(String input) { + public static byte[] gzip(String input) + { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; - try { + try + { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); - } catch (IOException e) { + } + catch (IOException e) + { e.printStackTrace(System.out); - } finally { - if (gzos != null) { - try { + } + finally + { + if (gzos != null) + { + try + { gzos.close(); - } catch (IOException ignore) { + } + catch (IOException ignore) + { } } } @@ -440,11 +514,15 @@ public class Metrics { * * @return true if mineshafter is installed on the server */ - private boolean isMineshafterPresent() { - try { + private boolean isMineshafterPresent() + { + try + { Class.forName("mineshafter.MineServer"); return true; - } catch (Exception e) { + } + catch (Exception e) + { return false; } } @@ -457,24 +535,33 @@ public class Metrics { * @param value * @throws UnsupportedEncodingException */ - private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { + private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException + { boolean isValueNumeric = false; - try { - if (value.equals("0") || !value.endsWith("0")) { + try + { + if (value.equals("0") || !value.endsWith("0")) + { Double.parseDouble(value); isValueNumeric = true; } - } catch (NumberFormatException e) { + } + catch (NumberFormatException e) + { isValueNumeric = false; } - if (json.charAt(json.length() - 1) != '{') { + if (json.charAt(json.length() - 1) != '{') + { json.append(','); } json.append(escapeJSON(key)); json.append(':'); - if (isValueNumeric) { + if (isValueNumeric) + { json.append(value); - } else { + } + else + { json.append(escapeJSON(value)); } } @@ -485,37 +572,43 @@ public class Metrics { * @param text * @return String */ - private static String escapeJSON(String text) { + private static String escapeJSON(String text) + { StringBuilder builder = new StringBuilder(); builder.append('"'); - for (int index = 0; index < text.length(); index++) { + for (int index = 0; index < text.length(); index++) + { char chr = text.charAt(index); - switch (chr) { - case '"': - case '\\': - builder.append('\\'); + switch (chr) + { + case '"': + case '\\': + builder.append('\\'); + builder.append(chr); + break; + case '\b': + builder.append("\\b"); + break; + case '\t': + builder.append("\\t"); + break; + case '\n': + builder.append("\\n"); + break; + case '\r': + builder.append("\\r"); + break; + default: + if (chr < ' ') + { + String t = "000" + Integer.toHexString(chr); + builder.append("\\u").append(t.substring(t.length() - 4)); + } + else + { builder.append(chr); - break; - case '\b': - builder.append("\\b"); - break; - case '\t': - builder.append("\\t"); - break; - case '\n': - builder.append("\\n"); - break; - case '\r': - builder.append("\\r"); - break; - default: - if (chr < ' ') { - String t = "000" + Integer.toHexString(chr); - builder.append("\\u").append(t.substring(t.length() - 4)); - } else { - builder.append(chr); - } - break; + } + break; } } builder.append('"'); @@ -525,17 +618,20 @@ public class Metrics { /** * Encode text as UTF-8 * - * @param text the text to encode + * @param text + * the text to encode * @return the encoded text, as UTF-8 */ - private static String urlEncode(final String text) throws UnsupportedEncodingException { + private static String urlEncode(final String text) throws UnsupportedEncodingException + { return URLEncoder.encode(text, "UTF-8"); } /** * Represents a custom graph on the website */ - public static class Graph { + public static class Graph + { /** * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is rejected @@ -546,7 +642,8 @@ public class Metrics { */ private final Set plotters = new LinkedHashSet<>(); - private Graph(final String name) { + private Graph(final String name) + { this.name = name; } @@ -555,25 +652,30 @@ public class Metrics { * * @return the Graph's name */ - public String getName() { + public String getName() + { return name; } /** * Add a plotter to the graph, which will be used to plot entries * - * @param plotter the plotter to add to the graph + * @param plotter + * the plotter to add to the graph */ - public void addPlotter(final Plotter plotter) { + public void addPlotter(final Plotter plotter) + { plotters.add(plotter); } /** * Remove a plotter from the graph * - * @param plotter the plotter to remove from the graph + * @param plotter + * the plotter to remove from the graph */ - public void removePlotter(final Plotter plotter) { + public void removePlotter(final Plotter plotter) + { plotters.remove(plotter); } @@ -582,18 +684,22 @@ public class Metrics { * * @return an unmodifiable {@link java.util.Set} of the plotter objects */ - public Set getPlotters() { + public Set getPlotters() + { return Collections.unmodifiableSet(plotters); } @Override - public int hashCode() { + public int hashCode() + { return name.hashCode(); } @Override - public boolean equals(final Object object) { - if (!(object instanceof Graph)) { + public boolean equals(final Object object) + { + if (!(object instanceof Graph)) + { return false; } final Graph graph = (Graph) object; @@ -603,14 +709,16 @@ public class Metrics { /** * Called when the server owner decides to opt-out of BukkitMetrics while the server is running. */ - protected void onOptOut() { + protected void onOptOut() + { } } /** * Interface used to collect custom data for a plugin */ - public static abstract class Plotter { + public static abstract class Plotter + { /** * The plot's name @@ -620,21 +728,26 @@ public class Metrics { /** * Construct a plotter with the default plot name */ - public Plotter() { + public Plotter() + { this("Default"); } /** * Construct a plotter with a specific plot name * - * @param name the name of the plotter to use, which will show up on the website + * @param name + * the name of the plotter to use, which will show up on the website */ - public Plotter(final String name) { + public Plotter(final String name) + { this.name = name; } /** - * Get the current value for the plotted point. Since this function defers to an external function it may or may not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called from any thread so care should be taken when accessing resources that need to be synchronized. + * Get the current value for the plotted point. Since this function defers to an external function it may or may not + * return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called from any thread + * so care should be taken when accessing resources that need to be synchronized. * * @return the current value for the point to be plotted. */ @@ -645,24 +758,29 @@ public class Metrics { * * @return the plotted point's column name */ - public String getColumnName() { + public String getColumnName() + { return name; } /** * Called after the website graphs have been updated */ - public void reset() { + public void reset() + { } @Override - public int hashCode() { + public int hashCode() + { return getColumnName().hashCode(); } @Override - public boolean equals(final Object object) { - if (!(object instanceof Plotter)) { + public boolean equals(final Object object) + { + if (!(object instanceof Plotter)) + { return false; } final Plotter plotter = (Plotter) object; diff --git a/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/me/libraryaddict/disguise/utilities/PacketsManager.java similarity index 66% rename from src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java rename to src/me/libraryaddict/disguise/utilities/PacketsManager.java index 6ffd10cd..045f8047 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -1,36 +1,11 @@ package me.libraryaddict.disguise.utilities; -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.PacketType.Play.Server; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.events.PacketListener; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.WrappedAttribute; -import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; -import com.comphenix.protocol.wrappers.WrappedDataWatcher; -import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry; -import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject; -import com.comphenix.protocol.wrappers.WrappedGameProfile; -import com.comphenix.protocol.wrappers.WrappedWatchableObject; -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.LibsDisguises; -import me.libraryaddict.disguise.disguisetypes.AnimalColor; -import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.FlagWatcher; -import me.libraryaddict.disguise.disguisetypes.MiscDisguise; -import me.libraryaddict.disguise.disguisetypes.MobDisguise; -import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher; -import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + import org.bukkit.Art; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -50,13 +25,41 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.PacketType.Play.Server; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.ListenerPriority; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.events.PacketListener; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.WrappedAttribute; +import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; +import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry; +import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject; +import com.comphenix.protocol.wrappers.WrappedGameProfile; +import com.comphenix.protocol.wrappers.WrappedWatchableObject; -public class PacketsManager { +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; +import me.libraryaddict.disguise.disguisetypes.AnimalColor; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.disguisetypes.FlagWatcher; +import me.libraryaddict.disguise.disguisetypes.MiscDisguise; +import me.libraryaddict.disguise.disguisetypes.MobDisguise; +import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; +import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher; +import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType; + +public class PacketsManager +{ /** * This is a fix for the stupidity that is * "I can't separate the sounds from the sounds the player heard, and the sounds of the entity tracker heard" @@ -72,47 +75,74 @@ public class PacketsManager { private static PacketListener viewDisguisesListener; private static boolean viewDisguisesListenerEnabled; - public static void addPacketListeners() { + public static void addPacketListeners() + { // Add a client listener to cancel them interacting with uninteractable disguised entitys. // You ain't supposed to be allowed to 'interact' with a item that cannot be clicked. // Because it kicks you for hacking. + clientInteractEntityListener = new PacketAdapter(libsDisguises, ListenerPriority.NORMAL, - PacketType.Play.Client.USE_ENTITY) { + PacketType.Play.Client.USE_ENTITY) + { @Override - public void onPacketReceiving(PacketEvent event) { + public void onPacketReceiving(PacketEvent event) + { + if (event.isCancelled()) return; - try { - if (event.getPlayer().getName().contains("UNKNOWN[")) //If the player is temporary + + try + { + if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary return; + Player observer = event.getPlayer(); + StructureModifier entityModifer = event.getPacket().getEntityModifier(observer.getWorld()); + Entity entity = entityModifer.read(0); + if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow - || entity == observer) { + || entity == observer) + { event.setCancelled(true); } + ItemStack item = observer.getItemInHand(); - if (item != null && item.getType() == Material.INK_SACK) { + + if (item != null && item.getType() == Material.INK_SACK) + { Disguise disguise = DisguiseAPI.getDisguise(observer, entity); + if (disguise != null - && (disguise.getType() == DisguiseType.SHEEP || disguise.getType() == DisguiseType.WOLF)) { + && (disguise.getType() == DisguiseType.SHEEP || disguise.getType() == DisguiseType.WOLF)) + { AnimalColor color = AnimalColor.getColor(item.getDurability()); - if (disguise.getType() == DisguiseType.SHEEP) { + + if (disguise.getType() == DisguiseType.SHEEP) + { SheepWatcher watcher = (SheepWatcher) disguise.getWatcher(); + watcher.setColor(DisguiseConfig.isSheepDyeable() ? color : watcher.getColor()); - } else { + } + else + { WolfWatcher watcher = (WolfWatcher) disguise.getWatcher(); + watcher.setCollarColor(DisguiseConfig.isWolfDyeable() ? color : watcher.getCollarColor()); } } } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } }; + ProtocolLibrary.getProtocolManager().addPacketListener(clientInteractEntityListener); + // Now I call this and the main listener is registered! setupMainPacketsListener(); } @@ -120,158 +150,233 @@ public class PacketsManager { /** * Construct the packets I need to spawn in the disguise */ - public static PacketContainer[][] constructSpawnPackets(final Player player, Disguise disguise, Entity disguisedEntity) { + public static PacketContainer[][] constructSpawnPackets(final Player player, Disguise disguise, Entity disguisedEntity) + { if (disguise.getEntity() == null) disguise.setEntity(disguisedEntity); + ArrayList packets = new ArrayList<>(); // This sends the armor packets so that the player isn't naked. // Please note it only sends the packets that wouldn't be sent normally - if (DisguiseConfig.isEquipmentPacketsEnabled()) { - for (EquipmentSlot slot : EquipmentSlot.values()) { + if (DisguiseConfig.isEquipmentPacketsEnabled()) + { + for (EquipmentSlot slot : EquipmentSlot.values()) + { ItemStack itemstack = disguise.getWatcher().getItemStack(slot); - if (itemstack != null && itemstack.getTypeId() != 0) { + + if (itemstack != null && itemstack.getTypeId() != 0) + { ItemStack item = null; - if (disguisedEntity instanceof LivingEntity) { + + if (disguisedEntity instanceof LivingEntity) + { item = ReflectionManager.getEquipment(slot, disguisedEntity); } - if (item == null || item.getType() == Material.AIR) { + + if (item == null || item.getType() == Material.AIR) + { PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT); + StructureModifier mods = packet.getModifier(); + mods.write(0, disguisedEntity.getEntityId()); mods.write(1, ReflectionManager.createEnumItemSlot(slot)); mods.write(2, ReflectionManager.getNmsItem(itemstack)); + packets.add(packet); } } } } - if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { - if (disguise.getWatcher() instanceof LivingWatcher) { + + if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) + { + if (disguise.getWatcher() instanceof LivingWatcher) + { PacketContainer packet = new PacketContainer(Server.UPDATE_ATTRIBUTES); - List attributes = new ArrayList<>(); + + List attributes = new ArrayList(); + Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth"); - if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { + + if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) + { builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth()); - } else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity() && disguisedEntity instanceof Damageable) { + } + else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity() && disguisedEntity instanceof Damageable) + { builder.baseValue(((Damageable) disguisedEntity).getMaxHealth()); - } else { + } + else + { builder.baseValue(DisguiseValues.getDisguiseValues(disguise.getType()).getMaxHealth()); } + builder.packet(packet); + attributes.add(builder.build()); + packet.getIntegers().write(0, disguisedEntity.getEntityId()); packet.getAttributeCollectionModifier().write(0, attributes); + packets.add(packet); } } + PacketContainer[] spawnPackets = new PacketContainer[2 + packets.size()]; PacketContainer[] delayedPackets = new PacketContainer[0]; - for (int i = 0; i < packets.size(); i++) { + + for (int i = 0; i < packets.size(); i++) + { spawnPackets[i + 2] = packets.get(i); } + Location loc = disguisedEntity.getLocation().clone().add(0, getYModifier(disguisedEntity, disguise), 0); + byte yaw = (byte) (int) (loc.getYaw() * 256.0F / 360.0F); byte pitch = (byte) (int) (loc.getPitch() * 256.0F / 360.0F); - if (DisguiseConfig.isMovementPacketsEnabled()) { + + if (DisguiseConfig.isMovementPacketsEnabled()) + { yaw = getYaw(disguise.getType(), disguisedEntity.getType(), yaw); pitch = getPitch(disguise.getType(), DisguiseType.getType(disguisedEntity.getType()), pitch); } - if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) { + if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) + { spawnPackets[0] = new PacketContainer(Server.SPAWN_ENTITY_EXPERIENCE_ORB); + StructureModifier mods = spawnPackets[0].getModifier(); + mods.write(0, disguisedEntity.getEntityId()); mods.write(1, Math.floor(loc.getX() * 32)); mods.write(2, Math.floor(loc.getY() * 32) + 2); mods.write(3, Math.floor(loc.getZ() * 32)); mods.write(4, 1); - } else if (disguise.getType() == DisguiseType.PAINTING) { + } + else if (disguise.getType() == DisguiseType.PAINTING) + { spawnPackets[0] = new PacketContainer(Server.SPAWN_ENTITY_PAINTING); + StructureModifier mods = spawnPackets[0].getModifier(); + mods.write(0, disguisedEntity.getEntityId()); mods.write(1, disguisedEntity.getUniqueId()); mods.write(2, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); mods.write(3, ReflectionManager.getEnumDirection(((int) loc.getYaw()) % 4)); + int id = ((MiscDisguise) disguise).getData(); + mods.write(4, ReflectionManager.getEnumArt(Art.values()[id])); // Make the teleport packet to make it visible.. spawnPackets[1] = new PacketContainer(Server.ENTITY_TELEPORT); + mods = spawnPackets[1].getModifier(); + mods.write(0, disguisedEntity.getEntityId()); mods.write(1, Math.floor(loc.getX() * 32D)); mods.write(2, Math.floor(loc.getY() * 32D)); mods.write(3, Math.floor(loc.getZ() * 32D)); mods.write(4, yaw); mods.write(5, pitch); - } else if (disguise.getType().isPlayer()) { + } + else if (disguise.getType().isPlayer()) + { PlayerDisguise playerDisguise = (PlayerDisguise) disguise; + String name = playerDisguise.getSkin() != null ? playerDisguise.getSkin() : playerDisguise.getName(); int entityId = disguisedEntity.getEntityId(); boolean removeName = false; - if (!DisguiseUtilities.hasGameProfile(name)) { + + if (!DisguiseUtilities.hasGameProfile(name)) + { removeName = !DisguiseUtilities.getAddedByPlugins().contains(name); } + WrappedGameProfile gameProfile = playerDisguise.getGameProfile(); - if (removeName) { + + if (removeName) + { DisguiseUtilities.getAddedByPlugins().remove(name); } + Object entityPlayer = ReflectionManager.createEntityPlayer(player.getWorld(), gameProfile); spawnPackets[0] = ProtocolLibrary.getProtocolManager() - .createPacketConstructor(Server.NAMED_ENTITY_SPAWN, entityPlayer) - .createPacket(entityPlayer); + .createPacketConstructor(Server.NAMED_ENTITY_SPAWN, entityPlayer).createPacket(entityPlayer); - //Write spawn packet in order - spawnPackets[0].getIntegers().write(0, entityId); //Id + // Write spawn packet in order + spawnPackets[0].getIntegers().write(0, entityId); // Id spawnPackets[0].getDoubles().write(0, loc.getX()); spawnPackets[0].getDoubles().write(1, loc.getY()); spawnPackets[0].getDoubles().write(2, loc.getZ()); - spawnPackets[0].getDataWatcherModifier().write(0, createDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher())); //watcher, duh + spawnPackets[0].getDataWatcherModifier().write(0, + createDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher())); // watcher, + // duh - - - if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) { + if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) + { PacketContainer[] newPackets = new PacketContainer[spawnPackets.length + 1]; + System.arraycopy(spawnPackets, 1, newPackets, 2, spawnPackets.length - 1); + newPackets[0] = spawnPackets[0]; spawnPackets = newPackets; + PacketContainer[] bedPackets = DisguiseUtilities.getBedPackets(player, loc.clone().subtract(0, PacketsManager.getYModifier(disguisedEntity, disguise), 0), player.getLocation(), ((PlayerDisguise) disguise)); + System.arraycopy(bedPackets, 0, spawnPackets, 1, 2); } - ArrayList newPackets = new ArrayList<>(); + ArrayList newPackets = new ArrayList(); newPackets.add(null); - for (PacketContainer spawnPacket : spawnPackets) { - if (spawnPacket != null) { // Get rid of empty packet '1' if it exists. + + for (PacketContainer spawnPacket : spawnPackets) + { + if (spawnPacket != null) + { // Get rid of empty packet '1' if it exists. newPackets.add(spawnPacket); } } - //Send player info along with the disguise + // Send player info along with the disguise spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]); spawnPackets[0] = new PacketContainer(Server.PLAYER_INFO); - //Add player to the list, necessary to spawn them + // Add player to the list, necessary to spawn them spawnPackets[0].getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0)); + List playerList = new ArrayList(); + playerList.add(ReflectionManager.getPlayerInfoData(spawnPackets[0].getHandle(), playerDisguise.getGameProfile())); spawnPackets[0].getModifier().write(1, playerList); - //Remove player from the list + // Remove player from the list PacketContainer delayedPacket = spawnPackets[0].shallowClone(); + delayedPacket.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4)); - delayedPackets = new PacketContainer[]{delayedPacket}; - } else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) { + + delayedPackets = new PacketContainer[] + { + delayedPacket + }; + } + else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) + { Vector vec = disguisedEntity.getVelocity(); + spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING); + StructureModifier mods = spawnPackets[0].getModifier(); + mods.write(0, disguisedEntity.getEntityId()); mods.write(1, UUID.randomUUID()); mods.write(2, disguise.getType().getTypeId()); - //region Vector calculations + + // region Vector calculations double d1 = 3.9D; double d2 = vec.getX(); double d3 = vec.getY(); @@ -288,7 +393,8 @@ public class PacketsManager { d3 = d1; if (d4 > d1) d4 = d1; - //endregion + // endregion + mods.write(3, loc.getX()); mods.write(4, loc.getY()); mods.write(5, loc.getZ()); @@ -297,215 +403,277 @@ public class PacketsManager { mods.write(8, (int) (d4 * 8000.0D)); mods.write(9, yaw); mods.write(10, pitch); + spawnPackets[0].getDataWatcherModifier().write(0, createDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher())); - } else if (disguise.getType().isMisc()) { + } + else if (disguise.getType().isMisc()) + { int objectId = disguise.getType().getObjectId(); int data = ((MiscDisguise) disguise).getData(); - if (disguise.getType() == DisguiseType.FALLING_BLOCK) { + + if (disguise.getType() == DisguiseType.FALLING_BLOCK) + { data = ReflectionManager.getCombinedId(((MiscDisguise) disguise).getId(), data); - } else if (disguise.getType() == DisguiseType.FISHING_HOOK && data == 0) { + } + else if (disguise.getType() == DisguiseType.FISHING_HOOK && data == 0) + { // If the MiscDisguise data isn't set. Then no entity id was provided, so default to the owners entity id data = disguisedEntity.getEntityId(); - } else if (disguise.getType() == DisguiseType.ITEM_FRAME) { + } + else if (disguise.getType() == DisguiseType.ITEM_FRAME) + { data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4; } + Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity); + spawnPackets[0] = ProtocolLibrary.getProtocolManager() .createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data) .createPacket(nmsEntity, objectId, data); spawnPackets[0].getModifier().write(8, pitch); spawnPackets[0].getModifier().write(9, yaw); - if (disguise.getType() == DisguiseType.ITEM_FRAME) { - if (data % 2 == 0) { + + if (disguise.getType() == DisguiseType.ITEM_FRAME) + { + if (data % 2 == 0) + { spawnPackets[0].getModifier().write(4, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D)); - } else { + } + else + { spawnPackets[0].getModifier().write(2, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D)); } } } - if (spawnPackets[1] == null || disguise.isPlayerDisguise()) { + if (spawnPackets[1] == null || disguise.isPlayerDisguise()) + { int entry = spawnPackets[1] == null ? 1 : 0; - if (entry == 0) { + + if (entry == 0) + { entry = spawnPackets.length; spawnPackets = Arrays.copyOf(spawnPackets, spawnPackets.length + 1); } // Make a packet to turn his head! + spawnPackets[entry] = new PacketContainer(Server.ENTITY_HEAD_ROTATION); + StructureModifier mods = spawnPackets[entry].getModifier(); + mods.write(0, disguisedEntity.getEntityId()); mods.write(1, yaw); } - return new PacketContainer[][]{spawnPackets, delayedPackets}; + return new PacketContainer[][] + { + spawnPackets, delayedPackets + }; } /** * Create a new datawatcher but with the 'correct' values */ - private static WrappedDataWatcher createDataWatcher(WrappedDataWatcher watcher, FlagWatcher flagWatcher) { + private static WrappedDataWatcher createDataWatcher(WrappedDataWatcher watcher, FlagWatcher flagWatcher) + { WrappedDataWatcher newWatcher = new WrappedDataWatcher(); - try { - List list = DisguiseConfig.isMetadataPacketsEnabled() ? flagWatcher.convert(watcher.getWatchableObjects()) : flagWatcher.getWatchableObjects(); - for (WrappedWatchableObject watchableObject : list) { - if (watchableObject == null) continue; - if (watchableObject.getValue() == null) continue; - if (Registry.get(watchableObject.getValue().getClass()) == null) continue; - WrappedDataWatcherObject obj = new WrappedDataWatcherObject(watchableObject.getIndex(), Registry.get(watchableObject.getValue().getClass())); + + try + { + List list = DisguiseConfig.isMetadataPacketsEnabled() + ? flagWatcher.convert(watcher.getWatchableObjects()) : flagWatcher.getWatchableObjects(); + + for (WrappedWatchableObject watchableObject : list) + { + if (watchableObject == null) + continue; + + if (watchableObject.getValue() == null) + continue; + + if (Registry.get(watchableObject.getValue().getClass()) == null) + continue; + + WrappedDataWatcherObject obj = new WrappedDataWatcherObject(watchableObject.getIndex(), + Registry.get(watchableObject.getValue().getClass())); + newWatcher.setObject(obj, watchableObject.getValue()); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } + return newWatcher; } - public static byte getPitch(DisguiseType disguiseType, DisguiseType entityType, byte value) { - switch (disguiseType) { - case MINECART: - case MINECART_CHEST: - case MINECART_COMMAND: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - value = (byte) -value; - break; - default: - break; + public static byte getPitch(DisguiseType disguiseType, DisguiseType entityType, byte value) + { + switch (disguiseType) + { + case MINECART: + case MINECART_CHEST: + case MINECART_COMMAND: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + value = (byte) -value; + break; + default: + break; } - switch (entityType) { - case MINECART: - case MINECART_CHEST: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - value = (byte) -value; - break; - default: - break; + switch (entityType) + { + case MINECART: + case MINECART_CHEST: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + value = (byte) -value; + break; + default: + break; } + return value; } /** * Add the yaw for the disguises */ - public static byte getYaw(DisguiseType disguiseType, EntityType entityType, byte value) { - switch (disguiseType) { - case MINECART: - case MINECART_CHEST: - case MINECART_COMMAND: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - value += 64; - break; - case ENDER_DRAGON: - value -= 128; - break; - case WITHER_SKULL: - value -= 128; - break; - case ARROW: - case TIPPED_ARROW: - case SPECTRAL_ARROW: - value = (byte) -value; - break; - case PAINTING: - case ITEM_FRAME: - value = (byte) -(value + 128); - break; - default: - if (disguiseType.isMisc() && disguiseType != DisguiseType.ARMOR_STAND) { - value -= 64; - } - break; - } - switch (entityType) { - case MINECART: - case MINECART_CHEST: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: + public static byte getYaw(DisguiseType disguiseType, EntityType entityType, byte value) + { + switch (disguiseType) + { + case MINECART: + case MINECART_CHEST: + case MINECART_COMMAND: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + value += 64; + break; + case ENDER_DRAGON: + value -= 128; + break; + case WITHER_SKULL: + value -= 128; + break; + case ARROW: + case TIPPED_ARROW: + case SPECTRAL_ARROW: + value = (byte) -value; + break; + case PAINTING: + case ITEM_FRAME: + value = (byte) -(value + 128); + break; + default: + if (disguiseType.isMisc() && disguiseType != DisguiseType.ARMOR_STAND) + { value -= 64; - break; - case ENDER_DRAGON: - case WITHER_SKULL: - value += 128; - break; - case ARROW: - value = (byte) -value; - break; - case PAINTING: - case ITEM_FRAME: - value = (byte) -(value - 128); - break; - default: - if (!entityType.isAlive()) { - value += 64; - } - break; + } + + break; } + switch (entityType) + { + case MINECART: + case MINECART_CHEST: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + value -= 64; + break; + case ENDER_DRAGON: + case WITHER_SKULL: + value += 128; + break; + case ARROW: + value = (byte) -value; + break; + case PAINTING: + case ITEM_FRAME: + value = (byte) -(value - 128); + break; + default: + if (!entityType.isAlive()) + { + value += 64; + } + + break; + } + return value; } /** * Get the Y level to add to the disguise for realism. */ - public static double getYModifier(Entity entity, Disguise disguise) { + public static double getYModifier(Entity entity, Disguise disguise) + { double yMod = 0; + if ((disguise.getType() != DisguiseType.PLAYER || !((PlayerWatcher) disguise.getWatcher()).isSleeping()) - && entity.getType() == EntityType.DROPPED_ITEM) { + && entity.getType() == EntityType.DROPPED_ITEM) + { yMod -= 0.13; } - switch (disguise.getType()) { - case BAT: - if (entity instanceof LivingEntity) - return yMod + ((LivingEntity) entity).getEyeHeight(); + + switch (disguise.getType()) + { + case BAT: + if (entity instanceof LivingEntity) + return yMod + ((LivingEntity) entity).getEyeHeight(); + case MINECART: + case MINECART_COMMAND: + case MINECART_CHEST: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + switch (entity.getType()) + { case MINECART: - case MINECART_COMMAND: case MINECART_CHEST: case MINECART_FURNACE: case MINECART_HOPPER: case MINECART_MOB_SPAWNER: case MINECART_TNT: - switch (entity.getType()) { - case MINECART: - case MINECART_CHEST: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - return yMod; - default: - return yMod + 0.4; - } - case TIPPED_ARROW: - case SPECTRAL_ARROW: - case BOAT: - case EGG: - case ENDER_PEARL: - case ENDER_SIGNAL: - case FIREWORK: - case PAINTING: - case SMALL_FIREBALL: - case SNOWBALL: - case SPLASH_POTION: - case THROWN_EXP_BOTTLE: - case WITHER_SKULL: - return yMod + 0.7; - case PLAYER: - if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) { - return yMod + 0.35; - } - break; - case DROPPED_ITEM: - return yMod + 0.13; + return yMod; default: - break; + return yMod + 0.4; + } + case TIPPED_ARROW: + case SPECTRAL_ARROW: + case BOAT: + case EGG: + case ENDER_PEARL: + case ENDER_SIGNAL: + case FIREWORK: + case PAINTING: + case SMALL_FIREBALL: + case SNOWBALL: + case SPLASH_POTION: + case THROWN_EXP_BOTTLE: + case WITHER_SKULL: + return yMod + 0.7; + case PLAYER: + if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) + { + return yMod + 0.35; + } + + break; + case DROPPED_ITEM: + return yMod + 0.13; + default: + break; } return yMod; } @@ -513,73 +681,125 @@ public class PacketsManager { /** * Creates the packet listeners */ - public static void init(LibsDisguises plugin) { + public static void init(LibsDisguises plugin) + { libsDisguises = plugin; - soundsListener = new PacketAdapter(libsDisguises, ListenerPriority.NORMAL, Server.NAMED_SOUND_EFFECT, Server.ENTITY_STATUS) { + soundsListener = new PacketAdapter(libsDisguises, ListenerPriority.NORMAL, Server.NAMED_SOUND_EFFECT, + Server.ENTITY_STATUS) + { @Override - public void onPacketSending(PacketEvent event) { - if (event.isCancelled()) { + public void onPacketSending(PacketEvent event) + { + if (event.isCancelled()) + { return; } - if (event.isAsync()) { + if (event.isAsync()) + { return; } - if (event.getPlayer().getName().contains("UNKNOWN[")) //If the player is temporary + + if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary return; + event.setPacket(event.getPacket().deepClone()); + StructureModifier mods = event.getPacket().getModifier(); + Player observer = event.getPlayer(); - if (event.getPacketType() == Server.NAMED_SOUND_EFFECT) { + + if (event.getPacketType() == Server.NAMED_SOUND_EFFECT) + { Object soundEffect = mods.read(0); + SoundType soundType = null; + Location soundLoc = new Location(observer.getWorld(), ((Integer) mods.read(2)) / 8D, ((Integer) mods.read(3)) / 8D, ((Integer) mods.read(4)) / 8D); + Entity disguisedEntity = null; DisguiseSound entitySound = null; + Disguise disguise = null; + Entity[] entities = soundLoc.getChunk().getEntities(); - for (Entity entity : entities) { + + for (Entity entity : entities) + { Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity); - if (entityDisguise != null) { + + if (entityDisguise != null) + { Location loc = entity.getLocation(); + loc = new Location(observer.getWorld(), ((int) (loc.getX() * 8)) / 8D, ((int) (loc.getY() * 8)) / 8D, ((int) (loc.getZ() * 8)) / 8D); - if (loc.equals(soundLoc)) { + + if (loc.equals(soundLoc)) + { entitySound = DisguiseSound.getType(entity.getType().name()); - if (entitySound != null) { + + if (entitySound != null) + { Object obj = null; - if (entity instanceof LivingEntity) { - try { + + if (entity instanceof LivingEntity) + { + try + { // Use reflection so that this works for either int or double methods obj = LivingEntity.class.getMethod("getHealth").invoke(entity); - if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0) { + + if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0) + { soundType = SoundType.DEATH; - } else { + } + else + { obj = null; } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - if (obj == null) { + + if (obj == null) + { boolean hasInvun = false; + Object nmsEntity = ReflectionManager.getNmsEntity(entity); - try { - if (entity instanceof LivingEntity) { - hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks").getInt( - nmsEntity) == ReflectionManager.getNmsField("EntityLiving", - "maxNoDamageTicks").getInt(nmsEntity); - } else { + + try + { + if (entity instanceof LivingEntity) + { + hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks") + .getInt(nmsEntity) == ReflectionManager + .getNmsField("EntityLiving", "maxNoDamageTicks") + .getInt(nmsEntity); + } + else + { Class clazz = ReflectionManager.getNmsClass("DamageSource"); - hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable", clazz) + + hasInvun = (Boolean) ReflectionManager + .getNmsMethod("Entity", "isInvulnerable", clazz) .invoke(nmsEntity, ReflectionManager.getNmsField(clazz, "GENERIC")); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } - soundType = entitySound.getType(ReflectionManager.convertSoundEffectToString(soundEffect), !hasInvun); + + soundType = entitySound.getType(ReflectionManager.convertSoundEffectToString(soundEffect), + !hasInvun); } - if (soundType != null) { + + if (soundType != null) + { disguise = entityDisguise; disguisedEntity = entity; break; @@ -588,79 +808,120 @@ public class PacketsManager { } } } - if (disguise != null) { - if (disguise.isSelfDisguiseSoundsReplaced() || disguisedEntity != event.getPlayer()) { - if (disguise.isSoundsReplaced()) { + + if (disguise != null) + { + if (disguise.isSelfDisguiseSoundsReplaced() || disguisedEntity != event.getPlayer()) + { + if (disguise.isSoundsReplaced()) + { String sound = null; + DisguiseSound dSound = DisguiseSound.getType(disguise.getType().name()); + if (dSound != null) sound = dSound.getSound(soundType); - if (sound == null) { + if (sound == null) + { event.setCancelled(true); - } else { - if (sound.equals("step.grass")) { - try { + } + else + { + if (sound.equals("step.grass")) + { + try + { int typeId = soundLoc.getWorld().getBlockTypeIdAt(soundLoc.getBlockX(), soundLoc.getBlockY() - 1, soundLoc.getBlockZ()); + Object block = ReflectionManager.getNmsMethod("RegistryMaterials", "a", int.class) - .invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null), - typeId); - if (block != null) { + .invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null), typeId); + + if (block != null) + { Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block); - mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound").invoke(step)); + + mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound") + .invoke(step)); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } // There is no else statement. Because seriously. This should never be null. Unless // someone is // sending fake sounds. In which case. Why cancel it. - } else { + } + else + { mods.write(0, ReflectionManager.getCraftSoundEffect(sound)); + // Time to change the pitch and volume if (soundType == SoundType.HURT || soundType == SoundType.DEATH - || soundType == SoundType.IDLE) { + || soundType == SoundType.IDLE) + { // If the volume is the default - if (mods.read(5).equals(entitySound.getDamageAndIdleSoundVolume())) { + if (mods.read(5).equals(entitySound.getDamageAndIdleSoundVolume())) + { mods.write(5, dSound.getDamageAndIdleSoundVolume()); } + // Here I assume its the default pitch as I can't calculate if its real. if (disguise instanceof MobDisguise && disguisedEntity instanceof LivingEntity - && ((MobDisguise) disguise).doesDisguiseAge()) { + && ((MobDisguise) disguise).doesDisguiseAge()) + { boolean baby = false; - if (disguisedEntity instanceof Zombie) { + + if (disguisedEntity instanceof Zombie) + { baby = ((Zombie) disguisedEntity).isBaby(); - } else if (disguisedEntity instanceof Ageable) { + } + else if (disguisedEntity instanceof Ageable) + { baby = !((Ageable) disguisedEntity).isAdult(); } - if (((MobDisguise) disguise).isAdult() == baby) { + if (((MobDisguise) disguise).isAdult() == baby) + { float pitch = (Integer) mods.read(5); - if (baby) { + + if (baby) + { // If the pitch is not the expected if (pitch > 97 || pitch < 111) return; - pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.5F; + + pitch = (DisguiseUtilities.random.nextFloat() + - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.5F; // Min = 1.5 // Cap = 97.5 // Max = 1.7 // Cap = 110.5 - } else { + } + else + { // If the pitch is not the expected if (pitch >= 63 || pitch <= 76) return; - pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.0F; + + pitch = (DisguiseUtilities.random.nextFloat() + - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.0F; // Min = 1 // Cap = 63 // Max = 1.2 // Cap = 75.6 } + pitch *= 63; + if (pitch < 0) pitch = 0; + if (pitch > 255) pitch = 255; + mods.write(6, (int) pitch); } } @@ -670,70 +931,117 @@ public class PacketsManager { } } } - } else if (event.getPacketType() == Server.ENTITY_STATUS) { - if ((byte) mods.read(1) == 2) { + } + else if (event.getPacketType() == Server.ENTITY_STATUS) + { + if ((byte) mods.read(1) == 2) + { // It made a damage animation Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0); + Disguise disguise = DisguiseAPI.getDisguise(observer, entity); + if (disguise != null && !disguise.getType().isPlayer() - && (disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer())) { + && (disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer())) + { DisguiseSound disSound = DisguiseSound.getType(entity.getType().name()); + if (disSound == null) return; + SoundType soundType = null; Object obj = null; - if (entity instanceof LivingEntity) { - try { + + if (entity instanceof LivingEntity) + { + try + { obj = LivingEntity.class.getMethod("getHealth").invoke(entity); - if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0) { + + if (obj instanceof Double ? (Double) obj == 0 : (Integer) obj == 0) + { soundType = SoundType.DEATH; - } else { + } + else + { obj = null; } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - if (obj == null) { + + if (obj == null) + { soundType = SoundType.HURT; } + if (disSound.getSound(soundType) == null - || (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer())) { - if (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer()) { + || (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer())) + { + if (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer()) + { cancelSound = !cancelSound; + if (cancelSound) return; } + disSound = DisguiseSound.getType(disguise.getType().name()); - if (disSound != null) { + + if (disSound != null) + { String sound = disSound.getSound(soundType); - if (sound != null) { + + if (sound != null) + { Location loc = entity.getLocation(); + PacketContainer packet = new PacketContainer(Server.NAMED_SOUND_EFFECT); + mods = packet.getModifier(); + Object craftSoundEffect = ReflectionManager.getCraftSoundEffect(sound); + mods.write(0, craftSoundEffect); - mods.write(1, ReflectionManager.getSoundCategory("master")); //Meh + mods.write(1, ReflectionManager.getSoundCategory("master")); // Meh mods.write(2, (int) (loc.getX() * 8D)); mods.write(3, (int) (loc.getY() * 8D)); mods.write(4, (int) (loc.getZ() * 8D)); mods.write(5, disSound.getDamageAndIdleSoundVolume()); + float pitch; - if (disguise instanceof MobDisguise && !((MobDisguise) disguise).isAdult()) { - pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.5F; - } else - pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.0F; + + if (disguise instanceof MobDisguise && !((MobDisguise) disguise).isAdult()) + { + pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) + * 0.2F + 1.5F; + } + else + pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) + * 0.2F + 1.0F; + if (disguise.getType() == DisguiseType.BAT) pitch *= 95F; + pitch *= 63; + if (pitch < 0) pitch = 0; + if (pitch > 255) pitch = 255; + mods.write(6, (int) pitch); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } @@ -744,102 +1052,159 @@ public class PacketsManager { } } }; - //Self disguise (/vsd) listener - viewDisguisesListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, - Server.NAMED_ENTITY_SPAWN, Server.ATTACH_ENTITY, - Server.REL_ENTITY_MOVE, Server.ENTITY_MOVE_LOOK, - Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, - Server.ENTITY_HEAD_ROTATION, Server.ENTITY_METADATA, - Server.ENTITY_EQUIPMENT, Server.ANIMATION, Server.BED, - Server.ENTITY_EFFECT, Server.ENTITY_VELOCITY, - Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS) { + + // Self disguise (/vsd) listener + viewDisguisesListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, Server.NAMED_ENTITY_SPAWN, + Server.ATTACH_ENTITY, Server.REL_ENTITY_MOVE, Server.ENTITY_MOVE_LOOK, Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, + Server.ENTITY_HEAD_ROTATION, Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION, Server.BED, + Server.ENTITY_EFFECT, Server.ENTITY_VELOCITY, Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS) + { @Override - public void onPacketSending(PacketEvent event) { + public void onPacketSending(PacketEvent event) + { if (event.isCancelled()) return; - if (event.getPlayer().getName().contains("UNKNOWN[")) //If the player is temporary + + if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary return; + final Player observer = event.getPlayer(); - if (event.getPacket().getIntegers().read(0) == observer.getEntityId()) { - if (DisguiseAPI.isSelfDisguised(observer)) { + + if (event.getPacket().getIntegers().read(0) == observer.getEntityId()) + { + if (DisguiseAPI.isSelfDisguised(observer)) + { // Here I grab the packets to convert them to, So I can display them as if the disguise sent them. PacketContainer[][] transformed = transformPacket(event.getPacket(), observer, observer); + PacketContainer[] packets = transformed == null ? null : transformed[0]; + final PacketContainer[] delayedPackets = transformed == null ? null : transformed[1]; - if (packets == null) { - packets = new PacketContainer[]{event.getPacket()}; + + if (packets == null) + { + packets = new PacketContainer[] + { + event.getPacket() + }; } - for (PacketContainer packet : packets) { - if (packet.getType() != Server.PLAYER_INFO) { - if (packet.equals(event.getPacket())) { + + for (PacketContainer packet : packets) + { + if (packet.getType() != Server.PLAYER_INFO) + { + if (packet.equals(event.getPacket())) + { packet = packet.shallowClone(); } + packet.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); } - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } - if (delayedPackets != null && delayedPackets.length > 0) { - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { - public void run() { - try { - for (PacketContainer packet : delayedPackets) { + + if (delayedPackets != null && delayedPackets.length > 0) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { + public void run() + { + try + { + for (PacketContainer packet : delayedPackets) + { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false); } - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } }, 2); } - if (event.getPacketType() == Server.ENTITY_METADATA) { + + if (event.getPacketType() == Server.ENTITY_METADATA) + { event.setPacket(event.getPacket().deepClone()); - for (WrappedWatchableObject watch : event.getPacket().getWatchableCollectionModifier().read(0)) { - if (watch.getIndex() == 0) { + + for (WrappedWatchableObject watch : event.getPacket().getWatchableCollectionModifier().read(0)) + { + if (watch.getIndex() == 0) + { byte b = (byte) watch.getValue(); + byte a = (byte) (b | 1 << 5); + if ((b & 1 << 3) != 0) a = (byte) (a | 1 << 3); + watch.setValue(a); } } - } else if (event.getPacketType() == Server.NAMED_ENTITY_SPAWN) { + } + else if (event.getPacketType() == Server.NAMED_ENTITY_SPAWN) + { event.setCancelled(true); + PacketContainer packet = new PacketContainer(Server.ENTITY_METADATA); + StructureModifier mods = packet.getModifier(); + mods.write(0, observer.getEntityId()); + List watchableList = new ArrayList<>(); Byte b = 1 << 5; + if (observer.isSprinting()) b = (byte) (b | 1 << 3); - WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, b)); + + WrappedWatchableObject watch = new WrappedWatchableObject( + ReflectionManager.createDataWatcherItem(0, b)); + watchableList.add(watch); packet.getWatchableCollectionModifier().write(0, watchableList); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } - } else if (event.getPacketType() == Server.ANIMATION) { - if (event.getPacket().getIntegers().read(1) != 2) { + } + else if (event.getPacketType() == Server.ANIMATION) + { + if (event.getPacket().getIntegers().read(1) != 2) + { event.setCancelled(true); } - } else if (event.getPacketType() == Server.ATTACH_ENTITY - || event.getPacketType() == Server.REL_ENTITY_MOVE - || event.getPacketType() == Server.ENTITY_MOVE_LOOK - || event.getPacketType() == Server.ENTITY_LOOK + } + else if (event.getPacketType() == Server.ATTACH_ENTITY || event.getPacketType() == Server.REL_ENTITY_MOVE + || event.getPacketType() == Server.ENTITY_MOVE_LOOK || event.getPacketType() == Server.ENTITY_LOOK || event.getPacketType() == Server.ENTITY_TELEPORT || event.getPacketType() == Server.ENTITY_HEAD_ROTATION || event.getPacketType() == Server.ENTITY_EFFECT - || event.getPacketType() == Server.ENTITY_EQUIPMENT) { + || event.getPacketType() == Server.ENTITY_EQUIPMENT) + { event.setCancelled(true); - } else if (event.getPacketType() == Server.ENTITY_STATUS) { + } + else if (event.getPacketType() == Server.ENTITY_STATUS) + { Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); + if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() - && event.getPacket().getBytes().read(0) == 2) { + && event.getPacket().getBytes().read(0) == 2) + { event.setCancelled(true); } } @@ -847,56 +1212,91 @@ public class PacketsManager { } } }; - inventoryListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGHEST, Server.SET_SLOT, - Server.WINDOW_ITEMS, PacketType.Play.Client.HELD_ITEM_SLOT, - PacketType.Play.Client.SET_CREATIVE_SLOT, PacketType.Play.Client.WINDOW_CLICK) { + + inventoryListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGHEST, Server.SET_SLOT, Server.WINDOW_ITEMS, + PacketType.Play.Client.HELD_ITEM_SLOT, PacketType.Play.Client.SET_CREATIVE_SLOT, + PacketType.Play.Client.WINDOW_CLICK) + { @Override - public void onPacketReceiving(final PacketEvent event) { + public void onPacketReceiving(final PacketEvent event) + { if (event.isCancelled()) return; - if (event.getPlayer().getName().contains("UNKNOWN[")) //If the player is temporary + + if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary return; + if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory) - && event.getPlayer().getVehicle() == null) { + && event.getPlayer().getVehicle() == null) + { Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); + // If player is disguised, views self disguises and has a inventory modifier - if (disguise != null && disguise.isSelfDisguiseVisible() && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { + if (disguise != null && disguise.isSelfDisguiseVisible() + && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) + { // If they are in creative and clicked on a slot - if (event.getPacketType() == PacketType.Play.Client.SET_CREATIVE_SLOT) { + if (event.getPacketType() == PacketType.Play.Client.SET_CREATIVE_SLOT) + { int slot = event.getPacket().getIntegers().read(0); - if (slot >= 5 && slot <= 8) { - if (disguise.isHidingArmorFromSelf()) { + + if (slot >= 5 && slot <= 8) + { + if (disguise.isHidingArmorFromSelf()) + { int armorSlot = Math.abs((slot - 5) - 3); - org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot]; - if (item != null && item.getType() != Material.AIR) { + + org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory() + .getArmorContents()[armorSlot]; + + if (item != null && item.getType() != Material.AIR) + { PacketContainer packet = new PacketContainer(Server.SET_SLOT); + StructureModifier mods = packet.getModifier(); + mods.write(0, 0); mods.write(1, slot); mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } } - } else if (slot >= 36 && slot <= 44) { - if (disguise.isHidingHeldItemFromSelf()) { + } + else if (slot >= 36 && slot <= 44) + { + if (disguise.isHidingHeldItemFromSelf()) + { int currentSlot = event.getPlayer().getInventory().getHeldItemSlot(); - if (slot + 36 == currentSlot) { + + if (slot + 36 == currentSlot) + { org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand(); - if (item != null && item.getType() != Material.AIR) { + + if (item != null && item.getType() != Material.AIR) + { PacketContainer packet = new PacketContainer(Server.SET_SLOT); + StructureModifier mods = packet.getModifier(); mods.write(0, 0); mods.write(1, slot); mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } @@ -905,97 +1305,149 @@ public class PacketsManager { } } // If the player switched item, aka he moved from slot 1 to slot 2 - else if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_SLOT) { - if (disguise.isHidingHeldItemFromSelf()) { + else if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_SLOT) + { + if (disguise.isHidingHeldItemFromSelf()) + { // From logging, it seems that both bukkit and nms uses the same thing for the slot switching. // 0 1 2 3 - 8 // If the packet is coming, then I need to replace the item they are switching to // As for the old item, I need to restore it. org.bukkit.inventory.ItemStack currentlyHeld = event.getPlayer().getItemInHand(); // If his old weapon isn't air - if (currentlyHeld != null && currentlyHeld.getType() != Material.AIR) { + if (currentlyHeld != null && currentlyHeld.getType() != Material.AIR) + { PacketContainer packet = new PacketContainer(Server.SET_SLOT); + StructureModifier mods = packet.getModifier(); + mods.write(0, 0); mods.write(1, event.getPlayer().getInventory().getHeldItemSlot() + 36); mods.write(2, ReflectionManager.getNmsItem(currentlyHeld)); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } + org.bukkit.inventory.ItemStack newHeld = event.getPlayer().getInventory() .getItem(event.getPacket().getIntegers().read(0)); + // If his new weapon isn't air either! - if (newHeld != null && newHeld.getType() != Material.AIR) { + if (newHeld != null && newHeld.getType() != Material.AIR) + { PacketContainer packet = new PacketContainer(Server.SET_SLOT); + StructureModifier mods = packet.getModifier(); + mods.write(0, 0); mods.write(1, event.getPacket().getIntegers().read(0) + 36); mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } } - } else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK) { + } + else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK) + { int slot = event.getPacket().getIntegers().read(1); + org.bukkit.inventory.ItemStack clickedItem; - if (event.getPacket().getShorts().read(0) == 1) { + + if (event.getPacket().getShorts().read(0) == 1) + { // Its a shift click clickedItem = event.getPacket().getItemModifier().read(0); - if (clickedItem != null && clickedItem.getType() != Material.AIR) { + + if (clickedItem != null && clickedItem.getType() != Material.AIR) + { // Rather than predict the clients actions // Lets just update the entire inventory.. - Bukkit.getScheduler().runTask(libsDisguises, new Runnable() { - public void run() { + Bukkit.getScheduler().runTask(libsDisguises, new Runnable() + { + public void run() + { event.getPlayer().updateInventory(); } }); } + return; - } else { + } + else + { // If its not a player inventory click // Shift clicking is exempted for the item in hand.. - if (event.getPacket().getIntegers().read(0) != 0) { + if (event.getPacket().getIntegers().read(0) != 0) + { return; } + clickedItem = event.getPlayer().getItemOnCursor(); } - if (clickedItem != null && clickedItem.getType() != Material.AIR) { + + if (clickedItem != null && clickedItem.getType() != Material.AIR) + { // If the slot is a armor slot - if (slot >= 5 && slot <= 8) { - if (disguise.isHidingArmorFromSelf()) { + if (slot >= 5 && slot <= 8) + { + if (disguise.isHidingArmorFromSelf()) + { PacketContainer packet = new PacketContainer(Server.SET_SLOT); + StructureModifier mods = packet.getModifier(); + mods.write(0, 0); mods.write(1, slot); mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } // Else if its a hotbar slot - } else if (slot >= 36 && slot <= 44) { - if (disguise.isHidingHeldItemFromSelf()) { + } + else if (slot >= 36 && slot <= 44) + { + if (disguise.isHidingHeldItemFromSelf()) + { int currentSlot = event.getPlayer().getInventory().getHeldItemSlot(); + // Check if the player is on the same slot as the slot that its setting - if (slot == currentSlot + 36) { + if (slot == currentSlot + 36) + { PacketContainer packet = new PacketContainer(Server.SET_SLOT); + StructureModifier mods = packet.getModifier(); mods.write(0, 0); mods.write(1, slot); mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); - try { + + try + { ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } @@ -1008,80 +1460,119 @@ public class PacketsManager { } @Override - public void onPacketSending(PacketEvent event) { + public void onPacketSending(PacketEvent event) + { // If the inventory is the players inventory if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory) - && event.getPlayer().getVehicle() == null && event.getPacket().getIntegers().read(0) == 0) { + && event.getPlayer().getVehicle() == null && event.getPacket().getIntegers().read(0) == 0) + { + Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); + // If the player is disguised, views self disguises and is hiding a item. if (disguise != null && disguise.isSelfDisguiseVisible() - && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { + && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) + { // If the server is setting the slot // Need to set it to air if its in a place it shouldn't be. // Things such as picking up a item, spawned in item. Plugin sets the item. etc. Will fire this /** * Done */ - if (event.getPacketType() == Server.SET_SLOT) { + if (event.getPacketType() == Server.SET_SLOT) + { // The raw slot // nms code has the start of the hotbar being 36. int slot = event.getPacket().getIntegers().read(1); + // If the slot is a armor slot - if (slot >= 5 && slot <= 8) { - if (disguise.isHidingArmorFromSelf()) { + if (slot >= 5 && slot <= 8) + { + if (disguise.isHidingArmorFromSelf()) + { // Get the bukkit armor slot! int armorSlot = Math.abs((slot - 5) - 3); - org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot]; - if (item != null && item.getType() != Material.AIR) { + + org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory() + .getArmorContents()[armorSlot]; + + if (item != null && item.getType() != Material.AIR) + { event.setPacket(event.getPacket().shallowClone()); - event.getPacket().getModifier() - .write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); + + event.getPacket().getModifier().write(2, + ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); } } // Else if its a hotbar slot - } else if (slot >= 36 && slot <= 44) { - if (disguise.isHidingHeldItemFromSelf()) { + } + else if (slot >= 36 && slot <= 44) + { + if (disguise.isHidingHeldItemFromSelf()) + { int currentSlot = event.getPlayer().getInventory().getHeldItemSlot(); + // Check if the player is on the same slot as the slot that its setting - if (slot == currentSlot + 36) { + if (slot == currentSlot + 36) + { org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand(); - if (item != null && item.getType() != Material.AIR) { + + if (item != null && item.getType() != Material.AIR) + { event.setPacket(event.getPacket().shallowClone()); - event.getPacket() - .getModifier() - .write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); + event.getPacket().getModifier().write(2, + ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0))); } } } } - } else if (event.getPacketType() == Server.WINDOW_ITEMS) { + } + else if (event.getPacketType() == Server.WINDOW_ITEMS) + { event.setPacket(event.getPacket().deepClone()); + StructureModifier mods = event.getPacket().getItemArrayModifier(); ItemStack[] items = mods.read(0); - for (int slot = 0; slot < items.length; slot++) { - if (slot >= 5 && slot <= 8) { - if (disguise.isHidingArmorFromSelf()) { + + for (int slot = 0; slot < items.length; slot++) + { + if (slot >= 5 && slot <= 8) + { + if (disguise.isHidingArmorFromSelf()) + { // Get the bukkit armor slot! int armorSlot = Math.abs((slot - 5) - 3); - org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot]; - if (item != null && item.getType() != Material.AIR) { + + org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory() + .getArmorContents()[armorSlot]; + + if (item != null && item.getType() != Material.AIR) + { items[slot] = new org.bukkit.inventory.ItemStack(0); } } // Else if its a hotbar slot - } else if (slot >= 36 && slot <= 44) { - if (disguise.isHidingHeldItemFromSelf()) { + } + else if (slot >= 36 && slot <= 44) + { + if (disguise.isHidingHeldItemFromSelf()) + { int currentSlot = event.getPlayer().getInventory().getHeldItemSlot(); + // Check if the player is on the same slot as the slot that its setting - if (slot == currentSlot + 36) { + if (slot == currentSlot + 36) + { org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand(); - if (item != null && item.getType() != Material.AIR) { + + if (item != null && item.getType() != Material.AIR) + { items[slot] = new org.bukkit.inventory.ItemStack(0); } } } } } + mods.write(0, items); } } @@ -1090,43 +1581,58 @@ public class PacketsManager { }; } - public static boolean isHearDisguisesEnabled() { + public static boolean isHearDisguisesEnabled() + { return soundsListenerEnabled; } - public static boolean isInventoryListenerEnabled() { + public static boolean isInventoryListenerEnabled() + { return inventoryModifierEnabled; } - public static boolean isViewDisguisesListenerEnabled() { + public static boolean isViewDisguisesListenerEnabled() + { return viewDisguisesListenerEnabled; } - public static void setHearDisguisesListener(boolean enabled) { - //TODO: FIX SOUNDS -// if (soundsListenerEnabled != enabled) { -// soundsListenerEnabled = enabled; -// if (soundsListenerEnabled) { -// ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener); -// } else { -// ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener); -// } -// } + public static void setHearDisguisesListener(boolean enabled) + { + // TODO: FIX SOUNDS + // if (soundsListenerEnabled != enabled) { + // soundsListenerEnabled = enabled; + // if (soundsListenerEnabled) { + // ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener); + // } else { + // ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener); + // } + // } } - public static void setInventoryListenerEnabled(boolean enabled) { - if (inventoryModifierEnabled != enabled) { + public static void setInventoryListenerEnabled(boolean enabled) + { + if (inventoryModifierEnabled != enabled) + { inventoryModifierEnabled = enabled; - if (inventoryModifierEnabled) { + + if (inventoryModifierEnabled) + { ProtocolLibrary.getProtocolManager().addPacketListener(inventoryListener); - } else { + } + else + { ProtocolLibrary.getProtocolManager().removePacketListener(inventoryListener); } - for (Player player : Bukkit.getOnlinePlayers()) { + + for (Player player : Bukkit.getOnlinePlayers()) + { Disguise disguise = DisguiseAPI.getDisguise(player, player); - if (disguise != null) { + + if (disguise != null) + { if (viewDisguisesListenerEnabled && disguise.isSelfDisguiseVisible() - && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { + && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) + { player.updateInventory(); } } @@ -1134,11 +1640,15 @@ public class PacketsManager { } } - public static void setupMainPacketsListener() { - if (clientInteractEntityListener != null) { - if (mainListener != null) { + public static void setupMainPacketsListener() + { + if (clientInteractEntityListener != null) + { + if (mainListener != null) + { ProtocolLibrary.getProtocolManager().removePacketListener(mainListener); } + List packetsToListen = new ArrayList<>(); // Add spawn packets { @@ -1148,105 +1658,161 @@ public class PacketsManager { packetsToListen.add(Server.SPAWN_ENTITY_LIVING); packetsToListen.add(Server.SPAWN_ENTITY_PAINTING); } + // Add packets that always need to be enabled to ensure safety { packetsToListen.add(Server.ENTITY_METADATA); } - if (DisguiseConfig.isCollectPacketsEnabled()) { + + if (DisguiseConfig.isCollectPacketsEnabled()) + { packetsToListen.add(Server.COLLECT); } - if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { + + if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) + { packetsToListen.add(Server.UPDATE_ATTRIBUTES); } + // The bed packet. - if (DisguiseConfig.isBedPacketsEnabled()) { + if (DisguiseConfig.isBedPacketsEnabled()) + { packetsToListen.add(Server.BED); } + // Add movement packets - if (DisguiseConfig.isMovementPacketsEnabled()) { + if (DisguiseConfig.isMovementPacketsEnabled()) + { packetsToListen.add(Server.ENTITY_LOOK); packetsToListen.add(Server.ENTITY_MOVE_LOOK); packetsToListen.add(Server.ENTITY_HEAD_ROTATION); packetsToListen.add(Server.ENTITY_TELEPORT); packetsToListen.add(Server.REL_ENTITY_MOVE); } + // Add equipment packet - if (DisguiseConfig.isEquipmentPacketsEnabled()) { + if (DisguiseConfig.isEquipmentPacketsEnabled()) + { packetsToListen.add(Server.ENTITY_EQUIPMENT); } + // Add the packet that ensures if they are sleeping or not - if (DisguiseConfig.isAnimationPacketsEnabled()) { + if (DisguiseConfig.isAnimationPacketsEnabled()) + { packetsToListen.add(Server.ANIMATION); } + // Add the packet that makes sure that entities with armor do not send unpickupable armor on death - if (DisguiseConfig.isEntityStatusPacketsEnabled()) { + if (DisguiseConfig.isEntityStatusPacketsEnabled()) + { packetsToListen.add(Server.ENTITY_STATUS); } - mainListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, packetsToListen) { + mainListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, packetsToListen) + { @Override - public void onPacketSending(PacketEvent event) { + public void onPacketSending(PacketEvent event) + { if (event.isCancelled()) return; - if (event.getPlayer().getName().contains("UNKNOWN[")) //If the player is temporary + + if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary return; + final Player observer = event.getPlayer(); + // First get the entity, the one sending this packet StructureModifier entityModifer = event.getPacket().getEntityModifier(observer.getWorld()); + org.bukkit.entity.Entity entity = entityModifer.read((Server.COLLECT == event.getPacketType() ? 1 : 0)); + // If the entity is the same as the sender. Don't disguise! // Prevents problems and there is no advantage to be gained. if (entity == observer) return; + PacketContainer[][] packets = transformPacket(event.getPacket(), event.getPlayer(), entity); - if (packets != null) { + + if (packets != null) + { event.setCancelled(true); - try { - for (PacketContainer packet : packets[0]) { + + try + { + for (PacketContainer packet : packets[0]) + { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false); } + final PacketContainer[] delayed = packets[1]; - if (delayed.length > 0) { - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { - public void run() { - try { - for (PacketContainer packet : delayed) { + + if (delayed.length > 0) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() + { + public void run() + { + try + { + for (PacketContainer packet : delayed) + { ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false); } - } catch (InvocationTargetException e) { + } + catch (InvocationTargetException e) + { e.printStackTrace(); } } }, 2); } - } catch (InvocationTargetException ex) { + } + catch (InvocationTargetException ex) + { ex.printStackTrace(); } } } }; + ProtocolLibrary.getProtocolManager().addPacketListener(mainListener); } } - public static void setViewDisguisesListener(boolean enabled) { - if (viewDisguisesListenerEnabled != enabled) { + public static void setViewDisguisesListener(boolean enabled) + { + if (viewDisguisesListenerEnabled != enabled) + { viewDisguisesListenerEnabled = enabled; - if (viewDisguisesListenerEnabled) { + + if (viewDisguisesListenerEnabled) + { ProtocolLibrary.getProtocolManager().addPacketListener(viewDisguisesListener); - } else { + } + else + { ProtocolLibrary.getProtocolManager().removePacketListener(viewDisguisesListener); } - for (Player player : Bukkit.getOnlinePlayers()) { + + for (Player player : Bukkit.getOnlinePlayers()) + { Disguise disguise = DisguiseAPI.getDisguise(player, player); - if (disguise != null) { - if (disguise.isSelfDisguiseVisible()) { - if (enabled) { + + if (disguise != null) + { + if (disguise.isSelfDisguiseVisible()) + { + if (enabled) + { DisguiseUtilities.setupFakeDisguise(disguise); - } else { + } + else + { DisguiseUtilities.removeSelfDisguise(player); } - if (inventoryModifierEnabled && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { + + if (inventoryModifierEnabled && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) + { player.updateInventory(); } } @@ -1259,144 +1825,216 @@ public class PacketsManager { * Transform the packet magically into the one I have always dreamed off. My true luv!!! This will return null if its not * transformed */ - public static PacketContainer[][] transformPacket(PacketContainer sentPacket, Player observer, Entity entity) { + public static PacketContainer[][] transformPacket(PacketContainer sentPacket, Player observer, Entity entity) + { PacketContainer[] packets = null; + PacketContainer[] delayedPackets = new PacketContainer[0]; - try { + + try + { Disguise disguise = DisguiseAPI.getDisguise(observer, entity); + // If disguised. - if (disguise != null) { - packets = new PacketContainer[]{sentPacket}; + if (disguise != null) + { + packets = new PacketContainer[] + { + sentPacket + }; // This packet sends attributes - if (sentPacket.getType() == Server.UPDATE_ATTRIBUTES) { - if (disguise.isMiscDisguise()) { + if (sentPacket.getType() == Server.UPDATE_ATTRIBUTES) + { + if (disguise.isMiscDisguise()) + { packets = new PacketContainer[0]; - } else { + } + else + { List attributes = new ArrayList<>(); - for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) { - if (attribute.getAttributeKey().equals("generic.maxHealth")) { + + for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) + { + if (attribute.getAttributeKey().equals("generic.maxHealth")) + { packets[0] = new PacketContainer(Server.UPDATE_ATTRIBUTES); + Builder builder; - if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { + + if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) + { builder = WrappedAttribute.newBuilder(); builder.attributeKey("generic.maxHealth"); builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth()); - } else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity()) { + } + else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity()) + { builder = WrappedAttribute.newBuilder(attribute); - } else { + } + else + { builder = WrappedAttribute.newBuilder(); builder.attributeKey("generic.maxHealth"); builder.baseValue(DisguiseValues.getDisguiseValues(disguise.getType()).getMaxHealth()); } + builder.packet(packets[0]); + attributes.add(builder.build()); break; } } - if (!attributes.isEmpty()) { + + if (!attributes.isEmpty()) + { packets[0].getIntegers().write(0, entity.getEntityId()); packets[0].getAttributeCollectionModifier().write(0, attributes); - } else { + } + else + { packets = new PacketContainer[0]; } } } // Else if the packet is sending entity metadata - else if (sentPacket.getType() == Server.ENTITY_METADATA) { - if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) { - List watchableObjects = disguise.getWatcher().convert( - packets[0].getWatchableCollectionModifier().read(0)); + else if (sentPacket.getType() == Server.ENTITY_METADATA) + { + if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) + { + List watchableObjects = disguise.getWatcher() + .convert(packets[0].getWatchableCollectionModifier().read(0)); + packets[0] = new PacketContainer(sentPacket.getType()); + StructureModifier newMods = packets[0].getModifier(); + newMods.write(0, entity.getEntityId()); + packets[0].getWatchableCollectionModifier().write(0, watchableObjects); - } else { + } + else + { packets = new PacketContainer[0]; } } // Else if the packet is spawning.. - else if (sentPacket.getType() == Server.NAMED_ENTITY_SPAWN - || sentPacket.getType() == Server.SPAWN_ENTITY_LIVING + else if (sentPacket.getType() == Server.NAMED_ENTITY_SPAWN || sentPacket.getType() == Server.SPAWN_ENTITY_LIVING || sentPacket.getType() == Server.SPAWN_ENTITY_EXPERIENCE_ORB - || sentPacket.getType() == Server.SPAWN_ENTITY - || sentPacket.getType() == Server.SPAWN_ENTITY_PAINTING) { + || sentPacket.getType() == Server.SPAWN_ENTITY || sentPacket.getType() == Server.SPAWN_ENTITY_PAINTING) + { PacketContainer[][] spawnPackets = constructSpawnPackets(observer, disguise, entity); + packets = spawnPackets[0]; delayedPackets = spawnPackets[1]; } // Else if the disguise is attempting to send players a forbidden packet - else if (sentPacket.getType() == Server.ANIMATION) { - if (disguise.getType().isMisc() - || (packets[0].getIntegers().read(1) == 2 && (!disguise.getType() - .isPlayer() || (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise - .getWatcher()).isSleeping())))) { + else if (sentPacket.getType() == Server.ANIMATION) + { + if (disguise.getType().isMisc() || (packets[0].getIntegers().read(1) == 2 && (!disguise.getType().isPlayer() + || (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping())))) + { packets = new PacketContainer[0]; } } - //Else if the disguise is collecting stuff - else if (sentPacket.getType() == Server.COLLECT) { - if (disguise.getType().isMisc()) { + // Else if the disguise is collecting stuff + else if (sentPacket.getType() == Server.COLLECT) + { + if (disguise.getType().isMisc()) + { packets = new PacketContainer[0]; - } else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer() - && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) { + } + + else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer() + && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) + { PacketContainer newPacket = new PacketContainer(Server.ANIMATION); + StructureModifier mods = newPacket.getIntegers(); mods.write(0, disguise.getEntity().getEntityId()); mods.write(1, 3); - packets = new PacketContainer[]{newPacket, sentPacket}; + + packets = new PacketContainer[] + { + newPacket, sentPacket + }; } } // Else if the disguise is moving. - else if (sentPacket.getType() == Server.ENTITY_MOVE_LOOK - || sentPacket.getType() == Server.ENTITY_LOOK - || sentPacket.getType() == Server.ENTITY_TELEPORT - || sentPacket.getType() == Server.REL_ENTITY_MOVE) { - if (disguise.getType() == DisguiseType.RABBIT && (sentPacket.getType() == Server.REL_ENTITY_MOVE || sentPacket.getType() == Server.ENTITY_MOVE_LOOK)) { - //Rabbit robbing... + else if (sentPacket.getType() == Server.ENTITY_MOVE_LOOK || sentPacket.getType() == Server.ENTITY_LOOK + || sentPacket.getType() == Server.ENTITY_TELEPORT || sentPacket.getType() == Server.REL_ENTITY_MOVE) + { + if (disguise.getType() == DisguiseType.RABBIT && (sentPacket.getType() == Server.REL_ENTITY_MOVE + || sentPacket.getType() == Server.ENTITY_MOVE_LOOK)) + { + // Rabbit robbing... if (entity.getMetadata("LibsRabbitHop").isEmpty() || System.currentTimeMillis() - entity.getMetadata("LibsRabbitHop").get(0).asLong() < 100 - || System.currentTimeMillis() - entity.getMetadata("LibsRabbitHop").get(0).asLong() > 500) { + || System.currentTimeMillis() - entity.getMetadata("LibsRabbitHop").get(0).asLong() > 500) + { if (entity.getMetadata("LibsRabbitHop").isEmpty() - || System.currentTimeMillis() - entity.getMetadata("LibsRabbitHop").get(0).asLong() > 500) { + || System.currentTimeMillis() - entity.getMetadata("LibsRabbitHop").get(0).asLong() > 500) + { entity.removeMetadata("LibsRabbitHop", libsDisguises); - entity.setMetadata("LibsRabbitHop", new FixedMetadataValue(libsDisguises, System.currentTimeMillis())); + entity.setMetadata("LibsRabbitHop", + new FixedMetadataValue(libsDisguises, System.currentTimeMillis())); } + packets = Arrays.copyOf(packets, packets.length + 1); + packets[1] = new PacketContainer(Server.ENTITY_STATUS); + packets[1].getIntegers().write(0, entity.getEntityId()); packets[1].getBytes().write(0, (byte) 1); } } - //Stop wither skulls from looking - if (sentPacket.getType() == Server.ENTITY_LOOK && disguise.getType() == DisguiseType.WITHER_SKULL) { + // Stop wither skulls from looking + if (sentPacket.getType() == Server.ENTITY_LOOK && disguise.getType() == DisguiseType.WITHER_SKULL) + { packets = new PacketContainer[0]; - } else if (sentPacket.getType() != Server.REL_ENTITY_MOVE) { + } + else if (sentPacket.getType() != Server.REL_ENTITY_MOVE) + { packets[0] = sentPacket.shallowClone(); + StructureModifier bytes = packets[0].getBytes(); + byte yawValue = bytes.read(0); - bytes.write(0, getYaw(disguise.getType(), entity.getType(), yawValue)); byte pitchValue = bytes.read(1); + + bytes.write(0, getYaw(disguise.getType(), entity.getType(), yawValue)); bytes.write(1, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue)); - if (sentPacket.getType() == Server.ENTITY_TELEPORT && disguise.getType() == DisguiseType.ITEM_FRAME) { + + if (sentPacket.getType() == Server.ENTITY_TELEPORT && disguise.getType() == DisguiseType.ITEM_FRAME) + { StructureModifier doubles = packets[0].getDoubles(); + Location loc = entity.getLocation(); + double data = (((loc.getYaw() % 360) + 720 + 45) / 90) % 4; - if (data % 2 == 0) { - if (data % 2 == 0) { + + if (data % 2 == 0) + { + if (data % 2 == 0) + { doubles.write(3, loc.getZ()); - } else { + } + else + { doubles.write(1, loc.getZ()); } } + double y = getYModifier(entity, disguise); - if (y != 0) { + + if (y != 0) + { y *= 32; doubles.write(2, doubles.read(2) + y); } @@ -1404,109 +2042,153 @@ public class PacketsManager { } } - //Else if the disguise is updating equipment - else if (sentPacket.getType() == Server.ENTITY_EQUIPMENT) { + // Else if the disguise is updating equipment + else if (sentPacket.getType() == Server.ENTITY_EQUIPMENT) + { EquipmentSlot slot = ReflectionManager.createEquipmentSlot(packets[0].getModifier().read(1)); + org.bukkit.inventory.ItemStack itemStack = disguise.getWatcher().getItemStack(slot); - if (itemStack != null) { + + if (itemStack != null) + { packets[0] = packets[0].shallowClone(); - packets[0].getModifier().write(2, (itemStack.getTypeId() == 0 ? null : ReflectionManager.getNmsItem(itemStack))); + + packets[0].getModifier().write(2, + (itemStack.getTypeId() == 0 ? null : ReflectionManager.getNmsItem(itemStack))); } - if (disguise.getWatcher().isRightClicking() && slot == EquipmentSlot.HAND) { + if (disguise.getWatcher().isRightClicking() && slot == EquipmentSlot.HAND) + { ItemStack heldItem = packets[0].getItemModifier().read(0); - if (heldItem != null && heldItem.getType() != Material.AIR) { + + if (heldItem != null && heldItem.getType() != Material.AIR) + { // Convert the datawatcher List list = new ArrayList<>(); - if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) { - WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, - WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); + + if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) + { + WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager + .createDataWatcherItem(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); + list.add(watch); + list = disguise.getWatcher().convert(list); - } else { - for (WrappedWatchableObject obj : disguise.getWatcher().getWatchableObjects()) { - if (obj.getIndex() == 0) { + } + else + { + for (WrappedWatchableObject obj : disguise.getWatcher().getWatchableObjects()) + { + if (obj.getIndex() == 0) + { list.add(obj); break; } } } + // Construct the packets to return PacketContainer packetBlock = new PacketContainer(Server.ENTITY_METADATA); + packetBlock.getModifier().write(0, entity.getEntityId()); packetBlock.getWatchableCollectionModifier().write(0, list); + PacketContainer packetUnblock = packetBlock.deepClone(); // Make a packet to send the 'unblock' - for (WrappedWatchableObject watcher : packetUnblock.getWatchableCollectionModifier().read(0)) { + for (WrappedWatchableObject watcher : packetUnblock.getWatchableCollectionModifier().read(0)) + { watcher.setValue((byte) ((byte) watcher.getValue() & ~(1 << 4))); } + // Send the unblock before the itemstack change so that the 2nd metadata packet works. Why? Scheduler // delay. - packets = new PacketContainer[]{packetUnblock, packets[0], packetBlock}; + packets = new PacketContainer[] + { + packetUnblock, packets[0], packetBlock + }; // Silly mojang made the right clicking datawatcher value only valid for one use. So I have to reset // it. } } } - //If the entity is going into a bed, stop everything but players from doing this - else if (sentPacket.getType() == Server.BED) { - if (!disguise.getType().isPlayer()) { + // If the entity is going into a bed, stop everything but players from doing this + else if (sentPacket.getType() == Server.BED) + { + if (!disguise.getType().isPlayer()) + { packets = new PacketContainer[0]; } } - //If the entity is updating their Facebook status, stop them from showing death - else if (sentPacket.getType() == Server.ENTITY_STATUS) { - if (packets[0].getBytes().read(0) == (byte) 3) { + // If the entity is updating their Facebook status, stop them from showing death + else if (sentPacket.getType() == Server.ENTITY_STATUS) + { + if (packets[0].getBytes().read(0) == (byte) 3) + { packets = new PacketContainer[0]; } } - //If the entity is rotating his head - else if (sentPacket.getType() == Server.ENTITY_HEAD_ROTATION) { - if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) { + // If the entity is rotating his head + else if (sentPacket.getType() == Server.ENTITY_HEAD_ROTATION) + { + if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) + { Location loc = entity.getLocation(); + byte pitch = getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), (byte) (int) (loc.getPitch() * 256.0F / 360.0F)); byte yaw = getYaw(disguise.getType(), entity.getType(), sentPacket.getBytes().read(0)); + PacketContainer rotation = new PacketContainer(Server.ENTITY_HEAD_ROTATION); + StructureModifier mods = rotation.getModifier(); + mods.write(0, entity.getEntityId()); mods.write(1, yaw); + PacketContainer look = new PacketContainer(Server.ENTITY_LOOK); + look.getIntegers().write(0, entity.getEntityId()); look.getBytes().write(0, yaw); look.getBytes().write(1, pitch); - packets = new PacketContainer[]{look, rotation}; + + packets = new PacketContainer[] + { + look, rotation + }; } } - //Whatever - else { + // Whatever + else + { packets = null; } } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } - return packets == null ? null : new PacketContainer[][]{packets, delayedPackets}; + return packets == null ? null : new PacketContainer[][] + { + packets, delayedPackets + }; } /** * Returns true if this disguise type doesn't have changing metadata. + * * @param disguise * @return */ - public static boolean isStaticMetadataDisguiseType(Disguise disguise) { - return (disguise.getType() == DisguiseType.WOLF || - disguise.getType() == DisguiseType.OCELOT || - disguise.getType() == DisguiseType.ENDERMAN || - disguise.getType() == DisguiseType.SHULKER || - disguise.getType() == DisguiseType.SPLASH_POTION || - disguise.getType() == DisguiseType.FIREWORK || - disguise.getType() == DisguiseType.DROPPED_ITEM || - disguise.getType() == DisguiseType.ENDER_CRYSTAL - ); + public static boolean isStaticMetadataDisguiseType(Disguise disguise) + { + return (disguise.getType() == DisguiseType.WOLF || disguise.getType() == DisguiseType.OCELOT + || disguise.getType() == DisguiseType.ENDERMAN || disguise.getType() == DisguiseType.SHULKER + || disguise.getType() == DisguiseType.SPLASH_POTION || disguise.getType() == DisguiseType.FIREWORK + || disguise.getType() == DisguiseType.DROPPED_ITEM || disguise.getType() == DisguiseType.ENDER_CRYSTAL); } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java similarity index 58% rename from src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java rename to src/me/libraryaddict/disguise/utilities/ReflectionManager.java index 01afdabc..df23d0d4 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -1,12 +1,13 @@ package me.libraryaddict.disguise.utilities; -import com.comphenix.protocol.wrappers.MinecraftKey; -import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry; -import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer; -import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject; -import com.comphenix.protocol.wrappers.WrappedGameProfile; -import com.google.common.collect.ImmutableMap; -import com.mojang.authlib.GameProfile; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Map; +import java.util.UUID; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Art; @@ -23,15 +24,16 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Map; -import java.util.UUID; +import com.comphenix.protocol.wrappers.MinecraftKey; +import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry; +import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer; +import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject; +import com.comphenix.protocol.wrappers.WrappedGameProfile; +import com.google.common.collect.ImmutableMap; +import com.mojang.authlib.GameProfile; -public class ReflectionManager { +public class ReflectionManager +{ private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3]; private static final Class craftItemClass; @@ -53,491 +55,732 @@ public class ReflectionManager { * * The publicly licensed version may be viewed here: https://gist.github.com/riking/2f330f831c30e2276df7 */ - static { - primitiveTypes = ImmutableMap., String>builder().put(boolean.class, "Z").put(byte.class, "B") + static + { + primitiveTypes = ImmutableMap., 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(); } - static { - for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) { - try { + static + { + for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) + { + try + { if (method.getReturnType() == float.class && Modifier.isProtected(method.getModifiers()) - && method.getParameterTypes().length == 0) { + && method.getParameterTypes().length == 0) + { Object entity = createEntityInstance("Cow"); + method.setAccessible(true); float value = (Float) method.invoke(entity); - if (value == 0.4F) { + + if (value == 0.4F) + { damageAndIdleSoundMethod = method; break; } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } + craftItemClass = getCraftClass("inventory.CraftItemStack"); + pingField = getNmsField("EntityPlayer", "ping"); + trackerField = getNmsField("WorldServer", "tracker"); + entitiesField = getNmsField("EntityTracker", "trackedEntities"); + ihmGet = getNmsMethod("IntHashMap", "get", int.class); - boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class, - 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")); + entityCountField = getNmsField("Entity", "entityCount"); + entityCountField.setAccessible(true); } - public static Object createEntityInstance(String entityName) { - try { + public static Object createEntityInstance(String entityName) + { + try + { Class entityClass = getNmsClass("Entity" + entityName); Object entityObject; Object world = getWorldServer(Bukkit.getWorlds().get(0)); - switch (entityName) { - case "Player": - Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null); - Object playerinteractmanager = getNmsClass("PlayerInteractManager").getDeclaredConstructor(getNmsClass("World")).newInstance(world); - WrappedGameProfile gameProfile = getGameProfile(null, "Steve"); - entityObject = entityClass.getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), - gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world, - gameProfile.getHandle(), playerinteractmanager); - break; - case "EnderPearl": - entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving")).newInstance(world, createEntityInstance("Cow")); - break; - case "Potion": - entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE, Double.TYPE, getNmsClass("ItemStack")) - .newInstance(world, 0d, 0d, 0d, getNmsItem(new ItemStack(Material.SPLASH_POTION))); + + switch (entityName) + { + case "Player": + Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null); + + Object playerinteractmanager = getNmsClass("PlayerInteractManager").getDeclaredConstructor(getNmsClass("World")) + .newInstance(world); + + WrappedGameProfile gameProfile = getGameProfile(null, "Steve"); + + entityObject = entityClass + .getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), + gameProfile.getHandleType(), playerinteractmanager.getClass()) + .newInstance(minecraftServer, world, gameProfile.getHandle(), playerinteractmanager); + break; + case "EnderPearl": + entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving")) + .newInstance(world, createEntityInstance("Cow")); + break; + case "Potion": + entityObject = entityClass + .getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE, Double.TYPE, + getNmsClass("ItemStack")) + .newInstance(world, 0d, 0d, 0d, getNmsItem(new ItemStack(Material.SPLASH_POTION))); + break; + default: + entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world); break; - default: - entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world); - break; } + return entityObject; - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } + return null; } - public static Object getMobEffectList(int id) { + public static Object getMobEffectList(int id) + { Method nmsMethod = getNmsMethod("MobEffectList", "fromId", Integer.TYPE); - try { + + try + { return nmsMethod.invoke(null, id); - } catch (IllegalAccessException | InvocationTargetException e) { + } + catch (IllegalAccessException | InvocationTargetException e) + { e.printStackTrace(); - return null; } - } - public static Object createMobEffect(PotionEffect effect) { - return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()); - } - - public static Object createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) { - try { - return getNmsClass("MobEffect").getDeclaredConstructor(getNmsClass("MobEffectList"), Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE) - .newInstance(getMobEffectList(id), duration, amplification, ambient, particles); - } catch (Exception e) { - e.printStackTrace(System.out); - } return null; } - private static String dir2fqn(String s) { + public static Object createMobEffect(PotionEffect effect) + { + return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), + effect.hasParticles()); + } + + public static Object createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) + { + try + { + return getNmsClass("MobEffect") + .getDeclaredConstructor(getNmsClass("MobEffectList"), Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE) + .newInstance(getMobEffectList(id), duration, amplification, ambient, particles); + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + + return null; + } + + private static String dir2fqn(String s) + { return s.replaceAll("/", "."); } - public static FakeBoundingBox getBoundingBox(Entity entity) { - try { + public static FakeBoundingBox getBoundingBox(Entity entity) + { + try + { Object boundingBox = getNmsMethod("Entity", "getBoundingBox").invoke(getNmsEntity(entity)); + double x = 0, y = 0, z = 0; int stage = 0; - for (Field field : boundingBox.getClass().getDeclaredFields()) { - if (field.getType().getSimpleName().equals("double")) { + + for (Field field : boundingBox.getClass().getDeclaredFields()) + { + 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??"); + + 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??"); } } } + return new FakeBoundingBox(x, y, z); - - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Entity getBukkitEntity(Object nmsEntity) { - try { + public static Entity getBukkitEntity(Object nmsEntity) + { + try + { return (Entity) getNmsMethod("Entity", "getBukkitEntity").invoke(nmsEntity); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static ItemStack getBukkitItem(Object nmsItem) { - try { + public static ItemStack getBukkitItem(Object nmsItem) + { + try + { return (ItemStack) craftItemClass.getMethod("asBukkitCopy", getNmsClass("ItemStack")).invoke(null, nmsItem); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } + return null; } - public static String getBukkitVersion() { + public static String getBukkitVersion() + { return bukkitVersion; } - public static Class getCraftClass(String className) { - try { + public static Class getCraftClass(String className) + { + try + { return Class.forName("org.bukkit.craftbukkit." + getBukkitVersion() + "." + className); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } + return null; } - public static Constructor getCraftConstructor(Class clazz, Class... parameters) { - try { + public static Constructor getCraftConstructor(Class clazz, Class... parameters) + { + try + { Constructor declaredConstructor = clazz.getDeclaredConstructor(parameters); declaredConstructor.setAccessible(true); return declaredConstructor; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { e.printStackTrace(System.out); } + return null; } - public static Constructor getCraftConstructor(String className, Class... parameters) { + public static Constructor getCraftConstructor(String className, Class... parameters) + { return getCraftConstructor(getCraftClass(className), parameters); } - public static String getCraftSound(Sound sound) { - try { + public static String getCraftSound(Sound sound) + { + try + { return (String) getCraftClass("CraftSound").getMethod("getSound", Sound.class).invoke(null, sound); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Object getEntityTrackerEntry(Entity target) throws Exception { + public static Object getEntityTrackerEntry(Entity target) throws Exception + { Object world = getWorldServer(target.getWorld()); Object tracker = trackerField.get(world); Object trackedEntities = entitiesField.get(tracker); + return ihmGet.invoke(trackedEntities, target.getEntityId()); } - public static Object getMinecraftServer() { - try { + public static Object getMinecraftServer() + { + try + { return getCraftMethod("CraftServer", "getServer").invoke(Bukkit.getServer()); - } catch (IllegalAccessException | InvocationTargetException e) { + } + catch (IllegalAccessException | InvocationTargetException e) + { e.printStackTrace(); } return null; } - public static String getEnumArt(Art art) { - try { + public static String getEnumArt(Art art) + { + try + { Object enumArt = getCraftClass("CraftArt").getMethod("BukkitToNotch", Art.class).invoke(null, art); - for (Field field : enumArt.getClass().getDeclaredFields()) { - if (field.getType() == String.class) { + for (Field field : enumArt.getClass().getDeclaredFields()) + { + if (field.getType() == String.class) + { return (String) field.get(enumArt); } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Object getBlockPosition(int x, int y, int z) { - try { + public static Object getBlockPosition(int x, int y, int z) + { + try + { return getNmsClass("BlockPosition").getDeclaredConstructor(int.class, int.class, int.class).newInstance(x, y, z); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Enum getEnumDirection(int direction) { - try { + public static Enum getEnumDirection(int direction) + { + try + { return (Enum) getNmsMethod("EnumDirection", "fromType2", int.class).invoke(null, direction); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Enum getEnumPlayerInfoAction(int action) { - try { + public static Enum getEnumPlayerInfoAction(int action) + { + try + { return (Enum) getNmsClass("PacketPlayOutPlayerInfo$EnumPlayerInfoAction").getEnumConstants()[action]; - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) { - try { + public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) + { + try + { Object playerListName = getNmsClass("ChatComponentText").getDeclaredConstructor(String.class) .newInstance(gameProfile.getName()); - return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData").getDeclaredConstructor(getNmsClass("PacketPlayOutPlayerInfo"), - gameProfile.getHandleType(), int.class, getNmsClass("WorldSettings$EnumGamemode"), getNmsClass("IChatBaseComponent")) + + return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData") + .getDeclaredConstructor(getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(), int.class, + getNmsClass("WorldSettings$EnumGamemode"), getNmsClass("IChatBaseComponent")) .newInstance(playerInfoPacket, gameProfile.getHandle(), 0, getNmsClass("WorldSettings$EnumGamemode").getEnumConstants()[1], playerListName); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static WrappedGameProfile getGameProfile(Player player) { + public static WrappedGameProfile getGameProfile(Player player) + { return WrappedGameProfile.fromPlayer(player); } - public static WrappedGameProfile getGameProfile(UUID uuid, String playerName) { - try { + public static WrappedGameProfile getGameProfile(UUID uuid, String playerName) + { + try + { return new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } return null; } - public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) { - try { + public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) + { + try + { WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName); gameProfile.getProperties().putAll(profileWithSkin.getProperties()); return gameProfile; - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Class getNmsClass(String className) { - try { + public static Class getNmsClass(String className) + { + try + { return Class.forName("net.minecraft.server." + getBukkitVersion() + "." + className); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } + return null; } - public static Constructor getNmsConstructor(Class clazz, Class... parameters) { - try { + public static Constructor getNmsConstructor(Class clazz, Class... parameters) + { + try + { Constructor declaredConstructor = clazz.getDeclaredConstructor(parameters); declaredConstructor.setAccessible(true); return declaredConstructor; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { e.printStackTrace(System.out); } + return null; } - public static Constructor getNmsConstructor(String className, Class... parameters) { + public static Constructor getNmsConstructor(String className, Class... parameters) + { return getNmsConstructor(getNmsClass(className), parameters); } - public static Object getNmsEntity(Entity entity) { - try { + public static Object getNmsEntity(Entity entity) + { + try + { return getCraftClass("entity.CraftEntity").getMethod("getHandle").invoke(entity); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Field getNmsField(Class clazz, String fieldName) { - try { + public static Field getNmsField(Class clazz, String fieldName) + { + try + { Field declaredField = clazz.getDeclaredField(fieldName); declaredField.setAccessible(true); + return declaredField; - } catch (NoSuchFieldException e) { + } + catch (NoSuchFieldException e) + { e.printStackTrace(System.out); } + return null; } - public static Field getNmsField(String className, String fieldName) { + public static Field getNmsField(String className, String fieldName) + { return getNmsField(getNmsClass(className), fieldName); } - public static Object getNmsItem(ItemStack itemstack) { - try { + public static Object getNmsItem(ItemStack itemstack) + { + try + { return craftItemClass.getDeclaredMethod("asNMSCopy", ItemStack.class).invoke(null, itemstack); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(System.out); } + return null; } - public static Method getCraftMethod(String className, String methodName, Class... parameters) { + public static Method getCraftMethod(String className, String methodName, Class... parameters) + { return getCraftMethod(getCraftClass(className), methodName, parameters); } - public static Method getCraftMethod(Class clazz, String methodName, Class... parameters) { - try { + public static Method getCraftMethod(Class clazz, String methodName, Class... parameters) + { + try + { Method declaredMethod = clazz.getDeclaredMethod(methodName, parameters); declaredMethod.setAccessible(true); + return declaredMethod; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { e.printStackTrace(System.out); } + return null; } - public static Method getNmsMethod(Class clazz, String methodName, Class... parameters) { - try { + public static Method getNmsMethod(Class clazz, String methodName, Class... parameters) + { + try + { Method declaredMethod = clazz.getDeclaredMethod(methodName, parameters); declaredMethod.setAccessible(true); + return declaredMethod; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) + { e.printStackTrace(System.out); } + return null; } - public static Method getNmsMethod(String className, String methodName, Class... parameters) { + public static Method getNmsMethod(String className, String methodName, Class... parameters) + { return getNmsMethod(getNmsClass(className), methodName, parameters); } - public static double getPing(Player player) { - try { + public static double getPing(Player player) + { + try + { return (double) pingField.getInt(ReflectionManager.getNmsEntity(player)); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } - return 0D; + + return 0; } - public static float[] getSize(Entity entity) { - try { + public static float[] getSize(Entity entity) + { + try + { 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}; - } catch (Exception ex) { + return new float[] + { + length, width, height + }; + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) { - try { + public static WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) + { + try + { Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null); - for (Method method : getNmsClass("MinecraftServer").getDeclaredMethods()) { - if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) { + + for (Method method : getNmsClass("MinecraftServer").getDeclaredMethods()) + { + if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) + { Object session = method.invoke(minecraftServer); + return WrappedGameProfile.fromHandle(session.getClass() .getDeclaredMethod("fillProfileProperties", gameProfile.getHandleType(), boolean.class) .invoke(session, gameProfile.getHandle(), true)); } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - public static Float getSoundModifier(Object entity) { - try { + public static Float getSoundModifier(Object entity) + { + try + { damageAndIdleSoundMethod.setAccessible(true); + return (Float) damageAndIdleSoundMethod.invoke(entity); - } catch (Exception ignored) { + } + catch (Exception ignored) + { } return null; } - public static WrappedGameProfile grabProfileAddUUID(String playername) { - try { + public static WrappedGameProfile grabProfileAddUUID(String playername) + { + try + { Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null); - for (Method method : getNmsClass("MinecraftServer").getDeclaredMethods()) { - if (method.getReturnType().getSimpleName().equals("GameProfileRepository")) { + + for (Method method : getNmsClass("MinecraftServer").getDeclaredMethods()) + { + if (method.getReturnType().getSimpleName().equals("GameProfileRepository")) + { Object profileRepo = method.invoke(minecraftServer); + Object agent = Class.forName("com.mojang.authlib.Agent").getDeclaredField("MINECRAFT").get(null); + LibsProfileLookupCaller callback = new LibsProfileLookupCaller(); - profileRepo - .getClass() - .getDeclaredMethod("findProfilesByNames", String[].class, agent.getClass(), - Class.forName("com.mojang.authlib.ProfileLookupCallback")) - .invoke(profileRepo, new String[]{playername}, agent, callback); - if (callback.getGameProfile() != null) { + + profileRepo.getClass().getDeclaredMethod("findProfilesByNames", String[].class, agent.getClass(), + Class.forName("com.mojang.authlib.ProfileLookupCallback")).invoke(profileRepo, new String[] + { + playername + }, agent, callback); + + if (callback.getGameProfile() != null) + { return callback.getGameProfile(); } + return getGameProfile(null, playername); } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } + return null; } - private static String methodSignaturePart(Class param) { - if (param.isArray()) { + private static String methodSignaturePart(Class param) + { + if (param.isArray()) + { return "[" + methodSignaturePart(param.getComponentType()); - } else if (param.isPrimitive()) { + } + else if (param.isPrimitive()) + { return primitiveTypes.get(param); - } else { + } + else + { return "L" + param.getName().replaceAll("\\.", "/") + ";"; } } - public static void removePlayer(Player player) { - //Some future remove code if needed + public static void removePlayer(Player player) + { + // Some future remove code if needed } - public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) { - try { + public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) + { + try + { Location loc = entity.getLocation(); + Object boundingBox = boundingBoxConstructor.newInstance(loc.getX() - newBox.getX(), loc.getY() - newBox.getY(), - loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(), loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ()); + loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(), loc.getY() + newBox.getY(), + loc.getZ() + newBox.getZ()); + setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(System.out); } } - public static Enum getSoundCategory(String category) { + public static Enum getSoundCategory(String category) + { Method method = getNmsMethod("SoundCategory", "a", String.class); - try { + + try + { Enum invoke = (Enum) method.invoke(null, category.toLowerCase()); - if (invoke == null) { + + if (invoke == null) + { Class clazz = getNmsClass("SoundCategory"); Enum[] enums = clazz != null ? (Enum[]) clazz.getEnumConstants() : null; - for (Enum anEnum : enums != null ? enums : new Enum[0]) { - if (anEnum.name().equals("MASTER")) return anEnum; + + for (Enum anEnum : enums != null ? enums : new Enum[0]) + { + if (anEnum.name().equals("MASTER")) + return anEnum; } } - return null; - } catch (Exception e) { - e.printStackTrace(); - return null; } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; } /** @@ -546,25 +789,31 @@ public class ReflectionManager { * @param slot * @return null if the equipment slot is null */ - public static Enum createEnumItemSlot(EquipmentSlot slot) { + public static Enum createEnumItemSlot(EquipmentSlot slot) + { Class clazz = getNmsClass("EnumItemSlot"); + Object[] enums = clazz != null ? clazz.getEnumConstants() : null; - if (enums == null) return null; - switch (slot) { - case HAND: - return (Enum) enums[0]; - case OFF_HAND: - return (Enum) enums[1]; - case FEET: - return (Enum) enums[2]; - case LEGS: - return (Enum) enums[3]; - case CHEST: - return (Enum) enums[4]; - case HEAD: - return (Enum) enums[5]; - default: - return null; + + if (enums == null) + return null; + + switch (slot) + { + case HAND: + return (Enum) enums[0]; + case OFF_HAND: + return (Enum) enums[1]; + case FEET: + return (Enum) enums[2]; + case LEGS: + return (Enum) enums[3]; + case CHEST: + return (Enum) enums[4]; + case HEAD: + return (Enum) enums[5]; + default: + return null; } } @@ -573,26 +822,32 @@ public class ReflectionManager { * * @return null if the object isn't an nms EnumItemSlot */ - public static EquipmentSlot createEquipmentSlot(Object enumItemSlot) { - try { + public static EquipmentSlot createEquipmentSlot(Object enumItemSlot) + { + try + { Enum nmsSlot = (Enum) enumItemSlot; - switch (nmsSlot.name()) { - case "MAINHAND": - return EquipmentSlot.HAND; - case "OFFHAND": - return EquipmentSlot.OFF_HAND; - case "FEET": - return EquipmentSlot.FEET; - case "LEGS": - return EquipmentSlot.LEGS; - case "CHEST": - return EquipmentSlot.CHEST; - case "HEAD": - return EquipmentSlot.HAND; + + switch (nmsSlot.name()) + { + case "MAINHAND": + return EquipmentSlot.HAND; + case "OFFHAND": + return EquipmentSlot.OFF_HAND; + case "FEET": + return EquipmentSlot.FEET; + case "LEGS": + return EquipmentSlot.LEGS; + case "CHEST": + return EquipmentSlot.CHEST; + case "HEAD": + return EquipmentSlot.HAND; } - } catch (Exception e) { - return null; } + catch (Exception e) + { + } + return null; } @@ -602,23 +857,27 @@ public class ReflectionManager { * @param slot * @return null if the disguisedEntity is not an instance of a living entity */ - public static ItemStack getEquipment(EquipmentSlot slot, Entity disguisedEntity) { - if (!(disguisedEntity instanceof LivingEntity)) return null; - switch (slot) { - case HAND: - return ((LivingEntity) disguisedEntity).getEquipment().getItemInMainHand(); - case OFF_HAND: - return ((LivingEntity) disguisedEntity).getEquipment().getItemInOffHand(); - case FEET: - return ((LivingEntity) disguisedEntity).getEquipment().getBoots(); - case LEGS: - return ((LivingEntity) disguisedEntity).getEquipment().getLeggings(); - case CHEST: - return ((LivingEntity) disguisedEntity).getEquipment().getChestplate(); - case HEAD: - return ((LivingEntity) disguisedEntity).getEquipment().getHelmet(); - default: - return null; + public static ItemStack getEquipment(EquipmentSlot slot, Entity disguisedEntity) + { + if (!(disguisedEntity instanceof LivingEntity)) + return null; + + switch (slot) + { + case HAND: + return ((LivingEntity) disguisedEntity).getEquipment().getItemInMainHand(); + case OFF_HAND: + return ((LivingEntity) disguisedEntity).getEquipment().getItemInOffHand(); + case FEET: + return ((LivingEntity) disguisedEntity).getEquipment().getBoots(); + case LEGS: + return ((LivingEntity) disguisedEntity).getEquipment().getLeggings(); + case CHEST: + return ((LivingEntity) disguisedEntity).getEquipment().getChestplate(); + case HEAD: + return ((LivingEntity) disguisedEntity).getEquipment().getHelmet(); + default: + return null; } } @@ -627,24 +886,35 @@ public class ReflectionManager { * * @return */ - public static String convertSoundEffectToString(Object soundEffect) { - try { + public static String convertSoundEffectToString(Object soundEffect) + { + try + { Field f_getMinecraftKey = getNmsField("SoundEffect", "b"); f_getMinecraftKey.setAccessible(true); MinecraftKey key = MinecraftKey.fromHandle(f_getMinecraftKey.get(soundEffect)); + return key.getKey(); - } catch (IllegalAccessException e) { + } + catch (IllegalAccessException e) + { e.printStackTrace(); } + return null; } - public static Object getCraftSoundEffect(String sound) { - try { + public static Object getCraftSoundEffect(String sound) + { + try + { return getCraftMethod("CraftSound", "getSoundEffect", String.class).invoke(null, sound); - } catch (IllegalAccessException | InvocationTargetException e) { + } + catch (IllegalAccessException | InvocationTargetException e) + { e.printStackTrace(); } + return null; } @@ -655,73 +925,107 @@ public class ReflectionManager { * @param value * @return */ - public static Object createDataWatcherItem(int id, Object value) { - if (value == null) return null; + public static Object createDataWatcherItem(int id, Object value) + { + if (value == null) + return null; + Serializer serializer = Registry.get(value.getClass()); + WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer); + Constructor construct = getNmsConstructor("DataWatcher$Item", getNmsClass("DataWatcherObject"), Object.class); - try { + + try + { return construct.newInstance(watcherObject.getHandle(), value); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + } + catch (InstantiationException | IllegalAccessException | InvocationTargetException e) + { e.printStackTrace(); } + return null; } - public static EntityEquipment createEntityEquipment(Entity entity) { - if (!(entity instanceof LivingEntity)) return null; - Constructor construct = getCraftConstructor("CraftEntityEquipment", getCraftClass("CraftLivingEntity")); - try { + public static EntityEquipment createEntityEquipment(Entity entity) + { + if (!(entity instanceof LivingEntity)) + return null; + + Constructor construct = getCraftConstructor("inventory.CraftEntityEquipment", getCraftClass("entity.CraftLivingEntity")); + + try + { return (EntityEquipment) construct.newInstance((LivingEntity) entity); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | ClassCastException e) { + } + catch (InstantiationException | IllegalAccessException | InvocationTargetException | ClassCastException e) + { e.printStackTrace(); } + return null; } - public static int getCombinedId(int id, int data) { + public static int getCombinedId(int id, int data) + { return id + (data << 12); } - public static Pair getFromCombinedId(int combinedId) { + public static Pair getFromCombinedId(int combinedId) + { int j = combinedId & 4095; int k = combinedId >> 12 & 15; + return new ImmutablePair<>(j, k); } - public static Object getWorldServer(World w) { - try { + public static Object getWorldServer(World w) + { + try + { return getCraftMethod("CraftWorld", "getHandle").invoke(w); - } catch (IllegalAccessException | InvocationTargetException e) { + } + catch (IllegalAccessException | InvocationTargetException e) + { e.printStackTrace(); } + return null; } - public static Object getPlayerInteractManager(World w) { + public static Object getPlayerInteractManager(World w) + { Object worldServer = getWorldServer(w); - try { + + try + { return getNmsConstructor("PlayerInteractManager", getNmsClass("World")).newInstance(worldServer); - } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { + } + catch (InstantiationException | InvocationTargetException | IllegalAccessException e) + { e.printStackTrace(); } + return null; } - public static Object createEntityPlayer(World w, WrappedGameProfile profile) { + public static Object createEntityPlayer(World w, WrappedGameProfile profile) + { Object entityPlayer = null; - try { - entityPlayer = getNmsConstructor("EntityPlayer", - getNmsClass("MinecraftServer"), - getNmsClass("WorldServer"), - GameProfile.class, - getNmsClass("PlayerInteractManager")) - .newInstance(getMinecraftServer(), getWorldServer(w), profile.getHandle(), getPlayerInteractManager(w)); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + + try + { + entityPlayer = getNmsConstructor("EntityPlayer", getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), + GameProfile.class, getNmsClass("PlayerInteractManager")).newInstance(getMinecraftServer(), getWorldServer(w), + profile.getHandle(), getPlayerInteractManager(w)); + } + catch (InstantiationException | IllegalAccessException | InvocationTargetException e) + { e.printStackTrace(); } + return entityPlayer; } - } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.java b/src/me/libraryaddict/disguise/utilities/UpdateChecker.java similarity index 100% rename from src/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.java rename to src/me/libraryaddict/disguise/utilities/UpdateChecker.java diff --git a/target/LibsDisguises.jar b/target/LibsDisguises.jar new file mode 100644 index 00000000..06ae7b78 Binary files /dev/null and b/target/LibsDisguises.jar differ diff --git a/target/classes/README.md b/target/classes/README.md new file mode 100644 index 00000000..bb2734f7 --- /dev/null +++ b/target/classes/README.md @@ -0,0 +1,15 @@ +LibsDisguises (1.9+) +============= + +A disguise plugin made by libraryaddict which is pretty cool.
+ +NOTE: These versions will NOT work with Spigot 1.8.8 and before. + +Spigot page: Link + + +When posting an issue:
+Please make sure you
+1) Post a stack trace error, if no stack trace, then post the odd behavior
+2) Post the exact steps you used in order to reproduce the issue.
+3) Give as much information as possible as to what the issue is and why it occurred so that we can fix it.
diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 00000000..282c1e11 --- /dev/null +++ b/target/classes/config.yml @@ -0,0 +1,130 @@ +# Shall I notify people of a LibsDisguises update? +NotifyUpdate: true +# Whats the permission to get the notification? +Permission: 'libsdisguises.update' +# Whats the max size allowed for command disguiseradius +DisguiseRadiusMax: 50 +# Whats the max size allowed for command undisguiseradius +UndisguiseRadiusMax: 50 +# Shall the players view their disguises? +# Best used when viewing yourself in 3rd person +ViewSelfDisguises: true +# Shall I disguise the sounds? +# This turns your damage sound into a MOOOO +DisguiseSounds: true +# Shall the disguised hear their disguise sounds or their damage sounds. +# I disable this as it can be a little confusing when not used with self disguises +HearSelfDisguise: true +# Shall I send the velocity packets? I REALLY recommend you don't disable. +# This is the only thing allowing the mobs to fly without glitching out. +SendVelocity: true +# For self disguises, they need to have the armor and the held item removed +# Else they see floating armor, floating held items. +# This turns the items invisible in the disguised players inventory. It does not actually remove them! +RemoveArmor: true +RemoveHeldItem: false +# If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible. +# Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking +# This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise. +AddEntityAnimations: true +# When a sheep or wolf is right clicked with dye. The client automatically assumes it was successful and displays the sheeps wool or the wolfs collar as dyed. +# This is a option that either prevents that happening, or it changes their color officially in the plugin so that everyone sees it changed. +# Its currently set to false which means that the color is not changed and will refresh itself to the player. +# Please note that this will not remove the dye from their hands. This also does not check if the disguised entity is actually a sheep/wolf and wants a say in its color. +DyeableSheep: false +DyeableWolf: false +# This is only called into action when the disguise is constructed using the commands. +# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance. +# Such as prophunt. Its also false because its kind of a retarded feature. +# This is pretty simple. It shows the players displayname (Name as it appears in chat) above their head. +# This also overrides any custom name they have set in their disguise options. +ShowNamesAboveDisguises: false +# This supports the above option. +# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not. +NameAboveHeadAlwaysVisible: true +# This modifys the bounding box, This is stuff like can a arrow hit them. +# If you turn this to true, arrows will act like they hit the disguise in the right place! +# So someone disguised as a enderdragon will easily get shot down by arrows! +# This WILL conflict with NoCheatPlus. Other plugins may also get problems. +# This shouldn't really be enabled for players as it also interferes with their movement because the server thinks the player is larger than he really is. +# That makes the player unable to approach this building because the server thinks he is trying to glitch inside blocks. +ModifyBoundingBox: false +# This prevents disguised players from being targeted by monsters. +# This doesn't prevent their targeting you if already targeting when disguised +# They will just ignore you unless provoked. +MonstersIgnoreDisguises: false +# Sigh. People are going to want this. +# So lets make your disguise blown if you are attacked.. +# Works only for disguised players when attacked by a entity (arrow, monster. etc) +# This will blow all disguises he has on him +BlowDisguises: false +BlownDisguiseMessage: '&cYour disguise was blown!' + +#Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected! +StopShulkerDisguisesFromMoving: true + +# A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring +DisguiseEntityExpire: 10 + +# Another option to choose the same thing for DisguiseClone command +DisguiseCloneExpire: 10 +# Max disguises to store at a time with the DisguiseClone command +DisguiseCloneSize: 3 + +# This I don't really recommend turning on as it can make a memory leak.. +# These disguises, as normal will not persist after a server restart. +# There is also no EntityDeath option as entities do not revive after death. +KeepDisguises: + EntityDespawn: false + PlayerDeath: false + PlayerLogout: false + +# This controls if a entitys max health is determined by the entity, or by the disguise. +# Wither is 200, a player is 20. With this enabled, a player disguised as a wither will have the boss bar health accurate to the players health. +# Else it will be 1/20 of the boss bar when he is full health. +# Setting this in LivingWatcher overrides both values. +MaxHealthDeterminedByEntity: true + +# This here is a option to turn off misc disguises. +# This means you can not have a living entity disguise as a non-living entity. +# This disables the Attributes packet, Non-living entities can still disguise as other non-living +# This means that the above option will not work as it uses the attribute packet. +MiscDisguisesForLiving: true + +# Turn this to true to have players undisguised when switching worlds +UndisguiseOnWorldChange: false + +# Contact Mojang's servers? Disabling this option will disable player skin disguises! +ContactMojangServers: true + +# This will help performance, especially with CPU +# Due to safety reasons, self disguises can never have their packets disabled. +PacketsEnabled: + # This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash. + # Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash + Animation: true + # Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player + # This also sends a chunk packet at key positions else it doesn't work for 1.8. Lazyness means it does it for older versions too currently. + Bed: true + # This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it + # This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well + Collect: true + # This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching. + EntityStatus: true + # Entity equipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item. + # Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing. + Equipment: true + # This doesn't actually disable the packet. It would introduce problems. Instead it does the next best thing and caches the data. + # This means that entity metadata will not change, and will only be sent in the spawn packet. + # This is good if performance is extremely in need. + # This is bad to disable unless you are ONLY going to use the disguises for decorations. + # To be honest. This is basically "Disable entity animations". That option is called 'AddEntityAnimations' in the config but unlike that, this is always in effect. + # Animations set by use of the api or through the disguise command are still in effect. + Metadata: true + # Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up. + # If you are using the Item_Frame disguise, when a packet is sent (Roughly every 2min) the disguise will bug up until they move. + Movement: true + # Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity + Riding: true + # When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way. + WitherSkull: true diff --git a/target/classes/me/libraryaddict/disguise/DisguiseAPI.class b/target/classes/me/libraryaddict/disguise/DisguiseAPI.class new file mode 100644 index 00000000..2fd42a41 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseAPI.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseConfig.class b/target/classes/me/libraryaddict/disguise/DisguiseConfig.class new file mode 100644 index 00000000..614858d3 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseConfig.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$1$1.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$1$1.class new file mode 100644 index 00000000..a220bc5d Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$1$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$1.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$1.class new file mode 100644 index 00000000..13589dc5 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$2.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$2.class new file mode 100644 index 00000000..34cfd294 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$2.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$3.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$3.class new file mode 100644 index 00000000..1a918aab Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$3.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$4.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$4.class new file mode 100644 index 00000000..875bb77b Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$4.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$5.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$5.class new file mode 100644 index 00000000..4bc34b77 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$5.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$6.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$6.class new file mode 100644 index 00000000..708ffc83 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$6.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener$7.class b/target/classes/me/libraryaddict/disguise/DisguiseListener$7.class new file mode 100644 index 00000000..71d65495 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener$7.class differ diff --git a/target/classes/me/libraryaddict/disguise/DisguiseListener.class b/target/classes/me/libraryaddict/disguise/DisguiseListener.class new file mode 100644 index 00000000..acb7a7a2 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/DisguiseListener.class differ diff --git a/target/classes/me/libraryaddict/disguise/LibsDisguises$1.class b/target/classes/me/libraryaddict/disguise/LibsDisguises$1.class new file mode 100644 index 00000000..225b600c Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/LibsDisguises$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/LibsDisguises.class b/target/classes/me/libraryaddict/disguise/LibsDisguises.class new file mode 100644 index 00000000..17ebb347 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/LibsDisguises.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand$1.class b/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand$1.class new file mode 100644 index 00000000..e29ce4a4 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand$DisguiseParseException.class b/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand$DisguiseParseException.class new file mode 100644 index 00000000..7c797d51 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand$DisguiseParseException.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand.class new file mode 100644 index 00000000..eaf260d7 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/BaseDisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/CloneDisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/CloneDisguiseCommand.class new file mode 100644 index 00000000..ff71eb00 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/CloneDisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/DisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/DisguiseCommand.class new file mode 100644 index 00000000..326bf8d4 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/DisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/DisguiseViewSelf.class b/target/classes/me/libraryaddict/disguise/commands/DisguiseViewSelf.class new file mode 100644 index 00000000..00ef1334 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/DisguiseViewSelf.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/EntityDisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/EntityDisguiseCommand.class new file mode 100644 index 00000000..7b957cc8 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/EntityDisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/HelpDisguiseCommand$EnumHelp.class b/target/classes/me/libraryaddict/disguise/commands/HelpDisguiseCommand$EnumHelp.class new file mode 100644 index 00000000..7af27153 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/HelpDisguiseCommand$EnumHelp.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/HelpDisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/HelpDisguiseCommand.class new file mode 100644 index 00000000..af4d5fbd Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/HelpDisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/LibsDisguisesCommand.class b/target/classes/me/libraryaddict/disguise/commands/LibsDisguisesCommand.class new file mode 100644 index 00000000..fc906669 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/LibsDisguisesCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.class new file mode 100644 index 00000000..a9bd62a5 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/PlayerDisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.class new file mode 100644 index 00000000..a95d53bf Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/RadiusDisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/UndisguiseCommand.class b/target/classes/me/libraryaddict/disguise/commands/UndisguiseCommand.class new file mode 100644 index 00000000..e71d23e5 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/UndisguiseCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.class b/target/classes/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.class new file mode 100644 index 00000000..efd7dce4 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/UndisguiseEntityCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.class b/target/classes/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.class new file mode 100644 index 00000000..2b28d76d Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/UndisguisePlayerCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.class b/target/classes/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.class new file mode 100644 index 00000000..3ba456b6 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/commands/UndisguiseRadiusCommand.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/AnimalColor.class b/target/classes/me/libraryaddict/disguise/disguisetypes/AnimalColor.class new file mode 100644 index 00000000..b4ed8680 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/AnimalColor.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$1.class b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$1.class new file mode 100644 index 00000000..a1bc40e3 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$2.class b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$2.class new file mode 100644 index 00000000..b4e8768a Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$2.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$3.class b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$3.class new file mode 100644 index 00000000..ffa68ecd Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise$3.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise.class b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise.class new file mode 100644 index 00000000..1b5e022f Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/Disguise.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/DisguiseType$1.class b/target/classes/me/libraryaddict/disguise/disguisetypes/DisguiseType$1.class new file mode 100644 index 00000000..f05c3af4 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/DisguiseType$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/DisguiseType.class b/target/classes/me/libraryaddict/disguise/disguisetypes/DisguiseType.class new file mode 100644 index 00000000..eba30215 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/DisguiseType.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/FlagWatcher$1.class b/target/classes/me/libraryaddict/disguise/disguisetypes/FlagWatcher$1.class new file mode 100644 index 00000000..09e8adfe Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/FlagWatcher$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/FlagWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/FlagWatcher.class new file mode 100644 index 00000000..10496491 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/FlagWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/MiscDisguise$1.class b/target/classes/me/libraryaddict/disguise/disguisetypes/MiscDisguise$1.class new file mode 100644 index 00000000..9a78c81b Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/MiscDisguise$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/MiscDisguise.class b/target/classes/me/libraryaddict/disguise/disguisetypes/MiscDisguise.class new file mode 100644 index 00000000..6833c383 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/MiscDisguise.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/MobDisguise.class b/target/classes/me/libraryaddict/disguise/disguisetypes/MobDisguise.class new file mode 100644 index 00000000..7da4f6f6 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/MobDisguise.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/PlayerDisguise$1.class b/target/classes/me/libraryaddict/disguise/disguisetypes/PlayerDisguise$1.class new file mode 100644 index 00000000..58d8feba Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/PlayerDisguise$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.class b/target/classes/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.class new file mode 100644 index 00000000..0f1a12cd Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/PlayerDisguise.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/RabbitType.class b/target/classes/me/libraryaddict/disguise/disguisetypes/RabbitType.class new file mode 100644 index 00000000..c3ccb818 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/RabbitType.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/TargetedDisguise$TargetType.class b/target/classes/me/libraryaddict/disguise/disguisetypes/TargetedDisguise$TargetType.class new file mode 100644 index 00000000..703e1dee Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/TargetedDisguise$TargetType.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.class b/target/classes/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.class new file mode 100644 index 00000000..71d7b52c Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/TargetedDisguise.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.class new file mode 100644 index 00000000..c016e956 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.class new file mode 100644 index 00000000..c72824de Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.class new file mode 100644 index 00000000..b6243f9b Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.class new file mode 100644 index 00000000..ec163a82 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.class new file mode 100644 index 00000000..71079a86 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.class new file mode 100644 index 00000000..8cb54bf9 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.class new file mode 100644 index 00000000..653318ee Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.class new file mode 100644 index 00000000..2eb12385 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.class new file mode 100644 index 00000000..9f862e29 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.class new file mode 100644 index 00000000..107a4b18 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.class new file mode 100644 index 00000000..b7b62010 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.class new file mode 100644 index 00000000..a8da95cb Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.class new file mode 100644 index 00000000..b8dafebf Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.class new file mode 100644 index 00000000..143f0ffa Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.class new file mode 100644 index 00000000..6c786b74 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.class new file mode 100644 index 00000000..46b3323b Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.class new file mode 100644 index 00000000..6cf31d42 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.class new file mode 100644 index 00000000..a085b052 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.class new file mode 100644 index 00000000..cd317483 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.class new file mode 100644 index 00000000..4e41e61f Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.class new file mode 100644 index 00000000..6e39d862 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.class new file mode 100644 index 00000000..972f095b Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.class new file mode 100644 index 00000000..c0de0b9e Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.class new file mode 100644 index 00000000..661021ff Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.class new file mode 100644 index 00000000..a30ccd66 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.class new file mode 100644 index 00000000..50c68c3c Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.class new file mode 100644 index 00000000..b633023d Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.class new file mode 100644 index 00000000..b5b0de62 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.class new file mode 100644 index 00000000..d6963af9 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.class new file mode 100644 index 00000000..00f4766e Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.class new file mode 100644 index 00000000..5bb27e19 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.class new file mode 100644 index 00000000..7df27109 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.class new file mode 100644 index 00000000..62b1747e Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.class new file mode 100644 index 00000000..e696f55e Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.class new file mode 100644 index 00000000..fed2221e Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.class new file mode 100644 index 00000000..842d8f97 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.class b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.class new file mode 100644 index 00000000..e0127a19 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.class differ diff --git a/target/classes/me/libraryaddict/disguise/events/DisguiseEvent.class b/target/classes/me/libraryaddict/disguise/events/DisguiseEvent.class new file mode 100644 index 00000000..9615a097 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/events/DisguiseEvent.class differ diff --git a/target/classes/me/libraryaddict/disguise/events/UndisguiseEvent.class b/target/classes/me/libraryaddict/disguise/events/UndisguiseEvent.class new file mode 100644 index 00000000..9cffe4ce Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/events/UndisguiseEvent.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/ClassGetter.class b/target/classes/me/libraryaddict/disguise/utilities/ClassGetter.class new file mode 100644 index 00000000..beff9276 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/ClassGetter.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound$1.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound$1.class new file mode 100644 index 00000000..c01d6870 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound$SoundType.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound$SoundType.class new file mode 100644 index 00000000..50a5a484 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound$SoundType.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound.class new file mode 100644 index 00000000..facbe731 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseSound.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$1.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$1.class new file mode 100644 index 00000000..0741e972 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$10.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$10.class new file mode 100644 index 00000000..b8da76ce Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$10.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$2.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$2.class new file mode 100644 index 00000000..5934cdfe Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$2.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$3$1.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$3$1.class new file mode 100644 index 00000000..684481d8 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$3$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$3.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$3.class new file mode 100644 index 00000000..201cda4e Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$3.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$4.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$4.class new file mode 100644 index 00000000..602cb904 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$4.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$5.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$5.class new file mode 100644 index 00000000..e832da89 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$5.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$6.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$6.class new file mode 100644 index 00000000..855c7b00 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$6.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$7.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$7.class new file mode 100644 index 00000000..f655bf8c Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$7.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$8.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$8.class new file mode 100644 index 00000000..1987c11d Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$8.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$9.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$9.class new file mode 100644 index 00000000..dc8fd826 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities$9.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities.class new file mode 100644 index 00000000..5d6c5159 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseUtilities.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseValues$1.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseValues$1.class new file mode 100644 index 00000000..6a5ac802 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseValues$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/DisguiseValues.class b/target/classes/me/libraryaddict/disguise/utilities/DisguiseValues.class new file mode 100644 index 00000000..9d8112b6 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/DisguiseValues.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/FakeBoundingBox.class b/target/classes/me/libraryaddict/disguise/utilities/FakeBoundingBox.class new file mode 100644 index 00000000..38cee377 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/FakeBoundingBox.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/LibsProfileLookup.class b/target/classes/me/libraryaddict/disguise/utilities/LibsProfileLookup.class new file mode 100644 index 00000000..5115cdf3 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/LibsProfileLookup.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.class b/target/classes/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.class new file mode 100644 index 00000000..ea6aeea7 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/LibsProfileLookupCaller.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/Metrics$1.class b/target/classes/me/libraryaddict/disguise/utilities/Metrics$1.class new file mode 100644 index 00000000..18449b5c Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/Metrics$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/Metrics$Graph.class b/target/classes/me/libraryaddict/disguise/utilities/Metrics$Graph.class new file mode 100644 index 00000000..1e58dc54 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/Metrics$Graph.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/Metrics$Plotter.class b/target/classes/me/libraryaddict/disguise/utilities/Metrics$Plotter.class new file mode 100644 index 00000000..0cc89304 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/Metrics$Plotter.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/Metrics.class b/target/classes/me/libraryaddict/disguise/utilities/Metrics.class new file mode 100644 index 00000000..b9284fb0 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/Metrics.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$1.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$1.class new file mode 100644 index 00000000..33c959bb Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$2.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$2.class new file mode 100644 index 00000000..d6fffcd0 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$2.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$3$1.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$3$1.class new file mode 100644 index 00000000..7a84e24d Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$3$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$3.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$3.class new file mode 100644 index 00000000..ec46af70 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$3.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$4$1.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$4$1.class new file mode 100644 index 00000000..438f01d3 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$4$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$4.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$4.class new file mode 100644 index 00000000..1c8eb6b6 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$4.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$5$1.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$5$1.class new file mode 100644 index 00000000..54c0d217 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$5$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$5.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$5.class new file mode 100644 index 00000000..2165733c Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$5.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$6.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$6.class new file mode 100644 index 00000000..5686ba81 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager$6.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/PacketsManager.class b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager.class new file mode 100644 index 00000000..198d1111 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/PacketsManager.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/ReflectionManager$1.class b/target/classes/me/libraryaddict/disguise/utilities/ReflectionManager$1.class new file mode 100644 index 00000000..a9db7606 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/ReflectionManager$1.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/ReflectionManager.class b/target/classes/me/libraryaddict/disguise/utilities/ReflectionManager.class new file mode 100644 index 00000000..20453713 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/ReflectionManager.class differ diff --git a/target/classes/me/libraryaddict/disguise/utilities/UpdateChecker.class b/target/classes/me/libraryaddict/disguise/utilities/UpdateChecker.class new file mode 100644 index 00000000..fee239f0 Binary files /dev/null and b/target/classes/me/libraryaddict/disguise/utilities/UpdateChecker.class differ diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 00000000..90faaaa0 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,103 @@ +name: LibsDisguises +main: me.libraryaddict.disguise.LibsDisguises +description: A disguise plugin with various disguises. +version: 0.0.1-SNAPSHOT +author: libraryaddict +authors: [Byteflux, Navid K.] +softdepend: [ProtocolLib] +commands: + libsdisguises: + permission: libsdisguises.seecmd.libsdisguises + description: Main command for libsdisguises. + disguise: + aliases: [d, dis] + permission: libsdisguises.seecmd.disguise + description: Disguise yourself as an entity. + disguiseentity: + aliases: [dentity, disentity] + permission: libsdisguises.seecmd.disguiseentity + description: Disguise an entity as another entity. + disguisehelp: + aliases: [dhelp, dishelp] + permission: libsdisguises.seecmd.disguisehelp + description: Help command for LibsDisguises. + disguiseplayer: + aliases: [dplayer, displayer] + permission: libsdisguises.seecmd.disguiseplayer + description: Disguise another player as an entity. + disguiseradius: + aliases: [disradius, dradius] + permission: libsdisguises.seecmd.disguiseradius + description: Disguise all entities within a radius as an entity. + undisguise: + aliases: [u, und, undis] + permission: libsdisguises.seecmd.undisguise + description: Undisguise yourself. + undisguiseentity: + aliases: [undisentity, undentity] + permission: libsdisguises.seecmd.undisguiseentity + description: Undisguise an entity. + undisguiseplayer: + aliases: [undisplayer, undplayer] + permission: libsdisguises.seecmd.undisguiseplayer + description: Undisguise a player. + undisguiseradius: + aliases: [undisradius, undradius] + permission: libsdisguises.seecmd.undisguiseradius + description: Undisguise all entities within a radius. + disguiseclone: + aliases: [disguisec, disc, disclone, dclone, clonedisguise, clonedis, cdisguise, cdis] + permission: libsdisguises.seecmd.disguiseclone + description: Copy a disguise (or entity) and use it later. + disguiseviewself: + aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd] + permission: libsdisguises.seecmd.viewself + description: Toggle seeing your own disguise on or off. + +permissions: + libsdisguises.reload: + description: Allows the user to reload LibsDisguises. + default: op + libsdisguises.seethrough: + description: Allows player to see through disguises. + default: false + libsdisguises.seecmd: + description: See all commands in tab-completion + default: true + children: + libsdisguises.seecmd.libsdisguises: true + libsdisguises.seecmd.disguise: true + libsdisguises.seecmd.disguiseentity: true + libsdisguises.seecmd.disguisehelp: true + libsdisguises.seecmd.disguiseplayer: true + libsdisguises.seecmd.disguiseradius: true + libsdisguises.seecmd.undisguise: true + libsdisguises.seecmd.undisguiseentity: true + libsdisguises.seecmd.undisguiseplayer: true + libsdisguises.seecmd.undisguiseradius: true + libsdisguises.seecmd.disguiseclone: true + libsdisguises.seecmd.disguiseviewself: true + libsdisguises.seecmd.libsdisguises: + description: See the /libsdisguises command in tab-completion + libsdisguises.seecmd.disguiseviewself: + description: See the /disguiseviewself command in tab-completion + libsdisguises.seecmd.disguise: + description: See the /disguise command in tab-completion + libsdisguises.seecmd.disguiseentity: + description: See the /disguiseentity command in tab-completion + libsdisguises.seecmd.disguisehelp: + description: See the /disguisehelp command in tab-completion + libsdisguises.seecmd.disguiseplayer: + description: See the /disguiseplayer command in tab-completion + libsdisguises.seecmd.disguiseradius: + description: See the /disguiseradius command in tab-completion + libsdisguises.seecmd.undisguise: + description: See the /undisguise command in tab-completion + libsdisguises.seecmd.undisguiseentity: + description: See the /undisguiseentity command in tab-completion + libsdisguises.seecmd.undisguiseplayer: + description: See the /undisguiseplayer command in tab-completion + libsdisguises.seecmd.undisguiseradius: + description: See the /undisguiseradius command in tab-completion + libsdisguises.seecmd.disguiseclone: + description: See the /disguiseclone command in tab-completion diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 00000000..5d9ffbe6 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue May 10 03:16:27 NZST 2016 +version=0.0.1-SNAPSHOT +groupId=LibsDisguises +artifactId=LibsDisguises diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 00000000..be0db8db --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,123 @@ +me\libraryaddict\disguise\disguisetypes\watchers\CreeperWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\EndermanWatcher.class +me\libraryaddict\disguise\disguisetypes\Disguise$1.class +me\libraryaddict\disguise\disguisetypes\watchers\MinecartWatcher.class +me\libraryaddict\disguise\utilities\PacketsManager$3.class +me\libraryaddict\disguise\utilities\PacketsManager.class +me\libraryaddict\disguise\disguisetypes\watchers\EnderDragonWatcher.class +me\libraryaddict\disguise\utilities\UpdateChecker.class +me\libraryaddict\disguise\commands\CloneDisguiseCommand.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$1.class +me\libraryaddict\disguise\utilities\LibsProfileLookup.class +me\libraryaddict\disguise\disguisetypes\watchers\TippedArrowWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\GuardianWatcher.class +me\libraryaddict\disguise\commands\UndisguiseCommand.class +me\libraryaddict\disguise\commands\PlayerDisguiseCommand.class +me\libraryaddict\disguise\LibsDisguises$1.class +me\libraryaddict\disguise\disguisetypes\MiscDisguise$1.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$4.class +me\libraryaddict\disguise\utilities\LibsProfileLookupCaller.class +me\libraryaddict\disguise\commands\EntityDisguiseCommand.class +me\libraryaddict\disguise\utilities\DisguiseUtilities.class +me\libraryaddict\disguise\commands\UndisguiseRadiusCommand.class +me\libraryaddict\disguise\disguisetypes\Disguise.class +me\libraryaddict\disguise\disguisetypes\watchers\WitherSkullWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\ItemFrameWatcher.class +me\libraryaddict\disguise\DisguiseListener$2.class +me\libraryaddict\disguise\disguisetypes\PlayerDisguise$1.class +me\libraryaddict\disguise\utilities\ClassGetter.class +me\libraryaddict\disguise\disguisetypes\watchers\VillagerWatcher.class +me\libraryaddict\disguise\utilities\DisguiseValues.class +me\libraryaddict\disguise\disguisetypes\watchers\PlayerWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\PigWatcher.class +me\libraryaddict\disguise\DisguiseListener$6.class +me\libraryaddict\disguise\disguisetypes\watchers\SlimeWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\ZombieWatcher.class +me\libraryaddict\disguise\utilities\PacketsManager$3$1.class +me\libraryaddict\disguise\disguisetypes\watchers\SkeletonWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\HorseWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\RabbitWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\SheepWatcher.class +me\libraryaddict\disguise\utilities\PacketsManager$4.class +me\libraryaddict\disguise\disguisetypes\watchers\WolfWatcher.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$9.class +me\libraryaddict\disguise\disguisetypes\watchers\ShulkerWatcher.class +me\libraryaddict\disguise\disguisetypes\AnimalColor.class +me\libraryaddict\disguise\disguisetypes\watchers\WitchWatcher.class +me\libraryaddict\disguise\DisguiseListener$1.class +me\libraryaddict\disguise\commands\BaseDisguiseCommand$DisguiseParseException.class +me\libraryaddict\disguise\commands\HelpDisguiseCommand.class +me\libraryaddict\disguise\disguisetypes\watchers\AreaEffectCloudWatcher.class +me\libraryaddict\disguise\commands\BaseDisguiseCommand.class +me\libraryaddict\disguise\utilities\Metrics.class +me\libraryaddict\disguise\commands\HelpDisguiseCommand$EnumHelp.class +me\libraryaddict\disguise\DisguiseListener$7.class +me\libraryaddict\disguise\disguisetypes\watchers\WitherWatcher.class +me\libraryaddict\disguise\utilities\DisguiseValues$1.class +me\libraryaddict\disguise\utilities\Metrics$1.class +me\libraryaddict\disguise\DisguiseListener.class +me\libraryaddict\disguise\disguisetypes\FlagWatcher$1.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$3.class +me\libraryaddict\disguise\disguisetypes\watchers\ArrowWatcher.class +me\libraryaddict\disguise\disguisetypes\PlayerDisguise.class +me\libraryaddict\disguise\disguisetypes\watchers\ArmorStandWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\EnderCrystalWatcher.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$5.class +me\libraryaddict\disguise\disguisetypes\FlagWatcher.class +me\libraryaddict\disguise\disguisetypes\watchers\SplashPotionWatcher.class +me\libraryaddict\disguise\utilities\DisguiseSound$SoundType.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$2.class +me\libraryaddict\disguise\commands\DisguiseViewSelf.class +me\libraryaddict\disguise\disguisetypes\MiscDisguise.class +me\libraryaddict\disguise\commands\UndisguisePlayerCommand.class +me\libraryaddict\disguise\disguisetypes\DisguiseType.class +me\libraryaddict\disguise\commands\UndisguiseEntityCommand.class +me\libraryaddict\disguise\DisguiseListener$3.class +me\libraryaddict\disguise\disguisetypes\MobDisguise.class +me\libraryaddict\disguise\disguisetypes\TargetedDisguise.class +me\libraryaddict\disguise\utilities\DisguiseSound.class +me\libraryaddict\disguise\utilities\PacketsManager$2.class +me\libraryaddict\disguise\utilities\ReflectionManager$1.class +me\libraryaddict\disguise\disguisetypes\watchers\OcelotWatcher.class +me\libraryaddict\disguise\utilities\PacketsManager$4$1.class +me\libraryaddict\disguise\utilities\ReflectionManager.class +me\libraryaddict\disguise\disguisetypes\watchers\LivingWatcher.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$8.class +me\libraryaddict\disguise\disguisetypes\watchers\BlazeWatcher.class +me\libraryaddict\disguise\disguisetypes\RabbitType.class +me\libraryaddict\disguise\disguisetypes\watchers\TameableWatcher.class +me\libraryaddict\disguise\utilities\DisguiseSound$1.class +me\libraryaddict\disguise\events\DisguiseEvent.class +me\libraryaddict\disguise\commands\DisguiseCommand.class +me\libraryaddict\disguise\utilities\Metrics$Plotter.class +me\libraryaddict\disguise\utilities\PacketsManager$5.class +me\libraryaddict\disguise\LibsDisguises.class +me\libraryaddict\disguise\disguisetypes\TargetedDisguise$TargetType.class +me\libraryaddict\disguise\disguisetypes\watchers\FallingBlockWatcher.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$7.class +me\libraryaddict\disguise\utilities\FakeBoundingBox.class +me\libraryaddict\disguise\disguisetypes\watchers\DroppedItemWatcher.class +me\libraryaddict\disguise\utilities\PacketsManager$1.class +me\libraryaddict\disguise\DisguiseListener$5.class +me\libraryaddict\disguise\disguisetypes\watchers\BatWatcher.class +me\libraryaddict\disguise\commands\RadiusDisguiseCommand.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$10.class +me\libraryaddict\disguise\events\UndisguiseEvent.class +me\libraryaddict\disguise\disguisetypes\Disguise$3.class +me\libraryaddict\disguise\commands\LibsDisguisesCommand.class +me\libraryaddict\disguise\disguisetypes\watchers\PaintingWatcher.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$3$1.class +me\libraryaddict\disguise\DisguiseConfig.class +me\libraryaddict\disguise\DisguiseAPI.class +me\libraryaddict\disguise\utilities\PacketsManager$5$1.class +me\libraryaddict\disguise\disguisetypes\watchers\GhastWatcher.class +me\libraryaddict\disguise\utilities\PacketsManager$6.class +me\libraryaddict\disguise\disguisetypes\watchers\AgeableWatcher.class +me\libraryaddict\disguise\utilities\Metrics$Graph.class +me\libraryaddict\disguise\DisguiseListener$1$1.class +me\libraryaddict\disguise\disguisetypes\DisguiseType$1.class +me\libraryaddict\disguise\disguisetypes\watchers\BoatWatcher.class +me\libraryaddict\disguise\utilities\DisguiseUtilities$6.class +me\libraryaddict\disguise\commands\BaseDisguiseCommand$1.class +me\libraryaddict\disguise\DisguiseListener$4.class +me\libraryaddict\disguise\disguisetypes\Disguise$2.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 00000000..2b2a8808 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,76 @@ +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\ReflectionManager.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\ArrowWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\events\DisguiseEvent.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\VillagerWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\PlayerDisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\LibsProfileLookupCaller.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\TippedArrowWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\AnimalColor.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\DisguiseValues.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\BaseDisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\DisguiseConfig.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\SheepWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\TargetedDisguise.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\ClassGetter.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\DisguiseListener.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\MobDisguise.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\WitchWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\DisguiseViewSelf.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\PacketsManager.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\UndisguiseRadiusCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\PlayerDisguise.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\CloneDisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\DisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\WitherSkullWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\LibsProfileLookup.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\UndisguisePlayerCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\GuardianWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\DisguiseUtilities.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\HelpDisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\WolfWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\BoatWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\EntityDisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\SkeletonWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\ItemFrameWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\LibsDisguises.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\FallingBlockWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\EndermanWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\ShulkerWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\ArmorStandWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\PigWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\Disguise.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\SplashPotionWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\PaintingWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\UndisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\CreeperWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\RabbitType.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\AgeableWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\EnderCrystalWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\BlazeWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\WitherWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\UpdateChecker.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\RadiusDisguiseCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\DisguiseSound.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\DroppedItemWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\DisguiseAPI.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\AreaEffectCloudWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\UndisguiseEntityCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\SlimeWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\OcelotWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\DisguiseType.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\MiscDisguise.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\commands\LibsDisguisesCommand.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\events\UndisguiseEvent.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\PlayerWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\FlagWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\HorseWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\TameableWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\FakeBoundingBox.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\EnderDragonWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\GhastWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\BatWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\MinecartWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\RabbitWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\ZombieWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\disguisetypes\watchers\LivingWatcher.java +C:\Users\Andrew\workspace\LibsDisguises\src\me\libraryaddict\disguise\utilities\Metrics.java