Updated to 1.13.1 and other changes
Updated error/debug output Changed quote splitter to use regex Updated default values for metadata to better replicate a normal entity Fixed typo, removed unused calls Fixed arrows gaining particles TippedArrows will now show a random color instead of aqua AreaEffectCloud will now show a random color AreaEffectCloud's color methods now uses color not int Added org.bukkit.Color to the disguise parameters available as RGB or name Added new method ParticlesColor to LivingWatcher Fixed LivingWatcher's potion effect particles
This commit is contained in:
parent
2b94217aae
commit
cc9dfe6bab
4
pom.xml
4
pom.xml
@ -43,12 +43,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -453,10 +453,6 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nmsEntityName != null) {
|
|
||||||
nmsClass = ReflectionManager.getNmsClass("Entity" + nmsEntityName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -506,6 +502,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity);
|
WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity);
|
||||||
ArrayList<MetaIndex> indexes = MetaIndex.getFlags(disguiseType.getWatcherClass());
|
ArrayList<MetaIndex> indexes = MetaIndex.getFlags(disguiseType.getWatcherClass());
|
||||||
|
boolean loggedName = false;
|
||||||
|
|
||||||
for (WrappedWatchableObject watch : watcher.getWatchableObjects()) {
|
for (WrappedWatchableObject watch : watcher.getWatchableObjects()) {
|
||||||
MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex());
|
MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex());
|
||||||
@ -522,14 +519,25 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
Object ourValue = ReflectionManager.convertInvalidMeta(flagType.getDefault());
|
Object ourValue = ReflectionManager.convertInvalidMeta(flagType.getDefault());
|
||||||
Object nmsValue = ReflectionManager.convertInvalidMeta(watch.getValue());
|
Object nmsValue = ReflectionManager.convertInvalidMeta(watch.getValue());
|
||||||
|
|
||||||
if (ourValue != nmsValue &&
|
if (ourValue.getClass() != nmsValue.getClass()) {
|
||||||
((ourValue == null || nmsValue == null) || ourValue.getClass() != nmsValue.getClass())) {
|
if (!loggedName) {
|
||||||
getLogger().severe("[MetaIndex mismatch for " + disguiseType + "! Index: " + watch.getIndex());
|
getLogger().severe(StringUtils.repeat("=", 20));
|
||||||
getLogger().severe("MetaIndex: " + flagType.getDefault() + " (" +
|
getLogger().severe("MetaIndex mismatch! Disguise " + disguiseType + ", Entity " +
|
||||||
flagType.getDefault().getClass() + ") (" + nmsEntity.getClass() + ") & " +
|
nmsEntityName);
|
||||||
watcherClass.getSimpleName());
|
loggedName = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogger().severe(StringUtils.repeat("-", 20));
|
||||||
|
getLogger().severe("Index: " + watch.getIndex() + " | " +
|
||||||
|
flagType.getFlagWatcher().getSimpleName() + " | " + MetaIndex.getName(flagType));
|
||||||
|
Object flagDefault = flagType.getDefault();
|
||||||
|
|
||||||
|
getLogger().severe("LibsDisguises: " + flagDefault + " (" + flagDefault.getClass() + ")");
|
||||||
|
getLogger().severe("LibsDisguises Converted: " + ourValue + " (" + ourValue.getClass() + ")");
|
||||||
getLogger().severe("Minecraft: " + watch.getRawValue() + " (" + watch.getRawValue().getClass() +
|
getLogger().severe("Minecraft: " + watch.getRawValue() + " (" + watch.getRawValue().getClass() +
|
||||||
")");
|
")");
|
||||||
|
getLogger().severe("Minecraft Converted: " + nmsValue + " (" + nmsValue.getClass() + ")");
|
||||||
|
getLogger().severe(StringUtils.repeat("-", 20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Particle> AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class, 3,
|
public static MetaIndex<Particle> AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class, 3,
|
||||||
Particle.SPELL_MOB);
|
Particle.SPELL_MOB);
|
||||||
|
|
||||||
public static MetaIndex<Float> AREA_EFFECT_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 0, 0F);
|
public static MetaIndex<Float> AREA_EFFECT_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 0, 3F);
|
||||||
|
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2,
|
public static MetaIndex<Vector3F> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2,
|
||||||
new Vector3F(0, 0, 0));
|
new Vector3F(0, 0, 0));
|
||||||
@ -42,28 +42,30 @@ public class MetaIndex<Y> {
|
|||||||
new Vector3F(0, 0, 0));
|
new Vector3F(0, 0, 0));
|
||||||
|
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 3,
|
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 3,
|
||||||
new Vector3F(0, 0, 0));
|
new Vector3F(-10, 0, -10));
|
||||||
|
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 5,
|
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 5,
|
||||||
new Vector3F(0, 0, 0));
|
new Vector3F(-1, 0, -1));
|
||||||
|
|
||||||
public static MetaIndex<Byte> ARMORSTAND_META = new MetaIndex<>(ArmorStandWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> ARMORSTAND_META = new MetaIndex<>(ArmorStandWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 4,
|
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 4,
|
||||||
new Vector3F(0, 0, 0));
|
new Vector3F(-15, 0, 10));
|
||||||
|
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 6,
|
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 6,
|
||||||
new Vector3F(0, 0, 0));
|
new Vector3F(1, 0, 1));
|
||||||
|
|
||||||
public static MetaIndex<Byte> ARROW_CRITICAL = new MetaIndex<>(ArrowWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> ARROW_CRITICAL = new MetaIndex<>(ArrowWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
|
public static MetaIndex<Optional<UUID>> ARROW_UUID = new MetaIndex<>(ArrowWatcher.class, 1, Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Byte> BAT_HANGING = new MetaIndex<>(BatWatcher.class, 0, (byte) 1);
|
public static MetaIndex<Byte> BAT_HANGING = new MetaIndex<>(BatWatcher.class, 0, (byte) 1);
|
||||||
|
|
||||||
public static MetaIndex<Byte> BLAZE_BLAZING = new MetaIndex<>(BlazeWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> BLAZE_BLAZING = new MetaIndex<>(BlazeWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Float> BOAT_DAMAGE = new MetaIndex<>(BoatWatcher.class, 2, 40F);
|
public static MetaIndex<Float> BOAT_DAMAGE = new MetaIndex<>(BoatWatcher.class, 2, 0F);
|
||||||
|
|
||||||
public static MetaIndex<Integer> BOAT_DIRECTION = new MetaIndex<>(BoatWatcher.class, 1, 0);
|
public static MetaIndex<Integer> BOAT_DIRECTION = new MetaIndex<>(BoatWatcher.class, 1, 1);
|
||||||
|
|
||||||
public static MetaIndex<Integer> BOAT_LAST_HIT = new MetaIndex<>(BoatWatcher.class, 0, 0);
|
public static MetaIndex<Integer> BOAT_LAST_HIT = new MetaIndex<>(BoatWatcher.class, 0, 0);
|
||||||
|
|
||||||
@ -89,21 +91,21 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> DOLPHIN_BREATH = new MetaIndex<>(DolphinWatcher.class, 2, 2400);
|
public static MetaIndex<Integer> DOLPHIN_BREATH = new MetaIndex<>(DolphinWatcher.class, 2, 2400);
|
||||||
|
|
||||||
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0,
|
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0,
|
||||||
new ItemStack(Material.STONE));
|
new ItemStack(Material.AIR));
|
||||||
|
|
||||||
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0,
|
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0,
|
||||||
Optional.empty());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Boolean> ENDER_CRYSTAL_PLATE = new MetaIndex<>(EnderCrystalWatcher.class, 1, false);
|
public static MetaIndex<Boolean> ENDER_CRYSTAL_PLATE = new MetaIndex<>(EnderCrystalWatcher.class, 1, true);
|
||||||
|
|
||||||
public static MetaIndex<Integer> ENDERD_RAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 0);
|
public static MetaIndex<Integer> ENDER_DRAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 10);
|
||||||
|
|
||||||
public static MetaIndex<Boolean> ENDERMAN_AGRESSIVE = new MetaIndex<>(EndermanWatcher.class, 1, false);
|
public static MetaIndex<Boolean> ENDERMAN_AGRESSIVE = new MetaIndex<>(EndermanWatcher.class, 1, false);
|
||||||
|
|
||||||
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0,
|
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0,
|
||||||
Optional.empty());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 0);
|
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 300);
|
||||||
|
|
||||||
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2,
|
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2,
|
||||||
Optional.empty());
|
Optional.empty());
|
||||||
@ -120,7 +122,7 @@ public class MetaIndex<Y> {
|
|||||||
BlockPosition.ORIGIN);
|
BlockPosition.ORIGIN);
|
||||||
|
|
||||||
public static MetaIndex<ItemStack> FIREWORK_ITEM = new MetaIndex<>(FireworkWatcher.class, 0,
|
public static MetaIndex<ItemStack> FIREWORK_ITEM = new MetaIndex<>(FireworkWatcher.class, 0,
|
||||||
new ItemStack(Material.AIR));
|
new ItemStack(Material.FIREWORK_ROCKET));
|
||||||
|
|
||||||
public static MetaIndex<Boolean> FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false);
|
public static MetaIndex<Boolean> FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false);
|
||||||
|
|
||||||
@ -169,9 +171,9 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Integer> LIVING_POTIONS = new MetaIndex<>(LivingWatcher.class, 2, 0);
|
public static MetaIndex<Integer> LIVING_POTIONS = new MetaIndex<>(LivingWatcher.class, 2, 0);
|
||||||
|
|
||||||
public static MetaIndex<Integer> LLAMA_CARPET = new MetaIndex<>(LlamaWatcher.class, 1, 0);
|
public static MetaIndex<Integer> LLAMA_CARPET = new MetaIndex<>(LlamaWatcher.class, 1, -1);
|
||||||
|
|
||||||
public static MetaIndex<Integer> LLAMA_COLOR = new MetaIndex<>(LlamaWatcher.class, 2, -1);
|
public static MetaIndex<Integer> LLAMA_COLOR = new MetaIndex<>(LlamaWatcher.class, 2, 0);
|
||||||
|
|
||||||
public static MetaIndex<Integer> LLAMA_STRENGTH = new MetaIndex<>(LlamaWatcher.class, 0, 0);
|
public static MetaIndex<Integer> LLAMA_STRENGTH = new MetaIndex<>(LlamaWatcher.class, 0, 0);
|
||||||
|
|
||||||
@ -179,7 +181,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Boolean> MINECART_BLOCK_VISIBLE = new MetaIndex<>(MinecartWatcher.class, 5, false);
|
public static MetaIndex<Boolean> MINECART_BLOCK_VISIBLE = new MetaIndex<>(MinecartWatcher.class, 5, false);
|
||||||
|
|
||||||
public static MetaIndex<Integer> MINECART_BLOCK_Y = new MetaIndex<>(MinecartWatcher.class, 4, 0);
|
public static MetaIndex<Integer> MINECART_BLOCK_Y = new MetaIndex<>(MinecartWatcher.class, 4, 6);
|
||||||
|
|
||||||
public static MetaIndex<Integer> MINECART_SHAKING_DIRECTION = new MetaIndex<>(MinecartWatcher.class, 1, 1);
|
public static MetaIndex<Integer> MINECART_SHAKING_DIRECTION = new MetaIndex<>(MinecartWatcher.class, 1, 1);
|
||||||
|
|
||||||
@ -229,7 +231,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1,
|
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1,
|
||||||
Optional.empty());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 10);
|
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 16);
|
||||||
|
|
||||||
public static MetaIndex<Direction> SHULKER_FACING = new MetaIndex<>(ShulkerWatcher.class, 0, Direction.DOWN);
|
public static MetaIndex<Direction> SHULKER_FACING = new MetaIndex<>(ShulkerWatcher.class, 0, Direction.DOWN);
|
||||||
|
|
||||||
@ -237,21 +239,21 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(SkeletonWatcher.class, 0, false);
|
public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(SkeletonWatcher.class, 0, false);
|
||||||
|
|
||||||
public static MetaIndex<Integer> SLIME_SIZE = new MetaIndex<>(SlimeWatcher.class, 0, 0);
|
public static MetaIndex<Integer> SLIME_SIZE = new MetaIndex<>(SlimeWatcher.class, 0, 1);
|
||||||
|
|
||||||
public static MetaIndex<Byte> SNOWMAN_DERP = new MetaIndex<>(SnowmanWatcher.class, 0, (byte) 16);
|
public static MetaIndex<Byte> SNOWMAN_DERP = new MetaIndex<>(SnowmanWatcher.class, 0, (byte) 16);
|
||||||
|
|
||||||
public static MetaIndex<Byte> SPIDER_CLIMB = new MetaIndex<>(SpiderWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> SPIDER_CLIMB = new MetaIndex<>(SpiderWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM;
|
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0,
|
||||||
|
new ItemStack(Material.SPLASH_POTION));
|
||||||
|
|
||||||
public static MetaIndex<Byte> TAMEABLE_META = new MetaIndex<>(TameableWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> TAMEABLE_META = new MetaIndex<>(TameableWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1,
|
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1,
|
||||||
Optional.empty());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(TippedArrowWatcher.class, 0,
|
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(TippedArrowWatcher.class, 0, -1);
|
||||||
Color.WHITE.asRGB());
|
|
||||||
|
|
||||||
public static MetaIndex<Integer> TNT_FUSE_TICKS = new MetaIndex<>(TNTWatcher.class, 0, Integer.MAX_VALUE);
|
public static MetaIndex<Integer> TNT_FUSE_TICKS = new MetaIndex<>(TNTWatcher.class, 0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
@ -293,7 +295,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Integer> WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, 14);
|
public static MetaIndex<Integer> WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, 14);
|
||||||
|
|
||||||
public static MetaIndex<Float> WOLF_DAMAGE = new MetaIndex<>(WolfWatcher.class, 0, 0F);
|
public static MetaIndex<Float> WOLF_DAMAGE = new MetaIndex<>(WolfWatcher.class, 0, 1F);
|
||||||
|
|
||||||
public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
||||||
|
|
||||||
@ -308,14 +310,6 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Boolean> ZOMBIE_VILLAGER_SHAKING = new MetaIndex<>(ZombieVillagerWatcher.class, 0, false);
|
public static MetaIndex<Boolean> ZOMBIE_VILLAGER_SHAKING = new MetaIndex<>(ZombieVillagerWatcher.class, 0, false);
|
||||||
|
|
||||||
static {
|
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();
|
setValues();
|
||||||
orderMetaIndexes();
|
orderMetaIndexes();
|
||||||
}
|
}
|
||||||
@ -432,7 +426,7 @@ public class MetaIndex<Y> {
|
|||||||
toPrint.sort(String.CASE_INSENSITIVE_ORDER);
|
toPrint.sort(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
for (String s : toPrint) {
|
for (String s : toPrint) {
|
||||||
DisguiseUtilities.getLogger().info(s);
|
DisguiseUtilities.getLogger().info(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,6 +480,24 @@ public class MetaIndex<Y> {
|
|||||||
return _values;
|
return _values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static String getName(MetaIndex metaIndex) {
|
||||||
|
try {
|
||||||
|
for (Field field : MetaIndex.class.getFields()) {
|
||||||
|
if (field.get(null) != metaIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return field.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void addMetaIndexes(MetaIndex... metaIndexes) {
|
public static void addMetaIndexes(MetaIndex... metaIndexes) {
|
||||||
_values = Arrays.copyOf(values(), values().length + metaIndexes.length);
|
_values = Arrays.copyOf(values(), values().length + metaIndexes.length);
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import org.apache.commons.lang.math.RandomUtils;
|
||||||
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,21 +15,13 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
public AreaEffectCloudWatcher(Disguise disguise) {
|
public AreaEffectCloudWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
setRadius(1);
|
setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRadius() {
|
public float getRadius() {
|
||||||
return getData(MetaIndex.AREA_EFFECT_RADIUS);
|
return getData(MetaIndex.AREA_EFFECT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor() {
|
|
||||||
return getData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIgnoreRadius() {
|
|
||||||
return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRadius(float radius) {
|
public void setRadius(float radius) {
|
||||||
if (radius > 30)
|
if (radius > 30)
|
||||||
radius = 30;
|
radius = 30;
|
||||||
@ -36,11 +30,20 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
sendData(MetaIndex.AREA_EFFECT_RADIUS);
|
sendData(MetaIndex.AREA_EFFECT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(int color) {
|
public Color getColor() {
|
||||||
setData(MetaIndex.AREA_EFFECT_CLOUD_COLOR, color);
|
int color = getData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
||||||
|
return Color.fromRGB(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
setData(MetaIndex.AREA_EFFECT_CLOUD_COLOR, color.asRGB());
|
||||||
sendData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
sendData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIgnoreRadius() {
|
||||||
|
return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
||||||
|
}
|
||||||
|
|
||||||
public void setIgnoreRadius(boolean ignore) {
|
public void setIgnoreRadius(boolean ignore) {
|
||||||
setData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS, ignore);
|
setData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS, ignore);
|
||||||
sendData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
sendData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
||||||
|
@ -10,7 +10,7 @@ public class ArrowWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCritical() {
|
public boolean isCritical() {
|
||||||
return (byte) getData(MetaIndex.ARROW_CRITICAL) == 1;
|
return getData(MetaIndex.ARROW_CRITICAL) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCritical(boolean critical) {
|
public void setCritical(boolean critical) {
|
||||||
|
@ -16,12 +16,12 @@ public class EnderDragonWatcher extends InsentientWatcher
|
|||||||
|
|
||||||
public int getPhase()
|
public int getPhase()
|
||||||
{
|
{
|
||||||
return getData(MetaIndex.ENDERD_RAGON_PHASE);
|
return getData(MetaIndex.ENDER_DRAGON_PHASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhase(int phase)
|
public void setPhase(int phase)
|
||||||
{
|
{
|
||||||
setData(MetaIndex.ENDERD_RAGON_PHASE, phase);
|
setData(MetaIndex.ENDER_DRAGON_PHASE, phase);
|
||||||
sendData(MetaIndex.ENDERD_RAGON_PHASE);
|
sendData(MetaIndex.ENDER_DRAGON_PHASE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,38 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LivingWatcher extends FlagWatcher {
|
public class LivingWatcher extends FlagWatcher {
|
||||||
static Map<Integer, Object> list = new HashMap<>();
|
|
||||||
static Method getId;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
getId = ReflectionManager
|
|
||||||
.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
|
|
||||||
Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null);
|
|
||||||
|
|
||||||
for (Object next : ((Iterable) REGISTRY)) {
|
|
||||||
int id = (int) getId.invoke(null, next);
|
|
||||||
list.put(id, next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double maxHealth;
|
private double maxHealth;
|
||||||
private boolean maxHealthSet;
|
private boolean maxHealthSet;
|
||||||
private HashSet<Integer> potionEffects = new HashSet<>();
|
private HashSet<String> potionEffects = new HashSet<>();
|
||||||
|
|
||||||
public LivingWatcher(Disguise disguise) {
|
public LivingWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPotionEffect(PotionEffectType potionEffect) {
|
|
||||||
if (!hasPotionEffect(potionEffect)) {
|
|
||||||
removePotionEffect(potionEffect);
|
|
||||||
potionEffects.add(potionEffect.getId());
|
|
||||||
|
|
||||||
sendPotionEffects();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LivingWatcher clone(Disguise disguise) {
|
public LivingWatcher clone(Disguise disguise) {
|
||||||
LivingWatcher clone = (LivingWatcher) super.clone(disguise);
|
LivingWatcher clone = (LivingWatcher) super.clone(disguise);
|
||||||
clone.potionEffects = (HashSet<Integer>) potionEffects.clone();
|
clone.potionEffects = (HashSet<String>) potionEffects.clone();
|
||||||
clone.maxHealth = maxHealth;
|
clone.maxHealth = maxHealth;
|
||||||
clone.maxHealthSet = maxHealthSet;
|
clone.maxHealthSet = maxHealthSet;
|
||||||
|
|
||||||
@ -73,7 +40,7 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getHealth() {
|
public float getHealth() {
|
||||||
return (float) getData(MetaIndex.LIVING_HEALTH);
|
return getData(MetaIndex.LIVING_HEALTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxHealth() {
|
public double getMaxHealth() {
|
||||||
@ -81,53 +48,75 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPotionParticlesAmbient() {
|
public boolean isPotionParticlesAmbient() {
|
||||||
return (boolean) getData(MetaIndex.LIVING_POTION_AMBIENT);
|
return getData(MetaIndex.LIVING_POTION_AMBIENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getParticlesColor() {
|
||||||
|
int color = getData(MetaIndex.LIVING_POTIONS);
|
||||||
|
return Color.fromRGB(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticlesColor(Color color) {
|
||||||
|
potionEffects.clear();
|
||||||
|
|
||||||
|
setData(MetaIndex.LIVING_POTIONS, color.asRGB());
|
||||||
|
sendData(MetaIndex.LIVING_POTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPotions() {
|
private int getPotions() {
|
||||||
int m = 3694022;
|
|
||||||
|
|
||||||
if (potionEffects.isEmpty()) {
|
if (potionEffects.isEmpty()) {
|
||||||
return m;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float f1 = 0.0F;
|
ArrayList<Color> colors = new ArrayList<>();
|
||||||
float f2 = 0.0F;
|
|
||||||
float f3 = 0.0F;
|
for (String typeId : potionEffects) {
|
||||||
float f4 = 0.0F;
|
PotionEffectType type = PotionEffectType.getByName(typeId);
|
||||||
try {
|
|
||||||
for (int localMobEffect : potionEffects) {
|
if (type == null) {
|
||||||
int n = (Integer) getId.invoke(null, list.get(localMobEffect));
|
continue;
|
||||||
f1 += (n >> 16 & 0xFF) / 255.0F;
|
|
||||||
f2 += (n >> 8 & 0xFF) / 255.0F;
|
|
||||||
f3 += (n & 0xFF) / 255.0F;
|
|
||||||
f4 += 1.0F;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
Color color = type.getColor();
|
||||||
ex.printStackTrace();
|
|
||||||
|
if (color == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
colors.add(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
f1 = f1 / f4 * 255.0F;
|
if (colors.isEmpty()) {
|
||||||
f2 = f2 / f4 * 255.0F;
|
return 0;
|
||||||
f3 = f3 / f4 * 255.0F;
|
}
|
||||||
|
|
||||||
return (int) f1 << 16 | (int) f2 << 8 | (int) f3;
|
Color color = colors.remove(0);
|
||||||
|
|
||||||
|
return color.mixColors(colors.toArray(new Color[0])).asRGB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPotionEffect(PotionEffectType type) {
|
public boolean hasPotionEffect(PotionEffectType type) {
|
||||||
return potionEffects.contains(type.getId());
|
return potionEffects.contains(type.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMaxHealthSet() {
|
public boolean isMaxHealthSet() {
|
||||||
return maxHealthSet;
|
return maxHealthSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePotionEffect(PotionEffectType type) {
|
public void addPotionEffect(PotionEffectType potionEffect) {
|
||||||
if (potionEffects.contains(type.getId())) {
|
if (!hasPotionEffect(potionEffect)) {
|
||||||
potionEffects.remove(type.getId());
|
potionEffects.add(potionEffect.getName());
|
||||||
sendPotionEffects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendPotionEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePotionEffect(PotionEffectType potionEffect) {
|
||||||
|
if (hasPotionEffect(potionEffect)) {
|
||||||
|
potionEffects.remove(potionEffect.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
sendPotionEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPotionParticlesAmbient(boolean particles) {
|
public void setPotionParticlesAmbient(boolean particles) {
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import org.apache.commons.lang.math.RandomUtils;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class TippedArrowWatcher extends ArrowWatcher {
|
public class TippedArrowWatcher extends ArrowWatcher {
|
||||||
|
|
||||||
public TippedArrowWatcher(Disguise disguise) {
|
public TippedArrowWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
int r = DisguiseUtilities.random.nextInt(256);
|
if (getDisguise().getType() != DisguiseType.ARROW) {
|
||||||
int g = DisguiseUtilities.random.nextInt(256);
|
setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)));
|
||||||
int b = DisguiseUtilities.random.nextInt(256);
|
}
|
||||||
|
|
||||||
setColor(Color.fromRGB(r, g, b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
int color = (int) getData(MetaIndex.TIPPED_ARROW_COLOR);
|
int color = getData(MetaIndex.TIPPED_ARROW_COLOR);
|
||||||
return Color.fromRGB(color);
|
return Color.fromRGB(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,12 @@ import org.bukkit.util.EulerAngle;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class DisguiseParser {
|
public class DisguiseParser {
|
||||||
public static class DisguiseParseException extends Exception {
|
public static class DisguiseParseException extends Exception {
|
||||||
@ -435,41 +437,15 @@ public class DisguiseParser {
|
|||||||
* Splits a string while respecting quotes
|
* Splits a string while respecting quotes
|
||||||
*/
|
*/
|
||||||
public static String[] split(String string) {
|
public static String[] split(String string) {
|
||||||
String[] strings = ChatColor.translateAlternateColorCodes('&', string).split(" ");
|
Matcher matcher = Pattern.compile("\"(?:\"(?=\\S)|\\\\\"|[^\"])*(?:[^\\\\]\"(?=\\s|$))|\\S+").matcher(string);
|
||||||
|
|
||||||
ArrayList<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
for (String s : strings) {
|
while (matcher.find()) {
|
||||||
String a = s.replaceAll("\\\\", "");
|
list.add(matcher.group());
|
||||||
|
|
||||||
if (builder.length() != 0 || s.startsWith("\"")) {
|
|
||||||
if (builder.length() != 0)
|
|
||||||
builder.append(' ');
|
|
||||||
|
|
||||||
String append;
|
|
||||||
|
|
||||||
if (s.startsWith("\""))
|
|
||||||
builder.append(s.substring(1));
|
|
||||||
else if (a.endsWith("\"") && !a.endsWith("\\\""))
|
|
||||||
builder.append(s.substring(0, s.length() - 1));
|
|
||||||
else
|
|
||||||
builder.append(s);
|
|
||||||
|
|
||||||
if (a.endsWith("\"") && !a.endsWith("\\\"")) {
|
|
||||||
list.add(builder.toString());
|
|
||||||
builder = new StringBuilder();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
list.add(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builder.length() != 0) {
|
return list.toArray(new String[0]);
|
||||||
list.addAll(Arrays.asList(("\"" + builder.toString()).split(" ")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.toArray(new String[list.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -844,6 +820,29 @@ public class DisguiseParser {
|
|||||||
} else if (param == Ocelot.Type.class) {
|
} else if (param == Ocelot.Type.class) {
|
||||||
// Parse to ocelot type
|
// Parse to ocelot type
|
||||||
value = callValueOf(param, valueString, methodName);
|
value = callValueOf(param, valueString, methodName);
|
||||||
|
} else if (param == Color.class) {
|
||||||
|
Class cl = Class.forName("org.bukkit.Color");
|
||||||
|
|
||||||
|
try {
|
||||||
|
value = cl.getField(valueString.toUpperCase()).get(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
try {
|
||||||
|
String[] split = valueString.split(",");
|
||||||
|
|
||||||
|
if (split.length == 1) {
|
||||||
|
value = Color.fromRGB(Integer.parseInt(split[0]));
|
||||||
|
} else if (split.length == 3) {
|
||||||
|
value = Color.fromRGB(Integer.parseInt(split[0]), Integer.parseInt(split[1]),
|
||||||
|
Integer.parseInt(split[2]));
|
||||||
|
} else {
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex2) {
|
||||||
|
throw parseToException(param, valueString, methodName);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (param.getSimpleName().equals("TreeSpecies")) {
|
} else if (param.getSimpleName().equals("TreeSpecies")) {
|
||||||
// Parse to tree species
|
// Parse to tree species
|
||||||
value = callValueOf(param, valueString, methodName);
|
value = callValueOf(param, valueString, methodName);
|
||||||
@ -915,7 +914,9 @@ public class DisguiseParser {
|
|||||||
try {
|
try {
|
||||||
String[] split = valueString.split(",");
|
String[] split = valueString.split(",");
|
||||||
|
|
||||||
assert split.length == 3;
|
if (split.length != 3) {
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
value = new BlockPosition(Integer.parseInt(split[0]), Integer.parseInt(split[1]),
|
value = new BlockPosition(Integer.parseInt(split[0]), Integer.parseInt(split[1]),
|
||||||
Integer.parseInt(split[2]));
|
Integer.parseInt(split[2]));
|
||||||
|
@ -857,8 +857,7 @@ public class DisguiseUtilities {
|
|||||||
gson = gsonBuilder.create();
|
gson = gsonBuilder.create();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
Object world = ReflectionManager.getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
Object world = ((List) server.getClass().getField("worlds").get(server)).get(0);
|
|
||||||
Class chunkClass = ReflectionManager.getNmsClass("Chunk");
|
Class chunkClass = ReflectionManager.getNmsClass("Chunk");
|
||||||
Object bedChunk = null;
|
Object bedChunk = null;
|
||||||
|
|
||||||
@ -883,8 +882,10 @@ public class DisguiseUtilities {
|
|||||||
.newInstance(0, true);
|
.newInstance(0, true);
|
||||||
|
|
||||||
Class blockClass = ReflectionManager.getNmsClass("Block");
|
Class blockClass = ReflectionManager.getNmsClass("Block");
|
||||||
|
Object REGISTRY = ReflectionManager.getNmsField("IRegistry", "BLOCK").get(null);
|
||||||
|
Object minecraftKey = ReflectionManager.createMinecraftKey("white_bed");
|
||||||
|
|
||||||
Object block = blockClass.getMethod("getByName", String.class).invoke(null, "white_bed");
|
Object block = REGISTRY.getClass().getMethod("get", minecraftKey.getClass()).invoke(REGISTRY, minecraftKey);
|
||||||
Object blockData = ReflectionManager.getNmsMethod(blockClass, "getBlockData").invoke(block);
|
Object blockData = ReflectionManager.getNmsMethod(blockClass, "getBlockData").invoke(block);
|
||||||
Method method = null;
|
Method method = null;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -154,6 +155,25 @@ public class ReflectionFlagWatchers {
|
|||||||
new ParamInfo(TropicalFish.Pattern.class, "Pattern", "Patterns of a tropical fish");
|
new ParamInfo(TropicalFish.Pattern.class, "Pattern", "Patterns of a tropical fish");
|
||||||
new ParamInfo(DyeColor.class, "DyeColor", "Dye colors of many different colors");
|
new ParamInfo(DyeColor.class, "DyeColor", "Dye colors of many different colors");
|
||||||
|
|
||||||
|
try {
|
||||||
|
ArrayList<String> colors = new ArrayList<>();
|
||||||
|
Class cl = Class.forName("org.bukkit.Color");
|
||||||
|
|
||||||
|
for (Field field : cl.getFields()) {
|
||||||
|
if (field.getType() != cl) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
colors.add(field.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
new ParamInfo(Color.class, "Color", "Colors that can also be defined through RGB",
|
||||||
|
colors.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<String> potionEnums = new ArrayList<>();
|
ArrayList<String> potionEnums = new ArrayList<>();
|
||||||
|
|
||||||
for (PotionEffectType effectType : PotionEffectType.values()) {
|
for (PotionEffectType effectType : PotionEffectType.values()) {
|
||||||
|
@ -927,6 +927,16 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object createMinecraftKey(String name) {
|
||||||
|
try{
|
||||||
|
return getNmsClass("MinecraftKey").getConstructor(String.class).newInstance(name);
|
||||||
|
}catch(Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getEntityType(Object nmsEntity) {
|
public static int getEntityType(Object nmsEntity) {
|
||||||
try {
|
try {
|
||||||
Field entityTypesField = null;
|
Field entityTypesField = null;
|
||||||
@ -936,9 +946,9 @@ public class ReflectionManager {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Object entityType = method.invoke(nmsEntity);
|
Object entityType = method.invoke(nmsEntity);
|
||||||
Class typesClass = getNmsClass("EntityTypes");
|
Class typesClass = getNmsClass("IRegistry");
|
||||||
|
|
||||||
Object registry = typesClass.getField("REGISTRY").get(null);
|
Object registry = typesClass.getField("ENTITY_TYPE").get(null);
|
||||||
|
|
||||||
return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityType);
|
return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityType);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user