From fed56419319b0537207c228d277004c2e8d3a407 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 4 Oct 2013 12:52:56 +1300 Subject: [PATCH] Revert "Test Commit" This reverts commit d230962e1985b133ddffe6fffb5fce8c24ed6b7e. --- config.yml | 8 +- .../disguise/Commands}/DisguiseCommand.java | 0 .../Commands}/DisguiseEntityCommand.java | 0 .../Commands}/DisguisePlayerCommand.java | 0 .../Commands}/DisguiseRadiusCommand.java | 0 .../disguise/Commands}/UndisguiseCommand.java | 0 .../Commands}/UndisguiseEntityCommand.java | 0 .../Commands}/UndisguisePlayerCommand.java | 0 .../Commands}/UndisguiseRadiusCommand.java | 0 .../libraryaddict/disguise/DisguiseAPI.java | 95 +++- .../disguise/DisguiseListener.java | 0 .../disguise/DisguiseTypes}/AnimalColor.java | 0 .../disguise/DisguiseTypes}/Disguise.java | 52 +- .../DisguiseTypes}/DisguiseSound.java | 15 +- .../disguise/DisguiseTypes}/DisguiseType.java | 0 .../disguise/DisguiseTypes}/FlagWatcher.java | 0 .../disguise/DisguiseTypes}/MiscDisguise.java | 0 .../disguise/DisguiseTypes}/MobDisguise.java | 0 .../DisguiseTypes}/PlayerDisguise.java | 0 .../disguise/DisguiseTypes}/Values.java | 0 .../Watchers}/AgeableWatcher.java | 0 .../DisguiseTypes/Watchers}/ArrowWatcher.java | 0 .../DisguiseTypes/Watchers}/BatWatcher.java | 0 .../DisguiseTypes/Watchers}/BlazeWatcher.java | 0 .../DisguiseTypes/Watchers}/BoatWatcher.java | 0 .../Watchers}/CreeperWatcher.java | 0 .../Watchers}/DroppedItemWatcher.java | 0 .../Watchers}/EndermanWatcher.java | 0 .../DisguiseTypes/Watchers}/GhastWatcher.java | 0 .../DisguiseTypes/Watchers}/HorseWatcher.java | 0 .../Watchers}/ItemFrameWatcher.java | 0 .../Watchers}/LivingWatcher.java | 0 .../Watchers}/MinecartWatcher.java | 0 .../Watchers}/OcelotWatcher.java | 0 .../DisguiseTypes/Watchers}/PigWatcher.java | 0 .../Watchers}/PlayerWatcher.java | 0 .../DisguiseTypes/Watchers}/SheepWatcher.java | 0 .../DisguiseTypes/Watchers}/SlimeWatcher.java | 0 .../Watchers}/VillagerWatcher.java | 0 .../Watchers}/WitherSkullWatcher.java | 0 .../DisguiseTypes/Watchers}/WolfWatcher.java | 0 .../Watchers}/ZombieWatcher.java | 0 .../disguise/Events}/DisguiseEvent.java | 0 .../disguise/Events}/UndisguiseEvent.java | 0 .../libraryaddict/disguise/LibsDisguises.java | 0 .../disguise/PacketsManager.java | 448 +----------------- .../libraryaddict/disguise/UpdateChecker.java | 0 47 files changed, 113 insertions(+), 505 deletions(-) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/DisguiseCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/DisguiseEntityCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/DisguisePlayerCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/DisguiseRadiusCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/UndisguiseCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/UndisguiseEntityCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/UndisguisePlayerCommand.java (100%) rename src/{mea/libraryaddict/disguise/commands => me/libraryaddict/disguise/Commands}/UndisguiseRadiusCommand.java (100%) rename src/{mea => me}/libraryaddict/disguise/DisguiseAPI.java (73%) rename src/{mea => me}/libraryaddict/disguise/DisguiseListener.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/AnimalColor.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/Disguise.java (95%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/DisguiseSound.java (89%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/DisguiseType.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/FlagWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/MiscDisguise.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/MobDisguise.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/PlayerDisguise.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes => me/libraryaddict/disguise/DisguiseTypes}/Values.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/AgeableWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/ArrowWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/BatWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/BlazeWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/BoatWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/CreeperWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/DroppedItemWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/EndermanWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/GhastWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/HorseWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/ItemFrameWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/LivingWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/MinecartWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/OcelotWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/PigWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/PlayerWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/SheepWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/SlimeWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/VillagerWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/WitherSkullWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/WolfWatcher.java (100%) rename src/{mea/libraryaddict/disguise/disguisetypes/watchers => me/libraryaddict/disguise/DisguiseTypes/Watchers}/ZombieWatcher.java (100%) rename src/{mea/libraryaddict/disguise/events => me/libraryaddict/disguise/Events}/DisguiseEvent.java (100%) rename src/{mea/libraryaddict/disguise/events => me/libraryaddict/disguise/Events}/UndisguiseEvent.java (100%) rename src/{mea => me}/libraryaddict/disguise/LibsDisguises.java (100%) rename src/{mea => me}/libraryaddict/disguise/PacketsManager.java (60%) rename src/{mea => me}/libraryaddict/disguise/UpdateChecker.java (100%) diff --git a/config.yml b/config.yml index c3398e45..8ac2946d 100644 --- a/config.yml +++ b/config.yml @@ -17,10 +17,4 @@ DisguiseSounds: true HearSelfDisguise: false # 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. -# However! This doesn't actually remove the armor! -# It just makes the client think the armor was removed so that it doesn't render it! -RemoveArmor: true -RemoveHeldItem: true \ No newline at end of file +SendVelocity: true \ No newline at end of file diff --git a/src/mea/libraryaddict/disguise/commands/DisguiseCommand.java b/src/me/libraryaddict/disguise/Commands/DisguiseCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/DisguiseCommand.java rename to src/me/libraryaddict/disguise/Commands/DisguiseCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/DisguiseEntityCommand.java b/src/me/libraryaddict/disguise/Commands/DisguiseEntityCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/DisguiseEntityCommand.java rename to src/me/libraryaddict/disguise/Commands/DisguiseEntityCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/DisguisePlayerCommand.java b/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/DisguisePlayerCommand.java rename to src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/DisguiseRadiusCommand.java b/src/me/libraryaddict/disguise/Commands/DisguiseRadiusCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/DisguiseRadiusCommand.java rename to src/me/libraryaddict/disguise/Commands/DisguiseRadiusCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/UndisguiseCommand.java b/src/me/libraryaddict/disguise/Commands/UndisguiseCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/UndisguiseCommand.java rename to src/me/libraryaddict/disguise/Commands/UndisguiseCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/UndisguiseEntityCommand.java b/src/me/libraryaddict/disguise/Commands/UndisguiseEntityCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/UndisguiseEntityCommand.java rename to src/me/libraryaddict/disguise/Commands/UndisguiseEntityCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/UndisguisePlayerCommand.java b/src/me/libraryaddict/disguise/Commands/UndisguisePlayerCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/UndisguisePlayerCommand.java rename to src/me/libraryaddict/disguise/Commands/UndisguisePlayerCommand.java diff --git a/src/mea/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java b/src/me/libraryaddict/disguise/Commands/UndisguiseRadiusCommand.java similarity index 100% rename from src/mea/libraryaddict/disguise/commands/UndisguiseRadiusCommand.java rename to src/me/libraryaddict/disguise/Commands/UndisguiseRadiusCommand.java diff --git a/src/mea/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java similarity index 73% rename from src/mea/libraryaddict/disguise/DisguiseAPI.java rename to src/me/libraryaddict/disguise/DisguiseAPI.java index 1bf81090..48616341 100644 --- a/src/mea/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -238,8 +238,6 @@ public class DisguiseAPI { } catch (Exception ex) { ex.printStackTrace(); } - // TODO Restore their currently held item - // TODO Restore their armor } } @@ -290,6 +288,23 @@ public class DisguiseAPI { // If the disguised player can't see himself. Return if (!disguise.viewSelfDisguise()) return; + // Grab the entity player + EntityPlayer entityplayer = ((CraftPlayer) player).getHandle(); + EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) entityplayer.world).tracker.trackedEntities.get(player + .getEntityId()); + if (tracker == 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.. + Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { + public void run() { + setupPlayerFakeDisguise(disguise); + } + }); + return; + } + // Add himself to his own entity tracker + tracker.trackedPlayers.add(entityplayer); try { // Grab the entity ID the fake disguise will use Field field = net.minecraft.server.v1_6_R3.Entity.class.getDeclaredField("entityCount"); @@ -301,7 +316,81 @@ public class DisguiseAPI { } catch (Exception ex) { ex.printStackTrace(); } - PacketsManager.sendSelfDisguise(player); + // Send the player a packet with himself being spawned + Packet20NamedEntitySpawn packet = new Packet20NamedEntitySpawn((EntityHuman) entityplayer); + entityplayer.playerConnection.sendPacket(packet); + if (!tracker.tracker.getDataWatcher().d()) { + entityplayer.playerConnection.sendPacket(new Packet40EntityMetadata(player.getEntityId(), tracker.tracker + .getDataWatcher(), true)); + } + // Send himself some entity attributes + if (tracker.tracker instanceof EntityLiving) { + AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) tracker.tracker).aX(); + Collection collection = attributemapserver.c(); + + if (!collection.isEmpty()) { + entityplayer.playerConnection.sendPacket(new Packet44UpdateAttributes(player.getEntityId(), collection)); + } + } + + // Why do we even have this? + tracker.j = tracker.tracker.motX; + tracker.k = tracker.tracker.motY; + tracker.l = tracker.tracker.motZ; + boolean isMoving = false; + try { + Field field = EntityTrackerEntry.class.getDeclaredField("isMoving"); + field.setAccessible(true); + isMoving = field.getBoolean(tracker); + } catch (Exception ex) { + ex.printStackTrace(); + } + // Send the velocity packets + if (isMoving) { + entityplayer.playerConnection.sendPacket(new Packet28EntityVelocity(player.getEntityId(), tracker.tracker.motX, + tracker.tracker.motY, tracker.tracker.motZ)); + } + + // Why the hell would he even need this. Meh. + if (tracker.tracker.vehicle != null && player.getEntityId() > tracker.tracker.vehicle.id) { + entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(0, tracker.tracker, tracker.tracker.vehicle)); + } else if (tracker.tracker.passenger != null && player.getEntityId() > tracker.tracker.passenger.id) { + entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(0, tracker.tracker.passenger, tracker.tracker)); + } + + if (tracker.tracker instanceof EntityInsentient && ((EntityInsentient) tracker.tracker).getLeashHolder() != null) { + entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(1, tracker.tracker, + ((EntityInsentient) tracker.tracker).getLeashHolder())); + } + + // Resend the armor + for (int i = 0; i < 5; ++i) { + ItemStack itemstack = ((EntityLiving) tracker.tracker).getEquipment(i); + + if (itemstack != null) { + entityplayer.playerConnection.sendPacket(new Packet5EntityEquipment(player.getEntityId(), i, itemstack)); + } + } + // If the disguised is sleeping for w/e reason + if (entityplayer.isSleeping()) { + entityplayer.playerConnection + .sendPacket(new Packet17EntityLocationAction(entityplayer, 0, (int) Math.floor(tracker.tracker.locX), + (int) Math.floor(tracker.tracker.locY), (int) Math.floor(tracker.tracker.locZ))); + } + + // CraftBukkit start - Fix for nonsensical head yaw + tracker.i = (int) Math.floor(tracker.tracker.getHeadRotation() * 256.0F / 360.0F); // tracker.ao() should be + // getHeadRotation + tracker.broadcast(new Packet35EntityHeadRotation(player.getEntityId(), (byte) tracker.i)); + // CraftBukkit end + + // Resend any active potion effects + Iterator iterator = entityplayer.getEffects().iterator(); + while (iterator.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator.next(); + + entityplayer.playerConnection.sendPacket(new Packet41MobEffect(player.getEntityId(), mobeffect)); + } } /** diff --git a/src/mea/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java similarity index 100% rename from src/mea/libraryaddict/disguise/DisguiseListener.java rename to src/me/libraryaddict/disguise/DisguiseListener.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/AnimalColor.java b/src/me/libraryaddict/disguise/DisguiseTypes/AnimalColor.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/AnimalColor.java rename to src/me/libraryaddict/disguise/DisguiseTypes/AnimalColor.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java similarity index 95% rename from src/mea/libraryaddict/disguise/disguisetypes/Disguise.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index a25c68bc..3d13bb21 100644 --- a/src/mea/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -26,6 +26,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; + import com.comphenix.protocol.Packets; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; @@ -40,24 +41,12 @@ public class Disguise { private DisguiseType disguiseType; private org.bukkit.entity.Entity entity; private boolean hearSelfDisguise = DisguiseAPI.canHearSelfDisguise(); - private boolean hideArmorFromSelf = DisguiseAPI.isHidingArmorFromSelf(); - private boolean hideHeldItemFromSelf = DisguiseAPI.isHidingHeldItemFromSelf(); - private boolean replaceSounds = DisguiseAPI.isSoundEnabled(); + private boolean replaceSounds; private BukkitRunnable runnable; private boolean velocitySent = DisguiseAPI.isVelocitySent(); private boolean viewSelfDisguise = DisguiseAPI.isViewDisguises(); private FlagWatcher watcher; - public boolean canHearSelfDisguise() { - return hearSelfDisguise; - } - - public Disguise clone() { - Disguise disguise = new Disguise().createDisguise(getType(), replaceSounds()); - disguise.setViewSelfDisguise(viewSelfDisguise()); - return disguise; - } - protected Disguise createDisguise(DisguiseType newType, boolean doSounds) { if (getWatcher() != null) return this; @@ -66,12 +55,7 @@ public class Disguise { // Set the option to replace the sounds setReplaceSounds(doSounds); // Get if they are a adult now.. - boolean isBaby = false; - if (this instanceof MobDisguise) { - if (!((MobDisguise) this).isAdult()) { - isBaby = true; - } - } + boolean isBaby = !(this instanceof MobDisguise && ((MobDisguise) this).isAdult()); try { // Construct the FlagWatcher from the stored class setWatcher((FlagWatcher) getType().getWatcherClass().getConstructor(Disguise.class).newInstance(this)); @@ -275,6 +259,16 @@ public class Disguise { return this; } + public boolean canHearSelfDisguise() { + return hearSelfDisguise; + } + + public Disguise clone() { + Disguise disguise = new Disguise().createDisguise(getType(), replaceSounds()); + disguise.setViewSelfDisguise(viewSelfDisguise()); + return disguise; + } + @Override public boolean equals(Object obj) { if (this == obj) @@ -333,14 +327,6 @@ public class Disguise { return watcher; } - public boolean isHidingArmorFromSelf() { - return hideArmorFromSelf; - } - - public boolean isHidingHeldItemFromSelf() { - return hideHeldItemFromSelf; - } - public boolean isMiscDisguise() { return this instanceof MiscDisguise; } @@ -377,7 +363,7 @@ public class Disguise { disguises.remove(getEntity().getEntityId()); // Gotta do reflection, copy code or open up calls. // Reflection is the cleanest? - if (getEntity() instanceof Player) { + if (entity instanceof Player) { disguiseAPI.removeVisibleDisguise((Player) entity); } // Better refresh the entity to undisguise it @@ -415,16 +401,6 @@ public class Disguise { this.hearSelfDisguise = hearSelfDisguise; } - public void setHideArmorFromSelf(boolean hideArmor) { - this.hideArmorFromSelf = hideArmor; - // TODO Update their armor if player - } - - public void setHideHeldItemFromSelf(boolean hideHeldItem) { - this.hideHeldItemFromSelf = hideHeldItem; - // TODO Update their held item if player - } - public void setReplaceSounds(boolean areSoundsReplaced) { replaceSounds = areSoundsReplaced; } diff --git a/src/mea/libraryaddict/disguise/disguisetypes/DisguiseSound.java b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java similarity index 89% rename from src/mea/libraryaddict/disguise/disguisetypes/DisguiseSound.java rename to src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java index ee2d0e91..1bb2e459 100644 --- a/src/mea/libraryaddict/disguise/disguisetypes/DisguiseSound.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java @@ -22,9 +22,7 @@ public enum DisguiseSound { CREEPER(Sound.CREEPER_HISS, Sound.STEP_GRASS, Sound.CREEPER_DEATH), - DONKEY(Sound.DONKEY_HIT, Sound.STEP_GRASS, Sound.DONKEY_DEATH, Sound.DONKEY_IDLE, Sound.DONKEY_ANGRY, Sound.HORSE_GALLOP, - Sound.HORSE_ANGRY, Sound.HORSE_ARMOR, Sound.HORSE_JUMP, Sound.HORSE_LAND, Sound.HORSE_SADDLE, Sound.HORSE_SOFT, - Sound.HORSE_WOOD), + DONKEY(Sound.DONKEY_HIT, Sound.STEP_GRASS, Sound.DONKEY_DEATH, Sound.DONKEY_IDLE, Sound.DONKEY_ANGRY), ENDER_DRAGON(Sound.ENDERDRAGON_HIT, null, Sound.ENDERDRAGON_DEATH, Sound.ENDERDRAGON_GROWL, Sound.ENDERDRAGON_WINGS, Sound.FALL_BIG, Sound.FALL_SMALL), @@ -37,8 +35,7 @@ public enum DisguiseSound { GIANT(Sound.HURT_FLESH, Sound.STEP_GRASS), - HORSE(Sound.HORSE_HIT, Sound.STEP_GRASS, "mob.horse.death", Sound.HORSE_IDLE, Sound.HORSE_GALLOP, Sound.HORSE_ANGRY, - Sound.HORSE_ARMOR, Sound.HORSE_JUMP, Sound.HORSE_LAND, Sound.HORSE_SADDLE, Sound.HORSE_SOFT, Sound.HORSE_WOOD), + HORSE(Sound.HORSE_HIT, Sound.STEP_GRASS, "mob.horse.death", Sound.HORSE_IDLE), IRON_GOLEM(Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_WALK, Sound.IRONGOLEM_DEATH, Sound.IRONGOLEM_THROW), @@ -62,9 +59,7 @@ public enum DisguiseSound { SKELETON(Sound.SKELETON_HURT, Sound.SKELETON_WALK, Sound.SKELETON_DEATH, Sound.SKELETON_IDLE), - SKELETON_HORSE("mob.horse.skeleton.hit", Sound.STEP_GRASS, Sound.HORSE_SKELETON_DEATH, Sound.HORSE_SKELETON_IDLE, - Sound.HORSE_GALLOP, Sound.HORSE_ANGRY, Sound.HORSE_ARMOR, Sound.HORSE_JUMP, Sound.HORSE_LAND, Sound.HORSE_SADDLE, - Sound.HORSE_SOFT, Sound.HORSE_WOOD), + SKELETON_HORSE("mob.horse.skeleton.hit", Sound.STEP_GRASS, Sound.HORSE_SKELETON_DEATH, Sound.HORSE_SKELETON_IDLE), SLIME(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK), @@ -74,9 +69,7 @@ public enum DisguiseSound { SQUID(), - UNDEAD_HORSE(Sound.HORSE_ZOMBIE_HIT, Sound.STEP_GRASS, Sound.HORSE_ZOMBIE_DEATH, Sound.HORSE_ZOMBIE_IDLE, Sound.HORSE_GALLOP, - Sound.HORSE_ANGRY, Sound.HORSE_ARMOR, Sound.HORSE_JUMP, Sound.HORSE_LAND, Sound.HORSE_SADDLE, Sound.HORSE_SOFT, - Sound.HORSE_WOOD), + UNDEAD_HORSE(Sound.HORSE_ZOMBIE_HIT, Sound.STEP_GRASS, Sound.HORSE_ZOMBIE_DEATH, Sound.HORSE_ZOMBIE_IDLE), VILLAGER(Sound.VILLAGER_HIT, null, Sound.VILLAGER_DEATH, Sound.VILLAGER_IDLE, Sound.VILLAGER_HAGGLE, Sound.VILLAGER_YES, Sound.VILLAGER_NO), diff --git a/src/mea/libraryaddict/disguise/disguisetypes/DisguiseType.java b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseType.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/DisguiseType.java rename to src/me/libraryaddict/disguise/DisguiseTypes/DisguiseType.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/FlagWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/MiscDisguise.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/MiscDisguise.java rename to src/me/libraryaddict/disguise/DisguiseTypes/MiscDisguise.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/MobDisguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/MobDisguise.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/MobDisguise.java rename to src/me/libraryaddict/disguise/DisguiseTypes/MobDisguise.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/PlayerDisguise.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/PlayerDisguise.java rename to src/me/libraryaddict/disguise/DisguiseTypes/PlayerDisguise.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/Values.java b/src/me/libraryaddict/disguise/DisguiseTypes/Values.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/Values.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Values.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/AgeableWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/AgeableWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ArrowWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ArrowWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/BatWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/BatWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/BlazeWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/BlazeWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/BoatWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/BoatWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/CreeperWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/CreeperWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/DroppedItemWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/DroppedItemWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/EndermanWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/EndermanWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/GhastWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/GhastWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/HorseWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/HorseWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ItemFrameWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ItemFrameWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/LivingWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/LivingWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/MinecartWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/MinecartWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/OcelotWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/OcelotWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/PigWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/PigWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/PlayerWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/PlayerWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/SheepWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/SheepWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/SlimeWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/SlimeWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/VillagerWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/VillagerWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/WitherSkullWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/WitherSkullWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/WolfWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/WolfWatcher.java diff --git a/src/mea/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ZombieWatcher.java similarity index 100% rename from src/mea/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ZombieWatcher.java diff --git a/src/mea/libraryaddict/disguise/events/DisguiseEvent.java b/src/me/libraryaddict/disguise/Events/DisguiseEvent.java similarity index 100% rename from src/mea/libraryaddict/disguise/events/DisguiseEvent.java rename to src/me/libraryaddict/disguise/Events/DisguiseEvent.java diff --git a/src/mea/libraryaddict/disguise/events/UndisguiseEvent.java b/src/me/libraryaddict/disguise/Events/UndisguiseEvent.java similarity index 100% rename from src/mea/libraryaddict/disguise/events/UndisguiseEvent.java rename to src/me/libraryaddict/disguise/Events/UndisguiseEvent.java diff --git a/src/mea/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java similarity index 100% rename from src/mea/libraryaddict/disguise/LibsDisguises.java rename to src/me/libraryaddict/disguise/LibsDisguises.java diff --git a/src/mea/libraryaddict/disguise/PacketsManager.java b/src/me/libraryaddict/disguise/PacketsManager.java similarity index 60% rename from src/mea/libraryaddict/disguise/PacketsManager.java rename to src/me/libraryaddict/disguise/PacketsManager.java index a492fe59..05b6484d 100644 --- a/src/mea/libraryaddict/disguise/PacketsManager.java +++ b/src/me/libraryaddict/disguise/PacketsManager.java @@ -18,39 +18,21 @@ import me.libraryaddict.disguise.disguisetypes.MobDisguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.disguisetypes.Values; import me.libraryaddict.disguise.disguisetypes.DisguiseSound.SoundType; -import net.minecraft.server.v1_6_R3.AttributeMapServer; import net.minecraft.server.v1_6_R3.AttributeSnapshot; import net.minecraft.server.v1_6_R3.Block; import net.minecraft.server.v1_6_R3.DataWatcher; -import net.minecraft.server.v1_6_R3.EntityHuman; -import net.minecraft.server.v1_6_R3.EntityInsentient; import net.minecraft.server.v1_6_R3.EntityLiving; -import net.minecraft.server.v1_6_R3.EntityPlayer; -import net.minecraft.server.v1_6_R3.EntityTrackerEntry; import net.minecraft.server.v1_6_R3.EnumArt; import net.minecraft.server.v1_6_R3.EnumEntitySize; import net.minecraft.server.v1_6_R3.ItemStack; import net.minecraft.server.v1_6_R3.MathHelper; -import net.minecraft.server.v1_6_R3.MobEffect; -import net.minecraft.server.v1_6_R3.Packet17EntityLocationAction; -import net.minecraft.server.v1_6_R3.Packet20NamedEntitySpawn; -import net.minecraft.server.v1_6_R3.Packet28EntityVelocity; -import net.minecraft.server.v1_6_R3.Packet35EntityHeadRotation; -import net.minecraft.server.v1_6_R3.Packet39AttachEntity; -import net.minecraft.server.v1_6_R3.Packet40EntityMetadata; -import net.minecraft.server.v1_6_R3.Packet41MobEffect; -import net.minecraft.server.v1_6_R3.Packet44UpdateAttributes; -import net.minecraft.server.v1_6_R3.Packet5EntityEquipment; import net.minecraft.server.v1_6_R3.WatchableObject; import net.minecraft.server.v1_6_R3.World; -import net.minecraft.server.v1_6_R3.WorldServer; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; @@ -73,14 +55,10 @@ import com.comphenix.protocol.events.PacketListener; import com.comphenix.protocol.reflect.StructureModifier; public class PacketsManager { - private static PacketListener inventoryListenerClient; - private static PacketListener inventoryListenerServer; - private static boolean inventoryModifierEnabled; private static PacketListener soundsListener; private static boolean soundsListenerEnabled; private static PacketListener viewDisguisesListener; private static boolean viewDisguisesListenerEnabled; - private static LibsDisguises libsDisguises; protected static void addPacketListeners(final JavaPlugin libsDisguises) { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); @@ -123,7 +101,7 @@ public class PacketsManager { }); // Now 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. + // Kicks you for hacking. manager.addPacketListener(new PacketAdapter(libsDisguises, ConnectionSide.CLIENT_SIDE, ListenerPriority.NORMAL, Packets.Client.USE_ENTITY) { @Override @@ -392,9 +370,6 @@ public class PacketsManager { return value; } - /** - * Get the Y level to add to the disguise for realism. - */ private static double getYModifier(Entity entity, DisguiseType disguiseType) { switch (disguiseType) { case BAT: @@ -425,11 +400,7 @@ public class PacketsManager { return 0; } - /** - * Creates the packet listeners - */ - protected static void init(LibsDisguises plugin) { - libsDisguises = plugin; + protected static void init(JavaPlugin libsDisguises) { soundsListener = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ENTITY_STATUS) { @Override @@ -681,412 +652,12 @@ public class PacketsManager { } } }; - // TODO Potentionally combine both listeners. - inventoryListenerServer = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGHEST, - Packets.Server.SET_SLOT) { - @Override - public void onPacketSending(PacketEvent event) { - // If the inventory is the players inventory - if (event.getPacket().getIntegers().read(0) == 0) { - Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); - // If the player is disguised, views self disguises and is hiding a item. - if (disguise != null && disguise.viewSelfDisguise() - && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { - switch (event.getPacketID()) { - // 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 - case Packets.Server.SET_SLOT: { - // The raw slot - // nms code has the start of the hotbar being 36. - int slot = event.getPacket().getIntegers().read(1); - Bukkit.broadcastMessage("Set slot: " + slot); - // If the slot is a armor 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) { - event.setPacket(event.getPacket().shallowClone()); - event.getPacket().getModifier() - .write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - } - } - // Else if its a hotbar slot - } 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) { - org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand(); - if (item != null && item.getType() != Material.AIR) { - event.setPacket(event.getPacket().shallowClone()); - event.getPacket().getModifier() - .write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - } - } - } - } - break; - } - // Don't think that we will ever need this. - // We will see. - case Packets.Server.WINDOW_ITEMS: { - // TODO Find out how this works - // It seems to 'update' the inventory.. Screw you.. - break; - } - default: - break; - } - } - } - } - }; - // TODO Add a listener for player click event. - // Items placed do not have the server confirm it - // So I need to set the item slot - inventoryListenerClient = new PacketAdapter(libsDisguises, ConnectionSide.CLIENT_SIDE, ListenerPriority.HIGHEST, - Packets.Client.BLOCK_ITEM_SWITCH, Packets.Client.SET_CREATIVE_SLOT, Packets.Client.WINDOW_CLICK) { - @Override - public void onPacketReceiving(PacketEvent event) { - Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); - // If player is disguised, views self disguises and has a inventory modifier - if (disguise != null && disguise.viewSelfDisguise() - && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { - switch (event.getPacketID()) { - // If they are in creative and clicked on a slot - case Packets.Client.SET_CREATIVE_SLOT: { - int slot = event.getPacket().getIntegers().read(0); - if (slot >= 5 && slot <= 8) { - if (disguise.isHidingArmorFromSelf()) { - int armorSlot = Math.abs(slot - 9); - org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot]; - if (item != null && item.getType() != Material.AIR) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, slot); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } else if (slot >= 36 && slot <= 44) { - if (disguise.isHidingHeldItemFromSelf()) { - int currentSlot = event.getPlayer().getInventory().getHeldItemSlot(); - if (slot + 36 == currentSlot) { - org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand(); - if (item != null && item.getType() != Material.AIR) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, slot); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, - false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - } - break; - } - // If the player switched item, aka he moved from slot 1 to slot 2 - // TODO Listen for this server sided, sometimes it may force him back to a old slot - // ^ But I think the client sends the packet again.. - // This currently works fine - case Packets.Client.BLOCK_ITEM_SWITCH: { - 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) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, event.getPlayer().getInventory().getHeldItemSlot() + 36); - mods.write(2, CraftItemStack.asNMSCopy(currentlyHeld)); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } 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) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, event.getPacket().getIntegers().read(0) + 36); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - break; - } - - case Packets.Client.WINDOW_CLICK: - // Seems like the cases are never met.. - // Probably slot mismatches again - { - int slot = event.getPacket().getIntegers().read(1); - org.bukkit.inventory.ItemStack clickedItem; - if (event.getPacket().getIntegers().read(3) == 1) { - // Its a shift click - clickedItem = event.getPacket().getItemModifier().read(0); - if (clickedItem != null && clickedItem.getType() != Material.AIR) { - org.bukkit.inventory.ItemStack armorItem = null; - int armorSlot = 0; - switch (clickedItem.getType()) { - case LEATHER_BOOTS: - case GOLD_BOOTS: - case CHAINMAIL_BOOTS: - case IRON_BOOTS: - case DIAMOND_BOOTS: - armorSlot = 8; - armorItem = event.getPlayer().getInventory().getBoots(); - break; - case LEATHER_LEGGINGS: - case GOLD_LEGGINGS: - case CHAINMAIL_LEGGINGS: - case IRON_LEGGINGS: - case DIAMOND_LEGGINGS: - armorSlot = 7; - armorItem = event.getPlayer().getInventory().getLeggings(); - break; - case LEATHER_CHESTPLATE: - case GOLD_CHESTPLATE: - case CHAINMAIL_CHESTPLATE: - case IRON_CHESTPLATE: - case DIAMOND_CHESTPLATE: - armorSlot = 6; - armorItem = event.getPlayer().getInventory().getChestplate(); - break; - case LEATHER_HELMET: - case GOLD_HELMET: - case CHAINMAIL_HELMET: - case IRON_HELMET: - case DIAMOND_HELMET: - armorSlot = 5; - armorItem = event.getPlayer().getInventory().getHelmet(); - break; - default: - break; - } - // Its a piece of armor they clicked on.. - if (armorSlot > 0) { - if (armorItem == null || armorItem.getType() == Material.AIR) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, armorSlot); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, - false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } else { - org.bukkit.inventory.ItemStack heldItem = event.getPlayer().getItemInHand(); - // If its not a piece of armor they clicked on - // Then it can't go into a armor slot - // So it has to go into the held item.. - // But the held item is full. - if (heldItem == null || heldItem.getType() == Material.AIR) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, 36 + event.getPlayer().getInventory().getHeldItemSlot()); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, - false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - return; - } else { - // If its not a player inventory click - // Shift clicking is exempted for the item in hand.. - if (event.getPacket().getIntegers().read(0) != 0) { - return; - } - clickedItem = event.getPlayer().getItemOnCursor(); - } - if (clickedItem != null && clickedItem.getType() != Material.AIR) { - // If the slot is a armor slot - if (slot >= 5 && slot <= 8) { - if (disguise.isHidingArmorFromSelf()) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, slot); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - // Else if its a hotbar slot - } 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) { - PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); - StructureModifier mods = packet.getModifier(); - mods.write(0, 0); - mods.write(1, slot); - mods.write(2, CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(0))); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, - false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - } - break; - } - - default: - break; - } - } - } - }; - } - - /** - * Sends the self disguise to the player - */ - public static void sendSelfDisguise(final Player player) { - EntityPlayer entityplayer = ((CraftPlayer) player).getHandle(); - EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) entityplayer.world).tracker.trackedEntities.get(player - .getEntityId()); - if (tracker == 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.. - Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { - public void run() { - sendSelfDisguise(player); - } - }); - return; - } - // Add himself to his own entity tracker - tracker.trackedPlayers.add(entityplayer); - // Send the player a packet with himself being spawned - Packet20NamedEntitySpawn packet = new Packet20NamedEntitySpawn((EntityHuman) entityplayer); - entityplayer.playerConnection.sendPacket(packet); - if (!tracker.tracker.getDataWatcher().d()) { - entityplayer.playerConnection.sendPacket(new Packet40EntityMetadata(player.getEntityId(), tracker.tracker - .getDataWatcher(), true)); - } - // Send himself some entity attributes - if (tracker.tracker instanceof EntityLiving) { - AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) tracker.tracker).aX(); - Collection collection = attributemapserver.c(); - - if (!collection.isEmpty()) { - entityplayer.playerConnection.sendPacket(new Packet44UpdateAttributes(player.getEntityId(), collection)); - } - } - - // Why do we even have this? - tracker.j = tracker.tracker.motX; - tracker.k = tracker.tracker.motY; - tracker.l = tracker.tracker.motZ; - boolean isMoving = false; - try { - Field field = EntityTrackerEntry.class.getDeclaredField("isMoving"); - field.setAccessible(true); - isMoving = field.getBoolean(tracker); - } catch (Exception ex) { - ex.printStackTrace(); - } - // Send the velocity packets - if (isMoving) { - entityplayer.playerConnection.sendPacket(new Packet28EntityVelocity(player.getEntityId(), tracker.tracker.motX, - tracker.tracker.motY, tracker.tracker.motZ)); - } - - // Why the hell would he even need this. Meh. - if (tracker.tracker.vehicle != null && player.getEntityId() > tracker.tracker.vehicle.id) { - entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(0, tracker.tracker, tracker.tracker.vehicle)); - } else if (tracker.tracker.passenger != null && player.getEntityId() > tracker.tracker.passenger.id) { - entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(0, tracker.tracker.passenger, tracker.tracker)); - } - - if (tracker.tracker instanceof EntityInsentient && ((EntityInsentient) tracker.tracker).getLeashHolder() != null) { - entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(1, tracker.tracker, - ((EntityInsentient) tracker.tracker).getLeashHolder())); - } - - // Resend the armor - for (int i = 0; i < 5; ++i) { - ItemStack itemstack = ((EntityLiving) tracker.tracker).getEquipment(i); - - if (itemstack != null) { - entityplayer.playerConnection.sendPacket(new Packet5EntityEquipment(player.getEntityId(), i, itemstack)); - } - } - // If the disguised is sleeping for w/e reason - if (entityplayer.isSleeping()) { - entityplayer.playerConnection - .sendPacket(new Packet17EntityLocationAction(entityplayer, 0, (int) Math.floor(tracker.tracker.locX), - (int) Math.floor(tracker.tracker.locY), (int) Math.floor(tracker.tracker.locZ))); - } - - // CraftBukkit start - Fix for nonsensical head yaw - tracker.i = (int) Math.floor(tracker.tracker.getHeadRotation() * 256.0F / 360.0F); // tracker.ao() should be - // getHeadRotation - tracker.broadcast(new Packet35EntityHeadRotation(player.getEntityId(), (byte) tracker.i)); - // CraftBukkit end - - // Resend any active potion effects - Iterator iterator = entityplayer.getEffects().iterator(); - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - entityplayer.playerConnection.sendPacket(new Packet41MobEffect(player.getEntityId(), mobeffect)); - } } public static boolean isHearDisguisesEnabled() { return soundsListenerEnabled; } - public static boolean isInventoryListenerEnabled() { - return inventoryModifierEnabled; - } - public static boolean isViewDisguisesListenerEnabled() { return viewDisguisesListenerEnabled; } @@ -1102,24 +673,9 @@ public class PacketsManager { } } - public static void setInventoryListenerEnabled(boolean enabled) { - if (inventoryModifierEnabled != enabled) { - inventoryModifierEnabled = enabled; - // TODO Update all disguises to update their inventories. - if (inventoryModifierEnabled) { - ProtocolLibrary.getProtocolManager().addPacketListener(inventoryListenerClient); - ProtocolLibrary.getProtocolManager().addPacketListener(inventoryListenerServer); - } else { - ProtocolLibrary.getProtocolManager().removePacketListener(inventoryListenerClient); - ProtocolLibrary.getProtocolManager().removePacketListener(inventoryListenerServer); - } - } - } - public static void setViewDisguisesListener(boolean enabled) { if (viewDisguisesListenerEnabled != enabled) { viewDisguisesListenerEnabled = enabled; - // TODO Remove all self disguises, or add them. if (viewDisguisesListenerEnabled) { ProtocolLibrary.getProtocolManager().addPacketListener(viewDisguisesListener); } else { diff --git a/src/mea/libraryaddict/disguise/UpdateChecker.java b/src/me/libraryaddict/disguise/UpdateChecker.java similarity index 100% rename from src/mea/libraryaddict/disguise/UpdateChecker.java rename to src/me/libraryaddict/disguise/UpdateChecker.java