Read desc

Removed duplicate horse watchers
All applicable disguisetypes are now the same names as entity type.
Fixed bug where it sometimes didnt return disguisetype when fed
entitytype
Added zombie_villager disguisetype even tho its not that big a
disguise..
Changed the entitytype I store to the bukkit's version. Should work the
same.. Untested ofc.
Hopefully broke peoples plugins :)
This commit is contained in:
Andrew 2013-07-16 23:42:35 +12:00
parent 20a7ed15da
commit 2138c7bc4f
11 changed files with 118 additions and 145 deletions

View File

@ -12,6 +12,10 @@ import org.bukkit.entity.Player;
public class UndisguiseRadiusCommand implements CommandExecutor {
private int maxRadius = 30;
public UndisguiseRadiusCommand(int maxRadius) {
this.maxRadius = maxRadius;
}
private boolean isNumeric(String string) {
try {
Integer.parseInt(string);
@ -21,10 +25,6 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
}
}
public UndisguiseRadiusCommand(int maxRadius) {
this.maxRadius = maxRadius;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {

View File

@ -25,6 +25,7 @@ import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -112,28 +113,25 @@ public class Disguise {
StructureModifier<Object> mods = spawnPackets[0].getModifier();
mods.write(0, e.getEntityId());
mods.write(1, (byte) EntityTypes.a(entity));
String name = toReadable(disguiseType.name());
if (disguiseType == DisguiseType.WITHER_SKELETON) {
String name = toReadable(getType().name());
if (getType() == DisguiseType.WITHER_SKELETON) {
name = "Skeleton";
} else if (disguiseType == DisguiseType.PRIMED_TNT) {
} else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
name = "Zombie";
} else if (getType() == DisguiseType.PRIMED_TNT) {
name = "TNTPrimed";
} else if (disguiseType == DisguiseType.DONKEY) {
} else if (getType() == DisguiseType.DONKEY || getType() == DisguiseType.MULE
|| getType() == DisguiseType.UNDEAD_HORSE || getType() == DisguiseType.SKELETON_HORSE) {
name = "Horse";
} else if (disguiseType == DisguiseType.MULE) {
name = "Horse";
} else if (disguiseType == DisguiseType.ZOMBIE_HORSE) {
name = "Horse";
} else if (disguiseType == DisguiseType.SKELETON_HORSE) {
name = "Horse";
} else if (disguiseType == DisguiseType.MINECART_TNT) {
} else if (getType() == DisguiseType.MINECART_TNT) {
name = "MinecartTNT";
} else if (disguiseType == DisguiseType.SPLASH_POTION)
} else if (getType() == DisguiseType.SPLASH_POTION)
name = "Potion";
else if (disguiseType == DisguiseType.GIANT)
else if (getType() == DisguiseType.GIANT)
name = "GiantZombie";
else if (disguiseType == DisguiseType.DROPPED_ITEM)
else if (getType() == DisguiseType.DROPPED_ITEM)
name = "Item";
else if (disguiseType == DisguiseType.FIREBALL)
else if (getType() == DisguiseType.FIREBALL)
name = "LargeFireball";
try {
Class entityClass = Class.forName("net.minecraft.server.v1_6_R2.Entity" + name);
@ -249,9 +247,16 @@ public class Disguise {
try {
String name;
if (getType() == DisguiseType.MINECART_FURNACE || getType() == DisguiseType.MINECART_HOPPER
|| getType() == DisguiseType.MINECART_MOB_SPAWNER || getType() == DisguiseType.MINECART_RIDEABLE
|| getType() == DisguiseType.MINECART_TNT || getType() == DisguiseType.MINECART_CHEST) {
|| getType() == DisguiseType.MINECART_MOB_SPAWNER || getType() == DisguiseType.MINECART_TNT
|| getType() == DisguiseType.MINECART_CHEST) {
name = "Minecart";
} else if (getType() == DisguiseType.DONKEY || getType() == DisguiseType.MULE
|| getType() == DisguiseType.UNDEAD_HORSE || getType() == DisguiseType.SKELETON_HORSE) {
name = "Horse";
} else if (getType() == DisguiseType.WITHER_SKELETON) {
name = "Skeleton";
} else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
name = "Zombie";
} else {
name = toReadable(getType().name());
}
@ -271,6 +276,17 @@ public class Disguise {
else if (tempWatcher instanceof ZombieWatcher)
tempWatcher.setValue(12, (byte) 1);
}
if (getType() == DisguiseType.WITHER_SKELETON)
tempWatcher.setValue(13, (byte) 1);
else if (getType() == DisguiseType.ZOMBIE_VILLAGER)
tempWatcher.setValue(13, (byte) 1);
else
try {
Variant horseType = Variant.valueOf(getType().name());
tempWatcher.setValue(19, (byte) horseType.ordinal());
} catch (Exception ex) {
// Ok.. So it aint a horse
}
HashMap<Integer, Object> disguiseValues = Values.getMetaValues(getType());
HashMap<Integer, Object> entityValues = Values.getMetaValues(DisguiseType.getType(type));
// Start from 2 as they ALL share 0 and 1

View File

@ -1,131 +1,131 @@
package me.libraryaddict.disguise.DisguiseTypes;
import org.bukkit.entity.EntityType;
public enum DisguiseType {
ARROW(EntityType.MISC, 60),
ARROW(EntityType.ARROW, 60),
BAT(EntityType.MOB),
BAT(EntityType.BAT),
BLAZE(EntityType.MOB),
BLAZE(EntityType.BLAZE),
BOAT(EntityType.MISC, 1),
BOAT(EntityType.BOAT, 1),
CAVE_SPIDER(EntityType.MOB),
CAVE_SPIDER(EntityType.CAVE_SPIDER),
CHICKEN(EntityType.MOB),
CHICKEN(EntityType.CHICKEN),
COW(EntityType.MOB),
COW(EntityType.COW),
CREEPER(EntityType.MOB),
CREEPER(EntityType.CREEPER),
DONKEY(EntityType.MOB),
DONKEY(EntityType.HORSE),
DROPPED_ITEM(EntityType.MISC, 2, 1),
DROPPED_ITEM(EntityType.DROPPED_ITEM, 2, 1),
EGG(EntityType.MISC, 62),
EGG(EntityType.EGG, 62),
ENDER_CRYSTAL(EntityType.MISC, 51),
ENDER_CRYSTAL(EntityType.ENDER_CRYSTAL, 51),
ENDER_DRAGON(EntityType.MOB),
ENDER_DRAGON(EntityType.ENDER_DRAGON),
ENDER_PEARL(EntityType.MISC, 65),
ENDER_PEARL(EntityType.ENDER_PEARL, 65),
ENDER_SIGNAL(EntityType.MISC, 72),
ENDER_SIGNAL(EntityType.ENDER_SIGNAL, 72),
ENDERMAN(EntityType.MOB),
ENDERMAN(EntityType.ENDERMAN),
EXPERIENCE_ORB(EntityType.MISC),
EXPERIENCE_ORB(EntityType.EXPERIENCE_ORB),
FALLING_BLOCK(EntityType.MISC, 70, 1),
FALLING_BLOCK(EntityType.FALLING_BLOCK, 70, 1),
FIREBALL(EntityType.MISC, 63, 0),
FIREBALL(EntityType.FIREBALL, 63, 0),
FIREWORKS(EntityType.MISC, 76),
FIREWORK(EntityType.FIREWORK, 76),
FISHING_HOOK(EntityType.MISC, 90),
FISHING_HOOK(EntityType.FISHING_HOOK, 90),
GHAST(EntityType.MOB),
GHAST(EntityType.GHAST),
GIANT(EntityType.MOB),
GIANT(EntityType.GIANT),
HORSE(EntityType.MOB),
HORSE(EntityType.HORSE),
IRON_GOLEM(EntityType.MOB),
IRON_GOLEM(EntityType.IRON_GOLEM),
ITEM_FRAME(EntityType.MISC, 71),
ITEM_FRAME(EntityType.ITEM_FRAME, 71),
MAGMA_CUBE(EntityType.MOB),
MAGMA_CUBE(EntityType.MAGMA_CUBE),
MINECART_CHEST(EntityType.MISC, 10, 1),
MINECART(EntityType.MINECART, 10, 0),
MINECART_FURNACE(EntityType.MISC, 10, 2),
MINECART_CHEST(EntityType.MINECART_CHEST, 10, 1),
MINECART_HOPPER(EntityType.MISC, 10),
MINECART_FURNACE(EntityType.MINECART_FURNACE, 10, 2),
MINECART_MOB_SPAWNER(EntityType.MISC, 10, 4),
MINECART_HOPPER(EntityType.MINECART_HOPPER, 10),
MINECART_RIDEABLE(EntityType.MISC, 10, 0),
MINECART_MOB_SPAWNER(EntityType.MINECART_MOB_SPAWNER, 10, 4),
MINECART_TNT(EntityType.MISC, 10, 3),
MINECART_TNT(EntityType.MINECART_TNT, 10, 3),
MULE(EntityType.MOB),
MULE(EntityType.HORSE),
MUSHROOM_COW(EntityType.MOB),
MUSHROOM_COW(EntityType.MUSHROOM_COW),
OCELOT(EntityType.MOB),
OCELOT(EntityType.OCELOT),
PAINTING(EntityType.MISC),
PAINTING(EntityType.PAINTING),
PIG(EntityType.MOB),
PIG(EntityType.PIG),
PIG_ZOMBIE(EntityType.MOB),
PIG_ZOMBIE(EntityType.PIG_ZOMBIE),
PLAYER(EntityType.PLAYER),
PRIMED_TNT(EntityType.MISC, 50),
PRIMED_TNT(EntityType.PRIMED_TNT, 50),
SHEEP(EntityType.MOB),
SHEEP(EntityType.SHEEP),
SILVERFISH(EntityType.MOB),
SILVERFISH(EntityType.SILVERFISH),
SKELETON(EntityType.MOB),
SKELETON(EntityType.SKELETON),
SKELETON_HORSE(EntityType.MOB),
SKELETON_HORSE(EntityType.HORSE),
SLIME(EntityType.MOB),
SLIME(EntityType.SLIME),
SMALL_FIREBALL(EntityType.MISC, 64, 0),
SMALL_FIREBALL(EntityType.SMALL_FIREBALL, 64, 0),
SNOWBALL(EntityType.MISC, 61),
SNOWBALL(EntityType.SNOWBALL, 61),
SNOWMAN(EntityType.MOB),
SNOWMAN(EntityType.SNOWMAN),
SPIDER(EntityType.MOB),
SPIDER(EntityType.SPIDER),
SPLASH_POTION(EntityType.MISC, 73),
SPLASH_POTION(EntityType.SPLASH_POTION, 73),
SQUID(EntityType.MOB),
SQUID(EntityType.SQUID),
THROWN_EXP_BOTTLE(EntityType.MISC, 75),
THROWN_EXP_BOTTLE(EntityType.THROWN_EXP_BOTTLE, 75),
VILLAGER(EntityType.MOB),
UNDEAD_HORSE(EntityType.HORSE),
WITCH(EntityType.MOB),
VILLAGER(EntityType.VILLAGER),
WITHER(EntityType.MOB),
WITCH(EntityType.WITCH),
WITHER_SKELETON(EntityType.MOB),
WITHER(EntityType.WITHER),
WITHER_SKULL(EntityType.MISC, 66),
WITHER_SKELETON(EntityType.SKELETON),
WOLF(EntityType.MOB),
WITHER_SKULL(EntityType.WITHER_SKULL, 66),
ZOMBIE(EntityType.MOB),
WOLF(EntityType.WOLF),
ZOMBIE_HORSE(EntityType.MOB);
ZOMBIE(EntityType.ZOMBIE),
public static enum EntityType {
MISC, MOB, PLAYER;
}
ZOMBIE_VILLAGER(EntityType.ZOMBIE);
public static DisguiseType getType(org.bukkit.entity.EntityType entityType) {
return DisguiseType.valueOf(entityType.name());
@ -164,11 +164,11 @@ public enum DisguiseType {
}
public boolean isMisc() {
return entityType == EntityType.MISC;
return !entityType.isAlive();
}
public boolean isMob() {
return entityType == EntityType.MOB;
return entityType.isAlive();
}
public boolean isPlayer() {

View File

@ -19,14 +19,17 @@ public class Values {
}
public static Values getValues(DisguiseType type) {
if (type == DisguiseType.DONKEY || type == DisguiseType.MULE || type == DisguiseType.ZOMBIE_HORSE
if (type == DisguiseType.DONKEY || type == DisguiseType.MULE || type == DisguiseType.UNDEAD_HORSE
|| type == DisguiseType.SKELETON_HORSE)
type = DisguiseType.HORSE;
if (type == DisguiseType.MINECART_CHEST || type == DisguiseType.MINECART_FURNACE || type == DisguiseType.MINECART_HOPPER
|| type == DisguiseType.MINECART_TNT || type == DisguiseType.MINECART_MOB_SPAWNER)
type = DisguiseType.MINECART_RIDEABLE;
if (type == DisguiseType.WITHER_SKELETON)
else if (type == DisguiseType.MINECART_CHEST || type == DisguiseType.MINECART_FURNACE
|| type == DisguiseType.MINECART_HOPPER || type == DisguiseType.MINECART_TNT
|| type == DisguiseType.MINECART_MOB_SPAWNER)
type = DisguiseType.MINECART;
else if (type == DisguiseType.WITHER_SKELETON)
type = DisguiseType.SKELETON;
else if (type == DisguiseType.ZOMBIE_VILLAGER)
type = DisguiseType.ZOMBIE;
return values.get(type);
}

View File

@ -1,10 +0,0 @@
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
public class DonkeyWatcher extends HorseWatcher {
public DonkeyWatcher(int entityId) {
super(entityId);
setValue(19, (byte) 1);
}
}

View File

@ -9,9 +9,7 @@ public class HorseWatcher extends AgeableWatcher {
public HorseWatcher(int entityId) {
super(entityId);
setValue(16, 0);
setValue(20, new Random().nextInt(7));
setValue(22, 0);
}
public Color getColor() {

View File

@ -1,10 +0,0 @@
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
public class MuleWatcher extends HorseWatcher {
public MuleWatcher(int entityId) {
super(entityId);
setValue(19, (byte) 2);
}
}

View File

@ -1,10 +0,0 @@
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
public class SkeletonHorseWatcher extends HorseWatcher {
public SkeletonHorseWatcher(int entityId) {
super(entityId);
setValue(19, (byte) 4);
}
}

View File

@ -1,10 +0,0 @@
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
public class WitherSkeletonWatcher extends LivingWatcher {
public WitherSkeletonWatcher(int entityId) {
super(entityId);
setValue(13, (byte) 1);
}
}

View File

@ -1,10 +0,0 @@
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
public class ZombieHorseWatcher extends HorseWatcher {
public ZombieHorseWatcher(int entityId) {
super(entityId);
setValue(19, (byte) 3);
}
}

View File

@ -270,18 +270,24 @@ public class LibsDisguises extends JavaPlugin implements Listener {
String name = toReadable(disguiseType.name());
if (disguiseType == DisguiseType.WITHER_SKELETON) {
continue;
} else if (disguiseType == DisguiseType.ZOMBIE_VILLAGER) {
continue;
} else if (disguiseType == DisguiseType.PRIMED_TNT) {
name = "TNTPrimed";
} else if (disguiseType == DisguiseType.DONKEY) {
continue;
} else if (disguiseType == DisguiseType.MULE) {
continue;
} else if (disguiseType == DisguiseType.ZOMBIE_HORSE) {
} else if (disguiseType == DisguiseType.UNDEAD_HORSE) {
continue;
} else if (disguiseType == DisguiseType.SKELETON_HORSE) {
continue;
} else if (disguiseType == DisguiseType.MINECART_TNT) {
name = "MinecartTNT";
} else if (disguiseType == DisguiseType.MINECART) {
name = "MinecartRideable";
} else if (disguiseType == DisguiseType.FIREWORK) {
name = "Fireworks";
} else if (disguiseType == DisguiseType.SPLASH_POTION)
name = "Potion";
else if (disguiseType == DisguiseType.GIANT)