Added the rest of disguisable entitys. Fixed crashes
This commit is contained in:
parent
6b8bce622d
commit
0c6d1c9280
@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class DisguiseCommand implements CommandExecutor {
|
public class DisguiseCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.isOp()) {
|
if (sender.isOp()) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
@ -5,6 +5,7 @@ import java.lang.reflect.Constructor;
|
|||||||
import me.libraryaddict.disguise.DisguiseTypes.Watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.DisguiseTypes.Watchers.AgeableWatcher;
|
||||||
import net.minecraft.server.v1_5_R3.Entity;
|
import net.minecraft.server.v1_5_R3.Entity;
|
||||||
import net.minecraft.server.v1_5_R3.EntityAgeable;
|
import net.minecraft.server.v1_5_R3.EntityAgeable;
|
||||||
|
import net.minecraft.server.v1_5_R3.EntityExperienceOrb;
|
||||||
import net.minecraft.server.v1_5_R3.EntityHuman;
|
import net.minecraft.server.v1_5_R3.EntityHuman;
|
||||||
import net.minecraft.server.v1_5_R3.EntityLiving;
|
import net.minecraft.server.v1_5_R3.EntityLiving;
|
||||||
import net.minecraft.server.v1_5_R3.EntitySkeleton;
|
import net.minecraft.server.v1_5_R3.EntitySkeleton;
|
||||||
@ -12,6 +13,7 @@ import net.minecraft.server.v1_5_R3.Packet;
|
|||||||
import net.minecraft.server.v1_5_R3.Packet20NamedEntitySpawn;
|
import net.minecraft.server.v1_5_R3.Packet20NamedEntitySpawn;
|
||||||
import net.minecraft.server.v1_5_R3.Packet23VehicleSpawn;
|
import net.minecraft.server.v1_5_R3.Packet23VehicleSpawn;
|
||||||
import net.minecraft.server.v1_5_R3.Packet24MobSpawn;
|
import net.minecraft.server.v1_5_R3.Packet24MobSpawn;
|
||||||
|
import net.minecraft.server.v1_5_R3.Packet26AddExpOrb;
|
||||||
import net.minecraft.server.v1_5_R3.World;
|
import net.minecraft.server.v1_5_R3.World;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
|
||||||
@ -36,26 +38,26 @@ public class Disguise {
|
|||||||
|
|
||||||
} else if (getType().isMisc()) {
|
} else if (getType().isMisc()) {
|
||||||
|
|
||||||
int id = 0;
|
|
||||||
if (getType() == DisguiseType.PRIMED_TNT)
|
|
||||||
id = 50;
|
|
||||||
else if (getType() == DisguiseType.ENDER_CRYSTAL)
|
|
||||||
id = 51;
|
|
||||||
else if (getType() == DisguiseType.FALLING_BLOCK)
|
|
||||||
id = 70;
|
|
||||||
Entity entity = getEntity(((CraftPlayer) p).getHandle().world, p.getLocation(), p.getEntityId());
|
Entity entity = getEntity(((CraftPlayer) p).getHandle().world, p.getLocation(), p.getEntityId());
|
||||||
if (((MiscDisguise) this).getId() > 0)
|
if (((MiscDisguise) this).getId() >= 0) {
|
||||||
spawnPacket = new Packet23VehicleSpawn(entity, id, ((MiscDisguise) this).getId()
|
if (((MiscDisguise) this).getData() >= 0) {
|
||||||
| ((MiscDisguise) this).getData() << 16);
|
spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId(), ((MiscDisguise) this).getId()
|
||||||
else
|
| ((MiscDisguise) this).getData() << 16);
|
||||||
spawnPacket = new Packet23VehicleSpawn(entity, id);
|
} else
|
||||||
|
spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId(), ((MiscDisguise) this).getId());
|
||||||
|
} else
|
||||||
|
spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId());
|
||||||
} else if (getType().isPlayer()) {
|
} else if (getType().isPlayer()) {
|
||||||
|
|
||||||
EntityHuman entityHuman = ((CraftPlayer) p).getHandle();
|
EntityHuman entityHuman = ((CraftPlayer) p).getHandle();
|
||||||
spawnPacket = new Packet20NamedEntitySpawn(entityHuman);
|
spawnPacket = new Packet20NamedEntitySpawn(entityHuman);
|
||||||
((Packet20NamedEntitySpawn) spawnPacket).b = ((PlayerDisguise) this).getName();
|
((Packet20NamedEntitySpawn) spawnPacket).b = ((PlayerDisguise) this).getName();
|
||||||
|
|
||||||
|
} else if (getType().isExp()) {
|
||||||
|
|
||||||
|
Entity entity = getEntity(((CraftPlayer) p).getHandle().world, p.getLocation(), p.getEntityId());
|
||||||
|
spawnPacket = new Packet26AddExpOrb((EntityExperienceOrb) entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
return spawnPacket;
|
return spawnPacket;
|
||||||
}
|
}
|
||||||
@ -73,6 +75,9 @@ public class Disguise {
|
|||||||
if (disguiseType == DisguiseType.PRIMED_TNT) {
|
if (disguiseType == DisguiseType.PRIMED_TNT) {
|
||||||
name = "TNTPrimed";
|
name = "TNTPrimed";
|
||||||
}
|
}
|
||||||
|
if (disguiseType == DisguiseType.MINECART_TNT) {
|
||||||
|
name = "MinecartTNT";
|
||||||
|
}
|
||||||
Class entityClass = Class.forName("net.minecraft.server.v1_5_R3.Entity" + name);
|
Class entityClass = Class.forName("net.minecraft.server.v1_5_R3.Entity" + name);
|
||||||
Constructor<?> contructor = entityClass.getDeclaredConstructor(World.class);
|
Constructor<?> contructor = entityClass.getDeclaredConstructor(World.class);
|
||||||
entity = (Entity) contructor.newInstance(world);
|
entity = (Entity) contructor.newInstance(world);
|
||||||
@ -95,6 +100,7 @@ public class Disguise {
|
|||||||
Constructor<?> contructor = watcherClass.getDeclaredConstructor(int.class);
|
Constructor<?> contructor = watcherClass.getDeclaredConstructor(int.class);
|
||||||
watcher = (FlagWatcher) contructor.newInstance(entityId);
|
watcher = (FlagWatcher) contructor.newInstance(entityId);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
System.out.print("No watcher found");
|
||||||
// There is no watcher for this entity
|
// There is no watcher for this entity
|
||||||
}
|
}
|
||||||
if (watcher == null && entity instanceof EntityAgeable && this instanceof MobDisguise) {
|
if (watcher == null && entity instanceof EntityAgeable && this instanceof MobDisguise) {
|
||||||
|
@ -1,29 +1,72 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes;
|
package me.libraryaddict.disguise.DisguiseTypes;
|
||||||
|
|
||||||
public enum DisguiseType {
|
public enum DisguiseType {
|
||||||
BAT(EntityType.MOB), BLAZE(EntityType.MOB), CAVE_SPIDER(EntityType.MOB), CHICKEN(EntityType.MOB), COW(EntityType.MOB), CREEPER(
|
ARROW(EntityType.MISC, 60), BAT(EntityType.MOB), BLAZE(EntityType.MOB), BOAT(EntityType.MISC, 1), CAVE_SPIDER(EntityType.MOB), CHICKEN(
|
||||||
EntityType.MOB), ENDER_CRYSTAL(EntityType.MISC), ENDER_DRAGON(EntityType.MOB), ENDERMAN(EntityType.MOB), GHAST(
|
EntityType.MOB), COW(EntityType.MOB), CREEPER(EntityType.MOB), EGG(EntityType.MISC, 62), ENDER_CRYSTAL(
|
||||||
EntityType.MOB), GIANT_ZOMBIE(EntityType.MOB), IRON_GOLEM(EntityType.MOB), MAGMA_CUBE(EntityType.MOB), MUSHROOM_COW(
|
EntityType.MISC, 51), ENDER_DRAGON(EntityType.MOB), ENDER_PEARL(EntityType.MISC, 65), ENDER_SIGNAL(
|
||||||
EntityType.MOB), OCELOT(EntityType.MOB), PIG(EntityType.MOB), PIG_ZOMBIE(EntityType.MOB), PLAYER(EntityType.PLAYER), SHEEP(
|
EntityType.MISC, 72), ENDERMAN(EntityType.MOB), EXPERIENCE_ORB(EntityType.EXP), FALLING_BLOCK(EntityType.MISC, 70, 1), FIREWORKS(
|
||||||
EntityType.MOB), SILVERFISH(EntityType.MOB), SKELETON(EntityType.MOB), SLIME(EntityType.MOB), SNOWMAN(EntityType.MOB), SPIDER(
|
EntityType.MISC, 76), FISHING_HOOK(EntityType.MISC, 90), GHAST(EntityType.MOB), GIANT_ZOMBIE(EntityType.MOB), IRON_GOLEM(
|
||||||
EntityType.MOB), SQUID(EntityType.MOB), PRIMED_TNT(EntityType.MISC), VILLAGER(EntityType.MOB), WITCH(EntityType.MOB), WITHER(
|
EntityType.MOB), ITEM(EntityType.MISC, 2, 1), ITEM_FRAME(EntityType.MISC, 71), LARGE_FIREBALL(EntityType.MISC, 63, 0), MAGMA_CUBE(EntityType.MOB), MINECART_CHEST(
|
||||||
EntityType.MOB), WITHER_SKELETON(EntityType.MOB), WOLF(EntityType.MOB), ZOMBIE(EntityType.MOB), FALLING_BLOCK(
|
EntityType.MISC, 10, 1), MINECART_FURNACE(EntityType.MISC, 10, 2), MINECART_HOPPER(EntityType.MISC, 10), MINECART_MOB_SPAWNER(
|
||||||
EntityType.MISC);
|
EntityType.MISC, 10, 4), MINECART_RIDEABLE(EntityType.MISC, 10, 0), MINECART_TNT(EntityType.MISC, 10, 3), MUSHROOM_COW(
|
||||||
|
EntityType.MOB), OCELOT(EntityType.MOB), PIG(EntityType.MOB), PIG_ZOMBIE(EntityType.MOB), PLAYER(EntityType.PLAYER), POTION(
|
||||||
|
EntityType.MISC, 73), PRIMED_TNT(EntityType.MISC, 50), SHEEP(EntityType.MOB), SILVERFISH(EntityType.MOB), SKELETON(
|
||||||
|
EntityType.MOB), SLIME(EntityType.MOB), SMALL_FIREBALL(EntityType.MISC, 64, 0), SNOWBALL(EntityType.MISC, 61), SNOWMAN(
|
||||||
|
EntityType.MOB), SPIDER(EntityType.MOB), SQUID(EntityType.MOB), THROWN_EXP_BOTTLE(EntityType.MISC, 75), VILLAGER(
|
||||||
|
EntityType.MOB), WITCH(EntityType.MOB), WITHER(EntityType.MOB), WITHER_SKELETON(EntityType.MOB), WITHER_SKULL(
|
||||||
|
EntityType.MISC, 66), WOLF(EntityType.MOB), ZOMBIE(EntityType.MOB);
|
||||||
|
|
||||||
public static enum EntityType {
|
public static enum EntityType {
|
||||||
MISC, MOB, PLAYER;
|
EXP, MISC, MOB, PLAYER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DisguiseType getType(org.bukkit.entity.EntityType entityType) {
|
public static DisguiseType getType(org.bukkit.entity.EntityType entityType) {
|
||||||
return DisguiseType.valueOf(entityType.name());
|
return DisguiseType.valueOf(entityType.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int defaultData;
|
||||||
|
private int defaultId;
|
||||||
|
private int entityId;
|
||||||
private EntityType entityType;
|
private EntityType entityType;
|
||||||
|
|
||||||
private DisguiseType(EntityType newType) {
|
private DisguiseType(EntityType newType) {
|
||||||
entityType = newType;
|
entityType = newType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DisguiseType(EntityType newType, int entityId) {
|
||||||
|
entityType = newType;
|
||||||
|
this.entityId = entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DisguiseType(EntityType newType, int entityId, int defaultId) {
|
||||||
|
entityType = newType;
|
||||||
|
this.entityId = entityId;
|
||||||
|
this.defaultId = defaultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DisguiseType(EntityType newType, int entityId, int defaultId, int defaultData) {
|
||||||
|
entityType = newType;
|
||||||
|
this.entityId = entityId;
|
||||||
|
this.defaultId = defaultId;
|
||||||
|
this.defaultData = defaultData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultData() {
|
||||||
|
return defaultData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultId() {
|
||||||
|
return defaultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExp() {
|
||||||
|
return entityType == EntityType.EXP;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMisc() {
|
public boolean isMisc() {
|
||||||
return entityType == EntityType.MISC;
|
return entityType == EntityType.MISC;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_5_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_5_R3.Packet40EntityMetadata;
|
import net.minecraft.server.v1_5_R3.Packet40EntityMetadata;
|
||||||
import net.minecraft.server.v1_5_R3.WatchableObject;
|
import net.minecraft.server.v1_5_R3.WatchableObject;
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ public abstract class FlagWatcher {
|
|||||||
classTypes.put(Short.class, 1);
|
classTypes.put(Short.class, 1);
|
||||||
classTypes.put(Integer.class, 2);
|
classTypes.put(Integer.class, 2);
|
||||||
classTypes.put(String.class, 4);
|
classTypes.put(String.class, 4);
|
||||||
|
classTypes.put(ItemStack.class, 5);
|
||||||
}
|
}
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private HashMap<Integer, Object> entityValues = new HashMap<Integer, Object>();
|
private HashMap<Integer, Object> entityValues = new HashMap<Integer, Object>();
|
||||||
@ -57,7 +59,7 @@ public abstract class FlagWatcher {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
watch.a(entityValues.get(watch.a()));
|
watch.a(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,6 +80,13 @@ public abstract class FlagWatcher {
|
|||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayName(boolean display) {
|
||||||
|
if ((Byte) getValue(6) != (display ? 1 : 0)) {
|
||||||
|
setValue(6, (byte) (display ? 1 : 0));
|
||||||
|
sendData(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected Object getValue(int no) {
|
protected Object getValue(int no) {
|
||||||
return entityValues.get(no);
|
return entityValues.get(no);
|
||||||
}
|
}
|
||||||
@ -104,13 +113,6 @@ public abstract class FlagWatcher {
|
|||||||
setValue(5, name);
|
setValue(5, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayName(boolean display) {
|
|
||||||
if ((Byte) getValue(6) != (display ? 1 : 0)) {
|
|
||||||
setValue(6, (byte) (display ? 1 : 0));
|
|
||||||
sendData(6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setValue(int no, Object value) {
|
protected void setValue(int no, Object value) {
|
||||||
entityValues.put(no, value);
|
entityValues.put(no, value);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes;
|
package me.libraryaddict.disguise.DisguiseTypes;
|
||||||
|
|
||||||
public class MiscDisguise extends Disguise {
|
public class MiscDisguise extends Disguise {
|
||||||
private int id = 1;
|
private int data = -1;
|
||||||
private int data = 0;
|
private int id = -1;
|
||||||
|
|
||||||
public MiscDisguise(DisguiseType disguiseType) {
|
public MiscDisguise(DisguiseType disguiseType) {
|
||||||
super(disguiseType);
|
super(disguiseType);
|
||||||
|
id = disguiseType.getDefaultId();
|
||||||
|
data = disguiseType.getDefaultData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiscDisguise(DisguiseType disguiseType, int id, int data) {
|
public MiscDisguise(DisguiseType disguiseType, int id, int data) {
|
||||||
@ -14,12 +16,12 @@ public class MiscDisguise extends Disguise {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getData() {
|
public int getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -9,14 +9,14 @@ public class BatWatcher extends FlagWatcher {
|
|||||||
setValue(16, (byte) 1);
|
setValue(16, (byte) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFlying() {
|
||||||
|
return (Byte) getValue(16) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFlying(boolean flying) {
|
public void setFlying(boolean flying) {
|
||||||
if ((Byte) getValue(16) != (flying ? 1 : 0)) {
|
if ((Byte) getValue(16) != (flying ? 1 : 0)) {
|
||||||
setValue(16, (byte) (flying ? 1 : 0));
|
setValue(16, (byte) (flying ? 1 : 0));
|
||||||
sendData(16);
|
sendData(16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlying() {
|
|
||||||
return (Byte) getValue(16) == 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher;
|
||||||
|
|
||||||
|
public class BoatWatcher extends FlagWatcher {
|
||||||
|
|
||||||
|
public BoatWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
setValue(19, 40);
|
||||||
|
setValue(17, 10);
|
||||||
|
setValue(18, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDamage(int dmg) {
|
||||||
|
if ((Integer) getValue(19) != dmg) {
|
||||||
|
setValue(19, dmg);
|
||||||
|
sendData(19);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHealth(int health) {
|
||||||
|
if ((Integer) getValue(17) != health) {
|
||||||
|
setValue(17, health);
|
||||||
|
sendData(17);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,21 +11,12 @@ public class EndermanWatcher extends FlagWatcher {
|
|||||||
setValue(18, (byte) 0);
|
setValue(18, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCarriedItem(int id, int dataValue) {
|
public int getCarriedData() {
|
||||||
if ((Byte) getValue(16) != id || (Byte) getValue(17) != dataValue) {
|
return ((Byte) getValue(17));
|
||||||
setValue(16, (byte) (id & 255));
|
|
||||||
setValue(17, (byte) (dataValue & 255));
|
|
||||||
sendData(16);
|
|
||||||
sendData(17);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCarriedId() {
|
public int getCarriedId() {
|
||||||
return (int) ((Byte) getValue(16));
|
return ((Byte) getValue(16));
|
||||||
}
|
|
||||||
|
|
||||||
public int getCarriedData() {
|
|
||||||
return (int) ((Byte) getValue(17));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAgressive() {
|
public boolean isAgressive() {
|
||||||
@ -37,4 +28,13 @@ public class EndermanWatcher extends FlagWatcher {
|
|||||||
sendData(18);
|
sendData(18);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCarriedItem(int id, int dataValue) {
|
||||||
|
if ((Byte) getValue(16) != id || (Byte) getValue(17) != dataValue) {
|
||||||
|
setValue(16, (byte) (id & 255));
|
||||||
|
setValue(17, (byte) (dataValue & 255));
|
||||||
|
sendData(16);
|
||||||
|
sendData(17);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.v1_5_R3.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher;
|
||||||
|
|
||||||
|
public class ItemWatcher extends FlagWatcher {
|
||||||
|
|
||||||
|
public ItemWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
setValue(10, CraftItemStack.asNMSCopy(new ItemStack(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
return CraftItemStack.asBukkitCopy((net.minecraft.server.v1_5_R3.ItemStack) getValue(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemStack(ItemStack item) {
|
||||||
|
setValue(10, CraftItemStack.asNMSCopy(item));
|
||||||
|
sendData(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher;
|
||||||
|
|
||||||
|
public abstract class MinecartAbstractWatcher extends FlagWatcher {
|
||||||
|
|
||||||
|
protected MinecartAbstractWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
setValue(16, (byte) 0);
|
||||||
|
setValue(17, 0);
|
||||||
|
setValue(18, 1);
|
||||||
|
setValue(19, 0);
|
||||||
|
setValue(20, 0);
|
||||||
|
setValue(21, 6);
|
||||||
|
setValue(22, (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
public class MinecartChestWatcher extends MinecartAbstractWatcher {
|
||||||
|
|
||||||
|
public MinecartChestWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
public class MinecartFurnaceWatcher extends MinecartAbstractWatcher {
|
||||||
|
|
||||||
|
public MinecartFurnaceWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
public class MinecartHopperWatcher extends MinecartAbstractWatcher{
|
||||||
|
|
||||||
|
public MinecartHopperWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
public class MinecartMobSpawnerWatcher extends MinecartAbstractWatcher{
|
||||||
|
|
||||||
|
public MinecartMobSpawnerWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
public class MinecartRideableWatcher extends MinecartAbstractWatcher{
|
||||||
|
|
||||||
|
public MinecartRideableWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||||
|
|
||||||
|
public class MinecartTntWatcher extends MinecartAbstractWatcher{
|
||||||
|
|
||||||
|
public MinecartTntWatcher(int entityId) {
|
||||||
|
super(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -8,7 +8,8 @@ public class SlimeWatcher extends FlagWatcher {
|
|||||||
|
|
||||||
public SlimeWatcher(int entityId) {
|
public SlimeWatcher(int entityId) {
|
||||||
super(entityId);
|
super(entityId);
|
||||||
setValue(16, (byte) new Random().nextInt(4) + 1);
|
setValue(16, (byte) (new Random().nextInt(4) + 1));
|
||||||
|
setValue(18, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
|
@ -3,8 +3,6 @@ package me.libraryaddict.disguise;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.MiscDisguise;
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.MobDisguise;
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.PlayerDisguise;
|
import me.libraryaddict.disguise.DisguiseTypes.PlayerDisguise;
|
||||||
import net.minecraft.server.v1_5_R3.WatchableObject;
|
import net.minecraft.server.v1_5_R3.WatchableObject;
|
||||||
|
|
||||||
@ -21,11 +19,13 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
|
|
||||||
public class LibsDisguises extends JavaPlugin {
|
public class LibsDisguises extends JavaPlugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getCommand("disguise").setExecutor(new DisguiseCommand());
|
getCommand("disguise").setExecutor(new DisguiseCommand());
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(
|
ProtocolLibrary.getProtocolManager().addPacketListener(
|
||||||
new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_ENTITY_SPAWN,
|
new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_ENTITY_SPAWN,
|
||||||
Packets.Server.ENTITY_METADATA) {
|
Packets.Server.ENTITY_METADATA) {
|
||||||
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
StructureModifier<Object> mods = event.getPacket().getModifier();
|
StructureModifier<Object> mods = event.getPacket().getModifier();
|
||||||
try {
|
try {
|
||||||
@ -36,22 +36,20 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
if (DisguiseAPI.isDisguised(watched.getName())) {
|
if (DisguiseAPI.isDisguised(watched.getName())) {
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(watched);
|
Disguise disguise = DisguiseAPI.getDisguise(watched);
|
||||||
if (event.getPacketID() == Packets.Server.NAMED_ENTITY_SPAWN) {
|
if (event.getPacketID() == Packets.Server.NAMED_ENTITY_SPAWN) {
|
||||||
if (disguise.getType().isMob()) {
|
if (disguise.getType().isPlayer()) {
|
||||||
event.setCancelled(true);
|
|
||||||
DisguiseAPI.disguiseToPlayer(watched, observer, (MobDisguise) disguise);
|
|
||||||
} else if (disguise.getType().isMisc()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
DisguiseAPI.disguiseToPlayer(watched, observer, (MiscDisguise) disguise);
|
|
||||||
} else if (disguise.getType().isPlayer()) {
|
|
||||||
String name = (String) mods.read(1);
|
String name = (String) mods.read(1);
|
||||||
if (!name.equals(((PlayerDisguise) disguise).getName())) {
|
if (!name.equals(((PlayerDisguise) disguise).getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
DisguiseAPI.disguiseToPlayer(watched, observer, (PlayerDisguise) disguise);
|
DisguiseAPI.disguiseToPlayer(watched, observer, disguise);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
|
DisguiseAPI.disguiseToPlayer(watched, observer, disguise);
|
||||||
}
|
}
|
||||||
} else if (!disguise.getType().isPlayer()) {
|
} else if (!disguise.getType().isPlayer()) {
|
||||||
if (disguise.hasWatcher())
|
if (disguise.hasWatcher()) {
|
||||||
mods.write(1, disguise.getWatcher().convert((List<WatchableObject>) mods.read(1)));
|
mods.write(1, disguise.getWatcher().convert((List<WatchableObject>) mods.read(1)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user