Work towards backwards compatibility

This commit is contained in:
libraryaddict 2017-06-24 09:21:34 +12:00
parent 788bbf4b4e
commit 2d28988cc4
17 changed files with 310 additions and 241 deletions

@ -46,22 +46,18 @@ public class LibsEquipment implements EntityEquipment {
flagWatcher.sendItemStack(slot, item);
}
@Override
public ItemStack getItemInMainHand() {
return getItem(EquipmentSlot.HAND);
}
@Override
public void setItemInMainHand(ItemStack item) {
setItem(EquipmentSlot.HAND, item);
}
@Override
public ItemStack getItemInOffHand() {
return getItem(EquipmentSlot.OFF_HAND);
}
@Override
public void setItemInOffHand(ItemStack item) {
setItem(EquipmentSlot.OFF_HAND, item);
}

@ -106,10 +106,6 @@ public class MetaIndex<Y> {
public static MetaIndex<Boolean> ENTITY_SILENT = new MetaIndex<>(FlagWatcher.class, 4, false);
public static MetaIndex<Byte> ILLAGER_SPELL_TICKS = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
public static MetaIndex<Byte> ILLAGER_META = new MetaIndex<>(IllagerWatcher.class, 0, (byte) 0);
public static MetaIndex<BlockPosition> FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0,
BlockPosition.ORIGIN);
@ -138,6 +134,10 @@ public class MetaIndex<Y> {
public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1,
Optional.<UUID>absent());
public static MetaIndex<Byte> ILLAGER_META = new MetaIndex<>(IllagerWatcher.class, 0, (byte) 0);
public static MetaIndex<Byte> ILLAGER_SPELL_TICKS = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
public static MetaIndex<Byte> INSENTIENT_META = new MetaIndex<>(InsentientWatcher.class, 0, (byte) 0);
public static MetaIndex<Byte> IRON_GOLEM_PLAYER_CREATED = new MetaIndex<>(IronGolemWatcher.class, 0, (byte) 0);
@ -220,8 +220,7 @@ public class MetaIndex<Y> {
public static MetaIndex<Byte> SPIDER_CLIMB = new MetaIndex<>(SpiderWatcher.class, 0, (byte) 0);
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0,
new ItemStack(Material.SPLASH_POTION));
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM;
public static MetaIndex<Byte> TAMEABLE_META = new MetaIndex<>(TameableWatcher.class, 0, (byte) 0);
@ -267,6 +266,13 @@ public class MetaIndex<Y> {
public static MetaIndex<Boolean> ZOMBIE_VILLAGER_SHAKING = new MetaIndex<>(ZombieVillagerWatcher.class, 0, false);
static {
try {
SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0,
new ItemStack(Material.valueOf("SPLASH_POTION")));
}
catch (Exception ex) {
SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0, new ItemStack(Material.POTION));
}
setValues();
}
@ -343,8 +349,10 @@ public class MetaIndex<Y> {
continue;
if (found != null) {
System.err.println(
entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" + type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")");
System.err.println(entry.getKey()
.getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" + type
.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher()
.getSimpleName() + ")");
continue loop;
}
@ -369,8 +377,8 @@ public class MetaIndex<Y> {
MetaIndex index = (MetaIndex) field.get(null);
toPrint.add(
index.getFlagWatcher().getSimpleName() + " " + field.getName() + " " + index.getIndex() + " " + index.getDefault().getClass().getSimpleName());
toPrint.add(index.getFlagWatcher().getSimpleName() + " " + field.getName() + " " + index
.getIndex() + " " + index.getDefault().getClass().getSimpleName());
}
}
catch (Exception ex) {
@ -443,8 +451,10 @@ public class MetaIndex<Y> {
continue;
}
System.err.println(
"[LibsDisguises] MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() + " has already registered this! (" + metaIndex.getDefault() + "," + index.getDefault() + ")");
System.err.println("[LibsDisguises] MetaIndex " + metaIndex.getFlagWatcher()
.getSimpleName() + " at index " + metaIndex
.getIndex() + " has already registered this! (" + metaIndex.getDefault() + "," + index
.getDefault() + ")");
}
values()[i] = metaIndexes[a];

@ -5,51 +5,40 @@ import org.bukkit.inventory.MainHand;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
public class InsentientWatcher extends LivingWatcher
{
public InsentientWatcher(Disguise disguise)
{
public class InsentientWatcher extends LivingWatcher {
public InsentientWatcher(Disguise disguise) {
super(disguise);
}
public void setMainHand(MainHand mainHand)
{
public void setMainHand(MainHand mainHand) {
setInsentientFlag(2, mainHand == MainHand.RIGHT);
sendData(MetaIndex.INSENTIENT_META);
}
public MainHand getMainHand()
{
public MainHand getMainHand() {
return getInsentientFlag(2) ? MainHand.RIGHT : MainHand.LEFT;
}
public boolean isAI()
{
public boolean isAI() {
return getInsentientFlag(1);
}
public void setAI(boolean ai)
{
public void setAI(boolean ai) {
setInsentientFlag(1, ai);
sendData(MetaIndex.INSENTIENT_META);
}
private void setInsentientFlag(int i, boolean flag)
{
private void setInsentientFlag(int i, boolean flag) {
byte b0 = (byte) getData(MetaIndex.INSENTIENT_META);
if (flag)
{
if (flag) {
setData(MetaIndex.INSENTIENT_META, (byte) (b0 | 1 << i));
}
else
{
} else {
setData(MetaIndex.INSENTIENT_META, (byte) (b0 & (~1 << i)));
}
}
private boolean getInsentientFlag(int i)
{
private boolean getInsentientFlag(int i) {
return ((byte) getData(MetaIndex.INSENTIENT_META) & 1 << i) != 0;
}
}

@ -60,10 +60,9 @@ public class PlayerWatcher extends LivingWatcher {
public BlockFace getSleepingDirection() {
if (sleepingDirection == null) {
if (this.getDisguise().getEntity() != null && isSleeping()) {
this.sleepingDirection = BlockFace
.values()[Math.round(this.getDisguise().getEntity().getLocation().getYaw() / 90F) & 0x3];
}
else {
this.sleepingDirection = BlockFace.values()[Math
.round(this.getDisguise().getEntity().getLocation().getYaw() / 90F) & 0x3];
} else {
return BlockFace.EAST;
}
}
@ -189,8 +188,9 @@ public class PlayerWatcher extends LivingWatcher {
try {
if (isSleeping()) {
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
PacketContainer[] packets = DisguiseUtilities.getBedPackets(getDisguise().getEntity().getLocation(),
player.getLocation(), (PlayerDisguise) getDisguise());
PacketContainer[] packets = DisguiseUtilities
.getBedPackets(getDisguise().getEntity().getLocation(), player.getLocation(),
(PlayerDisguise) getDisguise());
if (getDisguise().getEntity() == player) {
for (PacketContainer packet : packets) {
@ -200,15 +200,13 @@ public class PlayerWatcher extends LivingWatcher {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
}
}
else {
} else {
for (PacketContainer packet : packets) {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
}
}
}
}
else {
} else {
PacketContainer packet = new PacketContainer(Server.ANIMATION);
StructureModifier<Integer> mods = packet.getIntegers();
@ -232,10 +230,8 @@ public class PlayerWatcher extends LivingWatcher {
if (flag) {
setData(MetaIndex.PLAYER_SKIN, (byte) (b0 | 1 << i));
}
else {
} else {
setData(MetaIndex.PLAYER_SKIN, (byte) (b0 & (~1 << i)));
}
}
}

@ -704,7 +704,7 @@ public class DisguiseParser {
value = ReflectionManager.parseGameProfile(valueString);
}
catch (Exception ex) {
throw parseToException(GameProfile.class, valueString, methodName);
throw parseToException(WrappedGameProfile.class, valueString, methodName);
}
} else if (float.class == param || double.class == param) {
// Parse to number
@ -733,7 +733,7 @@ public class DisguiseParser {
catch (Exception ex) {
throw parseToException(param, valueString, methodName);
}
} else if (param == Llama.Color.class) {
} else if (param.getName().equals("org.bukkit.entity.Llama$Color")) {
try {
value = Llama.Color.valueOf(valueString.toUpperCase());
}

@ -10,83 +10,71 @@ import org.bukkit.Sound;
* Only living disguises go in here!
*/
public enum DisguiseSound {
ARROW(null, null, null, null, "entity.arrow.hit", "entity.arrow.shoot"),
ARROW(null, null, null, null, Sound.ENTITY_ARROW_HIT, Sound.ENTITY_ARROW_SHOOT),
BAT("entity.bat.hurt", null, "entity.bat.death", "entity.bat.ambient", "entity.player.small_fall",
"entity.bat.loop", "entity.player.big_fall", "entity.bat.takeoff"),
BAT(Sound.ENTITY_BAT_HURT, null, Sound.ENTITY_BAT_DEATH, Sound.ENTITY_BAT_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL,
Sound.ENTITY_BAT_LOOP, Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_BAT_TAKEOFF),
BLAZE("entity.blaze.hurt", null, "entity.blaze.death", "entity.blaze.ambient", "entity.player.small_fall",
"entity.player.big_fall"),
BLAZE(Sound.ENTITY_BLAZE_HURT, null, Sound.ENTITY_BLAZE_DEATH, Sound.ENTITY_BLAZE_AMBIENT,
Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_PLAYER_BIG_FALL),
CAVE_SPIDER("entity.spider.ambient", "entity.spider.step", "entity.spider.death", "entity.spider.ambient"),
CAVE_SPIDER(Sound.ENTITY_SPIDER_AMBIENT, Sound.ENTITY_SPIDER_STEP, Sound.ENTITY_SPIDER_DEATH,
Sound.ENTITY_SPIDER_AMBIENT),
CHICKEN("entity.chicken.hurt", "entity.chicken.step", "entity.chicken.hurt", "entity.chicken.ambient",
"entity.player.small_fall", "entity.chicken.egg", "entity.player.big_fall"),
CHICKEN(Sound.ENTITY_CHICKEN_HURT, Sound.ENTITY_CHICKEN_STEP, Sound.ENTITY_CHICKEN_HURT,
Sound.ENTITY_CHICKEN_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_CHICKEN_EGG,
Sound.ENTITY_PLAYER_BIG_FALL),
COW("entity.cow.hurt", "entity.cow.step", "entity.cow.death", "entity.cow.ambient"),
COW(Sound.ENTITY_COW_HURT, Sound.ENTITY_COW_STEP, Sound.ENTITY_COW_DEATH, Sound.ENTITY_COW_AMBIENT),
CREEPER("entity.creeper.hurt", "block.grass.step", "entity.creeper.death", null, "entity.creeper.primed"),
CREEPER(Sound.ENTITY_CREEPER_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_CREEPER_DEATH, null,
Sound.ENTITY_CREEPER_PRIMED),
DONKEY("entity.donkey.hurt", "block.grass.step", "entity.donkey.death", "entity.donkey.ambient",
"entity.horse.gallop", "entity.horse.saddle", "entity.donkey.angry", "entity.horse.step_wood",
"entity.horse.armor", "entity.horse.land", "entity.horse.jump", "entity.horse.angry"),
DONKEY(Sound.ENTITY_DONKEY_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_DONKEY_DEATH, Sound.ENTITY_DONKEY_AMBIENT,
Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY,
Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP,
Sound.ENTITY_HORSE_ANGRY),
ELDER_GUARDIAN("entity.elder_guardian.hurt", null, "entity.elder_guardian.death", "entity.elder_guardian.ambient"),
ELDER_GUARDIAN(Sound.ENTITY_ELDER_GUARDIAN_HURT, null, Sound.ENTITY_ELDER_GUARDIAN_DEATH,
Sound.ENTITY_ELDER_GUARDIAN_AMBIENT),
ENDER_DRAGON("entity.enderdragon.hurt", null, "entity.enderdragon.death", "entity.enderdragon.ambient",
"entity.player.small_fall", "entity.enderdragon.flap", "entity.player.big_fall"),
ENDER_DRAGON(Sound.ENTITY_ENDERDRAGON_HURT, null, Sound.ENTITY_ENDERDRAGON_DEATH, Sound.ENTITY_ENDERDRAGON_AMBIENT,
Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_ENDERDRAGON_FLAP, Sound.ENTITY_PLAYER_BIG_FALL),
ENDERMAN("entity.endermen.hurt", "block.grass.step", "entity.endermen.death", "entity.endermen.ambient",
"entity.endermen.scream", "entity.endermen.teleport", "entity.endermen.stare"),
ENDERMAN(Sound.ENTITY_ENDERMEN_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_ENDERMEN_DEATH,
Sound.ENTITY_ENDERMEN_AMBIENT, Sound.ENTITY_ENDERMEN_SCREAM, Sound.ENTITY_ENDERMEN_TELEPORT,
Sound.ENTITY_ENDERMEN_STARE),
ENDERMITE("entity.silverfish.hurt", "entity.endermite.step", "entity.endermite.death", "entity.endermite.ambient"),
ENDERMITE(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_ENDERMITE_STEP, Sound.ENTITY_ENDERMITE_DEATH,
Sound.ENTITY_ENDERMITE_AMBIENT),
EVOKER("entity.evocation_illager.hurt", null, "entity.evocation_illager.death", "entity.evocation_illager.ambient",
"entity.evocation_illager.cast_spell", "entity.evocation_illager.prepare_attack",
"entity.evocation_illager.prepare_summon", "entity.evocation_illager.prepare_wololo"),
EVOKER(Sound.ENTITY_EVOCATION_ILLAGER_HURT, null, Sound.ENTITY_EVOCATION_ILLAGER_DEATH,
Sound.ENTITY_EVOCATION_ILLAGER_AMBIENT, Sound.ENTITY_EVOCATION_ILLAGER_CAST_SPELL,
Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_ATTACK, Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON,
Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_WOLOLO),
EVOKER_FANGS(null, null, null, null, "entity.evocation_fangs.attack"),
EVOKER_FANGS(null, null, null, null, Sound.ENTITY_EVOCATION_FANGS_ATTACK),
GHAST("entity.ghast.hurt", null, "entity.ghast.death", "entity.ghast.ambient", "entity.player.small_fall",
"entity.ghast.shoot", "entity.player.big_fall", "entity.ghast.scream", "entity.ghast.warn"),
GHAST(Sound.ENTITY_GHAST_HURT, null, Sound.ENTITY_GHAST_DEATH, Sound.ENTITY_GHAST_AMBIENT,
Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_GHAST_SHOOT, Sound.ENTITY_PLAYER_BIG_FALL,
Sound.ENTITY_GHAST_SCREAM, Sound.ENTITY_GHAST_WARN),
GIANT("entity.player.hurt", "block.grass.step", null, null),
GIANT(Sound.ENTITY_PLAYER_HURT, Sound.BLOCK_GRASS_STEP, null, null),
GUARDIAN("entity.guardian.hurt", null, "entity.guardian.death", "entity.elder_guardian.ambient"),
GUARDIAN(Sound.ENTITY_GUARDIAN_HURT, null, Sound.ENTITY_GUARDIAN_DEATH, Sound.ENTITY_ELDER_GUARDIAN_AMBIENT),
HORSE(Sound.ENTITY_HORSE_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_HORSE_DEATH, Sound.ENTITY_HORSE_AMBIENT,
Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY,
Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP,
Sound.ENTITY_HORSE_ANGRY),
HORSE("entity.horse.hurt", "block.grass.step", "entity.horse.death", "entity.horse.ambient", "entity.horse.gallop",
"entity.horse.saddle", "entity.donkey.angry", "entity.horse.step_wood", "entity.horse.armor",
"entity.horse.land", "entity.horse.jump", "entity.horse.angry"),
ILLUSIONER("entity.illusion_illager.hurt", null, "entity.illusion_illager.death", "entity.illusion_illager.ambient",
"entity.illusion_illager.cast_spell", "entity.illusion_illager" + ".prepare_blindness",
"entity.illusion_illager.cast_spell", "entity.illusion_illager.prepare_blindness",
"entity.illusion_illager.prepare_mirror", "entity.illusion_illager.mirror_move"),
IRON_GOLEM(Sound.ENTITY_IRONGOLEM_HURT, Sound.ENTITY_IRONGOLEM_STEP, Sound.ENTITY_IRONGOLEM_DEATH,
Sound.ENTITY_IRONGOLEM_ATTACK),
IRON_GOLEM("entity.irongolem.hurt", "entity.irongolem.step", "entity.irongolem.death", "entity.irongolem.attack"),
LLAMA(Sound.ENTITY_LLAMA_HURT, Sound.ENTITY_LLAMA_STEP, Sound.ENTITY_LLAMA_DEATH, Sound.ENTITY_LLAMA_AMBIENT,
Sound.ENTITY_LLAMA_ANGRY, Sound.ENTITY_LLAMA_CHEST, Sound.ENTITY_LLAMA_EAT, Sound.ENTITY_LLAMA_SWAG),
LLAMA("entity.llama.hurt", "entity.llama.step", "entity.llama.death", "entity.llama.ambient", "entity.llama.angry",
"entity.llama.chest", "entity.llama.eat", "entity.llama.swag"),
MAGMA_CUBE(Sound.ENTITY_MAGMACUBE_HURT, Sound.ENTITY_MAGMACUBE_JUMP, null, null),
MAGMA_CUBE("entity.magmacube.hurt", "entity.magmacube.jump", null, null),
MULE(Sound.ENTITY_MULE_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_MULE_DEATH, Sound.ENTITY_MULE_AMBIENT),
MULE("entity.mule.hurt", "block.grass.step", "entity.mule.death", "entity.mule.ambient"),
MUSHROOM_COW(Sound.ENTITY_COW_HURT, Sound.ENTITY_COW_STEP, Sound.ENTITY_COW_HURT, Sound.ENTITY_COW_AMBIENT),
MUSHROOM_COW("entity.cow.hurt", "entity.cow.step", "entity.cow.hurt", "entity.cow.ambient"),
OCELOT(Sound.ENTITY_CAT_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_CAT_HURT, Sound.ENTITY_CAT_AMBIENT,
Sound.ENTITY_CAT_PURR, Sound.ENTITY_CAT_PURREOW),
OCELOT("entity.cat.hurt", "block.grass.step", "entity.cat.hurt", "entity.cat.ambient", "entity.cat.purr",
"entity.cat.purreow"),
PARROT("entity.parrot.hurt", "entity.parrot.step", "entity.parrot.death", "entity.parrot.ambient",
"entity.parrot.eat", "entity.parrot.fly", "entity.parrot.imitate.blaze", "entity.parrot.imitate.creeper",
@ -101,81 +89,77 @@ public enum DisguiseSound {
"entity.parrot.imitate.wolf", "entity.parrot.imitate.zombie", "entity.parrot.imitate.zombie_pigman",
"entity.parrot.imitate.zombie_villager"),
PIG(Sound.ENTITY_PIG_HURT, Sound.ENTITY_PIG_STEP, Sound.ENTITY_PIG_DEATH, Sound.ENTITY_PIG_AMBIENT),
PIG("entity.pig.hurt", "entity.pig.step", "entity.pig.death", "entity.pig.ambient"),
PIG_ZOMBIE(Sound.ENTITY_ZOMBIE_PIG_HURT, null, Sound.ENTITY_ZOMBIE_PIG_DEATH, Sound.ENTITY_ZOMBIE_PIG_AMBIENT,
Sound.ENTITY_ZOMBIE_PIG_ANGRY),
PIG_ZOMBIE("entity.zombie_pig.hurt", null, "entity.zombie_pig.death", "entity.zombie_pig.ambient",
"entity.zombie_pig.angry"),
PLAYER(Sound.ENTITY_PLAYER_HURT,
new Sound[]{Sound.BLOCK_STONE_STEP, Sound.BLOCK_GRASS_STEP, Sound.BLOCK_ANVIL_STEP, Sound.BLOCK_CLOTH_STEP,
Sound.BLOCK_GLASS_STEP, Sound.BLOCK_GRAVEL_STEP, Sound.BLOCK_LADDER_STEP, Sound.BLOCK_METAL_STEP,
Sound.BLOCK_SAND_STEP, Sound.BLOCK_SLIME_STEP, Sound.BLOCK_SNOW_STEP, Sound.BLOCK_WOOD_STEP},
Sound.ENTITY_PLAYER_DEATH, null),
PLAYER("entity.player.hurt", "block.stone.step", "block.grass.step", "block.anvil.step", "block.cloth.step",
"block.glass.step", "block.gravel.step", "block.ladder.step", "block.metal.step", "block.sand.step",
"block.slime.step", "block.snow.step", "block.wood.step", "entity.player.death", null),
RABBIT(Sound.ENTITY_RABBIT_HURT, Sound.ENTITY_RABBIT_JUMP, Sound.ENTITY_RABBIT_DEATH, Sound.ENTITY_RABBIT_AMBIENT),
RABBIT("entity.rabbit.hurt", "entity.rabbit.jump", "entity.rabbit.death", "entity.rabbit.ambient"),
SHEEP(Sound.ENTITY_SHEEP_HURT, Sound.ENTITY_SHEEP_STEP, null, Sound.ENTITY_SHEEP_AMBIENT, Sound.ENTITY_SHEEP_SHEAR),
SHEEP("entity.sheep.hurt", "entity.sheep.step", null, "entity.sheep.ambient", "entity.sheep.shear"),
SHULKER(Sound.ENTITY_SHULKER_HURT, null, Sound.ENTITY_SHULKER_DEATH, Sound.ENTITY_SHULKER_AMBIENT,
Sound.ENTITY_SHULKER_OPEN, Sound.ENTITY_SHULKER_CLOSE, Sound.ENTITY_SHULKER_HURT_CLOSED,
Sound.ENTITY_SHULKER_TELEPORT),
SHULKER("entity.shulker.hurt", null, "entity.shulker.death", "entity.shulker.ambient", "entity.shulker.open",
"entity.shulker.close", "entity.shulker.hurt_closed", "entity.shulker.teleport"),
SILVERFISH(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_SILVERFISH_STEP, Sound.ENTITY_SILVERFISH_DEATH,
Sound.ENTITY_SILVERFISH_AMBIENT),
SILVERFISH("entity.silverfish.hurt", "entity.silverfish.step", "entity.silverfish.death",
"entity.silverfish.ambient"),
SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH,
Sound.ENTITY_SKELETON_AMBIENT),
SKELETON("entity.skeleton.hurt", "entity.skeleton.step", "entity.skeleton.death", "entity.skeleton.ambient"),
SKELETON_HORSE(Sound.ENTITY_SKELETON_HORSE_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_SKELETON_HORSE_DEATH,
Sound.ENTITY_SKELETON_HORSE_AMBIENT, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE,
Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND,
Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY),
SKELETON_HORSE("entity.skeleton_horse.hurt", "block.grass.step", "entity.skeleton_horse.death",
"entity.skeleton_horse.ambient", "entity.horse.gallop", "entity.horse.saddle", "entity.donkey.angry",
"entity.horse.step_wood", "entity.horse.armor", "entity.horse.land", "entity.horse.jump",
"entity.horse.angry"),
SLIME(Sound.ENTITY_SLIME_HURT, Sound.ENTITY_SLIME_JUMP, Sound.ENTITY_SLIME_DEATH, null),
SLIME("entity.slime.hurt", "entity.slime.jump", "entity.slime.death", null),
SNOWMAN(Sound.ENTITY_SNOWMAN_HURT, null, Sound.ENTITY_SNOWMAN_DEATH, Sound.ENTITY_SNOWMAN_AMBIENT,
Sound.ENTITY_SNOWMAN_SHOOT),
SNOWMAN("entity.snowman.hurt", null, "entity.snowman.death", "entity.snowman.ambient", "entity.snowman.shoot"),
SPIDER(Sound.ENTITY_SPIDER_AMBIENT, Sound.ENTITY_SPIDER_STEP, Sound.ENTITY_SPIDER_DEATH,
Sound.ENTITY_SPIDER_AMBIENT),
SPIDER("entity.spider.ambient", "entity.spider.step", "entity.spider.death", "entity.spider.ambient"),
SQUID(Sound.ENTITY_SQUID_HURT, null, Sound.ENTITY_SQUID_DEATH, Sound.ENTITY_SQUID_AMBIENT),
SQUID("entity.squid.hurt", null, "entity.squid.death", "entity.squid.ambient"),
UNDEAD_HORSE(Sound.ENTITY_ZOMBIE_HORSE_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_ZOMBIE_HORSE_DEATH,
Sound.ENTITY_ZOMBIE_HORSE_AMBIENT, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE,
Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND,
Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY),
UNDEAD_HORSE("entity.zombie_horse.hurt", "block.grass.step", "entity.zombie_horse.death",
"entity.zombie_horse.ambient", "entity.horse.gallop", "entity.horse.saddle", "entity.donkey.angry",
"entity.horse.step_wood", "entity.horse.armor", "entity.horse.land", "entity.horse.jump",
"entity.horse.angry"),
VEX(Sound.ENTITY_VEX_HURT, null, Sound.ENTITY_VEX_DEATH, Sound.ENTITY_VEX_AMBIENT, Sound.ENTITY_VEX_CHARGE),
VEX("entity.vex.hurt", null, "entity.vex.death", "entity.vex.ambient", "entity.vex.charge"),
VILLAGER(Sound.ENTITY_VILLAGER_HURT, null, Sound.ENTITY_VILLAGER_DEATH, Sound.ENTITY_VILLAGER_AMBIENT,
Sound.ENTITY_VILLAGER_TRADING, Sound.ENTITY_VILLAGER_NO, Sound.ENTITY_VILLAGER_YES),
VILLAGER("entity.villager.hurt", null, "entity.villager.death", "entity.villager.ambient",
"entity.villager.trading", "entity.villager.no", "entity.villager.yes"),
VINDICATOR(Sound.ENTITY_VINDICATION_ILLAGER_HURT, null, Sound.ENTITY_VINDICATION_ILLAGER_DEATH,
Sound.ENTITY_VINDICATION_ILLAGER_AMBIENT),
VINDICATOR("entity.vindication_illager.hurt", null, "entity.vindication_illager.death",
"entity.vindication_illager.ambient"),
WITCH(Sound.ENTITY_WITCH_HURT, null, Sound.ENTITY_WITCH_DEATH, Sound.ENTITY_WITCH_AMBIENT),
WITCH("entity.witch.hurt", null, "entity.witch.death", "entity.witch.ambient"),
WITHER(Sound.ENTITY_WITHER_HURT, null, Sound.ENTITY_WITHER_DEATH, Sound.ENTITY_WITHER_AMBIENT,
Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_WITHER_SPAWN, Sound.ENTITY_PLAYER_BIG_FALL,
Sound.ENTITY_WITHER_SHOOT),
WITHER("entity.wither.hurt", null, "entity.wither.death", "entity.wither.ambient", "entity.player.small_fall",
"entity.wither.spawn", "entity.player.big_fall", "entity.wither.shoot"),
WITHER_SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH,
Sound.ENTITY_SKELETON_AMBIENT),
WITHER_SKELETON("entity.skeleton.hurt", "entity.skeleton.step", "entity.skeleton.death", "entity.skeleton.ambient"),
WOLF(Sound.ENTITY_WOLF_HURT, Sound.ENTITY_WOLF_STEP, Sound.ENTITY_WOLF_DEATH, Sound.ENTITY_WOLF_AMBIENT,
Sound.ENTITY_WOLF_GROWL, Sound.ENTITY_WOLF_PANT, Sound.ENTITY_WOLF_HOWL, Sound.ENTITY_WOLF_SHAKE,
Sound.ENTITY_WOLF_WHINE),
WOLF("entity.wolf.hurt", "entity.wolf.step", "entity.wolf.death", "entity.wolf.ambient", "entity.wolf.growl",
"entity.wolf.pant", "entity.wolf.howl", "entity.wolf.shake", "entity.wolf.whine"),
ZOMBIE(Sound.ENTITY_ZOMBIE_HURT, Sound.ENTITY_ZOMBIE_STEP, Sound.ENTITY_ZOMBIE_DEATH, Sound.ENTITY_ZOMBIE_AMBIENT,
Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD,
Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR), ZOMBIE_VILLAGER(Sound.ENTITY_ZOMBIE_VILLAGER_HURT,
Sound.ENTITY_ZOMBIE_VILLAGER_STEP, Sound.ENTITY_ZOMBIE_VILLAGER_DEATH, Sound.ENTITY_ZOMBIE_VILLAGER_AMBIENT,
Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD,
Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR);
ZOMBIE("entity.zombie.hurt", "entity.zombie.step", "entity.zombie.death", "entity.zombie.ambient",
"entity.zombie.infect", "entity.zombie.break_door_wood", "entity.zombie.attack_door_wood",
"entity.zombie.attack_iron_door"),
ZOMBIE_VILLAGER("entity.zombie_villager.hurt", "entity.zombie_villager.step", "entity.zombie_villager.death",
"entity.zombie_villager.ambient", "entity.zombie.infect", "entity.zombie.break_door_wood",
"entity.zombie.attack_door_wood", "entity.zombie.attack_iron_door");
public enum SoundType {
CANCEL, DEATH, HURT, IDLE, STEP
CANCEL,
DEATH,
HURT,
IDLE,
STEP
}
public static DisguiseSound getType(String name) {
@ -308,8 +292,8 @@ public enum DisguiseSound {
}*/
for (SoundType type : SoundType.values()) {
if (!disguiseSounds.containsKey(
type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT)) {
if (!disguiseSounds
.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT)) {
continue;
}

@ -920,8 +920,8 @@ public class DisguiseUtilities {
try {
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && disguise.getEntity().getName()
.equalsIgnoreCase(player)) {
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && ((Player) disguise.getEntity())
.getName().equalsIgnoreCase(player)) {
removeSelfDisguise((Player) disguise.getEntity());
if (disguise.isSelfDisguiseVisible()) {
@ -1178,7 +1178,15 @@ public class DisguiseUtilities {
// Code to stop player pushing
Scoreboard scoreboard = player.getScoreboard();
Team team = originalTeam == null ? null : scoreboard.getTeam(originalTeam);
Team ldTeam = scoreboard.getEntryTeam(player.getName());
Team ldTeam = null;
for (Team t : scoreboard.getTeams()) {
if (!t.hasEntry(player.getName()))
continue;
ldTeam = t;
break;
}
if (ldTeam != null) {
if (!ldTeam.getName().equals("LD Pushing") && !ldTeam.getName().endsWith("_LDP")) {
@ -1276,10 +1284,18 @@ public class DisguiseUtilities {
if (pOption != DisguisePushing.IGNORE_SCOREBOARD) {
// Code to stop player pushing
Scoreboard scoreboard = player.getScoreboard();
Team prevTeam = scoreboard.getEntryTeam(player.getName());
Team prevTeam = null;
Team ldTeam = null;
String ldTeamName = "LD Pushing";
for (Team t : scoreboard.getTeams()) {
if (!t.hasEntry(player.getName()))
continue;
prevTeam = t;
break;
}
// If the player is in a team already
if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName()
.endsWith("_LDP"))) {

@ -1,7 +1,7 @@
package me.libraryaddict.disguise.utilities;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.mojang.authlib.GameProfile;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import me.libraryaddict.disguise.disguisetypes.*;
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
import org.apache.commons.lang.StringUtils;
@ -10,7 +10,6 @@ import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;
@ -143,19 +142,32 @@ public class ReflectionFlagWatchers {
new ParamInfo(AnimalColor.class, "Animal Color", "View all the colors you can use for an animal color");
new ParamInfo(Art.class, "Art", "View all the paintings you can use for a painting disguise");
new ParamInfo(Llama.Color.class, "Llama Color", "View all the colors you can use for a llama color");
try {
new ParamInfo("org.bukkit.entity.Llama.Color", "Llama Color",
"View all the colors you can use for a llama color");
}
catch (Exception ex) {
}
new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color");
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
new ParamInfo(Villager.Profession.class, "Villager Profession",
"View all the professions you can set on a villager");
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 6), "Direction (North, East, South, West, " +
"Up, Down)",
"View the four directions usable on player setSleeping disguise");
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 6),
"Direction (North, East, South, West, " + "Up, Down)",
"View the directions usable on player setSleeping and shulker direction");
new ParamInfo(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into");
new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species");
try {
new ParamInfo("org.bukkit.inventory.MainHand", "Main Hand", "Set the main hand for an entity");
new ParamInfo("org.bukkit.entity.Llama.Color", "Llama Color",
"View all the colors you can use for a llama color");
}
catch (Exception ex) {
}
try {
new ParamInfo("org.bukkit.entity.Parrot$Variant", "Parrot Variant",
"View the different colors a parrot can be");
@ -178,11 +190,11 @@ public class ReflectionFlagWatchers {
materials[i] = Material.values()[i].name();
}
new ParamInfo(ItemStack.class, "Item (id:damage), damage optional", "An ItemStack compromised of " +
"ID:Durability", materials);
new ParamInfo(ItemStack.class, "Item (id:damage), damage optional",
"An ItemStack compromised of " + "ID:Durability", materials);
new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..), damage optional", "Four ItemStacks separated by an ,",
materials) {
new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..), damage optional",
"Four ItemStacks separated by an ,", materials) {
@Override
public String[] getEnums(String tabComplete) {
String beginning = tabComplete
@ -214,7 +226,7 @@ public class ReflectionFlagWatchers {
new ParamInfo(int[].class, "number,number,number..", "Numbers separated by an ,");
new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers separated by a ,");
new ParamInfo(GameProfile.class, "GameProfile",
new ParamInfo(WrappedGameProfile.class, "GameProfile",
"Get the gameprofile here https://sessionserver.mojang.com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false");
Collections.sort(paramList, new Comparator<ParamInfo>() {

@ -5,15 +5,12 @@ import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
import com.google.common.base.Optional;
import com.google.gson.Gson;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.EquipmentSlot;
@ -41,8 +38,8 @@ public class ReflectionManager {
static {
for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
try {
if (method.getReturnType() == float.class && Modifier.isProtected(
method.getModifiers()) && method.getParameterTypes().length == 0) {
if (method.getReturnType() == float.class && Modifier.isProtected(method.getModifiers()) && method
.getParameterTypes().length == 0) {
Object entity = createEntityInstance("Cow");
method.setAccessible(true);
@ -85,9 +82,8 @@ public class ReflectionManager {
String id = (String) response.get("id");
if (!id.contains("-")) {
id = Pattern.compile(
"([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)").matcher(
id).replaceFirst("$1-$2-$3-$4-$5");
id = Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)")
.matcher(id).replaceFirst("$1-$2-$3-$4-$5");
}
WrappedGameProfile gameProfile = new WrappedGameProfile(UUID.fromString(id), (String) response.get("name"));
@ -117,28 +113,29 @@ public class ReflectionManager {
case "Player":
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getDeclaredConstructor(
getNmsClass("World")).newInstance(world);
Object playerinteractmanager = getNmsClass("PlayerInteractManager")
.getDeclaredConstructor(getNmsClass("World")).newInstance(world);
WrappedGameProfile gameProfile = getGameProfile(new UUID(0, 0), "Steve");
entityObject = entityClass.getDeclaredConstructor(getNmsClass("MinecraftServer"),
getNmsClass("WorldServer"), gameProfile.getHandleType(),
playerinteractmanager.getClass()).newInstance(minecraftServer, world,
gameProfile.getHandle(), playerinteractmanager);
entityObject = entityClass
.getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
gameProfile.getHandleType(), playerinteractmanager.getClass())
.newInstance(minecraftServer, world, gameProfile.getHandle(), playerinteractmanager);
break;
case "EnderPearl":
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"),
getNmsClass("EntityLiving")).newInstance(world, createEntityInstance("Cow"));
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
.newInstance(world, createEntityInstance("Cow"));
break;
case "Potion":
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE,
Double.TYPE, getNmsClass("ItemStack")).newInstance(world, 0d, 0d, 0d,
getNmsItem(new ItemStack(Material.SPLASH_POTION)));
entityObject = entityClass
.getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE, Double.TYPE,
getNmsClass("ItemStack"))
.newInstance(world, 0d, 0d, 0d, getNmsItem(new ItemStack(Material.SPLASH_POTION)));
break;
case "FishingHook":
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"),
getNmsClass("EntityHuman")).newInstance(world, createEntityInstance("Player"));
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityHuman"))
.newInstance(world, createEntityInstance("Player"));
break;
default:
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world);
@ -174,9 +171,10 @@ public class ReflectionManager {
public static Object createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
try {
return getNmsClass("MobEffect").getDeclaredConstructor(getNmsClass("MobEffectList"), Integer.TYPE,
Integer.TYPE, Boolean.TYPE, Boolean.TYPE).newInstance(getMobEffectList(id), duration, amplification,
ambient, particles);
return getNmsClass("MobEffect")
.getDeclaredConstructor(getNmsClass("MobEffectList"), Integer.TYPE, Integer.TYPE, Boolean.TYPE,
Boolean.TYPE)
.newInstance(getMobEffectList(id), duration, amplification, ambient, particles);
}
catch (Exception e) {
e.printStackTrace();
@ -331,8 +329,8 @@ public class ReflectionManager {
public static Object getBlockPosition(int x, int y, int z) {
try {
return getNmsClass("BlockPosition").getDeclaredConstructor(int.class, int.class, int.class).newInstance(x,
y, z);
return getNmsClass("BlockPosition").getDeclaredConstructor(int.class, int.class, int.class)
.newInstance(x, y, z);
}
catch (Exception ex) {
ex.printStackTrace();
@ -365,13 +363,14 @@ public class ReflectionManager {
public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) {
try {
Object playerListName = getNmsClass("ChatComponentText").getDeclaredConstructor(String.class).newInstance(
gameProfile.getName());
Object playerListName = getNmsClass("ChatComponentText").getDeclaredConstructor(String.class)
.newInstance(gameProfile.getName());
return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData").getDeclaredConstructor(
getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(), int.class,
getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent")).newInstance(playerInfoPacket,
gameProfile.getHandle(), 0, getNmsClass("EnumGamemode").getEnumConstants()[1], playerListName);
return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData")
.getDeclaredConstructor(getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(),
int.class, getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent"))
.newInstance(playerInfoPacket, gameProfile.getHandle(), 0,
getNmsClass("EnumGamemode").getEnumConstants()[1], playerListName);
}
catch (Exception ex) {
ex.printStackTrace();
@ -555,9 +554,9 @@ public class ReflectionManager {
if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
Object session = method.invoke(minecraftServer);
return WrappedGameProfile.fromHandle(
session.getClass().getDeclaredMethod("fillProfileProperties", gameProfile.getHandleType(),
boolean.class).invoke(session, gameProfile.getHandle(), true));
return WrappedGameProfile.fromHandle(session.getClass()
.getDeclaredMethod("fillProfileProperties", gameProfile.getHandleType(), boolean.class)
.invoke(session, gameProfile.getHandle(), true));
}
}
}
@ -592,8 +591,8 @@ public class ReflectionManager {
LibsProfileLookupCaller callback = new LibsProfileLookupCaller();
profileRepo.getClass().getDeclaredMethod("findProfilesByNames", String[].class, agent.getClass(),
Class.forName("com.mojang.authlib.ProfileLookupCallback")).invoke(profileRepo,
new String[]{playername}, agent, callback);
Class.forName("com.mojang.authlib.ProfileLookupCallback"))
.invoke(profileRepo, new String[]{playername}, agent, callback);
if (callback.getGameProfile() != null) {
return callback.getGameProfile();
@ -614,9 +613,9 @@ public class ReflectionManager {
try {
Location loc = entity.getLocation();
Object boundingBox = boundingBoxConstructor.newInstance(loc.getX() - newBox.getX(),
loc.getY() - newBox.getY(), loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(),
loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ());
Object boundingBox = boundingBoxConstructor
.newInstance(loc.getX() - newBox.getX(), loc.getY() - newBox.getY(), loc.getZ() - newBox.getZ(),
loc.getX() + newBox.getX(), loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ());
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
}
@ -799,9 +798,8 @@ public class ReflectionManager {
BlockPosition pos = (BlockPosition) val;
try {
return Optional.of(
getNmsConstructor("BlockPosition", int.class, int.class, int.class).newInstance(pos.getX(),
pos.getY(), pos.getZ()));
return Optional.of(getNmsConstructor("BlockPosition", int.class, int.class, int.class)
.newInstance(pos.getX(), pos.getY(), pos.getZ()));
}
catch (Exception ex) {
ex.printStackTrace();
@ -818,16 +816,16 @@ public class ReflectionManager {
Vector3F angle = (Vector3F) value;
try {
return getNmsConstructor("Vector3f", float.class, float.class, float.class).newInstance(angle.getX(),
angle.getY(), angle.getZ());
return getNmsConstructor("Vector3f", float.class, float.class, float.class)
.newInstance(angle.getX(), angle.getY(), angle.getZ());
}
catch (Exception ex) {
ex.printStackTrace();
}
} else if (value instanceof Direction) {
try {
return (Enum) getNmsMethod("EnumDirection", "fromType1", int.class).invoke(null,
((Direction) value).ordinal());
return (Enum) getNmsMethod("EnumDirection", "fromType1", int.class)
.invoke(null, ((Direction) value).ordinal());
}
catch (Exception ex) {
ex.printStackTrace();
@ -836,8 +834,8 @@ public class ReflectionManager {
BlockPosition pos = (BlockPosition) value;
try {
return getNmsConstructor("BlockPosition", int.class, int.class, int.class).newInstance(pos.getX(),
pos.getY(), pos.getZ());
return getNmsConstructor("BlockPosition", int.class, int.class, int.class)
.newInstance(pos.getX(), pos.getY(), pos.getZ());
}
catch (Exception ex) {
ex.printStackTrace();
@ -906,7 +904,7 @@ public class ReflectionManager {
return id + (data << 12);
}
public static Pair<Integer, Integer> getFromCombinedId(int combinedId) {
public static ImmutablePair<Integer, Integer> getFromCombinedId(int combinedId) {
int j = combinedId & 4095;
int k = combinedId >> 12 & 15;

@ -1,8 +1,8 @@
package me.libraryaddict.disguise.utilities;
import me.libraryaddict.disguise.DisguiseConfig;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;

@ -2,8 +2,10 @@ package me.libraryaddict.disguise.utilities.backwards;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.ReflectionManager;
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_10;
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_11;
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_9;
import org.bukkit.Bukkit;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -14,16 +16,27 @@ import java.util.ArrayList;
public class BackwardsSupport {
public static BackwardMethods getMethods() {
try {
String version = ReflectionManager.getBukkitVersion();
String version = Bukkit.getVersion();
version = version.substring(version.lastIndexOf(" ") + 1, version.length() - 1);
Class<? extends BackwardMethods> methods = BackwardMethods.class;
if (version.equals("v1_11_R1")) {
if (version.equals("1.9") || version.equals("1.9.1") || version.equals("1.9.2") || version
.equals("1.9.3") || version.equals("1.9.4")) {
methods = Version_1_9.class;
} else if (version.equals("1.10") || version.equals("1.10.1") || version.equals("1.10.2")) {
methods = Version_1_10.class;
} else if (version.equals("1.11") || version.equals("1.11.1") || version.equals("1.11.2")) {
methods = Version_1_11.class;
}
if (!LibsPremium.isPremium() && methods != BackwardMethods.class) {
if (methods != BackwardMethods.class) {
if (!LibsPremium.isPremium()) {
System.out.println("[LibsDisguises] You must purchase the plugin to use backwards compatibility!");
methods = BackwardMethods.class;
} else {
System.out.println("[LibsDisguises] Enabled backwards support for " + version);
}
}
return setupMetadata(methods);
@ -35,12 +48,9 @@ public class BackwardsSupport {
return null;
}
private static BackwardMethods setupMetadata(Class<? extends BackwardMethods> backwardsClass) {
try {
BackwardMethods backwards = backwardsClass.newInstance();
ArrayList<MetaIndex> newIndexes = new ArrayList<>();
for (Field field : backwards.getClass().getFields()) {
private static void getIndexes(Class backwardsClass, BackwardMethods backwards,
ArrayList<MetaIndex> newIndexes) throws IllegalAccessException {
for (Field field : backwardsClass.getFields()) {
if (field.getType() != MetaIndex.class)
continue;
@ -51,6 +61,19 @@ public class BackwardsSupport {
newIndexes.add((MetaIndex) field.get(backwards));
}
backwardsClass = backwardsClass.getSuperclass();
if (backwardsClass.getSimpleName().contains("Version_"))
getIndexes(backwardsClass, backwards, newIndexes);
}
private static BackwardMethods setupMetadata(Class<? extends BackwardMethods> backwardsClass) {
try {
BackwardMethods backwards = backwardsClass.newInstance();
ArrayList<MetaIndex> newIndexes = new ArrayList<>();
getIndexes(backwardsClass, backwards, newIndexes);
MetaIndex.setValues();
MetaIndex.addMetaIndexes(newIndexes.toArray(new MetaIndex[0]));

@ -1,7 +1,13 @@
package me.libraryaddict.disguise.utilities.backwards.metadata;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
/**
* Created by libraryaddict on 9/06/2017.
* <p>
* Supports 1.10.0 1.10.1 and 1.10.2
*/
public class Version_1_10 {
public class Version_1_10 extends Version_1_11 {
private MetaIndex ILLAGER_META;
private MetaIndex ILLAGER_SPELL_TICKS;
}

@ -0,0 +1,7 @@
package me.libraryaddict.disguise.utilities.backwards.metadata;
/**
* Created by libraryaddict on 24/06/2017.
*/
public class Version_1_7 {
}

@ -0,0 +1,7 @@
package me.libraryaddict.disguise.utilities.backwards.metadata;
/**
* Created by libraryaddict on 24/06/2017.
*/
public class Version_1_8 {
}

@ -0,0 +1,9 @@
package me.libraryaddict.disguise.utilities.backwards.metadata;
/**
* Created by libraryaddict on 24/06/2017.
* <p>
* Intended for 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4
*/
public class Version_1_9 extends Version_1_10 {
}

@ -0,0 +1,10 @@
package org.bukkit.inventory;
public enum EquipmentSlot {
HAND,
OFF_HAND,
FEET,
LEGS,
CHEST,
HEAD
}

@ -0,0 +1,6 @@
package org.bukkit.inventory;
public enum MainHand {
LEFT,
RIGHT
}