Commit the update, this is a WIP
This commit is contained in:
parent
fffea76e8d
commit
3fd732c049
2
pom.xml
2
pom.xml
@ -98,7 +98,7 @@
|
|||||||
<asm.version>9.0</asm.version>
|
<asm.version>9.0</asm.version>
|
||||||
<lombok.version>1.18.16</lombok.version>
|
<lombok.version>1.18.16</lombok.version>
|
||||||
<protocollib.version>master-SNAPSHOT</protocollib.version>
|
<protocollib.version>master-SNAPSHOT</protocollib.version>
|
||||||
<spigot.version>[1.16,1.16.5]</spigot.version>
|
<spigot.version>[1.17,]</spigot.version>
|
||||||
<junit.version>4.13.1</junit.version>
|
<junit.version>4.13.1</junit.version>
|
||||||
<paper-api.version>[1.16,]</paper-api.version>
|
<paper-api.version>[1.16,]</paper-api.version>
|
||||||
<bungeecord-chat.version>1.12-SNAPSHOT</bungeecord-chat.version>
|
<bungeecord-chat.version>1.12-SNAPSHOT</bungeecord-chat.version>
|
||||||
|
@ -105,7 +105,9 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
try {
|
try {
|
||||||
getUpdateChecker().doUpdate();
|
if (isNumberedBuild()) {
|
||||||
|
getUpdateChecker().doUpdate();
|
||||||
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
getLogger().severe("Failed to even do a forced update");
|
getLogger().severe("Failed to even do a forced update");
|
||||||
}
|
}
|
||||||
@ -256,7 +258,9 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
new MetricsInitalizer();
|
new MetricsInitalizer();
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
try {
|
try {
|
||||||
getUpdateChecker().doUpdate();
|
if (isNumberedBuild()) {
|
||||||
|
getUpdateChecker().doUpdate();
|
||||||
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
getLogger().severe("Failed to even do a forced update");
|
getLogger().severe("Failed to even do a forced update");
|
||||||
}
|
}
|
||||||
|
@ -738,13 +738,13 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getInternalArmorstandIds().length > 0) {
|
if (getInternalArmorstandIds().length > 0) {
|
||||||
PacketContainer packet = new PacketContainer(Server.ENTITY_DESTROY);
|
|
||||||
packet.getIntegerArrays().write(0, getInternalArmorstandIds());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Player player : getEntity().getWorld().getPlayers()) {
|
for (PacketContainer packet : DisguiseUtilities.getDestroyPackets(getInternalArmorstandIds())) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
for (Player player : getEntity().getWorld().getPlayers()) {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.omg.CORBA.UNKNOWN;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
ARROW(60, 0),
|
ARROW(60, 0),
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17) AXOLOTL,
|
||||||
|
|
||||||
BAT,
|
BAT,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_15) BEE,
|
@NmsAddedIn(NmsVersion.v1_15) BEE,
|
||||||
@ -83,6 +86,12 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
GIANT,
|
GIANT,
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17) GLOW_ITEM_FRAME,
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17) GLOW_SQUID,
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17) GOAT,
|
||||||
|
|
||||||
GUARDIAN,
|
GUARDIAN,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_16) HOGLIN,
|
@NmsAddedIn(NmsVersion.v1_16) HOGLIN,
|
||||||
@ -105,6 +114,8 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
MAGMA_CUBE,
|
MAGMA_CUBE,
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17) MARKER,
|
||||||
|
|
||||||
MINECART(10),
|
MINECART(10),
|
||||||
|
|
||||||
MINECART_CHEST(10, 1),
|
MINECART_CHEST(10, 1),
|
||||||
@ -285,8 +296,7 @@ public enum DisguiseType {
|
|||||||
} else {
|
} else {
|
||||||
setEntityType(EntityType.valueOf(name()));
|
setEntityType(EntityType.valueOf(name()));
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,13 +351,11 @@ public enum DisguiseType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMisc() {
|
public boolean isMisc() {
|
||||||
return this == DisguiseType.MODDED_MISC ||
|
return this == DisguiseType.MODDED_MISC || (!isCustom() && getEntityType() != null && !getEntityType().isAlive());
|
||||||
(!isCustom() && getEntityType() != null && !getEntityType().isAlive());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMob() {
|
public boolean isMob() {
|
||||||
return this == DisguiseType.MODDED_LIVING ||
|
return this == DisguiseType.MODDED_LIVING || (!isCustom() && getEntityType() != null && getEntityType().isAlive() && !isPlayer());
|
||||||
(!isCustom() && getEntityType() != null && getEntityType().isAlive() && !isPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayer() {
|
public boolean isPlayer() {
|
||||||
|
@ -33,32 +33,28 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* The color of the Area Effect Cloud as RGB integer
|
* The color of the Area Effect Cloud as RGB integer
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_CLOUD_COLOR =
|
public static MetaIndex<Integer> AREA_EFFECT_CLOUD_COLOR = new MetaIndex<>(AreaEffectCloudWatcher.class, 1, Color.BLACK.asRGB());
|
||||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 1, Color.BLACK.asRGB());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignore radius and show effect as single point, not area
|
* Ignore radius and show effect as single point, not area
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Boolean> AREA_EFFECT_IGNORE_RADIUS =
|
public static MetaIndex<Boolean> AREA_EFFECT_IGNORE_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 2, false);
|
||||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 2, false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of particle to display
|
* The type of particle to display
|
||||||
*/
|
*/
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<WrappedParticle> AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class, 3,
|
public static MetaIndex<WrappedParticle> AREA_EFFECT_PARTICLE =
|
||||||
NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_13)
|
@NmsRemovedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0);
|
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0);
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_13)
|
@NmsRemovedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_1_OLD =
|
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_1_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 4, 0);
|
||||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 4, 0);
|
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_13)
|
@NmsRemovedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2_OLD =
|
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 5, 0);
|
||||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 5, 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the area
|
* The size of the area
|
||||||
@ -68,26 +64,22 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* Armorstand body eular vector
|
* Armorstand body eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_BODY =
|
public static MetaIndex<Vector3F> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0));
|
||||||
new MetaIndex<>(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand head eular vector
|
* Armorstand head eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_HEAD =
|
public static MetaIndex<Vector3F> ARMORSTAND_HEAD = new MetaIndex<>(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0));
|
||||||
new MetaIndex<>(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand left arm eular vector
|
* Armorstand left arm eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_ARM =
|
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 3, new Vector3F(-10, 0, -10));
|
||||||
new MetaIndex<>(ArmorStandWatcher.class, 3, new Vector3F(-10, 0, -10));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand left leg eular vector
|
* Armorstand left leg eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_LEG =
|
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 5, new Vector3F(-1, 0, -1));
|
||||||
new MetaIndex<>(ArmorStandWatcher.class, 5, new Vector3F(-1, 0, -1));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand metadata
|
* Armorstand metadata
|
||||||
@ -97,14 +89,12 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* Armorstand right arm eular vector
|
* Armorstand right arm eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM =
|
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 4, new Vector3F(-15, 0, 10));
|
||||||
new MetaIndex<>(ArmorStandWatcher.class, 4, new Vector3F(-15, 0, 10));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand right leg eular vector
|
* Armorstand right leg eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_LEG =
|
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 6, new Vector3F(1, 0, 1));
|
||||||
new MetaIndex<>(ArmorStandWatcher.class, 6, new Vector3F(1, 0, 1));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the arrow is a critical strike
|
* If the arrow is a critical strike
|
||||||
@ -121,6 +111,15 @@ public class MetaIndex<Y> {
|
|||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Byte> ARROW_PIERCE_LEVEL = new MetaIndex<>(ArrowWatcher.class, 2, (byte) 0);
|
public static MetaIndex<Byte> ARROW_PIERCE_LEVEL = new MetaIndex<>(ArrowWatcher.class, 2, (byte) 0);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
|
public static MetaIndex<Integer> AXOLOTL_VARIENT = new MetaIndex<>(AxolotlWatcher.class, 0, 0);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
|
public static MetaIndex<Boolean> AXOLOTL_PLAYING_DEAD = new MetaIndex<>(AxolotlWatcher.class, 1, false);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
|
public static MetaIndex<Boolean> AXOLOTL_FROM_BUCKET = new MetaIndex<>(AxolotlWatcher.class, 2, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the bat is hanging, false/true state
|
* If the bat is hanging, false/true state
|
||||||
*/
|
*/
|
||||||
@ -188,8 +187,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* No visible effect
|
* No visible effect
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<BlockPosition> DOLPHIN_TREASURE_POS =
|
public static MetaIndex<BlockPosition> DOLPHIN_TREASURE_POS = new MetaIndex<>(DolphinWatcher.class, 0, BlockPosition.ORIGIN);
|
||||||
new MetaIndex<>(DolphinWatcher.class, 0, BlockPosition.ORIGIN);
|
|
||||||
/**
|
/**
|
||||||
* No visible effect
|
* No visible effect
|
||||||
*/
|
*/
|
||||||
@ -203,11 +201,9 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* The itemstack of the dropped item, must be set
|
* The itemstack of the dropped item, must be set
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<ItemStack> DROPPED_ITEM =
|
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
new MetaIndex<>(DroppedItemWatcher.class, 0, new ItemStack(Material.AIR));
|
|
||||||
|
|
||||||
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM =
|
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0, Optional.empty());
|
||||||
new MetaIndex<>(EnderCrystalWatcher.class, 0, Optional.empty());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the ender crystal has a plate
|
* If the ender crystal has a plate
|
||||||
@ -217,8 +213,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> ENDER_DRAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 10);
|
public static MetaIndex<Integer> ENDER_DRAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 10);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<ItemStack> ENDER_SIGNAL_ITEM =
|
public static MetaIndex<ItemStack> ENDER_SIGNAL_ITEM = new MetaIndex<>(EnderSignalWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
new MetaIndex<>(EnderSignalWatcher.class, 0, new ItemStack(Material.AIR));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the enderman is screaming
|
* If the enderman is screaming
|
||||||
@ -231,8 +226,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* What block the enderman is holding
|
* What block the enderman is holding
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM =
|
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0, Optional.empty());
|
||||||
new MetaIndex<>(EndermanWatcher.class, 0, Optional.empty());
|
|
||||||
|
|
||||||
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 300);
|
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 300);
|
||||||
|
|
||||||
@ -240,8 +234,7 @@ public class MetaIndex<Y> {
|
|||||||
* The custom name of the entity, empty if not set
|
* The custom name of the entity, empty if not set
|
||||||
*/
|
*/
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME =
|
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2, Optional.empty());
|
||||||
new MetaIndex<>(FlagWatcher.class, 2, Optional.empty());
|
|
||||||
/**
|
/**
|
||||||
* The custom name of the entity, empty if not set
|
* The custom name of the entity, empty if not set
|
||||||
*/
|
*/
|
||||||
@ -275,15 +268,16 @@ public class MetaIndex<Y> {
|
|||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<EntityPose> ENTITY_POSE = new MetaIndex<>(FlagWatcher.class, 6, EntityPose.STANDING);
|
public static MetaIndex<EntityPose> ENTITY_POSE = new MetaIndex<>(FlagWatcher.class, 6, EntityPose.STANDING);
|
||||||
|
|
||||||
public static MetaIndex<BlockPosition> FALLING_BLOCK_POSITION =
|
@NmsAddedIn(NmsVersion.v1_16)
|
||||||
new MetaIndex<>(FallingBlockWatcher.class, 0, BlockPosition.ORIGIN);
|
public static MetaIndex<Integer> ENTITY_TICKS_FROZEN = new MetaIndex<>(FlagWatcher.class, 7, 0);
|
||||||
|
|
||||||
|
public static MetaIndex<BlockPosition> FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0, BlockPosition.ORIGIN);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<ItemStack> FIREBALL_ITEM =
|
public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR));
|
|
||||||
|
|
||||||
public static MetaIndex<ItemStack> FIREWORK_ITEM = new MetaIndex<>(FireworkWatcher.class, 0,
|
public static MetaIndex<ItemStack> FIREWORK_ITEM =
|
||||||
new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR));
|
new MetaIndex<>(FireworkWatcher.class, 0, new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR));
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -291,8 +285,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> FIREWORK_ATTACHED_ENTITY_OLD = new MetaIndex<>(FireworkWatcher.class, 1, 0);
|
public static MetaIndex<Integer> FIREWORK_ATTACHED_ENTITY_OLD = new MetaIndex<>(FireworkWatcher.class, 1, 0);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<OptionalInt> FIREWORK_ATTACHED_ENTITY =
|
public static MetaIndex<OptionalInt> FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1, OptionalInt.empty());
|
||||||
new MetaIndex<>(FireworkWatcher.class, 1, OptionalInt.empty());
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Boolean> FIREWORK_SHOT_AT_ANGLE = new MetaIndex<>(FireworkWatcher.class, 2, false);
|
public static MetaIndex<Boolean> FIREWORK_SHOT_AT_ANGLE = new MetaIndex<>(FireworkWatcher.class, 2, false);
|
||||||
@ -322,6 +315,12 @@ public class MetaIndex<Y> {
|
|||||||
*/
|
*/
|
||||||
public static MetaIndex<Boolean> GHAST_AGRESSIVE = new MetaIndex<>(GhastWatcher.class, 0, false);
|
public static MetaIndex<Boolean> GHAST_AGRESSIVE = new MetaIndex<>(GhastWatcher.class, 0, false);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
|
public static MetaIndex<Integer> GLOW_SQUID_DARK_TICKS_REMAINING = new MetaIndex<>(GlowSquidWatcher.class, 0, 0);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
|
public static MetaIndex<Boolean> GOAT_SCREAMING = new MetaIndex<>(GoatWatcher.class, 0, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch between the guardian spikes enabled/disabled
|
* Switch between the guardian spikes enabled/disabled
|
||||||
*/
|
*/
|
||||||
@ -338,8 +337,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* If horse has chest, set for donkey
|
* If horse has chest, set for donkey
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Boolean> HORSE_CHESTED_CARRYING_CHEST =
|
public static MetaIndex<Boolean> HORSE_CHESTED_CARRYING_CHEST = new MetaIndex<>(ChestedHorseWatcher.class, 0, false);
|
||||||
new MetaIndex<>(ChestedHorseWatcher.class, 0, false);
|
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Integer> HORSE_ARMOR = new MetaIndex<>(HorseWatcher.class, 1, 0);
|
public static MetaIndex<Integer> HORSE_ARMOR = new MetaIndex<>(HorseWatcher.class, 1, 0);
|
||||||
@ -356,8 +354,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* Owner of the horse, no visual effect
|
* Owner of the horse, no visual effect
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Optional<UUID>> HORSE_OWNER =
|
public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1, Optional.empty());
|
||||||
new MetaIndex<>(AbstractHorseWatcher.class, 1, Optional.empty());
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Byte> ILLAGER_SPELL = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> ILLAGER_SPELL = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
|
||||||
@ -375,8 +372,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* The itemstack inside the itemframe
|
* The itemstack inside the itemframe
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<ItemStack> ITEMFRAME_ITEM =
|
public static MetaIndex<ItemStack> ITEMFRAME_ITEM = new MetaIndex<>(ItemFrameWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
new MetaIndex<>(ItemFrameWatcher.class, 0, new ItemStack(Material.AIR));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The itemstack rotation inside the itemframe
|
* The itemstack rotation inside the itemframe
|
||||||
@ -415,8 +411,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> LIVING_STINGS = new MetaIndex<>(LivingWatcher.class, 5, 0);
|
public static MetaIndex<Integer> LIVING_STINGS = new MetaIndex<>(LivingWatcher.class, 5, 0);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Optional<BlockPosition>> LIVING_BED_POSITION =
|
public static MetaIndex<Optional<BlockPosition>> LIVING_BED_POSITION = new MetaIndex<>(LivingWatcher.class, 6, Optional.empty());
|
||||||
new MetaIndex<>(LivingWatcher.class, 6, Optional.empty());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is no carpet, -1. Otherwise it's a color enum value
|
* If there is no carpet, -1. Otherwise it's a color enum value
|
||||||
@ -525,11 +520,9 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Byte> PLAYER_SKIN = new MetaIndex<>(PlayerWatcher.class, 2, (byte) 127);
|
public static MetaIndex<Byte> PLAYER_SKIN = new MetaIndex<>(PlayerWatcher.class, 2, (byte) 127);
|
||||||
|
|
||||||
public static MetaIndex<NbtBase> PLAYER_LEFT_SHOULDER_ENTITY =
|
public static MetaIndex<NbtBase> PLAYER_LEFT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 4, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||||
new MetaIndex<>(PlayerWatcher.class, 4, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
|
||||||
|
|
||||||
public static MetaIndex<NbtBase> PLAYER_RIGHT_SHOULDER_ENTITY =
|
public static MetaIndex<NbtBase> PLAYER_RIGHT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 5, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||||
new MetaIndex<>(PlayerWatcher.class, 5, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
|
||||||
|
|
||||||
public static MetaIndex<Boolean> POLAR_BEAR_STANDING = new MetaIndex<>(PolarBearWatcher.class, 0, false);
|
public static MetaIndex<Boolean> POLAR_BEAR_STANDING = new MetaIndex<>(PolarBearWatcher.class, 0, false);
|
||||||
|
|
||||||
@ -542,8 +535,8 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Byte> SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED =
|
@NmsRemovedIn(NmsVersion.v1_17)
|
||||||
new MetaIndex<>(ShulkerWatcher.class, 1, Optional.empty());
|
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1, Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 16);
|
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 16);
|
||||||
|
|
||||||
@ -552,7 +545,10 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Byte> SHULKER_PEEKING = new MetaIndex<>(ShulkerWatcher.class, 2, (byte) 0);
|
public static MetaIndex<Byte> SHULKER_PEEKING = new MetaIndex<>(ShulkerWatcher.class, 2, (byte) 0);
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(SkeletonWatcher.class, 0, false);
|
public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(AbstractSkeletonWatcher.class, 0, false);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
|
public static MetaIndex<Boolean> SKELETON_CONVERTING_STRAY = new MetaIndex<>(SkeletonWatcher.class, 0, false);
|
||||||
|
|
||||||
public static MetaIndex<Integer> SLIME_SIZE = new MetaIndex<>(SlimeWatcher.class, 0, 1);
|
public static MetaIndex<Integer> SLIME_SIZE = new MetaIndex<>(SlimeWatcher.class, 0, 1);
|
||||||
|
|
||||||
@ -569,17 +565,14 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
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));
|
||||||
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 =
|
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1, Optional.empty());
|
||||||
new MetaIndex<>(TameableWatcher.class, 1, Optional.empty());
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<ItemStack> THROWABLE_ITEM =
|
public static MetaIndex<ItemStack> THROWABLE_ITEM = new MetaIndex<>(ThrowableWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
new MetaIndex<>(ThrowableWatcher.class, 0, new ItemStack(Material.AIR));
|
|
||||||
|
|
||||||
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(TippedArrowWatcher.class, 0, -1);
|
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(TippedArrowWatcher.class, 0, -1);
|
||||||
|
|
||||||
@ -592,15 +585,13 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Integer> TROPICAL_FISH_VARIANT = new MetaIndex<>(TropicalFishWatcher.class, 0, 0);
|
public static MetaIndex<Integer> TROPICAL_FISH_VARIANT = new MetaIndex<>(TropicalFishWatcher.class, 0, 0);
|
||||||
|
|
||||||
public static MetaIndex<BlockPosition> TURTLE_HOME_POSITION =
|
public static MetaIndex<BlockPosition> TURTLE_HOME_POSITION = new MetaIndex<>(TurtleWatcher.class, 0, BlockPosition.ORIGIN);
|
||||||
new MetaIndex<>(TurtleWatcher.class, 0, BlockPosition.ORIGIN);
|
|
||||||
|
|
||||||
public static MetaIndex<Boolean> TURTLE_HAS_EGG = new MetaIndex<>(TurtleWatcher.class, 1, false);
|
public static MetaIndex<Boolean> TURTLE_HAS_EGG = new MetaIndex<>(TurtleWatcher.class, 1, false);
|
||||||
|
|
||||||
public static MetaIndex<Boolean> TURTLE_UNKNOWN_3 = new MetaIndex<>(TurtleWatcher.class, 2, false);
|
public static MetaIndex<Boolean> TURTLE_UNKNOWN_3 = new MetaIndex<>(TurtleWatcher.class, 2, false);
|
||||||
|
|
||||||
public static MetaIndex<BlockPosition> TURTLE_TRAVEL_POSITION =
|
public static MetaIndex<BlockPosition> TURTLE_TRAVEL_POSITION = new MetaIndex<>(TurtleWatcher.class, 3, BlockPosition.ORIGIN);
|
||||||
new MetaIndex<>(TurtleWatcher.class, 3, BlockPosition.ORIGIN);
|
|
||||||
|
|
||||||
public static MetaIndex<Boolean> TURTLE_UNKNOWN_1 = new MetaIndex<>(TurtleWatcher.class, 4, false);
|
public static MetaIndex<Boolean> TURTLE_UNKNOWN_1 = new MetaIndex<>(TurtleWatcher.class, 4, false);
|
||||||
|
|
||||||
@ -616,8 +607,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0,
|
public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0,
|
||||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) :
|
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||||
null);
|
|
||||||
|
|
||||||
public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
|
public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
|
||||||
|
|
||||||
@ -655,13 +645,11 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0);
|
public static MetaIndex<Integer> ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0);
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION_OLD =
|
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION_OLD = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
||||||
new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
|
public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
|
||||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) :
|
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||||
null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shown for villager conversion
|
* Shown for villager conversion
|
||||||
@ -711,8 +699,7 @@ public class MetaIndex<Y> {
|
|||||||
HashMap<Class, Integer> maxValues = new HashMap<>();
|
HashMap<Class, Integer> maxValues = new HashMap<>();
|
||||||
|
|
||||||
for (MetaIndex type : values()) {
|
for (MetaIndex type : values()) {
|
||||||
if (maxValues.containsKey(type.getFlagWatcher()) &&
|
if (maxValues.containsKey(type.getFlagWatcher()) && maxValues.get(type.getFlagWatcher()) > type.getIndex()) {
|
||||||
maxValues.get(type.getFlagWatcher()) > type.getIndex()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,10 +722,8 @@ public class MetaIndex<Y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() +
|
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" +
|
||||||
" has multiple FlagType's registered for the index " + i + " (" +
|
type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")");
|
||||||
type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() +
|
|
||||||
")");
|
|
||||||
continue loop;
|
continue loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,15 +734,14 @@ public class MetaIndex<Y> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i);
|
||||||
.severe(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(),
|
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(), getDefault().getClass().getSimpleName(),
|
||||||
getDefault().getClass().getSimpleName(), DisguiseUtilities.getGson().toJson(getDefault()));
|
DisguiseUtilities.getGson().toJson(getDefault()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -923,15 +907,12 @@ public class MetaIndex<Y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MetaIndex metaIndex : values()) {
|
for (MetaIndex metaIndex : values()) {
|
||||||
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() ||
|
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() || metaIndex.getIndex() != index.getIndex()) {
|
||||||
metaIndex.getIndex() != index.getIndex()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().severe("MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() +
|
||||||
.severe("MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " +
|
" has already registered this! (" + metaIndex.getDefault() + "," + index.getDefault() + ")");
|
||||||
metaIndex.getIndex() + " has already registered this! (" + metaIndex.getDefault() +
|
|
||||||
"," + index.getDefault() + ")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
values()[i] = metaIndexes[a];
|
values()[i] = metaIndexes[a];
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
public abstract class AbstractSkeletonWatcher extends InsentientWatcher {
|
||||||
|
public AbstractSkeletonWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
|
public boolean isSwingArms() {
|
||||||
|
return getData(MetaIndex.SKELETON_SWING_ARMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
|
public void setSwingArms(boolean swingingArms) {
|
||||||
|
setData(MetaIndex.SKELETON_SWING_ARMS, swingingArms);
|
||||||
|
sendData(MetaIndex.SKELETON_SWING_ARMS);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import org.bukkit.entity.Axolotl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 15/06/2021.
|
||||||
|
*/
|
||||||
|
public class AxolotlWatcher extends AgeableWatcher {
|
||||||
|
public AxolotlWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayingDead() {
|
||||||
|
return getData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayingDead(boolean playingDead) {
|
||||||
|
setData(MetaIndex.AXOLOTL_PLAYING_DEAD, playingDead);
|
||||||
|
sendData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Axolotl.Variant getVarient() {
|
||||||
|
return Axolotl.Variant.values()[getData(MetaIndex.AXOLOTL_VARIENT)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVarient(Axolotl.Variant varient) {
|
||||||
|
setData(MetaIndex.AXOLOTL_VARIENT, varient.ordinal());
|
||||||
|
sendData(MetaIndex.AXOLOTL_VARIENT);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 15/06/2021.
|
||||||
|
*/
|
||||||
|
public class GlowSquidWatcher extends SquidWatcher {
|
||||||
|
public GlowSquidWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDarkTicksRemaining() {
|
||||||
|
return getData(MetaIndex.GLOW_SQUID_DARK_TICKS_REMAINING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDarkTicksRemaining(int ticks) {
|
||||||
|
setData(MetaIndex.GLOW_SQUID_DARK_TICKS_REMAINING, ticks);
|
||||||
|
sendData(MetaIndex.GLOW_SQUID_DARK_TICKS_REMAINING);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 15/06/2021.
|
||||||
|
*/
|
||||||
|
public class GoatWatcher extends AgeableWatcher {
|
||||||
|
public GoatWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isScreaming() {
|
||||||
|
return getData(MetaIndex.GOAT_SCREAMING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScreaming(boolean screaming) {
|
||||||
|
setData(MetaIndex.GOAT_SCREAMING, screaming);
|
||||||
|
sendData(MetaIndex.GOAT_SCREAMING);
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +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.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* Created by libraryaddict on 15/06/2021.
|
||||||
*/
|
*/
|
||||||
public class SkeletonWatcher extends InsentientWatcher {
|
public class SkeletonWatcher extends AbstractSkeletonWatcher {
|
||||||
public SkeletonWatcher(Disguise disguise) {
|
public SkeletonWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
public boolean isConvertingStray() {
|
||||||
public boolean isSwingArms() {
|
return getData(MetaIndex.SKELETON_CONVERTING_STRAY);
|
||||||
return getData(MetaIndex.SKELETON_SWING_ARMS);
|
}
|
||||||
}
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
@Deprecated
|
public void setConvertingStray(boolean converting) {
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
setData(MetaIndex.SKELETON_CONVERTING_STRAY, converting);
|
||||||
public void setSwingArms(boolean swingingArms) {
|
sendData(MetaIndex.SKELETON_CONVERTING_STRAY);
|
||||||
setData(MetaIndex.SKELETON_SWING_ARMS, swingingArms);
|
}
|
||||||
sendData(MetaIndex.SKELETON_SWING_ARMS);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 15/06/2021.
|
||||||
|
*/
|
||||||
|
public class StrayWatcher extends AbstractSkeletonWatcher {
|
||||||
|
public StrayWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 15/06/2021.
|
||||||
|
*/
|
||||||
|
public class WitherSkeletonWatcher extends AbstractSkeletonWatcher {
|
||||||
|
public WitherSkeletonWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
}
|
@ -41,6 +41,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
|
import net.minecraft.server.level.EntityTrackerEntry;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.math.RandomUtils;
|
import org.apache.commons.lang.math.RandomUtils;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
@ -349,11 +350,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void removeInvisibleSlime(Player player) {
|
public static void removeInvisibleSlime(Player player) {
|
||||||
PacketContainer container = new PacketContainer(Server.ENTITY_DESTROY);
|
|
||||||
container.getIntegerArrays().write(0, new int[]{DisguiseAPI.getEntityAttachmentId()});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, container, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, getDestroyPacket(DisguiseAPI.getEntityAttachmentId()), false);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -990,9 +988,7 @@ public class DisguiseUtilities {
|
|||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||||
// ConcurrentModificationException
|
// ConcurrentModificationException
|
||||||
|
|
||||||
PacketContainer destroyPacket = new PacketContainer(Server.ENTITY_DESTROY);
|
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||||
|
|
||||||
destroyPacket.getIntegerArrays().write(0, new int[]{disguise.getEntity().getEntityId()});
|
|
||||||
|
|
||||||
for (Object p : trackedPlayers) {
|
for (Object p : trackedPlayers) {
|
||||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||||
@ -1057,6 +1053,10 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PacketContainer getDestroyPacket(int... ids) {
|
public static PacketContainer getDestroyPacket(int... ids) {
|
||||||
|
if (NmsVersion.v1_17.isSupported() && ids.length != 1) {
|
||||||
|
throw new IllegalStateException("Should use getDestroyPackets for ints of len " + ids.length);
|
||||||
|
}
|
||||||
|
|
||||||
PacketContainer destroyPacket = new PacketContainer(Server.ENTITY_DESTROY);
|
PacketContainer destroyPacket = new PacketContainer(Server.ENTITY_DESTROY);
|
||||||
|
|
||||||
destroyPacket.getIntegerArrays().write(0, ids);
|
destroyPacket.getIntegerArrays().write(0, ids);
|
||||||
@ -1064,6 +1064,22 @@ public class DisguiseUtilities {
|
|||||||
return destroyPacket;
|
return destroyPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PacketContainer[] getDestroyPackets(int... ids) {
|
||||||
|
if (!NmsVersion.v1_17.isSupported()) {
|
||||||
|
return new PacketContainer[]{getDestroyPacket(ids)};
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketContainer[] packets = new PacketContainer[ids.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < packets.length; i++) {
|
||||||
|
packets[i] = new PacketContainer(Server.ENTITY_DESTROY);
|
||||||
|
|
||||||
|
packets[i].getIntegers().write(0, ids[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return packets;
|
||||||
|
}
|
||||||
|
|
||||||
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
||||||
int entityId = entity.getEntityId();
|
int entityId = entity.getEntityId();
|
||||||
|
|
||||||
@ -1768,12 +1784,12 @@ public class DisguiseUtilities {
|
|||||||
ids[ids.length - 1] = DisguiseAPI.getSelfDisguiseId();
|
ids[ids.length - 1] = DisguiseAPI.getSelfDisguiseId();
|
||||||
|
|
||||||
// Send a packet to destroy the fake entity
|
// Send a packet to destroy the fake entity
|
||||||
PacketContainer packet = getDestroyPacket(ids);
|
for (PacketContainer packet : getDestroyPackets(ids)) {
|
||||||
|
try {
|
||||||
try {
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
} catch (Exception ex) {
|
||||||
} catch (Exception ex) {
|
ex.printStackTrace();
|
||||||
ex.printStackTrace();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// player.spigot().setCollidesWithEntities(true);
|
// player.spigot().setCollidesWithEntities(true);
|
||||||
@ -1806,10 +1822,10 @@ public class DisguiseUtilities {
|
|||||||
if (!runningPaper) {
|
if (!runningPaper) {
|
||||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
|
|
||||||
((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getNmsEntity(player));
|
((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getEntityTrackerInstance(player));
|
||||||
} else {
|
} else {
|
||||||
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry))
|
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry))
|
||||||
.remove(ReflectionManager.getNmsEntity(player));
|
.remove(ReflectionManager.getEntityTrackerInstance(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -2345,10 +2361,10 @@ public class DisguiseUtilities {
|
|||||||
// Add himself to his own entity tracker
|
// Add himself to his own entity tracker
|
||||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
|
|
||||||
((Set<Object>) trackedPlayersObj).add(ReflectionManager.getNmsEntity(player));
|
((Set<Object>) trackedPlayersObj).add(ReflectionManager.getEntityTrackerInstance(player));
|
||||||
} else {
|
} else {
|
||||||
Field field = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap");
|
Field field = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap");
|
||||||
Object nmsEntity = ReflectionManager.getNmsEntity(player);
|
Object nmsEntity = ReflectionManager.getEntityTrackerInstance(player);
|
||||||
Map<Object, Object> map = ((Map<Object, Object>) field.get(entityTrackerEntry));
|
Map<Object, Object> map = ((Map<Object, Object>) field.get(entityTrackerEntry));
|
||||||
map.put(nmsEntity, true);
|
map.put(nmsEntity, true);
|
||||||
}
|
}
|
||||||
@ -2365,7 +2381,8 @@ public class DisguiseUtilities {
|
|||||||
boolean isMoving = false;
|
boolean isMoving = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField(NmsVersion.v1_14.isSupported() ? "q" : "isMoving");
|
Field field = ReflectionManager.getNmsClass("EntityTrackerEntry")
|
||||||
|
.getDeclaredField(NmsVersion.v1_17.isSupported() ? "r" : NmsVersion.v1_14.isSupported() ? "q" : "isMoving");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
isMoving = field.getBoolean(entityTrackerEntry);
|
isMoving = field.getBoolean(entityTrackerEntry);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -2978,7 +2995,9 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (destroyIds.length > 0) {
|
if (destroyIds.length > 0) {
|
||||||
packets.add(getDestroyPacket(destroyIds));
|
for (PacketContainer packet : getDestroyPackets(destroyIds)) {
|
||||||
|
packets.add(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return packets;
|
return packets;
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
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.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,36 +25,65 @@ public class PacketListenerEntityDestroy extends PacketAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NmsVersion.v1_17.isSupported()) {
|
||||||
|
onPre17Packet(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] toAdd = getToRemove(event.getPlayer(), event.getPacket().getIntegers().read(0));
|
||||||
|
|
||||||
|
if (toAdd == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (PacketContainer container : DisguiseUtilities.getDestroyPackets(toAdd)) {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), container);
|
||||||
|
}
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] getToRemove(Player player, int entityId) {
|
||||||
|
if (entityId == DisguiseAPI.getSelfDisguiseId()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Disguise disguise = DisguiseUtilities.getDisguise(player, entityId);
|
||||||
|
|
||||||
|
if (disguise == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int len = disguise.getMultiNameLength();
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return disguise.getArmorstandIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPre17Packet(PacketEvent event) {
|
||||||
int[] entityIds = event.getPacket().getIntegerArrays().read(0);
|
int[] entityIds = event.getPacket().getIntegerArrays().read(0);
|
||||||
int[] newEntityIds = entityIds;
|
int[] newEntityIds = entityIds;
|
||||||
|
|
||||||
for (int entityId : entityIds) {
|
for (int entityId : entityIds) {
|
||||||
if (entityId == DisguiseAPI.getSelfDisguiseId()) {
|
int[] toAdd = getToRemove(event.getPlayer(), entityId);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Disguise disguise = DisguiseUtilities.getDisguise(event.getPlayer(), entityId);
|
if (toAdd == null) {
|
||||||
|
|
||||||
if (disguise == null) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = disguise.getMultiNameLength();
|
newEntityIds = Arrays.copyOf(entityIds, entityIds.length + toAdd.length);
|
||||||
|
|
||||||
if (len == 0) {
|
for (int a = 0; a < toAdd.length; a++) {
|
||||||
continue;
|
newEntityIds[newEntityIds.length - (a + 1)] = toAdd[a];
|
||||||
}
|
|
||||||
|
|
||||||
// If this packet has already been processed
|
|
||||||
if (entityIds.length == newEntityIds.length &&
|
|
||||||
Arrays.stream(entityIds).anyMatch(id -> id == disguise.getArmorstandIds()[0])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
newEntityIds = Arrays.copyOf(entityIds, entityIds.length + len);
|
|
||||||
|
|
||||||
for (int a = 0; a < len; a++) {
|
|
||||||
newEntityIds[newEntityIds.length - (a + 1)] = disguise.getArmorstandIds()[a];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ public enum NmsVersion {
|
|||||||
v1_13,
|
v1_13,
|
||||||
v1_14,
|
v1_14,
|
||||||
v1_15,
|
v1_15,
|
||||||
v1_16;
|
v1_16,
|
||||||
|
v1_17;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this nms version isn't newer than the running version
|
* If this nms version isn't newer than the running version
|
||||||
|
@ -112,20 +112,35 @@ public class ReflectionManager {
|
|||||||
private static Method getObjectives;
|
private static Method getObjectives;
|
||||||
private static Method getPlayerScoreObjective;
|
private static Method getPlayerScoreObjective;
|
||||||
private static Method setScore;
|
private static Method setScore;
|
||||||
|
private static HashMap<String, String> classLocations = new HashMap<>();
|
||||||
|
private static Field playerConnection;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
try {
|
try {
|
||||||
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class, double.class, double.class, double.class);
|
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class, double.class, double.class, double.class);
|
||||||
|
|
||||||
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
||||||
entityCountField = getNmsField("Entity", "entityCount");
|
|
||||||
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
|
for (Field f : getNmsClass("Entity").getDeclaredFields()) {
|
||||||
|
if (f.getType() != AtomicInteger.class) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
entityCountField = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entityCountField = getNmsField("Entity", "entityCount");
|
||||||
|
}
|
||||||
|
|
||||||
mobEffectConstructor = getNmsConstructor("MobEffect", getNmsClass("MobEffectList"), Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE);
|
mobEffectConstructor = getNmsConstructor("MobEffect", getNmsClass("MobEffectList"), Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE);
|
||||||
mobEffectList = getNmsMethod("MobEffectList", "fromId", Integer.TYPE);
|
mobEffectList = getNmsMethod("MobEffectList", "fromId", Integer.TYPE);
|
||||||
boundingBoxMethod = getNmsMethod("Entity", "getBoundingBox");
|
boundingBoxMethod = getNmsMethod("Entity", "getBoundingBox");
|
||||||
bukkitEntityMethod = getNmsMethod("Entity", "getBukkitEntity");
|
bukkitEntityMethod = getNmsMethod("Entity", "getBukkitEntity");
|
||||||
|
|
||||||
Class<?> craftItemClass = getCraftClass("inventory.CraftItemStack");
|
Class<?> craftItemClass = getCraftClass("CraftItemStack");
|
||||||
itemAsCraftCopyMethod = getCraftMethod(craftItemClass, "asCraftCopy", ItemStack.class);
|
itemAsCraftCopyMethod = getCraftMethod(craftItemClass, "asCraftCopy", ItemStack.class);
|
||||||
itemAsNmsCopyMethod = getCraftMethod(craftItemClass, "asNMSCopy", ItemStack.class);
|
itemAsNmsCopyMethod = getCraftMethod(craftItemClass, "asNMSCopy", ItemStack.class);
|
||||||
itemAsBukkitMethod = getCraftMethod(craftItemClass, "asBukkitCopy", getNmsClass("ItemStack"));
|
itemAsBukkitMethod = getCraftMethod(craftItemClass, "asBukkitCopy", getNmsClass("ItemStack"));
|
||||||
@ -136,11 +151,19 @@ public class ReflectionManager {
|
|||||||
enumDirectionMethod = getNmsMethod("EnumDirection", "fromType2", int.class);
|
enumDirectionMethod = getNmsMethod("EnumDirection", "fromType2", int.class);
|
||||||
enumPlayerInfoAction = (Enum[]) getNmsClass("PacketPlayOutPlayerInfo$EnumPlayerInfoAction").getEnumConstants();
|
enumPlayerInfoAction = (Enum[]) getNmsClass("PacketPlayOutPlayerInfo$EnumPlayerInfoAction").getEnumConstants();
|
||||||
chatComponentConstructor = getNmsConstructor("ChatComponentText", String.class);
|
chatComponentConstructor = getNmsConstructor("ChatComponentText", String.class);
|
||||||
packetPlayOutConstructor =
|
|
||||||
getNmsConstructor("PacketPlayOutPlayerInfo$PlayerInfoData", getNmsClass("PacketPlayOutPlayerInfo"), GameProfile.class, int.class,
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent"));
|
packetPlayOutConstructor =
|
||||||
|
getNmsConstructor("PacketPlayOutPlayerInfo$PlayerInfoData", GameProfile.class, int.class, getNmsClass("EnumGamemode"),
|
||||||
|
getNmsClass("IChatBaseComponent"));
|
||||||
|
} else {
|
||||||
|
packetPlayOutConstructor =
|
||||||
|
getNmsConstructor("PacketPlayOutPlayerInfo$PlayerInfoData", getNmsClass("PacketPlayOutPlayerInfo"), GameProfile.class, int.class,
|
||||||
|
getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent"));
|
||||||
|
}
|
||||||
|
|
||||||
enumGamemode = (Enum[]) getNmsClass("EnumGamemode").getEnumConstants();
|
enumGamemode = (Enum[]) getNmsClass("EnumGamemode").getEnumConstants();
|
||||||
getNmsEntityMethod = getCraftMethod("entity.CraftEntity", "getHandle");
|
getNmsEntityMethod = getCraftMethod("CraftEntity", "getHandle");
|
||||||
enumItemSlots = (Enum[]) getNmsClass("EnumItemSlot").getEnumConstants();
|
enumItemSlots = (Enum[]) getNmsClass("EnumItemSlot").getEnumConstants();
|
||||||
|
|
||||||
Class craftSound = getCraftClass("CraftSound");
|
Class craftSound = getCraftClass("CraftSound");
|
||||||
@ -159,23 +182,30 @@ public class ReflectionManager {
|
|||||||
getBlockData = getNmsMethod(getNmsClass("Block"), "getBlockData");
|
getBlockData = getNmsMethod(getNmsClass("Block"), "getBlockData");
|
||||||
|
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
craftBlockDataGetState = getCraftMethod("block.data.CraftBlockData", "getState");
|
craftBlockDataGetState = getCraftMethod("CraftBlockData", "getState");
|
||||||
magicGetBlock = getCraftMethod("util.CraftMagicNumbers", "getBlock", Material.class);
|
magicGetBlock = getCraftMethod("CraftMagicNumbers", "getBlock", Material.class);
|
||||||
magicGetMaterial = getCraftMethod("util.CraftMagicNumbers", "getMaterial", getNmsClass("Block"));
|
magicGetMaterial = getCraftMethod("CraftMagicNumbers", "getMaterial", getNmsClass("Block"));
|
||||||
entityTypesAMethod = getNmsMethod("EntityTypes", "a", String.class);
|
entityTypesAMethod = getNmsMethod("EntityTypes", "a", String.class);
|
||||||
|
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
entityPoseClass = getNmsClass("EntityPose");
|
entityPoseClass = getNmsClass("EntityPose");
|
||||||
registryBlocksGetMethod = getNmsMethod("RegistryBlocks", "get", getNmsClass("MinecraftKey"));
|
registryBlocksGetMethod = getNmsMethod("RegistryBlocks", "get", getNmsClass("MinecraftKey"));
|
||||||
villagerDataConstructor = getNmsConstructor("VillagerData", getNmsClass("VillagerType"), getNmsClass("VillagerProfession"), int.class);
|
villagerDataConstructor = getNmsConstructor("VillagerData", getNmsClass("VillagerType"), getNmsClass("VillagerProfession"), int.class);
|
||||||
villagerProfessionRegistry = getNmsField("IRegistry", "VILLAGER_PROFESSION").get(null);
|
|
||||||
villagerTypeRegistry = getNmsField("IRegistry", "VILLAGER_TYPE").get(null);
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
|
villagerProfessionRegistry = getNmsField("IRegistry", "ap").get(null);
|
||||||
|
villagerTypeRegistry = getNmsField("IRegistry", "ao").get(null);
|
||||||
|
playerConnection = getNmsField("EntityPlayer", "b");
|
||||||
|
} else {
|
||||||
|
villagerProfessionRegistry = getNmsField("IRegistry", "VILLAGER_PROFESSION").get(null);
|
||||||
|
villagerTypeRegistry = getNmsField("IRegistry", "VILLAGER_TYPE").get(null);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
registryBlocksGetMethod = getNmsMethod("RegistryBlocks", "getOrDefault", getNmsClass("MinecraftKey"));
|
registryBlocksGetMethod = getNmsMethod("RegistryBlocks", "getOrDefault", getNmsClass("MinecraftKey"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bukkitKeyToNms = getCraftMethod("util.CraftNamespacedKey", "toMinecraft", NamespacedKey.class);
|
bukkitKeyToNms = getCraftMethod("CraftNamespacedKey", "toMinecraft", NamespacedKey.class);
|
||||||
dataWatcherItemConstructor = getNmsConstructor("DataWatcher$Item", getNmsClass("DataWatcherObject"), Object.class);
|
dataWatcherItemConstructor = getNmsConstructor("DataWatcher$Item", getNmsClass("DataWatcherObject"), Object.class);
|
||||||
vec3DConstructor = getNmsConstructor("Vec3D", double.class, double.class, double.class);
|
vec3DConstructor = getNmsConstructor("Vec3D", double.class, double.class, double.class);
|
||||||
getOldItemAsBlock = getNmsMethod(getNmsClass("Block"), "asBlock", getNmsClass("Item"));
|
getOldItemAsBlock = getNmsMethod(getNmsClass("Block"), "asBlock", getNmsClass("Item"));
|
||||||
@ -183,14 +213,44 @@ public class ReflectionManager {
|
|||||||
getBlockDataAsId = getNmsMethod("Block", "getCombinedId", getNmsClass("IBlockData"));
|
getBlockDataAsId = getNmsMethod("Block", "getCombinedId", getNmsClass("IBlockData"));
|
||||||
|
|
||||||
getNmsWorld = getCraftMethod("CraftWorld", "getHandle");
|
getNmsWorld = getCraftMethod("CraftWorld", "getHandle");
|
||||||
deserializedItemMeta = getCraftMethod(getCraftClass("inventory.CraftMetaItem$SerializableMeta"), "deserialize", Map.class);
|
deserializedItemMeta = getCraftMethod(getCraftClass("CraftMetaItem$SerializableMeta"), "deserialize", Map.class);
|
||||||
|
|
||||||
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
|
boolean nextInt = false;
|
||||||
|
|
||||||
|
for (Field f : getNmsClass("Entity").getDeclaredFields()) {
|
||||||
|
if (f.getType().getSimpleName().equals("Tag")) {
|
||||||
|
nextInt = true;
|
||||||
|
} else if (f.getType() == int.class && nextInt) {
|
||||||
|
noDamageTicks = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
noDamageTicks = getNmsField("Entity", "noDamageTicks");
|
||||||
|
}
|
||||||
|
|
||||||
noDamageTicks = getNmsField("Entity", "noDamageTicks");
|
|
||||||
isInvul = getNmsMethod("Entity", "isInvulnerable", getNmsClass("DamageSource"));
|
isInvul = getNmsMethod("Entity", "isInvulnerable", getNmsClass("DamageSource"));
|
||||||
genericDamage = getNmsField("DamageSource", "GENERIC").get(null);
|
|
||||||
boardField = getCraftClass("scoreboard.CraftScoreboard").getDeclaredField("board");
|
for (Field f : getNmsClass("DamageSource").getFields()) {
|
||||||
|
Object obj = f.get(null);
|
||||||
|
|
||||||
|
if (obj == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!obj.toString().contains("(generic)")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
genericDamage = obj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
boardField = getCraftClass("CraftScoreboard").getDeclaredField("board");
|
||||||
boardField.setAccessible(true);
|
boardField.setAccessible(true);
|
||||||
scoreboardCrtieriaHealth = getNmsField("IScoreboardCriteria", NmsVersion.v1_13.isSupported() ? "HEALTH" : "g").get(null);
|
scoreboardCrtieriaHealth =
|
||||||
|
getNmsField("IScoreboardCriteria", NmsVersion.v1_17.isSupported() ? NmsVersion.v1_13.isSupported() ? "f" : "HEALTH" : "g").get(null);
|
||||||
setScore = getNmsMethod("ScoreboardScore", "setScore", int.class);
|
setScore = getNmsMethod("ScoreboardScore", "setScore", int.class);
|
||||||
|
|
||||||
if (!NmsVersion.v1_13.isSupported()) {
|
if (!NmsVersion.v1_13.isSupported()) {
|
||||||
@ -241,15 +301,15 @@ public class ReflectionManager {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
pingField = getNmsField("EntityPlayer", "ping");
|
pingField = getNmsField("EntityPlayer", NmsVersion.v1_17.isSupported() ? "e" : "ping");
|
||||||
|
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
chunkMapField = getNmsField("ChunkProviderServer", "playerChunkMap");
|
chunkMapField = getNmsField("ChunkProviderServer", NmsVersion.v1_17.isSupported() ? "a" : "playerChunkMap");
|
||||||
trackedEntitiesField = getNmsField("PlayerChunkMap", "trackedEntities");
|
trackedEntitiesField = getNmsField("PlayerChunkMap", NmsVersion.v1_17.isSupported() ? "G" : "trackedEntities");
|
||||||
entityTrackerField = getNmsField("PlayerChunkMap$EntityTracker", "trackerEntry");
|
entityTrackerField = getNmsField("PlayerChunkMap$EntityTracker", NmsVersion.v1_17.isSupported() ? "b" : "trackerEntry");
|
||||||
|
|
||||||
if (NmsVersion.v1_16.isSupported()) {
|
if (NmsVersion.v1_16.isSupported()) {
|
||||||
chunkProviderField = getNmsField("WorldServer", "chunkProvider");
|
chunkProviderField = getNmsField("WorldServer", NmsVersion.v1_17.isSupported() ? "C" : "chunkProvider");
|
||||||
} else {
|
} else {
|
||||||
chunkProviderField = getNmsField("World", "chunkProvider");
|
chunkProviderField = getNmsField("World", "chunkProvider");
|
||||||
}
|
}
|
||||||
@ -384,23 +444,52 @@ public class ReflectionManager {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object getEntityTrackerInstance(Player player) {
|
||||||
|
try {
|
||||||
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
|
return playerConnection.get(getNmsEntity(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
return getNmsEntity(player);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Object createEntityInstance(DisguiseType disguiseType, String entityName) {
|
public static Object createEntityInstance(DisguiseType disguiseType, String entityName) {
|
||||||
try {
|
try {
|
||||||
Class<?> entityClass = getNmsClass("Entity" + entityName);
|
Class<?> entityClass;
|
||||||
|
|
||||||
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
|
entityClass = getNmsClassIgnoreErrors("Entity" + entityName);
|
||||||
|
|
||||||
|
if (entityClass == null) {
|
||||||
|
entityClass = getNmsClass(entityName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entityClass = getNmsClass("Entity" + entityName);
|
||||||
|
}
|
||||||
|
|
||||||
Object entityObject;
|
Object entityObject;
|
||||||
Object world = getWorldServer(Bukkit.getWorlds().get(0));
|
Object world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
|
|
||||||
if (entityName.equals("Player")) {
|
if (entityName.equals("Player")) {
|
||||||
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
||||||
|
|
||||||
Object playerinteractmanager =
|
|
||||||
getNmsClass("PlayerInteractManager").getDeclaredConstructor(getNmsClass(NmsVersion.v1_14.isSupported() ? "WorldServer" : "World"))
|
|
||||||
.newInstance(world);
|
|
||||||
|
|
||||||
WrappedGameProfile gameProfile = getGameProfile(new UUID(0, 0), "Steve");
|
WrappedGameProfile gameProfile = getGameProfile(new UUID(0, 0), "Steve");
|
||||||
|
|
||||||
entityObject = entityClass.getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), gameProfile.getHandleType(),
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, gameProfile.getHandle(), playerinteractmanager);
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), gameProfile.getHandleType())
|
||||||
|
.newInstance(minecraftServer, world, gameProfile.getHandle());
|
||||||
|
} else {
|
||||||
|
Object playerinteractmanager =
|
||||||
|
getNmsClass("PlayerInteractManager").getDeclaredConstructor(getNmsClass(NmsVersion.v1_14.isSupported() ? "WorldServer" : "World"))
|
||||||
|
.newInstance(world);
|
||||||
|
|
||||||
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), gameProfile.getHandleType(),
|
||||||
|
playerinteractmanager.getClass()).newInstance(minecraftServer, world, gameProfile.getHandle(), playerinteractmanager);
|
||||||
|
}
|
||||||
} else if (entityName.equals("EnderPearl")) {
|
} else if (entityName.equals("EnderPearl")) {
|
||||||
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
||||||
.newInstance(world, createEntityInstance(DisguiseType.COW, "Cow"));
|
.newInstance(world, createEntityInstance(DisguiseType.COW, "Cow"));
|
||||||
@ -564,7 +653,7 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static Class<?> getCraftClass(String className) {
|
public static Class<?> getCraftClass(String className) {
|
||||||
try {
|
try {
|
||||||
return Class.forName("org.bukkit.craftbukkit." + getBukkitVersion() + "." + className);
|
return Class.forName(getLocation("org.bukkit.craftbukkit", className));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -679,6 +768,10 @@ public class ReflectionManager {
|
|||||||
try {
|
try {
|
||||||
Object playerListName = chatComponentConstructor.newInstance(gameProfile.getName());
|
Object playerListName = chatComponentConstructor.newInstance(gameProfile.getName());
|
||||||
|
|
||||||
|
if (NmsVersion.v1_17.isSupported()) {
|
||||||
|
return packetPlayOutConstructor.newInstance(gameProfile.getHandle(), 0, enumGamemode[1], playerListName);
|
||||||
|
}
|
||||||
|
|
||||||
return packetPlayOutConstructor.newInstance(playerInfoPacket, gameProfile.getHandle(), 0, enumGamemode[1], playerListName);
|
return packetPlayOutConstructor.newInstance(playerInfoPacket, gameProfile.getHandle(), 0, enumGamemode[1], playerListName);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -748,9 +841,33 @@ public class ReflectionManager {
|
|||||||
return new UUID(firstLong, secondLong);
|
return new UUID(firstLong, secondLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getLocation(String pack, String className) {
|
||||||
|
String toReturn = classLocations.get(className);
|
||||||
|
|
||||||
|
if (toReturn != null) {
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ArrayList<String> classes = ClassGetter.getEntriesForPackage(pack);
|
||||||
|
|
||||||
|
String realLocation = classes.stream().filter(s -> s.endsWith("/" + className + ".class")).findAny().get().replace("/", ".").replace(".class", "");
|
||||||
|
|
||||||
|
classLocations.put(className, realLocation);
|
||||||
|
|
||||||
|
return realLocation;
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
// System.err.println(pack + " - " + className);
|
||||||
|
// throwable.printStackTrace();
|
||||||
|
classLocations.put(className, className);
|
||||||
|
}
|
||||||
|
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
public static Class getNmsClass(String className) {
|
public static Class getNmsClass(String className) {
|
||||||
try {
|
try {
|
||||||
return Class.forName("net.minecraft.server." + getBukkitVersion() + "." + className);
|
return Class.forName(getLocation("net.minecraft", className));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -760,7 +877,7 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static Class getNmsClassIgnoreErrors(String className) {
|
public static Class getNmsClassIgnoreErrors(String className) {
|
||||||
try {
|
try {
|
||||||
return Class.forName("net.minecraft.server." + getBukkitVersion() + "." + className);
|
return Class.forName(getLocation("net.minecraft", className));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,7 +1329,7 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
Object mcKey = getNmsConstructor("MinecraftKey", String.class).newInstance(name);
|
Object mcKey = getNmsConstructor("MinecraftKey", String.class).newInstance(name);
|
||||||
|
|
||||||
Object registry = getNmsField("IRegistry", "ITEM").get(null);
|
Object registry = getNmsField("IRegistry", NmsVersion.v1_17.isSupported() ? "Z" : "ITEM").get(null);
|
||||||
|
|
||||||
Method getMethod = getNmsMethod(getNmsClass("RegistryMaterials"), "get", mcKey.getClass());
|
Method getMethod = getNmsMethod(getNmsClass("RegistryMaterials"), "get", mcKey.getClass());
|
||||||
Object item = getMethod.invoke(registry, mcKey);
|
Object item = getMethod.invoke(registry, mcKey);
|
||||||
@ -1221,7 +1338,7 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Method getMaterial = getCraftMethod("util.CraftMagicNumbers", "getMaterial", getNmsClass("Item"));
|
Method getMaterial = getCraftMethod("CraftMagicNumbers", "getMaterial", getNmsClass("Item"));
|
||||||
|
|
||||||
return (Material) getMaterial.invoke(null, item);
|
return (Material) getMaterial.invoke(null, item);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -1247,7 +1364,7 @@ public class ReflectionManager {
|
|||||||
Object registry;
|
Object registry;
|
||||||
|
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
registry = getNmsField("IRegistry", "ITEM").get(null);
|
registry = getNmsField("IRegistry", NmsVersion.v1_17.isSupported() ? "Z" : "ITEM").get(null);
|
||||||
} else {
|
} else {
|
||||||
registry = getNmsField("Item", "REGISTRY").get(null);
|
registry = getNmsField("Item", "REGISTRY").get(null);
|
||||||
}
|
}
|
||||||
@ -1415,7 +1532,7 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
Class typesClass = getNmsClass("IRegistry");
|
Class typesClass = getNmsClass("IRegistry");
|
||||||
|
|
||||||
Object registry = typesClass.getField("ENTITY_TYPE").get(null);
|
Object registry = typesClass.getField(NmsVersion.v1_17.isSupported() ? "Y" : "ENTITY_TYPE").get(null);
|
||||||
|
|
||||||
Constructor c = getNmsClass("EntityTypes").getConstructors()[0];
|
Constructor c = getNmsClass("EntityTypes").getConstructors()[0];
|
||||||
|
|
||||||
@ -1452,9 +1569,9 @@ public class ReflectionManager {
|
|||||||
try {
|
try {
|
||||||
Class typesClass = getNmsClass("IRegistry");
|
Class typesClass = getNmsClass("IRegistry");
|
||||||
|
|
||||||
Object registry = typesClass.getField("ENTITY_TYPE").get(null);
|
Object registry = typesClass.getField(NmsVersion.v1_17.isSupported() ? "Y" : "ENTITY_TYPE").get(null);
|
||||||
|
|
||||||
return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityTypes);
|
return (int) registry.getClass().getMethod(NmsVersion.v1_17.isSupported() ? "getId" : "a", Object.class).invoke(registry, entityTypes);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1469,9 +1586,9 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
Class typesClass = getNmsClass("IRegistry");
|
Class typesClass = getNmsClass("IRegistry");
|
||||||
|
|
||||||
Object registry = typesClass.getField("ENTITY_TYPE").get(null);
|
Object registry = typesClass.getField(NmsVersion.v1_17.isSupported() ? "Y" : "ENTITY_TYPE").get(null);
|
||||||
|
|
||||||
return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityTypes);
|
return (int) registry.getClass().getMethod(NmsVersion.v1_17.isSupported() ? "getId" : "a", Object.class).invoke(registry, entityTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entityType.getTypeId();
|
return entityType.getTypeId();
|
||||||
@ -1486,10 +1603,10 @@ public class ReflectionManager {
|
|||||||
try {
|
try {
|
||||||
Class typesClass = getNmsClass("IRegistry");
|
Class typesClass = getNmsClass("IRegistry");
|
||||||
|
|
||||||
Object registry = typesClass.getField("ENTITY_TYPE").get(null);
|
Object registry = typesClass.getField(NmsVersion.v1_17.isSupported() ? "Y" : "ENTITY_TYPE").get(null);
|
||||||
Object mcKey = getNmsConstructor("MinecraftKey", String.class).newInstance(name.toString());
|
Object mcKey = getNmsConstructor("MinecraftKey", String.class).newInstance(name.toString());
|
||||||
|
|
||||||
return registry.getClass().getMethod("a", mcKey.getClass()).invoke(registry, mcKey);
|
return registry.getClass().getMethod(NmsVersion.v1_17.isSupported() ? "getId" : "a", mcKey.getClass()).invoke(registry, mcKey);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1552,7 +1669,7 @@ public class ReflectionManager {
|
|||||||
Object iBlockData = idMethod.invoke(null, id);
|
Object iBlockData = idMethod.invoke(null, id);
|
||||||
Class iBlockClass = getNmsClass("IBlockData");
|
Class iBlockClass = getNmsClass("IBlockData");
|
||||||
|
|
||||||
return (BlockData) getCraftMethod("block.data.CraftBlockData", "fromData", iBlockClass).invoke(null, iBlockData);
|
return (BlockData) getCraftMethod("CraftBlockData", "fromData", iBlockClass).invoke(null, iBlockData);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1609,6 +1726,12 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
switch (disguiseType) {
|
switch (disguiseType) {
|
||||||
|
case MARKER:
|
||||||
|
watcherClass = FlagWatcher.class;
|
||||||
|
break;
|
||||||
|
case GLOW_ITEM_FRAME:
|
||||||
|
watcherClass = ItemFrameWatcher.class;
|
||||||
|
break;
|
||||||
case ARROW:
|
case ARROW:
|
||||||
watcherClass = TippedArrowWatcher.class;
|
watcherClass = TippedArrowWatcher.class;
|
||||||
break;
|
break;
|
||||||
@ -1648,10 +1771,6 @@ public class ReflectionManager {
|
|||||||
case ELDER_GUARDIAN:
|
case ELDER_GUARDIAN:
|
||||||
watcherClass = GuardianWatcher.class;
|
watcherClass = GuardianWatcher.class;
|
||||||
break;
|
break;
|
||||||
case WITHER_SKELETON:
|
|
||||||
case STRAY:
|
|
||||||
watcherClass = SkeletonWatcher.class;
|
|
||||||
break;
|
|
||||||
case ILLUSIONER:
|
case ILLUSIONER:
|
||||||
case EVOKER:
|
case EVOKER:
|
||||||
watcherClass = IllagerWizardWatcher.class;
|
watcherClass = IllagerWizardWatcher.class;
|
||||||
@ -1764,6 +1883,21 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
if (nmsEntityName == null) {
|
if (nmsEntityName == null) {
|
||||||
switch (disguiseType) {
|
switch (disguiseType) {
|
||||||
|
case AXOLOTL:
|
||||||
|
nmsEntityName = "Axolotl";
|
||||||
|
break;
|
||||||
|
case GOAT:
|
||||||
|
nmsEntityName = "Goat";
|
||||||
|
break;
|
||||||
|
case GLOW_ITEM_FRAME:
|
||||||
|
nmsEntityName = "GlowItemFrame";
|
||||||
|
break;
|
||||||
|
case GLOW_SQUID:
|
||||||
|
nmsEntityName = "GlowSquid";
|
||||||
|
break;
|
||||||
|
case MARKER:
|
||||||
|
nmsEntityName = "Marker";
|
||||||
|
break;
|
||||||
case DONKEY:
|
case DONKEY:
|
||||||
nmsEntityName = "HorseDonkey";
|
nmsEntityName = "HorseDonkey";
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user