mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-04 13:54:35 +01:00
First jenkins dev build for packetevents
I'll probably do the actual changelog in the release only, tiring
This commit is contained in:
parent
ed2a33f703
commit
9b7cc9b1b3
@ -13,7 +13,7 @@ There are a few features which you need to pay for, but none of it is needed to
|
|||||||
Spigot page: <a href="https://www.spigotmc.org/resources/32453/">Link</a>
|
Spigot page: <a href="https://www.spigotmc.org/resources/32453/">Link</a>
|
||||||
Jenkins Downloads: <a href="https://ci.md-5.net/job/LibsDisguises/">Link</a>
|
Jenkins Downloads: <a href="https://ci.md-5.net/job/LibsDisguises/">Link</a>
|
||||||
|
|
||||||
NOTE: These versions will NOT work with older versions of Minecraft. There is no support for older versions of this plugin.
|
NOTE: These versions will NOT work with older versions of Minecraft than 1.12, there is no support for older versions of this plugin.
|
||||||
|
|
||||||
When posting an issue:<br>
|
When posting an issue:<br>
|
||||||
Please make sure you<br>
|
Please make sure you<br>
|
||||||
@ -21,7 +21,7 @@ Please make sure you<br>
|
|||||||
2) Post the exact steps you used in order to reproduce the issue.<br>
|
2) Post the exact steps you used in order to reproduce the issue.<br>
|
||||||
3) Give as much information as possible as to what the issue is and why it occurred so that we can fix it.<br>
|
3) Give as much information as possible as to what the issue is and why it occurred so that we can fix it.<br>
|
||||||
|
|
||||||
Verify that there were no error messages while Lib's Disguises was loading, that you're using the appropiate version of <a href="https://www.spigotmc.org/resources/protocollib.1997/">ProtocolLib</a>.
|
Verify that there were no error messages while Lib's Disguises was loading, that you're using the appropiate version of <a href="https://www.spigotmc.org/resources/packetevents-api.80279/">PacketEvents</a>.
|
||||||
If you're using the development builds of Lib's Disguises, make sure you are up to date before reporting a bug.
|
If you're using the development builds of Lib's Disguises, make sure you are up to date before reporting a bug.
|
||||||
|
|
||||||
Important Note
|
Important Note
|
||||||
|
89
minimessage/pom.xml
Normal file
89
minimessage/pom.xml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<groupId>LibsDisguises</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>minimessage</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>${paper-api.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-api</artifactId>
|
||||||
|
<version>${adventure-minimessage.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>${adventure-minimessage.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-serializer-json</artifactId>
|
||||||
|
<version>${adventure-text.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>net.kyori:*</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.kyori</pattern>
|
||||||
|
<shadedPattern>libsdisg.shaded.net.kyori</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
10
nms/pom.xml
10
nms/pom.xml
@ -12,6 +12,15 @@
|
|||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>LibsDisguises</groupId>
|
||||||
|
<artifactId>shared</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>v1_17_R1</module>
|
<module>v1_17_R1</module>
|
||||||
<module>v1_18_R1</module>
|
<module>v1_18_R1</module>
|
||||||
@ -22,6 +31,7 @@
|
|||||||
<module>v1_20_R1</module>
|
<module>v1_20_R1</module>
|
||||||
<module>v1_20_R2</module>
|
<module>v1_20_R2</module>
|
||||||
<module>v1_20_R3</module>
|
<module>v1_20_R3</module>
|
||||||
|
<module>v1_20_R4</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,27 +1,15 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_17;
|
package me.libraryaddict.disguise.utilities.reflection.v1_17;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -32,21 +20,13 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
import net.minecraft.world.entity.decoration.Motive;
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -68,19 +48,13 @@ import org.bukkit.craftbukkit.v1_17_R1.util.CraftNamespacedKey;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.List;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -98,15 +72,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("b");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("b");
|
||||||
@ -124,20 +101,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile);
|
||||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||||
@ -155,55 +134,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getCraftSound(Sound sound) {
|
@Override
|
||||||
return CraftSound.getSoundEffect(sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkProvider();
|
ServerChunkCache chunkSource = world.getChunkProvider();
|
||||||
@ -220,56 +191,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return Registry.MOTIVE.getKey(CraftArt.BukkitToNotch(art)).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
ClientboundPlayerInfoPacket.PlayerUpdate entry =
|
|
||||||
new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
|
||||||
new TextComponent(displayName));
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
|
|
||||||
modifier.write(0, ClientboundPlayerInfoPacket.Action.valueOf(actions[0].name()));
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -287,11 +236,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -299,120 +250,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||||
@ -421,45 +285,50 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
return Registry.ENTITY_TYPE.getId(entityType);
|
return Registry.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -473,4 +342,38 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
|
List<SynchedEntityData.DataItem<?>> dataItems = watcher.getAll();
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
|
||||||
|
SynchedEntityData.pack(dataItems, new FriendlyByteBuf(buf));
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<Motive> registry = Registry.MOTIVE;
|
||||||
|
|
||||||
|
Motive ref = registry.byId(paintingId);
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<Motive> registry = Registry.MOTIVE;
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.BukkitToNotch(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mojang</groupId>
|
<groupId>com.mojang</groupId>
|
||||||
|
@ -1,28 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_18_1;
|
package me.libraryaddict.disguise.utilities.reflection.v1_18_1;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -33,20 +21,13 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
import net.minecraft.world.entity.decoration.Motive;
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -68,19 +49,14 @@ import org.bukkit.craftbukkit.v1_18_R1.util.CraftNamespacedKey;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -98,15 +74,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("b");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("b");
|
||||||
@ -124,20 +103,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile);
|
||||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||||
@ -155,55 +136,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getCraftSound(Sound sound) {
|
@Override
|
||||||
return CraftSound.getSoundEffect(sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -220,56 +193,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return Registry.MOTIVE.getKey(CraftArt.BukkitToNotch(art)).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
ClientboundPlayerInfoPacket.PlayerUpdate entry =
|
|
||||||
new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
|
||||||
new TextComponent(displayName));
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
|
|
||||||
modifier.write(0, ClientboundPlayerInfoPacket.Action.valueOf(actions[0].name()));
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -287,11 +238,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -299,120 +252,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||||
@ -421,45 +287,50 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
return Registry.ENTITY_TYPE.getId(entityType);
|
return Registry.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_18_R1.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_18_R1.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -473,4 +344,38 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
|
List<SynchedEntityData.DataItem<?>> dataItems = watcher.getAll();
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
|
||||||
|
SynchedEntityData.pack(dataItems, new FriendlyByteBuf(buf));
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<Motive> registry = Registry.MOTIVE;
|
||||||
|
|
||||||
|
Motive ref = registry.byId(paintingId);
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<Motive> registry = Registry.MOTIVE;
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.BukkitToNotch(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mojang</groupId>
|
<groupId>com.mojang</groupId>
|
||||||
|
@ -1,28 +1,17 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_18_2;
|
package me.libraryaddict.disguise.utilities.reflection.v1_18_2;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -33,20 +22,13 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
import net.minecraft.world.entity.decoration.Motive;
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -68,19 +50,14 @@ import org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -88,6 +65,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
|
||||||
public boolean hasInvul(Entity entity) {
|
public boolean hasInvul(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
@ -98,15 +76,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
||||||
@ -124,20 +105,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile);
|
||||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||||
@ -155,55 +138,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getCraftSound(Sound sound) {
|
@Override
|
||||||
return CraftSound.getSoundEffect(sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -220,56 +195,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return Registry.MOTIVE.getKey(CraftArt.BukkitToNotch(art)).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
ClientboundPlayerInfoPacket.PlayerUpdate entry =
|
|
||||||
new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
|
||||||
new TextComponent(displayName));
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
|
|
||||||
modifier.write(0, ClientboundPlayerInfoPacket.Action.valueOf(actions[0].name()));
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -287,11 +240,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -299,120 +254,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||||
@ -421,45 +289,50 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
return Registry.ENTITY_TYPE.getId(entityType);
|
return Registry.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -473,4 +346,39 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
|
List<SynchedEntityData.DataItem<?>> dataItems = watcher.getAll();
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
|
||||||
|
SynchedEntityData.pack(dataItems, new FriendlyByteBuf(buf));
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
|
||||||
|
Registry<Motive> registry = Registry.MOTIVE;
|
||||||
|
|
||||||
|
Holder<Motive> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<Motive> registry = Registry.MOTIVE;
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.BukkitToNotch(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,30 +1,18 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_19_R1;
|
package me.libraryaddict.disguise.utilities.reflection.v1_19_R1;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
@ -34,24 +22,13 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
|
||||||
import net.minecraft.world.entity.animal.FrogVariant;
|
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariants;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -70,24 +47,17 @@ import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_19_R1.util.CraftMagicNumbers;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftNamespacedKey;
|
import org.bukkit.craftbukkit.v1_19_R1.util.CraftNamespacedKey;
|
||||||
import org.bukkit.entity.Cat;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -105,15 +75,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
||||||
@ -131,20 +104,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle(), null);
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile, null);
|
||||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||||
@ -162,55 +137,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getCraftSound(Sound sound) {
|
@Override
|
||||||
return CraftSound.getSoundEffect(sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -227,56 +194,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return Registry.PAINTING_VARIANT.getKey(CraftArt.BukkitToNotch(art).value()).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
ClientboundPlayerInfoPacket.PlayerUpdate entry =
|
|
||||||
new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
|
||||||
Component.literal(displayName), null);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
|
|
||||||
modifier.write(0, ClientboundPlayerInfoPacket.Action.valueOf(actions[0].name()));
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -294,11 +239,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -306,120 +253,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||||
@ -428,45 +288,50 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
return Registry.ENTITY_TYPE.getId(entityType);
|
return Registry.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R1.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R1.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -481,129 +346,37 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public Object convertInvalidMeta(Object value) {
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
if (value instanceof Frog.Variant) {
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
return getFrogVariant((Frog.Variant) value);
|
List<SynchedEntityData.DataItem<?>> dataItems = watcher.getAll();
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
|
||||||
|
SynchedEntityData.pack(dataItems, new FriendlyByteBuf(buf));
|
||||||
|
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Cat.Type) {
|
@Override
|
||||||
return getCatVariant((Cat.Type) value);
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Art) {
|
@Override
|
||||||
return Registry.PAINTING_VARIANT.getHolderOrThrow(getArtVariant((Art) value));
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = Registry.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
Holder<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
@Override
|
||||||
}
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<PaintingVariant> registry = Registry.PAINTING_VARIANT;
|
||||||
|
|
||||||
private FrogVariant getFrogVariant(Frog.Variant variant) {
|
return registry.getId(CraftArt.BukkitToNotch(type).value());
|
||||||
switch (variant) {
|
|
||||||
case COLD:
|
|
||||||
return FrogVariant.COLD;
|
|
||||||
case WARM:
|
|
||||||
return FrogVariant.WARM;
|
|
||||||
case TEMPERATE:
|
|
||||||
return FrogVariant.TEMPERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatVariant getCatVariant(Cat.Type type) {
|
|
||||||
switch (type) {
|
|
||||||
case TABBY:
|
|
||||||
return CatVariant.TABBY;
|
|
||||||
case BLACK:
|
|
||||||
return CatVariant.BLACK;
|
|
||||||
case RED:
|
|
||||||
return CatVariant.RED;
|
|
||||||
case SIAMESE:
|
|
||||||
return CatVariant.SIAMESE;
|
|
||||||
case BRITISH_SHORTHAIR:
|
|
||||||
return CatVariant.BRITISH_SHORTHAIR;
|
|
||||||
case CALICO:
|
|
||||||
return CatVariant.CALICO;
|
|
||||||
case PERSIAN:
|
|
||||||
return CatVariant.PERSIAN;
|
|
||||||
case RAGDOLL:
|
|
||||||
return CatVariant.RAGDOLL;
|
|
||||||
case WHITE:
|
|
||||||
return CatVariant.WHITE;
|
|
||||||
case JELLIE:
|
|
||||||
return CatVariant.JELLIE;
|
|
||||||
case ALL_BLACK:
|
|
||||||
return CatVariant.ALL_BLACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResourceKey<PaintingVariant> getArtVariant(Art art) {
|
|
||||||
switch (art) {
|
|
||||||
case KEBAB:
|
|
||||||
return PaintingVariants.KEBAB;
|
|
||||||
case AZTEC:
|
|
||||||
return PaintingVariants.AZTEC;
|
|
||||||
case ALBAN:
|
|
||||||
return PaintingVariants.ALBAN;
|
|
||||||
case AZTEC2:
|
|
||||||
return PaintingVariants.AZTEC2;
|
|
||||||
case BOMB:
|
|
||||||
return PaintingVariants.BOMB;
|
|
||||||
case PLANT:
|
|
||||||
return PaintingVariants.PLANT;
|
|
||||||
case WASTELAND:
|
|
||||||
return PaintingVariants.WASTELAND;
|
|
||||||
case POOL:
|
|
||||||
return PaintingVariants.POOL;
|
|
||||||
case COURBET:
|
|
||||||
return PaintingVariants.COURBET;
|
|
||||||
case SEA:
|
|
||||||
return PaintingVariants.SEA;
|
|
||||||
case SUNSET:
|
|
||||||
return PaintingVariants.SUNSET;
|
|
||||||
case CREEBET:
|
|
||||||
return PaintingVariants.CREEBET;
|
|
||||||
case WANDERER:
|
|
||||||
return PaintingVariants.WANDERER;
|
|
||||||
case GRAHAM:
|
|
||||||
return PaintingVariants.GRAHAM;
|
|
||||||
case MATCH:
|
|
||||||
return PaintingVariants.MATCH;
|
|
||||||
case BUST:
|
|
||||||
return PaintingVariants.BUST;
|
|
||||||
case STAGE:
|
|
||||||
return PaintingVariants.STAGE;
|
|
||||||
case VOID:
|
|
||||||
return PaintingVariants.VOID;
|
|
||||||
case SKULL_AND_ROSES:
|
|
||||||
return PaintingVariants.SKULL_AND_ROSES;
|
|
||||||
case WITHER:
|
|
||||||
return PaintingVariants.WITHER;
|
|
||||||
case FIGHTERS:
|
|
||||||
return PaintingVariants.FIGHTERS;
|
|
||||||
case POINTER:
|
|
||||||
return PaintingVariants.POINTER;
|
|
||||||
case PIGSCENE:
|
|
||||||
return PaintingVariants.PIGSCENE;
|
|
||||||
case BURNING_SKULL:
|
|
||||||
return PaintingVariants.BURNING_SKULL;
|
|
||||||
case SKELETON:
|
|
||||||
return PaintingVariants.SKELETON;
|
|
||||||
case DONKEY_KONG:
|
|
||||||
return PaintingVariants.DONKEY_KONG;
|
|
||||||
case EARTH:
|
|
||||||
return PaintingVariants.EARTH;
|
|
||||||
case WIND:
|
|
||||||
return PaintingVariants.WIND;
|
|
||||||
case WATER:
|
|
||||||
return PaintingVariants.WATER;
|
|
||||||
case FIRE:
|
|
||||||
return PaintingVariants.FIRE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,31 +1,18 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_19_R2;
|
package me.libraryaddict.disguise.utilities.reflection.v1_19_R2;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -36,24 +23,13 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
|
||||||
import net.minecraft.world.entity.animal.FrogVariant;
|
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -72,36 +48,36 @@ import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_19_R2.util.CraftMagicNumbers;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.util.CraftNamespacedKey;
|
import org.bukkit.craftbukkit.v1_19_R2.util.CraftNamespacedKey;
|
||||||
import org.bukkit.entity.Cat;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
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.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
private Field dataItemsField;
|
||||||
|
|
||||||
|
public ReflectionManager() {
|
||||||
|
for (Field f : SynchedEntityData.class.getDeclaredFields()) {
|
||||||
|
if (Modifier.isStatic(f.getModifiers()) || !Int2ObjectMap.class.isAssignableFrom(f.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
dataItemsField = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasInvul(Entity entity) {
|
public boolean hasInvul(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
@ -112,15 +88,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
||||||
@ -138,20 +117,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile);
|
||||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||||
@ -173,55 +154,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<SoundEvent> getCraftSound(Sound sound) {
|
@Override
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -238,95 +211,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getKey(CraftArt.BukkitToNotch(art).value()).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTablistPacket(PacketEvent event, Function<UUID, Boolean> shouldRemove) {
|
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) event.getPacket().getHandle();
|
|
||||||
|
|
||||||
if (!packet.actions().contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> canKeep = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ClientboundPlayerInfoUpdatePacket.Entry entry : packet.entries()) {
|
|
||||||
if (shouldRemove.apply(entry.profileId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
canKeep.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.size() == packet.entries().size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.isEmpty()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.getPacket().getModifier().write(1, canKeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
if (actions[0] == EnumWrappers.PlayerInfoAction.REMOVE_PLAYER) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
|
||||||
packet.getModifier().write(0, Collections.singletonList(gameProfile.getUUID()));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry entry =
|
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(gameProfile.getUUID(), (GameProfile) gameProfile.getHandle(), nameVisible, 0,
|
|
||||||
GameType.SURVIVAL, Component.literal(displayName), null);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.copyOf(
|
|
||||||
Arrays.stream(actions).map(action -> ClientboundPlayerInfoUpdatePacket.Action.valueOf(action.name()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
|
|
||||||
modifier.write(0, enumSet);
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -344,11 +256,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -356,124 +270,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Holder<SoundEvent> createSoundEvent(String minecraftKey) {
|
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvent.createVariableRangeEvent(createMinecraftKey(minecraftKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
||||||
@ -482,46 +305,51 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
|
|
||||||
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R2.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R2.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -536,41 +364,42 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public Object convertInvalidMeta(Object value) {
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
if (value instanceof Frog.Variant) {
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
return getFrogVariant((Frog.Variant) value);
|
Int2ObjectMap<SynchedEntityData.DataItem<?>> dataItems = (Int2ObjectMap<SynchedEntityData.DataItem<?>>) dataItemsField.get(watcher);
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
FriendlyByteBuf serializer = new FriendlyByteBuf(buf);
|
||||||
|
|
||||||
|
for (SynchedEntityData.DataItem dataItem : dataItems.values()) {
|
||||||
|
dataItem.value().write(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Cat.Type) {
|
serializer.writeByte(255);
|
||||||
return getCatVariant((Cat.Type) value);
|
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Art) {
|
@Override
|
||||||
return getArtVariant((Art) value);
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FrogVariant getFrogVariant(Frog.Variant variant) {
|
@Override
|
||||||
switch (variant) {
|
public int getPaintingAsInt(Art type) {
|
||||||
case COLD:
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
return FrogVariant.COLD;
|
|
||||||
case WARM:
|
|
||||||
return FrogVariant.WARM;
|
|
||||||
case TEMPERATE:
|
|
||||||
return FrogVariant.TEMPERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return registry.getId(CraftArt.BukkitToNotch(type).value());
|
||||||
}
|
|
||||||
|
|
||||||
private CatVariant getCatVariant(Cat.Type type) {
|
|
||||||
return BuiltInRegistries.CAT_VARIANT.byId(type.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Holder.Reference<PaintingVariant> getArtVariant(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getHolder(art.ordinal()).get();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,31 +1,18 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_19_R3;
|
package me.libraryaddict.disguise.utilities.reflection.v1_19_R3;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -36,23 +23,13 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
|
||||||
import net.minecraft.world.entity.animal.FrogVariant;
|
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -71,36 +48,37 @@ import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_19_R3.util.CraftMagicNumbers;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.util.CraftNamespacedKey;
|
import org.bukkit.craftbukkit.v1_19_R3.util.CraftNamespacedKey;
|
||||||
import org.bukkit.entity.Cat;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
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.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
private Field dataItemsField;
|
||||||
|
|
||||||
|
public ReflectionManager() {
|
||||||
|
for (Field f : SynchedEntityData.class.getDeclaredFields()) {
|
||||||
|
if (Modifier.isStatic(f.getModifiers()) || !Int2ObjectMap.class.isAssignableFrom(f.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
dataItemsField = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasInvul(Entity entity) {
|
public boolean hasInvul(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
@ -111,15 +89,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
||||||
@ -137,20 +118,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile);
|
||||||
} else {
|
} else {
|
||||||
entity = entityType.create(world);
|
entity = entityType.create(world);
|
||||||
}
|
}
|
||||||
@ -168,55 +151,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<SoundEvent> getCraftSound(Sound sound) {
|
@Override
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -233,95 +208,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getKey(CraftArt.BukkitToNotch(art).value()).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTablistPacket(PacketEvent event, Function<UUID, Boolean> shouldRemove) {
|
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) event.getPacket().getHandle();
|
|
||||||
|
|
||||||
if (!packet.actions().contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> canKeep = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ClientboundPlayerInfoUpdatePacket.Entry entry : packet.entries()) {
|
|
||||||
if (shouldRemove.apply(entry.profileId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
canKeep.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.size() == packet.entries().size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.isEmpty()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.getPacket().getModifier().write(1, canKeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
if (actions[0] == EnumWrappers.PlayerInfoAction.REMOVE_PLAYER) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
|
||||||
packet.getModifier().write(0, Collections.singletonList(gameProfile.getUUID()));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry entry =
|
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(gameProfile.getUUID(), (GameProfile) gameProfile.getHandle(), nameVisible, 0,
|
|
||||||
GameType.SURVIVAL, Component.literal(displayName), null);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.copyOf(
|
|
||||||
Arrays.stream(actions).map(action -> ClientboundPlayerInfoUpdatePacket.Action.valueOf(action.name()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
|
|
||||||
modifier.write(0, enumSet);
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@ -339,11 +253,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -351,124 +267,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Holder<SoundEvent> createSoundEvent(String minecraftKey) {
|
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvent.createVariableRangeEvent(createMinecraftKey(minecraftKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
||||||
@ -477,46 +302,51 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
|
|
||||||
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R3.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R3.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -531,45 +361,42 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public Object convertInvalidMeta(Object value) {
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
if (value instanceof Frog.Variant) {
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
return getFrogVariant((Frog.Variant) value);
|
Int2ObjectMap<SynchedEntityData.DataItem<?>> dataItems = (Int2ObjectMap<SynchedEntityData.DataItem<?>>) dataItemsField.get(watcher);
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
FriendlyByteBuf serializer = new FriendlyByteBuf(buf);
|
||||||
|
|
||||||
|
for (SynchedEntityData.DataItem dataItem : dataItems.values()) {
|
||||||
|
dataItem.value().write(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Cat.Type) {
|
serializer.writeByte(255);
|
||||||
return getCatVariant((Cat.Type) value);
|
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Art) {
|
@Override
|
||||||
return getArtVariant((Art) value);
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof BlockData) {
|
@Override
|
||||||
return ((CraftBlockData) value).getState();
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
@Override
|
||||||
}
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
private FrogVariant getFrogVariant(Frog.Variant variant) {
|
return registry.getId(CraftArt.BukkitToNotch(type).value());
|
||||||
switch (variant) {
|
|
||||||
case COLD:
|
|
||||||
return FrogVariant.COLD;
|
|
||||||
case WARM:
|
|
||||||
return FrogVariant.WARM;
|
|
||||||
case TEMPERATE:
|
|
||||||
return FrogVariant.TEMPERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatVariant getCatVariant(Cat.Type type) {
|
|
||||||
return BuiltInRegistries.CAT_VARIANT.byId(type.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Holder.Reference<PaintingVariant> getArtVariant(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getHolder(art.ordinal()).get();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,31 +1,18 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_20_R1;
|
package me.libraryaddict.disguise.utilities.reflection.v1_20_R1;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -36,23 +23,12 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
|
||||||
import net.minecraft.world.entity.animal.FrogVariant;
|
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -71,37 +47,36 @@ import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
|||||||
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_20_R1.util.CraftMagicNumbers;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.util.CraftNamespacedKey;
|
import org.bukkit.craftbukkit.v1_20_R1.util.CraftNamespacedKey;
|
||||||
import org.bukkit.entity.Cat;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Sniffer;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
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.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
private Field dataItemsField;
|
||||||
|
|
||||||
|
public ReflectionManager() {
|
||||||
|
for (Field f : SynchedEntityData.class.getDeclaredFields()) {
|
||||||
|
if (Modifier.isStatic(f.getModifiers()) || !Int2ObjectMap.class.isAssignableFrom(f.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
dataItemsField = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasInvul(Entity entity) {
|
public boolean hasInvul(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
@ -112,15 +87,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
||||||
@ -138,20 +116,22 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile);
|
||||||
} else {
|
} else {
|
||||||
entity = entityType.create(world);
|
entity = entityType.create(world);
|
||||||
}
|
}
|
||||||
@ -169,55 +149,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return MobEffect.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<SoundEvent> getCraftSound(Sound sound) {
|
@Override
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -234,95 +206,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getKey(CraftArt.BukkitToNotch(art).value()).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTablistPacket(PacketEvent event, Function<UUID, Boolean> shouldRemove) {
|
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) event.getPacket().getHandle();
|
|
||||||
|
|
||||||
if (!packet.actions().contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> canKeep = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ClientboundPlayerInfoUpdatePacket.Entry entry : packet.entries()) {
|
|
||||||
if (shouldRemove.apply(entry.profileId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
canKeep.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.size() == packet.entries().size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.isEmpty()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.getPacket().getModifier().write(1, canKeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
if (actions[0] == EnumWrappers.PlayerInfoAction.REMOVE_PLAYER) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
|
||||||
packet.getModifier().write(0, Collections.singletonList(gameProfile.getUUID()));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry entry =
|
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(gameProfile.getUUID(), (GameProfile) gameProfile.getHandle(), nameVisible, 0,
|
|
||||||
GameType.SURVIVAL, Component.literal(displayName), null);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.copyOf(
|
|
||||||
Arrays.stream(actions).map(action -> ClientboundPlayerInfoUpdatePacket.Action.valueOf(action.name()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
|
|
||||||
modifier.write(0, enumSet);
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
// Default is 1.0F on EntityLiving
|
// Default is 1.0F on EntityLiving
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
@ -341,11 +252,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
Agent agent = Agent.MINECRAFT;
|
Agent agent = Agent.MINECRAFT;
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -353,124 +266,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Holder<SoundEvent> createSoundEvent(String minecraftKey) {
|
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvent.createVariableRangeEvent(createMinecraftKey(minecraftKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
||||||
@ -479,46 +301,51 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
|
|
||||||
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R1.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R1.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -533,58 +360,42 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public Object convertInvalidMeta(Object value) {
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
if (value instanceof Frog.Variant) {
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
return getFrogVariant((Frog.Variant) value);
|
Int2ObjectMap<SynchedEntityData.DataItem<?>> dataItems = (Int2ObjectMap<SynchedEntityData.DataItem<?>>) dataItemsField.get(watcher);
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
FriendlyByteBuf serializer = new FriendlyByteBuf(buf);
|
||||||
|
|
||||||
|
for (SynchedEntityData.DataItem dataItem : dataItems.values()) {
|
||||||
|
dataItem.value().write(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Cat.Type) {
|
serializer.writeByte(255);
|
||||||
return getCatVariant((Cat.Type) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Art) {
|
return buf;
|
||||||
return getArtVariant((Art) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof BlockData) {
|
|
||||||
return ((CraftBlockData) value).getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Sniffer.State) {
|
|
||||||
return net.minecraft.world.entity.animal.sniffer.Sniffer.State.values()[((Sniffer.State) value).ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrogVariant getFrogVariant(Frog.Variant variant) {
|
|
||||||
switch (variant) {
|
|
||||||
case COLD:
|
|
||||||
return FrogVariant.COLD;
|
|
||||||
case WARM:
|
|
||||||
return FrogVariant.WARM;
|
|
||||||
case TEMPERATE:
|
|
||||||
return FrogVariant.TEMPERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatVariant getCatVariant(Cat.Type type) {
|
|
||||||
return BuiltInRegistries.CAT_VARIANT.byId(type.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Holder.Reference<PaintingVariant> getArtVariant(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getHolder(art.ordinal()).get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getNmsClass(Class cl) {
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
if (Sniffer.State.class.isAssignableFrom(cl)) {
|
return ((CraftPlayer) player).getProfile();
|
||||||
return net.minecraft.world.entity.animal.sniffer.Sniffer.State.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cl;
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.NotchToBukkit(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.BukkitToNotch(type).value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,30 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_20_R2;
|
package me.libraryaddict.disguise.utilities.reflection.v1_20_R2;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -36,25 +22,16 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.HumanoidArm;
|
import net.minecraft.world.entity.HumanoidArm;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
import net.minecraft.world.entity.animal.CatVariant;
|
||||||
import net.minecraft.world.entity.animal.FrogVariant;
|
import net.minecraft.world.entity.animal.FrogVariant;
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.entity.player.ChatVisiblity;
|
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -68,7 +45,9 @@ import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
|
|||||||
import org.bukkit.craftbukkit.v1_20_R2.CraftSound;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftSound;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_20_R2.block.data.CraftBlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftCat;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftFrog;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_20_R2.util.CraftMagicNumbers;
|
||||||
@ -78,32 +57,33 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
import org.bukkit.entity.Frog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Sniffer;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
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.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
private Field dataItemsField;
|
||||||
|
|
||||||
|
public ReflectionManager() {
|
||||||
|
for (Field f : SynchedEntityData.class.getDeclaredFields()) {
|
||||||
|
if (!f.getType().isArray()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
dataItemsField = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasInvul(Entity entity) {
|
public boolean hasInvul(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
@ -114,15 +94,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
||||||
@ -140,22 +123,24 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
ClientInformation information =
|
ClientInformation information =
|
||||||
new ClientInformation("english", 10, ChatVisiblity.FULL, true, 0, HumanoidArm.RIGHT, true, true);
|
new ClientInformation("english", 10, ChatVisiblity.FULL, true, 0, HumanoidArm.RIGHT, true, true);
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle(), information);
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile, information);
|
||||||
} else {
|
} else {
|
||||||
entity = entityType.create(world);
|
entity = entityType.create(world);
|
||||||
}
|
}
|
||||||
@ -173,55 +158,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return BuiltInRegistries.MOB_EFFECT.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<SoundEvent> getCraftSound(Sound sound) {
|
@Override
|
||||||
return CraftSound.bukkitToMinecraftHolder(sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -238,95 +215,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getKey(CraftArt.bukkitToMinecraft(art)).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTablistPacket(PacketEvent event, Function<UUID, Boolean> shouldRemove) {
|
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) event.getPacket().getHandle();
|
|
||||||
|
|
||||||
if (!packet.actions().contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> canKeep = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ClientboundPlayerInfoUpdatePacket.Entry entry : packet.entries()) {
|
|
||||||
if (shouldRemove.apply(entry.profileId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
canKeep.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.size() == packet.entries().size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.isEmpty()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.getPacket().getModifier().write(1, canKeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
if (actions[0] == EnumWrappers.PlayerInfoAction.REMOVE_PLAYER) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
|
||||||
packet.getModifier().write(0, Collections.singletonList(gameProfile.getUUID()));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry entry =
|
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(gameProfile.getUUID(), (GameProfile) gameProfile.getHandle(), nameVisible, 0,
|
|
||||||
GameType.SURVIVAL, Component.literal(displayName), null);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.copyOf(
|
|
||||||
Arrays.stream(actions).map(action -> ClientboundPlayerInfoUpdatePacket.Action.valueOf(action.name()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
|
|
||||||
modifier.write(0, enumSet);
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
// Default is 1.0F on EntityLiving
|
// Default is 1.0F on EntityLiving
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
@ -345,10 +261,12 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -356,124 +274,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.bukkitToMinecraft(sound).getLocation().toString();
|
return CraftSound.bukkitToMinecraft(sound).getLocation().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Holder<SoundEvent> createSoundEvent(String minecraftKey) {
|
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvent.createVariableRangeEvent(createMinecraftKey(minecraftKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
||||||
@ -482,46 +309,51 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
|
|
||||||
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R2.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R2.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -537,57 +369,73 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object convertInvalidMeta(Object value) {
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
if (value instanceof Frog.Variant) {
|
net.minecraft.world.entity.Entity ent = (net.minecraft.world.entity.Entity) getNmsEntity(entity);
|
||||||
return getFrogVariant((Frog.Variant) value);
|
List<SynchedEntityData.DataValue<?>> dataList = ent.getEntityData().getNonDefaultValues();
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Cat.Type) {
|
|
||||||
return getCatVariant((Cat.Type) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Art) {
|
|
||||||
return getArtVariant((Art) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof BlockData) {
|
|
||||||
return ((CraftBlockData) value).getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Sniffer.State) {
|
|
||||||
return net.minecraft.world.entity.animal.sniffer.Sniffer.State.values()[((Sniffer.State) value).ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrogVariant getFrogVariant(Frog.Variant variant) {
|
|
||||||
switch (variant) {
|
|
||||||
case COLD:
|
|
||||||
return FrogVariant.COLD;
|
|
||||||
case WARM:
|
|
||||||
return FrogVariant.WARM;
|
|
||||||
case TEMPERATE:
|
|
||||||
return FrogVariant.TEMPERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (dataList == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CatVariant getCatVariant(Cat.Type type) {
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
return BuiltInRegistries.CAT_VARIANT.byId(type.ordinal());
|
FriendlyByteBuf serializer = new FriendlyByteBuf(buf);
|
||||||
}
|
|
||||||
|
|
||||||
private Holder.Reference<PaintingVariant> getArtVariant(Art art) {
|
dataList.forEach(d -> d.write(serializer));
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getHolder(art.ordinal()).get();
|
serializer.writeByte(255);
|
||||||
|
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getNmsClass(Class cl) {
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
if (Sniffer.State.class.isAssignableFrom(cl)) {
|
return ((CraftPlayer) player).getProfile();
|
||||||
return net.minecraft.world.entity.animal.sniffer.Sniffer.State.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cl;
|
@Override
|
||||||
|
public Cat.Type getCatTypeFromInt(int catType) {
|
||||||
|
Registry<CatVariant> registry = BuiltInRegistries.CAT_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<CatVariant> ref = registry.getHolder(catType).get();
|
||||||
|
|
||||||
|
return CraftCat.CraftType.minecraftToBukkit(ref.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCatVariantAsInt(Cat.Type type) {
|
||||||
|
Registry<CatVariant> registry = BuiltInRegistries.CAT_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftCat.CraftType.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Frog.Variant getFrogVariantFromInt(int frogType) {
|
||||||
|
Registry<FrogVariant> registry = BuiltInRegistries.FROG_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<FrogVariant> ref = registry.getHolder(frogType).get();
|
||||||
|
|
||||||
|
return CraftFrog.CraftVariant.minecraftToBukkit(ref.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFrogVariantAsInt(Frog.Variant type) {
|
||||||
|
Registry<FrogVariant> registry = BuiltInRegistries.FROG_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftFrog.CraftVariant.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.bukkitToMinecraft(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>shared</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,30 +1,17 @@
|
|||||||
package me.libraryaddict.disguise.utilities.reflection.v1_20_R3;
|
package me.libraryaddict.disguise.utilities.reflection.v1_20_R3;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vector3f;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
@ -36,25 +23,16 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.EntityDimensions;
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
import net.minecraft.world.entity.HumanoidArm;
|
import net.minecraft.world.entity.HumanoidArm;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
import net.minecraft.world.entity.animal.CatVariant;
|
||||||
import net.minecraft.world.entity.animal.FrogVariant;
|
import net.minecraft.world.entity.animal.FrogVariant;
|
||||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
import net.minecraft.world.entity.npc.VillagerData;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerType;
|
|
||||||
import net.minecraft.world.entity.player.ChatVisiblity;
|
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -68,7 +46,9 @@ import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
|||||||
import org.bukkit.craftbukkit.v1_20_R3.CraftSound;
|
import org.bukkit.craftbukkit.v1_20_R3.CraftSound;
|
||||||
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftCat;
|
||||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftFrog;
|
||||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_20_R3.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_20_R3.util.CraftMagicNumbers;
|
||||||
@ -78,32 +58,33 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
import org.bukkit.entity.Frog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Sniffer;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.util.EulerAngle;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
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.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
private Field dataItemsField;
|
||||||
|
|
||||||
|
public ReflectionManager() {
|
||||||
|
for (Field f : SynchedEntityData.class.getDeclaredFields()) {
|
||||||
|
if (Modifier.isStatic(f.getModifiers()) || !Int2ObjectMap.class.isAssignableFrom(f.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
dataItemsField = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasInvul(Entity entity) {
|
public boolean hasInvul(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
@ -114,15 +95,18 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIncrementedStateId(Player player) {
|
public int getIncrementedStateId(Player player) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId() {
|
public int getNewEntityId() {
|
||||||
return getNewEntityId(true);
|
return getNewEntityId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNewEntityId(boolean increment) {
|
public int getNewEntityId(boolean increment) {
|
||||||
try {
|
try {
|
||||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("d");
|
||||||
@ -140,13 +124,15 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
return ((CraftPlayer) player).getHandle().connection;
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
|
|
||||||
if (!optional.isPresent()) {
|
if (!optional.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
@ -156,10 +142,10 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
net.minecraft.world.entity.Entity entity;
|
net.minecraft.world.entity.Entity entity;
|
||||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
ClientInformation information =
|
ClientInformation information =
|
||||||
new ClientInformation("english", 10, ChatVisiblity.FULL, true, 0, HumanoidArm.RIGHT, true, true);
|
new ClientInformation("english", 10, ChatVisiblity.FULL, true, 0, HumanoidArm.RIGHT, true, true);
|
||||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle(), information);
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile, information);
|
||||||
} else {
|
} else {
|
||||||
entity = entityType.create(world);
|
entity = entityType.create(world);
|
||||||
}
|
}
|
||||||
@ -174,55 +160,47 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobEffect getMobEffectList(int id) {
|
@Override
|
||||||
return BuiltInRegistries.MOB_EFFECT.byId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
|
||||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(),
|
|
||||||
effect.hasParticles());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
|
||||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AABB getBoundingBox(Entity entity) {
|
public AABB getBoundingBox(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getXBoundingBox(Entity entity) {
|
public double getXBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getYBoundingBox(Entity entity) {
|
public double getYBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getZBoundingBox(Entity entity) {
|
public double getZBoundingBox(Entity entity) {
|
||||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Entity getBukkitEntity(Object nmsEntity) {
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getBukkitItem(Object nmsItem) {
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<SoundEvent> getCraftSound(Sound sound) {
|
@Override
|
||||||
return CraftSound.bukkitToMinecraftHolder(sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
ServerChunkCache chunkSource = world.getChunkSource();
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
@ -239,95 +217,34 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return (ServerEntity) field.get(trackedEntity);
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DedicatedServer getMinecraftServer() {
|
public DedicatedServer getMinecraftServer() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnumArt(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getKey(CraftArt.bukkitToMinecraft(art)).getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
|
||||||
return new BlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
|
||||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTablistPacket(PacketEvent event, Function<UUID, Boolean> shouldRemove) {
|
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) event.getPacket().getHandle();
|
|
||||||
|
|
||||||
if (!packet.actions().contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> canKeep = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ClientboundPlayerInfoUpdatePacket.Entry entry : packet.entries()) {
|
|
||||||
if (shouldRemove.apply(entry.profileId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
canKeep.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.size() == packet.entries().size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canKeep.isEmpty()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.getPacket().getModifier().write(1, canKeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketContainer getTabListPacket(String displayName, WrappedGameProfile gameProfile, boolean nameVisible,
|
|
||||||
EnumWrappers.PlayerInfoAction... actions) {
|
|
||||||
if (actions[0] == EnumWrappers.PlayerInfoAction.REMOVE_PLAYER) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
|
||||||
packet.getModifier().write(0, Collections.singletonList(gameProfile.getUUID()));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry entry =
|
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(gameProfile.getUUID(), (GameProfile) gameProfile.getHandle(), nameVisible, 0,
|
|
||||||
GameType.SURVIVAL, Component.literal(displayName), null);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
StructureModifier<Object> modifier = packet.getModifier();
|
|
||||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> enumSet = EnumSet.copyOf(
|
|
||||||
Arrays.stream(actions).map(action -> ClientboundPlayerInfoUpdatePacket.Action.valueOf(action.name()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
|
|
||||||
modifier.write(0, enumSet);
|
|
||||||
modifier.write(1, Collections.singletonList(entry));
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getNmsEntity(Entity entity) {
|
public Object getNmsEntity(Entity entity) {
|
||||||
return ((CraftEntity) entity).getHandle();
|
return ((CraftEntity) entity).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getPing(Player player) {
|
public double getPing(Player player) {
|
||||||
return player.getPing();
|
return player.getPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float[] getSize(Entity entity) {
|
public float[] getSize(Entity entity) {
|
||||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MinecraftSessionService getMinecraftSessionService() {
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
return getMinecraftServer().getSessionService();
|
return getMinecraftServer().getSessionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Float getSoundModifier(Object entity) {
|
public Float getSoundModifier(Object entity) {
|
||||||
// Default is 1.0F on EntityLiving
|
// Default is 1.0F on EntityLiving
|
||||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
@ -346,10 +263,12 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, callback);
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
((CraftEntity) entity).getHandle().setBoundingBox(
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
@ -357,124 +276,33 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
loc.getZ() + z / 2));
|
loc.getZ() + z / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getSoundCategory(String category) {
|
@Override
|
||||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
public String getSoundString(Sound sound) {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
|
||||||
*
|
|
||||||
* @param slot
|
|
||||||
* @return null if the equipment slot is null
|
|
||||||
*/
|
|
||||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
|
||||||
case OFF_HAND:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
|
||||||
case FEET:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
|
||||||
case LEGS:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
|
||||||
case CHEST:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
|
||||||
case HEAD:
|
|
||||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSoundString(Sound sound) {
|
|
||||||
return CraftSound.bukkitToMinecraft(sound).getLocation().toString();
|
return CraftSound.bukkitToMinecraft(sound).getLocation().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<?> convertOptional(Object val) {
|
@Override
|
||||||
if (val instanceof BlockPosition) {
|
|
||||||
BlockPosition pos = (BlockPosition) val;
|
|
||||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
} else if (val instanceof WrappedBlockData) {
|
|
||||||
Object obj = ((WrappedBlockData) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof ItemStack) {
|
|
||||||
Object obj = getNmsItem((ItemStack) val);
|
|
||||||
return Optional.of(obj);
|
|
||||||
} else if (val instanceof WrappedChatComponent) {
|
|
||||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.of(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f convertVec3(Object object) {
|
|
||||||
if (object instanceof Vector3F) {
|
|
||||||
Vector3F vector3F = (Vector3F) object;
|
|
||||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
|
||||||
} else if (object instanceof EulerAngle) {
|
|
||||||
EulerAngle eulerAngle = (EulerAngle) object;
|
|
||||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
|
||||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(String name) {
|
public Material getMaterial(String name) {
|
||||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getItemName(Material material) {
|
public String getItemName(Material material) {
|
||||||
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
|
||||||
return CraftItemStack.asNMSCopy(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession, int level) {
|
|
||||||
VillagerType nmsVillagerType = BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
|
||||||
VillagerProfession nmsVillagerProfession =
|
|
||||||
BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
|
||||||
|
|
||||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerType getVillagerType(Villager.Type type) {
|
|
||||||
return BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
|
||||||
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject,
|
|
||||||
T metaItem) {
|
|
||||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Holder<SoundEvent> createSoundEvent(String minecraftKey) {
|
|
||||||
return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvent.createVariableRangeEvent(createMinecraftKey(minecraftKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation createMinecraftKey(String name) {
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
return new ResourceLocation(name);
|
return new ResourceLocation(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getVec3D(Vector vector) {
|
@Override
|
||||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
return net.minecraft.world.entity.EntityType.byString(
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerEntityType(NamespacedKey key) {
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, FeatureFlagSet.of());
|
||||||
@ -483,46 +311,51 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(Object entityTypes) {
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
|
|
||||||
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEntityTypeId(EntityType entityType) {
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
return getEntityTypeId(getEntityType(entityType));
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEntityType(NamespacedKey name) {
|
public Object getEntityType(NamespacedKey name) {
|
||||||
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getNmsEntityPose(String enumPose) {
|
@Override
|
||||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCombinedIdByBlockData(BlockData data) {
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
BlockState state = ((CraftBlockData) data).getState();
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
return Block.getId(state);
|
return Block.getId(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
return Block.getId(block.defaultBlockState());
|
return Block.getId(block.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockData getBlockDataByCombinedId(int id) {
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
return CraftBlockData.fromData(Block.stateById(id));
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack getItemStackByCombinedId(int id) {
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerLevel getWorldServer(World w) {
|
public ServerLevel getWorldServer(World w) {
|
||||||
return ((CraftWorld) w).getHandle();
|
return ((CraftWorld) w).getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R3.inventory.CraftMetaItem$SerializableMeta");
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R3.inventory.CraftMetaItem$SerializableMeta");
|
||||||
@ -537,58 +370,74 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public Object convertInvalidMeta(Object value) {
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
if (value instanceof Frog.Variant) {
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
return getFrogVariant((Frog.Variant) value);
|
Int2ObjectMap<SynchedEntityData.DataItem<?>> dataItems = (Int2ObjectMap<SynchedEntityData.DataItem<?>>) dataItemsField.get(watcher);
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
FriendlyByteBuf serializer = new FriendlyByteBuf(buf);
|
||||||
|
|
||||||
|
for (SynchedEntityData.DataItem dataItem : dataItems.values()) {
|
||||||
|
dataItem.value().write(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof Cat.Type) {
|
serializer.writeByte(255);
|
||||||
return getCatVariant((Cat.Type) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Art) {
|
return buf;
|
||||||
return getArtVariant((Art) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof BlockData) {
|
|
||||||
return ((CraftBlockData) value).getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Sniffer.State) {
|
|
||||||
return net.minecraft.world.entity.animal.sniffer.Sniffer.State.values()[((Sniffer.State) value).ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FrogVariant getFrogVariant(Frog.Variant variant) {
|
|
||||||
switch (variant) {
|
|
||||||
case COLD:
|
|
||||||
return FrogVariant.COLD;
|
|
||||||
case WARM:
|
|
||||||
return FrogVariant.WARM;
|
|
||||||
case TEMPERATE:
|
|
||||||
return FrogVariant.TEMPERATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatVariant getCatVariant(Cat.Type type) {
|
|
||||||
return BuiltInRegistries.CAT_VARIANT.byId(type.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Holder.Reference<PaintingVariant> getArtVariant(Art art) {
|
|
||||||
return BuiltInRegistries.PAINTING_VARIANT.getHolder(art.ordinal()).get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getNmsClass(Class cl) {
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
if (Sniffer.State.class.isAssignableFrom(cl)) {
|
return ((CraftPlayer) player).getProfile();
|
||||||
return net.minecraft.world.entity.animal.sniffer.Sniffer.State.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cl;
|
@Override
|
||||||
|
public Cat.Type getCatTypeFromInt(int catType) {
|
||||||
|
Registry<CatVariant> registry = BuiltInRegistries.CAT_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<CatVariant> ref = registry.getHolder(catType).get();
|
||||||
|
|
||||||
|
return CraftCat.CraftType.minecraftToBukkit(ref.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCatVariantAsInt(Cat.Type type) {
|
||||||
|
Registry<CatVariant> registry = BuiltInRegistries.CAT_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftCat.CraftType.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Frog.Variant getFrogVariantFromInt(int frogType) {
|
||||||
|
Registry<FrogVariant> registry = BuiltInRegistries.FROG_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<FrogVariant> ref = registry.getHolder(frogType).get();
|
||||||
|
|
||||||
|
return CraftFrog.CraftVariant.minecraftToBukkit(ref.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFrogVariantAsInt(Frog.Variant type) {
|
||||||
|
Registry<FrogVariant> registry = BuiltInRegistries.FROG_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftFrog.CraftVariant.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<PaintingVariant> registry = BuiltInRegistries.PAINTING_VARIANT;
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.bukkitToMinecraft(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
113
nms/v1_20_R4/pom.xml
Normal file
113
nms/v1_20_R4/pom.xml
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>nms</artifactId>
|
||||||
|
<groupId>LibsDisguises</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>v1_20_R4</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
<spigot.version>1.20.6-R0.1-SNAPSHOT</spigot.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>${spigot.version}</version>
|
||||||
|
<classifier>remapped-mojang</classifier>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>${spigot.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
<artifactId>fastutil</artifactId>
|
||||||
|
<version>8.5.8</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>6.0.54</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>datafixerupper</artifactId>
|
||||||
|
<version>7.0.14</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>brigadier</artifactId>
|
||||||
|
<version>1.2.9</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
<artifactId>specialsource-maven-plugin</artifactId>
|
||||||
|
<version>2.0.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>remap</goal>
|
||||||
|
</goals>
|
||||||
|
<id>remap-obf</id>
|
||||||
|
<configuration>
|
||||||
|
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
|
||||||
|
<reverse>true</reverse>
|
||||||
|
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
|
||||||
|
<remappedClassifierName>remapped-mojang</remappedClassifierName>
|
||||||
|
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>remap</goal>
|
||||||
|
</goals>
|
||||||
|
<id>remap-spigot</id>
|
||||||
|
<configuration>
|
||||||
|
<inputFile>target/${project.build.finalName}-remapped-mojang.jar</inputFile>
|
||||||
|
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
|
||||||
|
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
|
||||||
|
<remappedClassifierName>remapped-spigot</remappedClassifierName>
|
||||||
|
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,484 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.reflection.v1_20_R4;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import com.mojang.serialization.DataResult;
|
||||||
|
import com.mojang.serialization.JavaOps;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.component.DataComponentPatch;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
|
import net.minecraft.server.level.ChunkMap;
|
||||||
|
import net.minecraft.server.level.ClientInformation;
|
||||||
|
import net.minecraft.server.level.ServerChunkCache;
|
||||||
|
import net.minecraft.server.level.ServerEntity;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import net.minecraft.world.entity.EntityDimensions;
|
||||||
|
import net.minecraft.world.entity.HumanoidArm;
|
||||||
|
import net.minecraft.world.entity.animal.CatVariant;
|
||||||
|
import net.minecraft.world.entity.animal.FrogVariant;
|
||||||
|
import net.minecraft.world.entity.animal.WolfVariant;
|
||||||
|
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||||
|
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||||
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import org.bukkit.Art;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.CraftArt;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.CraftSound;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.block.data.CraftBlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftCat;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftFrog;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftWolf;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R4.util.CraftNamespacedKey;
|
||||||
|
import org.bukkit.entity.Cat;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Frog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||||
|
private Field dataItemsField;
|
||||||
|
|
||||||
|
public ReflectionManager() {
|
||||||
|
for (Field f : SynchedEntityData.class.getDeclaredFields()) {
|
||||||
|
if (!f.getType().isArray()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.setAccessible(true);
|
||||||
|
dataItemsField = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasInvul(Entity entity) {
|
||||||
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
|
if (nmsEntity instanceof net.minecraft.world.entity.LivingEntity) {
|
||||||
|
return nmsEntity.invulnerableTime > 0;
|
||||||
|
} else {
|
||||||
|
return nmsEntity.isInvulnerableTo(nmsEntity.damageSources().generic());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIncrementedStateId(Player player) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewEntityId() {
|
||||||
|
return getNewEntityId(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewEntityId(boolean increment) {
|
||||||
|
try {
|
||||||
|
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
||||||
|
entityCounter.setAccessible(true);
|
||||||
|
AtomicInteger atomicInteger = (AtomicInteger) entityCounter.get(null);
|
||||||
|
if (increment) {
|
||||||
|
return atomicInteger.incrementAndGet();
|
||||||
|
} else {
|
||||||
|
return atomicInteger.get();
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||||
|
return ((CraftPlayer) player).getHandle().connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||||
|
Optional<net.minecraft.world.entity.EntityType<?>> optional =
|
||||||
|
net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ENGLISH));
|
||||||
|
|
||||||
|
if (!optional.isPresent()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||||
|
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||||
|
net.minecraft.world.entity.Entity entity;
|
||||||
|
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||||
|
GameProfile gameProfile = new GameProfile(new UUID(0, 0), "Steve");
|
||||||
|
ClientInformation information =
|
||||||
|
new ClientInformation("english", 10, ChatVisiblity.FULL, true, 0, HumanoidArm.RIGHT, true, true);
|
||||||
|
entity = new ServerPlayer(getMinecraftServer(), world, gameProfile, information);
|
||||||
|
} else {
|
||||||
|
entity = entityType.create(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for paper being 2 smart 4 me
|
||||||
|
entity.setPos(1.0, 1.0, 1.0);
|
||||||
|
entity.setPos(0.0, 0.0, 0.0);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AABB getBoundingBox(Entity entity) {
|
||||||
|
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getXBoundingBox(Entity entity) {
|
||||||
|
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getYBoundingBox(Entity entity) {
|
||||||
|
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getZBoundingBox(Entity entity) {
|
||||||
|
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||||
|
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity getBukkitEntity(Object nmsEntity) {
|
||||||
|
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getBukkitItem(Object nmsItem) {
|
||||||
|
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||||
|
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
|
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||||
|
ServerChunkCache chunkSource = world.getChunkSource();
|
||||||
|
ChunkMap chunkMap = chunkSource.chunkMap;
|
||||||
|
Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = chunkMap.entityMap;
|
||||||
|
ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
|
||||||
|
if (trackedEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Field field = ChunkMap.TrackedEntity.class.getDeclaredField("b");
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
return (ServerEntity) field.get(trackedEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DedicatedServer getMinecraftServer() {
|
||||||
|
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getNmsEntity(Entity entity) {
|
||||||
|
return ((CraftEntity) entity).getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getPing(Player player) {
|
||||||
|
return player.getPing();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] getSize(Entity entity) {
|
||||||
|
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||||
|
return new float[]{dimensions.width(), nmsEntity.getEyeHeight()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MinecraftSessionService getMinecraftSessionService() {
|
||||||
|
return getMinecraftServer().getSessionService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Float getSoundModifier(Object entity) {
|
||||||
|
// Default is 1.0F on EntityLiving
|
||||||
|
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||||
|
return 0.0f;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Method method = net.minecraft.world.entity.LivingEntity.class.getDeclaredMethod("fe");
|
||||||
|
method.setAccessible(true);
|
||||||
|
|
||||||
|
return (Float) method.invoke(entity);
|
||||||
|
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||||
|
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||||
|
Location loc = entity.getLocation();
|
||||||
|
((CraftEntity) entity).getHandle().setBoundingBox(
|
||||||
|
new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2,
|
||||||
|
loc.getZ() + z / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSoundString(Sound sound) {
|
||||||
|
return CraftSound.bukkitToMinecraft(sound).getLocation().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getMaterial(String name) {
|
||||||
|
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getItemName(Material material) {
|
||||||
|
return BuiltInRegistries.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation createMinecraftKey(String name) {
|
||||||
|
return new ResourceLocation(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||||
|
return net.minecraft.world.entity.EntityType.byString(
|
||||||
|
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object registerEntityType(NamespacedKey key) {
|
||||||
|
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||||
|
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0, 0, FeatureFlagSet.of());
|
||||||
|
Registry.register(BuiltInRegistries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(key), newEntity);
|
||||||
|
newEntity.getDescriptionId();
|
||||||
|
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEntityTypeId(Object entityTypes) {
|
||||||
|
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||||
|
|
||||||
|
return BuiltInRegistries.ENTITY_TYPE.getId(entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEntityTypeId(EntityType entityType) {
|
||||||
|
return getEntityTypeId(getEntityType(entityType));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getEntityType(NamespacedKey name) {
|
||||||
|
return BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCombinedIdByBlockData(BlockData data) {
|
||||||
|
BlockState state = ((CraftBlockData) data).getState();
|
||||||
|
return Block.getId(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
|
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||||
|
return Block.getId(block.defaultBlockState());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockData getBlockDataByCombinedId(int id) {
|
||||||
|
return CraftBlockData.fromData(Block.stateById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemStackByCombinedId(int id) {
|
||||||
|
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerLevel getWorldServer(World w) {
|
||||||
|
return ((CraftWorld) w).getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||||
|
try {
|
||||||
|
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_20_R4.inventory.CraftMetaItem$SerializableMeta");
|
||||||
|
Method deserialize = aClass.getDeclaredMethod("deserialize", Map.class);
|
||||||
|
Object itemMeta = deserialize.invoke(null, meta);
|
||||||
|
|
||||||
|
return (ItemMeta) itemMeta;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public ByteBuf getDataWatcherValues(Entity entity) {
|
||||||
|
SynchedEntityData watcher = ((CraftEntity) entity).getHandle().getEntityData();
|
||||||
|
SynchedEntityData.DataItem[] dataItems = (SynchedEntityData.DataItem[]) dataItemsField.get(watcher);
|
||||||
|
|
||||||
|
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
|
||||||
|
RegistryFriendlyByteBuf serializer = RegistryFriendlyByteBuf.decorator(this.getMinecraftServer().registryAccess()).apply(buf);
|
||||||
|
|
||||||
|
for (SynchedEntityData.DataItem dataItem : dataItems) {
|
||||||
|
dataItem.value().write(serializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
serializer.writeByte(255);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameProfile getMCGameProfile(Player player) {
|
||||||
|
return ((CraftPlayer) player).getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cat.Type getCatTypeFromInt(int catType) {
|
||||||
|
Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT);
|
||||||
|
|
||||||
|
Holder.Reference<CatVariant> ref = registry.getHolder(catType).get();
|
||||||
|
|
||||||
|
return CraftCat.CraftType.minecraftHolderToBukkit(registry.getHolder(catType).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCatVariantAsInt(Cat.Type type) {
|
||||||
|
Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT);
|
||||||
|
|
||||||
|
return registry.getId(CraftCat.CraftType.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Frog.Variant getFrogVariantFromInt(int frogType) {
|
||||||
|
Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT);
|
||||||
|
|
||||||
|
Holder.Reference<FrogVariant> ref = registry.getHolder(frogType).get();
|
||||||
|
|
||||||
|
return CraftFrog.CraftVariant.minecraftHolderToBukkit(registry.getHolder(frogType).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFrogVariantAsInt(Frog.Variant type) {
|
||||||
|
Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT);
|
||||||
|
|
||||||
|
return registry.getId(CraftFrog.CraftVariant.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Art getPaintingFromInt(int paintingId) {
|
||||||
|
Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT);
|
||||||
|
|
||||||
|
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
|
||||||
|
|
||||||
|
return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPaintingAsInt(Art type) {
|
||||||
|
Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT);
|
||||||
|
|
||||||
|
return registry.getId(CraftArt.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Wolf.Variant getWolfVariantFromInt(int wolfVariant) {
|
||||||
|
Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT);
|
||||||
|
|
||||||
|
Holder.Reference<WolfVariant> ref = registry.getHolder(wolfVariant).get();
|
||||||
|
|
||||||
|
return CraftWolf.CraftVariant.minecraftHolderToBukkit(registry.getHolder(wolfVariant).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWolfVariantAsInt(Wolf.Variant type) {
|
||||||
|
Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT);
|
||||||
|
|
||||||
|
return registry.getId(CraftWolf.CraftVariant.bukkitToMinecraft(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object serializeComponents(ItemStack itemStack) {
|
||||||
|
if (itemStack == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
net.minecraft.world.item.ItemStack item = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
DataComponentPatch comps = item.getComponentsPatch();
|
||||||
|
|
||||||
|
if (comps == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataResult<Object> cond = DataComponentPatch.CODEC.encodeStart(JavaOps.INSTANCE, comps);
|
||||||
|
|
||||||
|
return cond.result().orElse(null);
|
||||||
|
}
|
||||||
|
}
|
@ -98,20 +98,16 @@
|
|||||||
<includes>
|
<includes>
|
||||||
<include>**</include>
|
<include>**</include>
|
||||||
</includes>
|
</includes>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/**/v*/**</exclude>
|
||||||
|
</excludes>
|
||||||
</filter>
|
</filter>
|
||||||
</filters>
|
</filters>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>net.kyori:*</include>
|
|
||||||
<include>LibsDisguises:*</include>
|
<include>LibsDisguises:*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>net.kyori</pattern>
|
|
||||||
<shadedPattern>libsdisg.shaded.net.kyori</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -119,14 +115,8 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>${lombok.version}</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dmulloy2</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -134,11 +124,6 @@
|
|||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
@ -150,45 +135,17 @@
|
|||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-chat</artifactId>
|
<artifactId>bungeecord-chat</artifactId>
|
||||||
<version>${bungeecord-chat.version}</version>
|
<version>${bungeecord-chat.version}</version>
|
||||||
<optional>true</optional>
|
<scope>provided</scope>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
|
||||||
<version>${adventure-minimessage.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
|
||||||
<version>${adventure-text.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-api</artifactId>
|
|
||||||
<version>${adventure-text.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<!-- Tests -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter</artifactId>
|
|
||||||
<version>${junit-jupiter.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--NMS Packages-->
|
<!--NMS Packages-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>LibsDisguises</groupId>
|
||||||
|
<artifactId>minimessage</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>LibsDisguises</groupId>
|
<groupId>LibsDisguises</groupId>
|
||||||
<artifactId>shared</artifactId>
|
<artifactId>shared</artifactId>
|
||||||
@ -268,6 +225,14 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>LibsDisguises</groupId>
|
||||||
|
<artifactId>v1_20_R4</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<classifier>remapped-spigot</classifier>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<!-- Libraries -->
|
<!-- Libraries -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.unimi.dsi</groupId>
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package me.libraryaddict.disguise;
|
package me.libraryaddict.disguise;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
@ -81,8 +80,8 @@ public class DisguiseAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addGameProfile(String profileName, WrappedGameProfile gameProfile) {
|
public static void addGameProfile(String profileName, UserProfile gameProfile) {
|
||||||
DisguiseUtilities.addGameProfile(profileName, gameProfile);
|
DisguiseUtilities.addUserProfile(profileName, gameProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRawCustomDisguise(String disguiseName) {
|
public static String getRawCustomDisguise(String disguiseName) {
|
||||||
@ -145,20 +144,18 @@ public class DisguiseAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(entity);
|
for (EntityData data : ReflectionManager.getEntityWatcher(entity)) {
|
||||||
|
MetaIndex index = MetaIndex.getMetaIndex(watcher.getClass(), data.getIndex());
|
||||||
for (WrappedWatchableObject obj : dataWatcher.getWatchableObjects()) {
|
|
||||||
MetaIndex index = MetaIndex.getMetaIndex(watcher.getClass(), obj.getIndex());
|
|
||||||
|
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.getDefault() == obj.getValue() || index.getDefault() == obj.getRawValue()) {
|
if (index.getDefault() == data.getValue()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
watcher.setUnsafeData(index, obj.getValue());
|
watcher.setUnsafeData(index, data.getValue());
|
||||||
|
|
||||||
// Update the meta for 0, otherwise boolean be weird
|
// Update the meta for 0, otherwise boolean be weird
|
||||||
if (index == MetaIndex.ENTITY_META) {
|
if (index == MetaIndex.ENTITY_META) {
|
||||||
|
@ -211,6 +211,7 @@ public class DisguiseConfig {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static BarColor bossBarColor = BarColor.GREEN;
|
private static BarColor bossBarColor = BarColor.GREEN;
|
||||||
|
@Getter
|
||||||
private static PermissionDefault commandVisibility = PermissionDefault.TRUE;
|
private static PermissionDefault commandVisibility = PermissionDefault.TRUE;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -286,7 +287,10 @@ public class DisguiseConfig {
|
|||||||
private static List<String> disabledMethods = new ArrayList<>();
|
private static List<String> disabledMethods = new ArrayList<>();
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static boolean neverUpdateProtocolLib;
|
private static boolean neverUpdatePacketEvents;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private static boolean removeDisguiseBlockPlace, removeDisguiseBlockBreak;
|
||||||
|
|
||||||
public static boolean isArmorstandsName() {
|
public static boolean isArmorstandsName() {
|
||||||
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
||||||
@ -440,10 +444,6 @@ public class DisguiseConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PermissionDefault getCommandVisibility() {
|
|
||||||
return commandVisibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCommandVisibility(PermissionDefault permissionDefault) {
|
public static void setCommandVisibility(PermissionDefault permissionDefault) {
|
||||||
if (permissionDefault == null || getCommandVisibility() == permissionDefault) {
|
if (permissionDefault == null || getCommandVisibility() == permissionDefault) {
|
||||||
return;
|
return;
|
||||||
@ -557,10 +557,51 @@ public class DisguiseConfig {
|
|||||||
TranslateType.refreshTranslations();
|
TranslateType.refreshTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadConfig() {
|
private static ConfigLoader getConfig() {
|
||||||
ConfigLoader configLoader = new ConfigLoader();
|
ConfigLoader configLoader = new ConfigLoader();
|
||||||
configLoader.saveMissingConfigs();
|
configLoader.saveMissingConfigs();
|
||||||
|
|
||||||
|
return configLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigLoader loadPreConfig() {
|
||||||
|
ConfigLoader configLoader = getConfig();
|
||||||
|
|
||||||
|
loadPreConfig(configLoader);
|
||||||
|
|
||||||
|
return configLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only called for DisguiseMethods.class so we know what the defaults of disguise parameters are, eg, tall disguises visible
|
||||||
|
*/
|
||||||
|
private static ConfigurationSection loadPreConfig(ConfigLoader configLoader) {
|
||||||
|
ConfigurationSection config = configLoader.load();
|
||||||
|
|
||||||
|
setAddEntityAnimations(config.getBoolean("AddEntityAnimations"));
|
||||||
|
setDisguiseCloneExpire(config.getInt("DisguiseCloneExpire"));
|
||||||
|
setDisguiseEntityExpire(config.getInt("DisguiseEntityExpire"));
|
||||||
|
setDynamicExpiry(config.getBoolean("DynamicExpiry"));
|
||||||
|
setHideDisguisedPlayers(config.getBoolean("HideDisguisedPlayersFromTab"));
|
||||||
|
setPlayerHideArmor(config.getBoolean("PlayerHideArmor"));
|
||||||
|
setTallSelfDisguises(config.getBoolean("TallSelfDisguises"));
|
||||||
|
setRandomDisguises(config.getBoolean("RandomDisguiseOptions"));
|
||||||
|
setViewDisguises(config.getBoolean("ViewSelfDisguises"));
|
||||||
|
setViewSelfDisguisesDefault(config.getBoolean("ViewSelfDisguisesDefault"));
|
||||||
|
setSelfDisguisesSoundsReplaced(config.getBoolean("HearSelfDisguise"));
|
||||||
|
setShowDisguisedPlayersInTab(config.getBoolean("ShowPlayerDisguisesInTab"));
|
||||||
|
setVelocitySent(config.getBoolean("SendVelocity"));
|
||||||
|
|
||||||
|
setHideHeldItemFromSelf(config.getBoolean("RemoveHeldItem"));
|
||||||
|
setHideArmorFromSelf(config.getBoolean("RemoveArmor"));
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadConfig() {
|
||||||
|
ConfigLoader configLoader = getConfig();
|
||||||
|
ConfigurationSection config = loadPreConfig(configLoader);
|
||||||
|
|
||||||
loadModdedDisguiseTypes();
|
loadModdedDisguiseTypes();
|
||||||
|
|
||||||
File skinsFolder = new File(LibsDisguises.getInstance().getDataFolder(), "Skins");
|
File skinsFolder = new File(LibsDisguises.getInstance().getDataFolder(), "Skins");
|
||||||
@ -582,11 +623,8 @@ public class DisguiseConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationSection config = configLoader.load();
|
|
||||||
|
|
||||||
PacketsManager.setViewDisguisesListener(true);
|
PacketsManager.setViewDisguisesListener(true);
|
||||||
|
|
||||||
setAddEntityAnimations(config.getBoolean("AddEntityAnimations"));
|
|
||||||
setAnimationPacketsEnabled(config.getBoolean("PacketsEnabled.Animation"));
|
setAnimationPacketsEnabled(config.getBoolean("PacketsEnabled.Animation"));
|
||||||
setCatDyeable(config.getBoolean("DyeableCat"));
|
setCatDyeable(config.getBoolean("DyeableCat"));
|
||||||
setCollectPacketsEnabled(config.getBoolean("PacketsEnabled.Collect"));
|
setCollectPacketsEnabled(config.getBoolean("PacketsEnabled.Collect"));
|
||||||
@ -597,16 +635,10 @@ public class DisguiseConfig {
|
|||||||
setPvPTimer(config.getDouble("PvPTimer"));
|
setPvPTimer(config.getDouble("PvPTimer"));
|
||||||
setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguisesWhenAttacked"));
|
setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguisesWhenAttacked"));
|
||||||
setDisguiseBlownWhenAttacking(config.getBoolean("BlowDisguisesWhenAttacking"));
|
setDisguiseBlownWhenAttacking(config.getBoolean("BlowDisguisesWhenAttacking"));
|
||||||
setDisguiseCloneExpire(config.getInt("DisguiseCloneExpire"));
|
|
||||||
setDisguiseEntityExpire(config.getInt("DisguiseEntityExpire"));
|
|
||||||
setDynamicExpiry(config.getBoolean("DynamicExpiry"));
|
|
||||||
setEntityStatusPacketsEnabled(config.getBoolean("PacketsEnabled.EntityStatus"));
|
setEntityStatusPacketsEnabled(config.getBoolean("PacketsEnabled.EntityStatus"));
|
||||||
setEquipmentPacketsEnabled(config.getBoolean("PacketsEnabled.Equipment"));
|
setEquipmentPacketsEnabled(config.getBoolean("PacketsEnabled.Equipment"));
|
||||||
setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplicitDisguises"));
|
setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplicitDisguises"));
|
||||||
setHideArmorFromSelf(config.getBoolean("RemoveArmor"));
|
|
||||||
setHidingCreativeEquipmentFromSelf(config.getBoolean("RemoveCreativeEquipment"));
|
setHidingCreativeEquipmentFromSelf(config.getBoolean("RemoveCreativeEquipment"));
|
||||||
setHideDisguisedPlayers(config.getBoolean("HideDisguisedPlayersFromTab"));
|
|
||||||
setHideHeldItemFromSelf(config.getBoolean("RemoveHeldItem"));
|
|
||||||
setHorseSaddleable(config.getBoolean("SaddleableHorse"));
|
setHorseSaddleable(config.getBoolean("SaddleableHorse"));
|
||||||
setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath"));
|
setKeepDisguiseOnPlayerDeath(config.getBoolean("KeepDisguises.PlayerDeath"));
|
||||||
setLlamaCarpetable(config.getBoolean("CarpetableLlama"));
|
setLlamaCarpetable(config.getBoolean("CarpetableLlama"));
|
||||||
@ -622,38 +654,32 @@ public class DisguiseConfig {
|
|||||||
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
|
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
|
||||||
setNameOfPlayerShownAboveDisguise(config.getBoolean("ShowNamesAboveDisguises"));
|
setNameOfPlayerShownAboveDisguise(config.getBoolean("ShowNamesAboveDisguises"));
|
||||||
setNameAboveDisguise(config.getString("NameAboveDisguise"));
|
setNameAboveDisguise(config.getString("NameAboveDisguise"));
|
||||||
setPlayerHideArmor(config.getBoolean("PlayerHideArmor"));
|
|
||||||
setRetaliationCombat(config.getBoolean("RetaliationCombat"));
|
setRetaliationCombat(config.getBoolean("RetaliationCombat"));
|
||||||
setSaveGameProfiles(config.getBoolean("SaveGameProfiles"));
|
setSaveGameProfiles(config.getBoolean("SaveGameProfiles"));
|
||||||
setSavePlayerDisguises(config.getBoolean("SaveDisguises.Players"));
|
setSavePlayerDisguises(config.getBoolean("SaveDisguises.Players"));
|
||||||
setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities"));
|
setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities"));
|
||||||
setSelfDisguisesSoundsReplaced(config.getBoolean("HearSelfDisguise"));
|
|
||||||
setSheepDyeable(config.getBoolean("DyeableSheep"));
|
setSheepDyeable(config.getBoolean("DyeableSheep"));
|
||||||
setShowDisguisedPlayersInTab(config.getBoolean("ShowPlayerDisguisesInTab"));
|
|
||||||
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
|
|
||||||
setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true));
|
setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true));
|
||||||
setUUIDGeneratedVersion(config.getInt("UUIDVersion"));
|
setUUIDGeneratedVersion(config.getInt("UUIDVersion"));
|
||||||
setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange"));
|
setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange"));
|
||||||
setUpdateGameProfiles(config.getBoolean("UpdateGameProfiles"));
|
setUpdateGameProfiles(config.getBoolean("UpdateGameProfiles"));
|
||||||
setUseTranslations(config.getBoolean("Translations"));
|
setUseTranslations(config.getBoolean("Translations"));
|
||||||
setVelocitySent(config.getBoolean("SendVelocity"));
|
|
||||||
setViewDisguises(config.getBoolean("ViewSelfDisguises"));
|
|
||||||
setWarnScoreboardConflict(config.getBoolean("Scoreboard.WarnConflict"));
|
setWarnScoreboardConflict(config.getBoolean("Scoreboard.WarnConflict"));
|
||||||
setCopyPlayerTeamInfo(config.getBoolean("Scoreboard.CopyPlayerTeamInfo"));
|
setCopyPlayerTeamInfo(config.getBoolean("Scoreboard.CopyPlayerTeamInfo"));
|
||||||
setWitherSkullPacketsEnabled(config.getBoolean("PacketsEnabled.WitherSkull"));
|
setWitherSkullPacketsEnabled(config.getBoolean("PacketsEnabled.WitherSkull"));
|
||||||
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
||||||
setTablistRemoveDelay(config.getInt("TablistRemoveDelay"));
|
setTablistRemoveDelay(config.getInt("TablistRemoveDelay"));
|
||||||
setAutoUpdate(config.getBoolean("AutoUpdate"));
|
setAutoUpdate(config.getBoolean("AutoUpdate"));
|
||||||
setTallSelfDisguises(config.getBoolean("TallSelfDisguises"));
|
|
||||||
setOverrideCustomNames(config.getBoolean("OverrideCustomNames"));
|
setOverrideCustomNames(config.getBoolean("OverrideCustomNames"));
|
||||||
setRandomDisguises(config.getBoolean("RandomDisguiseOptions"));
|
|
||||||
setSaveUserPreferences(config.getBoolean("SaveUserPreferences"));
|
setSaveUserPreferences(config.getBoolean("SaveUserPreferences"));
|
||||||
setPlayerDisguisesSkinExpiresMove(config.getInt("PlayerDisguisesTablistExpiresMove"));
|
setPlayerDisguisesSkinExpiresMove(config.getInt("PlayerDisguisesTablistExpiresMove"));
|
||||||
setViewSelfDisguisesDefault(config.getBoolean("ViewSelfDisguisesDefault"));
|
|
||||||
setContactMojangServers(config.getBoolean("ContactMojangServers"));
|
setContactMojangServers(config.getBoolean("ContactMojangServers"));
|
||||||
setDisguiseRadiusMax(config.getInt("DisguiseRadiusMax"));
|
setDisguiseRadiusMax(config.getInt("DisguiseRadiusMax"));
|
||||||
setRandomUUIDS(config.getBoolean("RandomUUIDs"));
|
setRandomUUIDS(config.getBoolean("RandomUUIDs"));
|
||||||
|
setRemoveDisguiseBlockBreak(config.getBoolean("UndisguiseOnBlockBreak"));
|
||||||
|
setRemoveDisguiseBlockPlace(config.getBoolean("UndisguiseOnBlockPlace"));
|
||||||
String apiKey = config.getString("MineSkinAPIKey");
|
String apiKey = config.getString("MineSkinAPIKey");
|
||||||
|
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
|
||||||
|
|
||||||
if (apiKey != null && apiKey.matches("[a-zA-Z\\d]{8,}")) {
|
if (apiKey != null && apiKey.matches("[a-zA-Z\\d]{8,}")) {
|
||||||
DisguiseUtilities.getMineSkinAPI().setApiKey(apiKey);
|
DisguiseUtilities.getMineSkinAPI().setApiKey(apiKey);
|
||||||
@ -708,16 +734,16 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setDisabledDisguises(
|
setDisabledDisguises(
|
||||||
config.getStringList("DisabledDisguises").stream().map(s -> DisguiseType.valueOf(s.toUpperCase(Locale.ROOT)))
|
config.getStringList("DisabledDisguises").stream().map(s -> DisguiseType.valueOf(s.toUpperCase(Locale.ENGLISH)))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning("Cannot load 'DisabledDisguises' in features.yml, invalid disguise types provided?");
|
DisguiseUtilities.getLogger().warning("Cannot load 'DisabledDisguises' in features.yml, invalid disguise types provided?");
|
||||||
}
|
}
|
||||||
|
|
||||||
setDisabledMethods(
|
setDisabledMethods(
|
||||||
config.getStringList("DisabledMethods").stream().map(s -> s.toLowerCase(Locale.ROOT)).collect(Collectors.toList()));
|
config.getStringList("DisabledMethods").stream().map(s -> s.toLowerCase(Locale.ENGLISH)).collect(Collectors.toList()));
|
||||||
|
|
||||||
setNeverUpdateProtocolLib(config.getBoolean("NeverUpdateProtocolLib", false));
|
setNeverUpdatePacketEvents(config.getBoolean("NeverUpdatePacketEvents", config.getBoolean("NeverUpdateProtocolLib", false)));
|
||||||
|
|
||||||
String seeCommands = config.getString("Permissions.SeeCommands");
|
String seeCommands = config.getString("Permissions.SeeCommands");
|
||||||
PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands);
|
PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands);
|
||||||
@ -854,7 +880,7 @@ public class DisguiseConfig {
|
|||||||
requireMessage = DisguiseUtilities.translateAlternateColorCodes(requireMessage);
|
requireMessage = DisguiseUtilities.translateAlternateColorCodes(requireMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModdedEntity entity = new ModdedEntity(null, name, living, mod, version, requireMessage, 0);
|
ModdedEntity entity = new ModdedEntity(null, null, name, living, mod, version, requireMessage, 0);
|
||||||
|
|
||||||
if (ModdedManager.getModdedEntity(name) != null) {
|
if (ModdedManager.getModdedEntity(name) != null) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger()
|
||||||
@ -1021,46 +1047,52 @@ public class DisguiseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setAnimationPacketsEnabled(boolean enabled) {
|
public static void setAnimationPacketsEnabled(boolean enabled) {
|
||||||
if (enabled != isAnimationPacketsEnabled()) {
|
if (enabled == isAnimationPacketsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
animationPacketsEnabled = enabled;
|
animationPacketsEnabled = enabled;
|
||||||
|
|
||||||
PacketsManager.setupMainPacketsListener();
|
PacketsManager.setupMainPacketsListener();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCollectPacketsEnabled(boolean enabled) {
|
public static void setCollectPacketsEnabled(boolean enabled) {
|
||||||
if (enabled != isCollectPacketsEnabled()) {
|
if (enabled == isCollectPacketsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
collectPacketsEnabled = enabled;
|
collectPacketsEnabled = enabled;
|
||||||
|
|
||||||
PacketsManager.setupMainPacketsListener();
|
PacketsManager.setupMainPacketsListener();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void setEntityStatusPacketsEnabled(boolean enabled) {
|
public static void setEntityStatusPacketsEnabled(boolean enabled) {
|
||||||
if (enabled != isEntityStatusPacketsEnabled()) {
|
if (enabled == isEntityStatusPacketsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entityStatusPacketsEnabled = enabled;
|
entityStatusPacketsEnabled = enabled;
|
||||||
|
|
||||||
PacketsManager.setupMainPacketsListener();
|
PacketsManager.setupMainPacketsListener();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void setEquipmentPacketsEnabled(boolean enabled) {
|
public static void setEquipmentPacketsEnabled(boolean enabled) {
|
||||||
if (enabled != isEquipmentPacketsEnabled()) {
|
if (enabled == isEquipmentPacketsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
equipmentPacketsEnabled = enabled;
|
equipmentPacketsEnabled = enabled;
|
||||||
|
|
||||||
PacketsManager.setupMainPacketsListener();
|
PacketsManager.setupMainPacketsListener();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the plugin to hide self disguises armor from theirselves
|
* Set the plugin to hide self disguises armor from theirselves
|
||||||
*/
|
*/
|
||||||
public static void setHideArmorFromSelf(boolean hideArmor) {
|
public static void setHideArmorFromSelf(boolean hideArmor) {
|
||||||
if (hidingArmorFromSelf != hideArmor) {
|
|
||||||
hidingArmorFromSelf = hideArmor;
|
hidingArmorFromSelf = hideArmor;
|
||||||
|
|
||||||
PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
|
updateInventoryListener();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1068,28 +1100,34 @@ public class DisguiseConfig {
|
|||||||
* self disguise
|
* self disguise
|
||||||
*/
|
*/
|
||||||
public static void setHideHeldItemFromSelf(boolean hideHelditem) {
|
public static void setHideHeldItemFromSelf(boolean hideHelditem) {
|
||||||
if (hidingHeldItemFromSelf != hideHelditem) {
|
|
||||||
hidingHeldItemFromSelf = hideHelditem;
|
hidingHeldItemFromSelf = hideHelditem;
|
||||||
|
|
||||||
PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
|
updateInventoryListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updateInventoryListener() {
|
||||||
|
PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMiscDisguisesForLivingEnabled(boolean enabled) {
|
public static void setMiscDisguisesForLivingEnabled(boolean enabled) {
|
||||||
if (enabled != isMiscDisguisesForLivingEnabled()) {
|
if (enabled == isMiscDisguisesForLivingEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
miscDisguisesForLivingEnabled = enabled;
|
miscDisguisesForLivingEnabled = enabled;
|
||||||
|
|
||||||
PacketsManager.setupMainPacketsListener();
|
PacketsManager.setupMainPacketsListener();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void setMovementPacketsEnabled(boolean enabled) {
|
public static void setMovementPacketsEnabled(boolean enabled) {
|
||||||
if (enabled != isMovementPacketsEnabled()) {
|
if (enabled == isMovementPacketsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
movementPacketsEnabled = enabled;
|
movementPacketsEnabled = enabled;
|
||||||
|
|
||||||
PacketsManager.setupMainPacketsListener();
|
PacketsManager.setupMainPacketsListener();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the disguises play sounds when hurt
|
* Set if the disguises play sounds when hurt
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.libraryaddict.disguise;
|
package me.libraryaddict.disguise;
|
||||||
|
|
||||||
|
import io.github.retrooper.packetevents.util.SpigotReflectionUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
||||||
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||||
@ -38,6 +40,7 @@ import me.libraryaddict.disguise.utilities.reflection.ClassMappings;
|
|||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.sounds.SoundManager;
|
import me.libraryaddict.disguise.utilities.sounds.SoundManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.updates.PacketEventsUpdater;
|
||||||
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
|
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
|
||||||
import me.libraryaddict.disguise.utilities.watchers.CompileMethods;
|
import me.libraryaddict.disguise.utilities.watchers.CompileMethods;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -54,13 +57,23 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class LibsDisguises extends JavaPlugin {
|
public class LibsDisguises extends JavaPlugin {
|
||||||
|
/**
|
||||||
|
* -- GETTER --
|
||||||
|
* External APIs shouldn't actually need this instance. DisguiseAPI should be enough to handle most cases.
|
||||||
|
*
|
||||||
|
* @return The instance of this plugin
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
private static LibsDisguises instance;
|
private static LibsDisguises instance;
|
||||||
|
@Getter
|
||||||
private DisguiseListener listener;
|
private DisguiseListener listener;
|
||||||
private String buildNumber;
|
private String buildNumber;
|
||||||
@Getter
|
@Getter
|
||||||
@ -72,55 +85,58 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private PlayerSkinHandler skinHandler;
|
private PlayerSkinHandler skinHandler;
|
||||||
private DisguiseCommandConfig commandConfig;
|
private DisguiseCommandConfig commandConfig;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
private boolean packetEventsUpdateDownloaded;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
try {
|
try {
|
||||||
if (instance != null || !Bukkit.getServer().getWorlds().isEmpty() || !Bukkit.getOnlinePlayers().isEmpty()) {
|
boolean hasInstanceAlready = instance != null;
|
||||||
|
|
||||||
|
if (hasInstanceAlready || !Bukkit.getServer().getWorlds().isEmpty() || !Bukkit.getOnlinePlayers().isEmpty()) {
|
||||||
reloaded = true;
|
reloaded = true;
|
||||||
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
|
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle reloads gracefully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("packetevents");
|
||||||
|
|
||||||
if (plugin == null || DisguiseUtilities.isProtocolLibOutdated()) {
|
// Skipping the isPacketEventsOutdated check cos DisguiseConfig wouldn't be loaded
|
||||||
if (DisguiseConfig.isNeverUpdateProtocolLib()) {
|
if (plugin == null /*|| DisguiseUtilities.isPacketEventsOutdated()*/) {
|
||||||
|
// I don't think anyone will ever see this plugin message, DisguiseConfig isn't loaded at this point
|
||||||
|
if (DisguiseConfig.isNeverUpdatePacketEvents()) {
|
||||||
getLogger().warning(
|
getLogger().warning(
|
||||||
"Defined in plugins/LibsDisguises/configs/sanity.yml, you have requested that Lib's Disguises never updates or " +
|
"Defined in plugins/LibsDisguises/configs/sanity.yml, you have requested that Lib's Disguises never updates or " +
|
||||||
"installs ProtocolLib. " + "Please do not report any issues with this plugin.");
|
"installs PacketEvents. Please do not report any issues with this plugin.");
|
||||||
} else {
|
} else {
|
||||||
String reason;
|
String reason = getPacketEventsFailedReason(plugin);
|
||||||
|
|
||||||
if (plugin == null) {
|
|
||||||
reason = "ProtocolLib not installed";
|
|
||||||
} else if (!plugin.isEnabled()) {
|
|
||||||
reason = "ProtocolLib is not enabled";
|
|
||||||
} else if (DisguiseUtilities.isProtocolLibOutdated()) {
|
|
||||||
reason = "ProtocolLib is outdated";
|
|
||||||
} else {
|
|
||||||
reason = "Lib's Disguises couldn't process ProtocolLib properly";
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().warning(
|
getLogger().warning(
|
||||||
"An issue occured when trying to load ProtocolLib: " + reason + ". Lib's Disguises will attempt to update it.");
|
"An issue occured when trying to load PacketEvents: " + reason + ". Lib's Disguises will attempt to update it.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File dest = DisguiseUtilities.updateProtocolLib();
|
PacketEventsUpdater updater = new PacketEventsUpdater();
|
||||||
|
boolean attempt = updater.doUpdate();
|
||||||
|
|
||||||
if (plugin == null) {
|
if (!attempt) {
|
||||||
getLogger().info("ProtocolLib downloaded and stuck in plugins folder! Now trying to load it!");
|
getLogger().severe(
|
||||||
plugin = Bukkit.getPluginManager().loadPlugin(dest);
|
"PacketEvents download has failed, please install PacketEvents manually from https://www.spigotmc" +
|
||||||
|
".org/resources/packetevents-api.80279/");
|
||||||
|
} else if (plugin == null) {
|
||||||
|
getLogger().info("PacketEvents downloaded and stuck in plugins folder! Now trying to load it!");
|
||||||
|
plugin = Bukkit.getPluginManager().loadPlugin(updater.getDestination());
|
||||||
plugin.onLoad();
|
plugin.onLoad();
|
||||||
|
|
||||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||||
} else {
|
} else {
|
||||||
getLogger().severe("Please restart the server to complete the ProtocolLib update!");
|
getLogger().severe("Please restart the server to complete the PacketEvents update!");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().severe("Looks like ProtocolLib's site may be down! Try download it manually from https://ci.dmulloy2" +
|
getLogger().severe(
|
||||||
".net/job/ProtocolLib/");
|
"Looks like PacketEvents's site may be down! Try download it manually from https://www.spigotmc" +
|
||||||
|
".org/resources/packetevents-api.80279/");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,15 +145,16 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
|
getLogger().severe(
|
||||||
"plugin will continue to load, but it will look like a mugging victim");
|
"Oh dear, you seem to be using CraftBukkit. Please upgrade to use Spigot or Paper instead! This plugin will continue " +
|
||||||
|
"to load, but it will look like a mugging victim");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that Forge/Hybrid is unsupported
|
// Note that Forge/Hybrid is unsupported
|
||||||
// Previously was supported but changes in both LD and nms has made it unsustainable
|
// Previously was supported but changes in both LD and nms has made it unsustainable
|
||||||
// The time and complexibility it would take is far too high for the amount of usage it would receive.
|
// The time and complexibility it would take is far too high for the amount of usage it would receive.
|
||||||
// Any extra income from sales would never cover the time spent implementing this.
|
// Any extra income from sales would never cover the time spent implementing this.
|
||||||
if (Bukkit.getVersion().toLowerCase().matches(".*(arclight|mohist|magma).*")) {
|
if (Bukkit.getVersion().toLowerCase(Locale.ENGLISH).matches(".*(arclight|mohist|magma).*")) {
|
||||||
getLogger().severe(
|
getLogger().severe(
|
||||||
"Lib's Disguises will not work correctly on Forge/Hybrid servers, due to complexibility and time commitment there is " +
|
"Lib's Disguises will not work correctly on Forge/Hybrid servers, due to complexibility and time commitment there is " +
|
||||||
"no support for this. Do not report any issues to Lib's Disguises.");
|
"no support for this. Do not report any issues to Lib's Disguises.");
|
||||||
@ -145,7 +162,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
commandConfig = new DisguiseCommandConfig();
|
commandConfig = new DisguiseCommandConfig();
|
||||||
|
|
||||||
if (!reloaded) {
|
if (!hasInstanceAlready && (isReleaseBuild() || LibsPremium.getPaidInformation() != null || !LibsPremium.isPremium())) {
|
||||||
commandConfig.load();
|
commandConfig.load();
|
||||||
}
|
}
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
@ -165,10 +182,114 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
if (reloaded) {
|
if (isReloaded()) {
|
||||||
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
|
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle reloads gracefully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runWarnings();
|
||||||
|
updateOldDisguisesYaml();
|
||||||
|
loadYamlWarnVirus();
|
||||||
|
logInfo();
|
||||||
|
|
||||||
|
DisguiseConfig.loadInternalConfig();
|
||||||
|
|
||||||
|
LibsPremium.check(getDescription().getVersion(), getFile());
|
||||||
|
|
||||||
|
someMoreLogging();
|
||||||
|
|
||||||
|
if (ReflectionManager.getVersion() == null) {
|
||||||
|
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is intended for " +
|
||||||
|
StringUtils.join(Arrays.stream(NmsVersion.values()).filter(v -> v != NmsVersion.UNSUPPORTED)
|
||||||
|
.map(v -> String.join(", ", v.getSupportedVersions())).collect(Collectors.toList()), ", ") + "!");
|
||||||
|
getPluginLoader().disablePlugin(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
startOutdatedPacketevents();
|
||||||
|
|
||||||
|
// If this is a release build, even if jenkins build..
|
||||||
|
if (isReleaseBuild()) {
|
||||||
|
// If downloaded from spigot, forcibly set release build to true
|
||||||
|
if (LibsPremium.getUserID().matches("\\d+")) {
|
||||||
|
DisguiseConfig.setUsingReleaseBuilds(true);
|
||||||
|
}
|
||||||
|
// Otherwise leave it untouched as they might've just happened to hit a dev build, which is a release build
|
||||||
|
} else {
|
||||||
|
DisguiseConfig.setUsingReleaseBuilds(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
runBackendStuff();
|
||||||
|
|
||||||
|
DisguiseConfig.loadConfig();
|
||||||
|
|
||||||
|
registerListeners();
|
||||||
|
registerCommands();
|
||||||
|
|
||||||
|
new MetricsInitalizer();
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
try {
|
||||||
|
if (isNumberedBuild() && DisguiseConfig.isAutoUpdate()) {
|
||||||
|
getUpdateChecker().doUpdate();
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
getLogger().severe("Lib's Disguises couldn't update itself");
|
||||||
|
}
|
||||||
|
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runBackendStuff() {
|
||||||
|
ClassMappings.loadMappingsCache(getDataFolder());
|
||||||
|
|
||||||
|
if (SpigotReflectionUtil.VERSION == null) {
|
||||||
|
SpigotReflectionUtil.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReflectionManager.init();
|
||||||
|
|
||||||
|
PacketsManager.init();
|
||||||
|
DisguiseUtilities.init();
|
||||||
|
|
||||||
|
new SoundManager().load();
|
||||||
|
|
||||||
|
ReflectionManager.registerValues();
|
||||||
|
DisguiseParser.createDefaultMethods();
|
||||||
|
|
||||||
|
ParamInfoManager.getParamInfoSoundGroup().recalculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
PacketsManager.addPacketListeners();
|
||||||
|
|
||||||
|
listener = new DisguiseListener(this);
|
||||||
|
skinHandler = new PlayerSkinHandler();
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().registerEvents(getSkinHandler(), LibsDisguises.getInstance());
|
||||||
|
|
||||||
|
if (NmsVersion.v1_18.isSupported()) {
|
||||||
|
Bukkit.getPluginManager().registerEvents(new DisguiseListener1_18(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisguiseUtilities.isRunningPaper()) {
|
||||||
|
Bukkit.getPluginManager().registerEvents(new PaperDisguiseListener(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String getPacketEventsFailedReason(Plugin plugin) {
|
||||||
|
if (plugin == null) {
|
||||||
|
return "PacketEvents not installed";
|
||||||
|
} else if (!plugin.isEnabled()) {
|
||||||
|
return "PacketEvents is not enabled";
|
||||||
|
} else if (DisguiseUtilities.isPacketEventsOutdated()) {
|
||||||
|
return "PacketEvents is outdated";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Lib's Disguises couldn't access PacketEvents properly";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runWarnings() {
|
||||||
if (Bukkit.getVersion().contains("(MC: 1.17)")) {
|
if (Bukkit.getVersion().contains("(MC: 1.17)")) {
|
||||||
getLogger().severe("Please update from MC 1.17! You should be using 1.17.1!");
|
getLogger().severe("Please update from MC 1.17! You should be using 1.17.1!");
|
||||||
}
|
}
|
||||||
@ -187,10 +308,13 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
|
getLogger().severe(
|
||||||
"plugin will continue to load, but it will look like a mugging victim");
|
"Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This plugin will continue to load, " +
|
||||||
|
"but it will look like a mugging victim");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateOldDisguisesYaml() {
|
||||||
File disguiseFile = new File(getDataFolder(), "configs/disguises.yml");
|
File disguiseFile = new File(getDataFolder(), "configs/disguises.yml");
|
||||||
|
|
||||||
if (!disguiseFile.exists()) {
|
if (!disguiseFile.exists()) {
|
||||||
@ -204,7 +328,9 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
saveResource("configs/disguises.yml", false);
|
saveResource("configs/disguises.yml", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadYamlWarnVirus() throws IOException {
|
||||||
YamlConfiguration pluginYml = ReflectionManager.getPluginYAML(getFile());
|
YamlConfiguration pluginYml = ReflectionManager.getPluginYAML(getFile());
|
||||||
buildNumber = StringUtils.stripToNull(pluginYml.getString("build-number"));
|
buildNumber = StringUtils.stripToNull(pluginYml.getString("build-number"));
|
||||||
buildDate = StringUtils.stripToNull(pluginYml.getString("build-date"));
|
buildDate = StringUtils.stripToNull(pluginYml.getString("build-date"));
|
||||||
@ -215,10 +341,16 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
if (fileCount != expected) {
|
if (fileCount != expected) {
|
||||||
getLogger().severe("Lib's Disguises may be infected with malware, there were " + (fileCount - expected) +
|
getLogger().severe("Lib's Disguises may be infected with malware, there were " + (fileCount - expected) +
|
||||||
" unknown files injected into the jar. Please redownload from a trusted source such as SpigotMC. If this warning " +
|
" unknown files injected into the jar. Please redownload from a trusted source such as SpigotMC. If this warning " +
|
||||||
"shows even after updating, try https://www.spigotmc.org/resources/spigot-anti-malware.64982/ otherwise if that " +
|
"shows even after updating, try https://www.spigotmc.org/resources/spigot-anti-malware.64982/ but you will likely " +
|
||||||
"doesn't help then please contact libraryaddict on discord https://discord.gg/J5XRqYX");
|
"need to reinstall all your plugins, jars, etc as just one infected plugin will infect everything else when it loads.");
|
||||||
|
getLogger().severe(
|
||||||
|
"This normally happens when a server owner is tricked into adding third party plugins. Please note that Lib's " +
|
||||||
|
"Disguises is only detecting this and doesn't know what plugins are infected, only that Lib's Disguises itself " +
|
||||||
|
"has been infected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logInfo() {
|
||||||
getLogger().info("File Name: " + getFile().getName());
|
getLogger().info("File Name: " + getFile().getName());
|
||||||
|
|
||||||
String nmsPackageName = ReflectionManager.getNmsPackage();
|
String nmsPackageName = ReflectionManager.getNmsPackage();
|
||||||
@ -227,22 +359,18 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
nmsPackageName = "{Not package relocated}";
|
nmsPackageName = "{Not package relocated}";
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info(
|
getLogger().info("Discovered nms version: (Package: " + nmsPackageName + ") (LD: " + ReflectionManager.getVersion() + ") (MC: " +
|
||||||
"Discovered nms version: (Package: " + nmsPackageName + ") (LD: " + ReflectionManager.getVersion() + ") (MC: " +
|
|
||||||
ReflectionManager.getMinecraftVersion() + ")");
|
ReflectionManager.getMinecraftVersion() + ")");
|
||||||
|
|
||||||
getLogger().info("Jenkins Build: " + (isNumberedBuild() ? "#" : "") + getBuildNo());
|
getLogger().info("Jenkins Build: " + (isNumberedBuild() ? "#" : "") + getBuildNo());
|
||||||
|
|
||||||
getLogger().info("Build Date: " + buildDate);
|
getLogger().info("Build Date: " + buildDate);
|
||||||
|
}
|
||||||
|
|
||||||
DisguiseConfig.loadInternalConfig();
|
private void someMoreLogging() {
|
||||||
|
|
||||||
LibsPremium.check(getDescription().getVersion(), getFile());
|
|
||||||
|
|
||||||
if (!LibsPremium.isPremium()) {
|
if (!LibsPremium.isPremium()) {
|
||||||
getLogger().info(
|
getLogger().info(
|
||||||
"You are running the free version, commands limited to non-players and operators. (Console," + " Command " +
|
"You are running the free version, commands limited to non-players and operators. (Console, Command Blocks, Admins)");
|
||||||
"Blocks, Admins)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a message so people are more aware
|
// Add a message so people are more aware
|
||||||
@ -251,66 +379,22 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
"Config 'TallSelfDisguises' is set to 'false', LD will hide oversized disguises from self disguise. https://www" +
|
"Config 'TallSelfDisguises' is set to 'false', LD will hide oversized disguises from self disguise. https://www" +
|
||||||
".spigotmc.org/wiki/lib-s-disguises-faq/#tall-disguises-self-disguises");
|
".spigotmc.org/wiki/lib-s-disguises-faq/#tall-disguises-self-disguises");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReflectionManager.getVersion() == null) {
|
|
||||||
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " + "intended for " +
|
|
||||||
StringUtils.join(Arrays.stream(NmsVersion.values()).filter(v -> v != NmsVersion.UNSUPPORTED)
|
|
||||||
.map(v -> String.join(", ", v.getSupportedVersions())).collect(Collectors.toList()), ", ") + "!");
|
|
||||||
getPluginLoader().disablePlugin(this);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DisguiseConfig.isNeverUpdateProtocolLib() && DisguiseUtilities.isProtocolLibOutdated()) {
|
private void startOutdatedPacketevents() {
|
||||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
if (!DisguiseConfig.isNeverUpdatePacketEvents() && DisguiseUtilities.isPacketEventsOutdated()) {
|
||||||
String version = Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
|
String requiredPacketEvents = PacketEventsUpdater.getMinimumPacketEventsVersion();
|
||||||
|
String version = Bukkit.getPluginManager().getPlugin("packetevents").getDescription().getVersion();
|
||||||
|
|
||||||
BukkitRunnable runnable = createProtocolLibOutdatedRunnable(version, requiredProtocolLib);
|
BukkitRunnable runnable = createPacketEventsOutdatedRunnable(version, requiredPacketEvents);
|
||||||
runnable.run();
|
runnable.run();
|
||||||
runnable.runTaskTimer(this, 20, 10 * 60 * 20);
|
runnable.runTaskTimer(this, 20, 10 * 60 * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a release build, even if jenkins build..
|
PacketEventsUpdater.doShadedWarning();
|
||||||
if (isReleaseBuild()) {
|
|
||||||
// If downloaded from spigot, forcibly set release build to true
|
|
||||||
if (LibsPremium.getUserID().matches("\\d+")) {
|
|
||||||
DisguiseConfig.setUsingReleaseBuilds(true);
|
|
||||||
}
|
|
||||||
// Otherwise leave it untouched as they might've just happened to hit a dev build, which is a release build
|
|
||||||
} else {
|
|
||||||
DisguiseConfig.setUsingReleaseBuilds(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassMappings.loadMappingsCache(getDataFolder());
|
|
||||||
|
|
||||||
ReflectionManager.init();
|
|
||||||
|
|
||||||
PacketsManager.init();
|
|
||||||
DisguiseUtilities.init();
|
|
||||||
|
|
||||||
new SoundManager().load();
|
|
||||||
|
|
||||||
ReflectionManager.registerValues();
|
|
||||||
DisguiseParser.createDefaultMethods();
|
|
||||||
|
|
||||||
ParamInfoManager.getParamInfoSoundGroup().recalculate();
|
|
||||||
|
|
||||||
DisguiseConfig.loadConfig();
|
|
||||||
|
|
||||||
PacketsManager.addPacketListeners();
|
|
||||||
|
|
||||||
listener = new DisguiseListener(this);
|
|
||||||
skinHandler = new PlayerSkinHandler();
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(getSkinHandler(), LibsDisguises.getInstance());
|
|
||||||
|
|
||||||
if (NmsVersion.v1_18.isSupported()) {
|
|
||||||
Bukkit.getPluginManager().registerEvents(new DisguiseListener1_18(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DisguiseUtilities.isRunningPaper()) {
|
|
||||||
Bukkit.getPluginManager().registerEvents(new PaperDisguiseListener(), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCommands() {
|
||||||
registerCommand("libsdisguises", new LibsDisguisesCommand());
|
registerCommand("libsdisguises", new LibsDisguisesCommand());
|
||||||
registerCommand("disguise", new DisguiseCommand());
|
registerCommand("disguise", new DisguiseCommand());
|
||||||
registerCommand("undisguise", new UndisguiseCommand());
|
registerCommand("undisguise", new UndisguiseCommand());
|
||||||
@ -334,23 +418,10 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
registerCommand("grabhead", new GrabHeadCommand());
|
registerCommand("grabhead", new GrabHeadCommand());
|
||||||
|
|
||||||
unregisterCommands(false);
|
unregisterCommands(false);
|
||||||
|
|
||||||
new MetricsInitalizer();
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
try {
|
|
||||||
if (isNumberedBuild() && DisguiseConfig.isAutoUpdate()) {
|
|
||||||
getUpdateChecker().doUpdate();
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
getLogger().severe("Failed to even do a forced update");
|
|
||||||
}
|
|
||||||
|
|
||||||
throw throwable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private BukkitRunnable createProtocolLibOutdatedRunnable(String version, String requiredProtocolLib) {
|
private BukkitRunnable createPacketEventsOutdatedRunnable(String version, String requiredPacketEvents) {
|
||||||
return new BukkitRunnable() {
|
return new BukkitRunnable() {
|
||||||
private int timesRun;
|
private int timesRun;
|
||||||
|
|
||||||
@ -358,17 +429,16 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
getLogger().severe("!! May I have your attention please !!");
|
getLogger().severe("!! May I have your attention please !!");
|
||||||
|
|
||||||
if (DisguiseUtilities.isProtocollibUpdateDownloaded()) {
|
if (isPacketEventsUpdateDownloaded()) {
|
||||||
getLogger().severe(
|
getLogger().severe(
|
||||||
"An update for ProtocolLib has been downloaded and will be installed when the server restarts. When possible, " +
|
"An update for PacketEvents has been downloaded and will be installed when the server restarts. When possible, " +
|
||||||
"please restart " + "the server. Lib's Disguises may not work correctly until you do so.");
|
"please restart the server. Lib's Disguises may not work correctly until you do so.");
|
||||||
} else {
|
} else {
|
||||||
getLogger().severe(
|
getLogger().severe(
|
||||||
"Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " +
|
"Update your PacketEvents! You are running " + version + " but the minimum version you should be on is " +
|
||||||
requiredProtocolLib + "!");
|
requiredPacketEvents + "!");
|
||||||
getLogger().severe(
|
getLogger().severe("https://www.spigotmc.org/resources/packetevents-api.80279/");
|
||||||
"https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
|
getLogger().severe("Or! Use /ld packetevents - To have Lib's Disguises download the latest release from Modrinth");
|
||||||
getLogger().severe("Or! Use /ld protocollib - To update to the latest development build");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timesRun++ > 0) {
|
if (timesRun++ > 0) {
|
||||||
@ -457,25 +527,4 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
command.setTabCompleter((TabCompleter) executioner);
|
command.setTabCompleter((TabCompleter) executioner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads the config with new config options.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void reload() {
|
|
||||||
DisguiseConfig.loadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DisguiseListener getListener() {
|
|
||||||
return listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* External APIs shouldn't actually need this instance. DisguiseAPI should be enough to handle most cases.
|
|
||||||
*
|
|
||||||
* @return The instance of this plugin
|
|
||||||
*/
|
|
||||||
public static LibsDisguises getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
@ -13,6 +13,7 @@ import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
|
|||||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
|
||||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
|
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
@ -22,7 +23,7 @@ import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
|||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.libraryaddict.disguise.utilities.updates.PacketEventsUpdater;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -80,12 +81,12 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isNotPremium(CommandSender sender) {
|
protected boolean isNotPremium(CommandSender sender) {
|
||||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
String requiredPacketEvents = PacketEventsUpdater.getMinimumPacketEventsVersion();
|
||||||
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
|
String version = Bukkit.getPluginManager().getPlugin("packetevents").getDescription().getVersion();
|
||||||
|
|
||||||
if (!DisguiseConfig.isNeverUpdateProtocolLib() && DisguiseUtilities.isProtocolLibOutdated() &&
|
if (!DisguiseConfig.isNeverUpdatePacketEvents() && DisguiseUtilities.isPacketEventsOutdated() &&
|
||||||
sender.hasPermission("libsdisguises.update")) {
|
sender.hasPermission("libsdisguises.update")) {
|
||||||
DisguiseUtilities.sendProtocolLibUpdateMessage(sender, version, requiredProtocolLib);
|
DisguiseUtilities.sendPacketEventsUpdateMessage(sender, version, requiredPacketEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already sent the message, assign after the previous
|
// Already sent the message, assign after the previous
|
||||||
@ -155,7 +156,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
for (WatcherMethod method : methods) {
|
for (WatcherMethod method : methods) {
|
||||||
String arg = allArgs[i];
|
String arg = allArgs[i];
|
||||||
|
|
||||||
if (!method.getName().equalsIgnoreCase(arg)) {
|
if (!method.getMappedName().equalsIgnoreCase(arg)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,13 +182,14 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
String methodName = null;
|
String methodName = null;
|
||||||
|
|
||||||
if (allArgs.length == startsAt) {
|
if (allArgs.length == startsAt) {
|
||||||
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK || disguisePerm.getType() == DisguiseType.BLOCK_DISPLAY) {
|
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK || disguisePerm.getType() == DisguiseType.BLOCK_DISPLAY ||
|
||||||
info = ParamInfoManager.getParamInfoItemBlock();
|
MinecartWatcher.class.isAssignableFrom(disguisePerm.getWatcherClass())) {
|
||||||
|
info = ParamInfoManager.getParamInfo(WrappedBlockState.class);
|
||||||
methodName = "setBlock";
|
methodName = "setBlock";
|
||||||
} else if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM || disguisePerm.getType() == DisguiseType.ITEM_DISPLAY) {
|
} else if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM || disguisePerm.getType() == DisguiseType.ITEM_DISPLAY) {
|
||||||
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
||||||
methodName = "setItemStack";
|
methodName = "setItemStack";
|
||||||
} else if (disguisePerm.getType() == DisguiseType.ITEM_FRAME) {
|
} else if (disguisePerm.getType() == DisguiseType.ITEM_FRAME || disguisePerm.getType() == DisguiseType.GLOW_ITEM_FRAME) {
|
||||||
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
||||||
methodName = "setItem";
|
methodName = "setItem";
|
||||||
} else if (disguisePerm.getType() == DisguiseType.PAINTING) {
|
} else if (disguisePerm.getType() == DisguiseType.PAINTING) {
|
||||||
@ -207,7 +209,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
|
|
||||||
// Enderman can't hold non-blocks
|
// Enderman can't hold non-blocks
|
||||||
if (disguisePerm.getType() == DisguiseType.ENDERMAN && prevArg.equalsIgnoreCase("setItemInMainHand")) {
|
if (disguisePerm.getType() == DisguiseType.ENDERMAN && prevArg.equalsIgnoreCase("setItemInMainHand")) {
|
||||||
info = ParamInfoManager.getParamInfoItemBlock();
|
info = ParamInfoManager.getParamInfo(WrappedBlockState.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +218,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
Collection<String> wantToUse = null;
|
Collection<String> wantToUse = null;
|
||||||
|
|
||||||
// If there is a list of default values
|
// If there is a list of default values
|
||||||
if (info.hasValues()) {
|
if (info.hasTabCompletion()) {
|
||||||
wantToUse = info.getEnums(currentArg);
|
wantToUse = info.getEnums(currentArg);
|
||||||
} else if (info.isParam(String.class)) {
|
} else if (info.isParam(String.class)) {
|
||||||
wantToUse = new ArrayList<>();
|
wantToUse = new ArrayList<>();
|
||||||
@ -253,12 +255,12 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
if (addMethods) {
|
if (addMethods) {
|
||||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(disguisePerm.getWatcherClass())) {
|
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(disguisePerm.getWatcherClass())) {
|
||||||
if (!perms.isAllowedDisguise(disguisePerm, Collections.singletonList(method.getName())) ||
|
if (!perms.isAllowedDisguise(disguisePerm, Collections.singletonList(method.getMappedName())) ||
|
||||||
!method.isUsable(disguisePerm.getType())) {
|
method.isHidden(disguisePerm.getType())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs.add(method.getName());
|
tabs.add(method.getMappedName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import me.libraryaddict.disguise.commands.libsdisguises.LDChangelog;
|
|||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDCommand;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDCommand;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDConfig;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDConfig;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDCount;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDCount;
|
||||||
|
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugDisguiseLoop;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugMineSkin;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugMineSkin;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugPlayer;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugPlayer;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDHelp;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDHelp;
|
||||||
@ -16,7 +17,7 @@ import me.libraryaddict.disguise.commands.libsdisguises.LDPermTest;
|
|||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDReload;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDReload;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDScoreboard;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDScoreboard;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdate;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdate;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdateProtocolLib;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdatePacketEvents;
|
||||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUploadLogs;
|
import me.libraryaddict.disguise.commands.libsdisguises.LDUploadLogs;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
@ -49,8 +50,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||||||
getCommands().add(new LDMetaInfo());
|
getCommands().add(new LDMetaInfo());
|
||||||
getCommands().add(new LDDebugPlayer());
|
getCommands().add(new LDDebugPlayer());
|
||||||
getCommands().add(new LDUploadLogs());
|
getCommands().add(new LDUploadLogs());
|
||||||
getCommands().add(new LDUpdateProtocolLib());
|
getCommands().add(new LDUpdatePacketEvents());
|
||||||
getCommands().add(new LDDebugMineSkin());
|
getCommands().add(new LDDebugMineSkin());
|
||||||
|
getCommands().add(new LDDebugDisguiseLoop());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||||
|
@ -12,7 +12,6 @@ import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
|||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -80,8 +79,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
|
|
||||||
Collections.sort(classes);
|
Collections.sort(classes);
|
||||||
|
|
||||||
LibsMsg.DRADIUS_ENTITIES.send(sender,
|
LibsMsg.DRADIUS_ENTITIES.send(sender, StringUtils.join(classes, LibsMsg.DRADIUS_JOINER.getRaw()));
|
||||||
ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,4 +18,8 @@ public interface LDCommand {
|
|||||||
void onCommand(CommandSender sender, String[] args);
|
void onCommand(CommandSender sender, String[] args);
|
||||||
|
|
||||||
LibsMsg getHelp();
|
LibsMsg getHelp();
|
||||||
|
|
||||||
|
default boolean isEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,125 @@
|
|||||||
|
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 22/05/2021.
|
||||||
|
*/
|
||||||
|
public class LDDebugDisguiseLoop implements LDCommand {
|
||||||
|
@Override
|
||||||
|
public List<String> getTabComplete() {
|
||||||
|
return Collections.singletonList("disguiseloop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender) {
|
||||||
|
return sender.isOp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermission() {
|
||||||
|
return "libsdisguises.disguise";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return !LibsDisguises.getInstance().isNumberedBuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage(ChatColor.RED +
|
||||||
|
"Must be a player to use this command, if you're seeing this then you clearly don't know what this command is for and " +
|
||||||
|
"wouldn't benefit from using it.");
|
||||||
|
return;
|
||||||
|
} else if (args.length != 2 || !args[1].equalsIgnoreCase("agree")) {
|
||||||
|
sender.sendMessage(ChatColor.RED +
|
||||||
|
"This is for debugging and is meant to loop over every disguise and disguise you to verify if there's any obvious issues." +
|
||||||
|
" There is no value for you in this command. Type 'agree' into the command to continue.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<String> iterator = getDisguisesToRun().iterator();
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!((Player) sender).isOnline()) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String command = iterator.next();
|
||||||
|
String message = ChatColor.AQUA + "Now disguising " + sender.getName() + " as " + command;
|
||||||
|
sender.sendMessage(message);
|
||||||
|
DisguiseUtilities.getLogger().info(message);
|
||||||
|
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise((Player) sender);
|
||||||
|
|
||||||
|
try {
|
||||||
|
((Player) sender).performCommand("disguise " + command);
|
||||||
|
|
||||||
|
if (disguise == DisguiseAPI.getDisguise((Player) sender)) {
|
||||||
|
DisguiseUtilities.getLogger().info("Looks like '" + command + "' failed.");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (!iterator.hasNext()) {
|
||||||
|
cancel();
|
||||||
|
sender.sendMessage(ChatColor.AQUA + "Command Complete!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(LibsDisguises.getInstance(), 5, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static List<String> getDisguisesToRun() {
|
||||||
|
List<String> commands = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
|
if (type.getEntityType() == null || type.isUnknown() || type.isCustom()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String command;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case PLAYER:
|
||||||
|
command = "player libraryaddict";
|
||||||
|
break;
|
||||||
|
case DROPPED_ITEM:
|
||||||
|
command = "dropped_item grass";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
command = type.name();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
commands.add(command);
|
||||||
|
}
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LibsMsg getHelp() {
|
||||||
|
return LibsMsg.LD_DEBUG_MINESKIN;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package me.libraryaddict.disguise.commands.libsdisguises;
|
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.ItemStackSerializer;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -14,7 +13,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -48,27 +46,7 @@ public class LDJson implements LDCommand {
|
|||||||
// item amount data {nbt}
|
// item amount data {nbt}
|
||||||
|
|
||||||
String itemName = ReflectionManager.getItemName(item.getType());
|
String itemName = ReflectionManager.getItemName(item.getType());
|
||||||
ArrayList<String> mcArray = new ArrayList<>();
|
List<String> mcArray = ItemStackSerializer.serialize(item);
|
||||||
|
|
||||||
if (NmsVersion.v1_13.isSupported() && item.hasItemMeta()) {
|
|
||||||
mcArray.add(itemName + DisguiseUtilities.serialize(NbtFactory.fromItemTag(item)));
|
|
||||||
} else {
|
|
||||||
mcArray.add(itemName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.getAmount() != 1) {
|
|
||||||
mcArray.add(String.valueOf(item.getAmount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NmsVersion.v1_13.isSupported()) {
|
|
||||||
if (item.getDurability() != 0) {
|
|
||||||
mcArray.add(String.valueOf(item.getDurability()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.hasItemMeta()) {
|
|
||||||
mcArray.add(DisguiseUtilities.serialize(NbtFactory.fromItemTag(item)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String ldItem = StringUtils.join(mcArray, "-");
|
String ldItem = StringUtils.join(mcArray, "-");
|
||||||
String mcItem = StringUtils.join(mcArray, " ");
|
String mcItem = StringUtils.join(mcArray, " ");
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.commands.libsdisguises;
|
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketListener;
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -26,7 +19,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 20/04/2020.
|
* Created by libraryaddict on 20/04/2020.
|
||||||
@ -128,47 +120,6 @@ public class LDScoreboard implements LDCommand {
|
|||||||
LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.send(sender);
|
LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.send(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream().filter(
|
|
||||||
listener -> listener.getPlugin() != LibsDisguises.getInstance() &&
|
|
||||||
listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!listeners.isEmpty()) {
|
|
||||||
ComponentBuilder builder = new ComponentBuilder("");
|
|
||||||
builder.append(
|
|
||||||
"The following plugins are listening for scoreboard teams using ProtocolLib, and could be modifying collisions: ");
|
|
||||||
builder.color(net.md_5.bungee.api.ChatColor.BLUE);
|
|
||||||
|
|
||||||
boolean comma = false;
|
|
||||||
|
|
||||||
for (PacketListener listener : listeners) {
|
|
||||||
if (comma) {
|
|
||||||
builder.reset();
|
|
||||||
builder.append(", ");
|
|
||||||
builder.color(net.md_5.bungee.api.ChatColor.BLUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
comma = true;
|
|
||||||
|
|
||||||
builder.reset();
|
|
||||||
builder.append(listener.getPlugin().getName());
|
|
||||||
builder.color(net.md_5.bungee.api.ChatColor.AQUA);
|
|
||||||
|
|
||||||
String plugin = ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" +
|
|
||||||
listener.getPlugin().getDescription().getVersion();
|
|
||||||
String listenerClass = ChatColor.GOLD + "Listener: " + ChatColor.YELLOW + listener.getClass();
|
|
||||||
String packets =
|
|
||||||
ChatColor.GOLD + "Packets: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getTypes(), ", ");
|
|
||||||
String priority = ChatColor.GOLD + "Priority: " + ChatColor.YELLOW + listener.getSendingWhitelist().getPriority();
|
|
||||||
String options =
|
|
||||||
ChatColor.GOLD + "Options: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getOptions(), ", ");
|
|
||||||
|
|
||||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
|
||||||
TextComponent.fromLegacyText(plugin + "\n" + listenerClass + "\n" + packets + "\n" + priority + "\n" + options)));
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.spigot().sendMessage(builder.create());
|
|
||||||
}
|
|
||||||
|
|
||||||
LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.send(sender);
|
LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.send(sender);
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED +
|
sender.sendMessage(ChatColor.RED +
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.commands.libsdisguises;
|
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
|
import me.libraryaddict.disguise.utilities.updates.PacketEventsUpdater;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
@ -15,12 +14,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 30/06/2020.
|
* Created by libraryaddict on 30/06/2020.
|
||||||
*/
|
*/
|
||||||
public class LDUpdateProtocolLib implements LDCommand {
|
public class LDUpdatePacketEvents implements LDCommand {
|
||||||
private final AtomicBoolean updateInProgress = new AtomicBoolean(false);
|
private final AtomicBoolean updateInProgress = new AtomicBoolean(false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabComplete() {
|
public List<String> getTabComplete() {
|
||||||
return Arrays.asList("updateprotocollib", "updatepl", "protocollib");
|
return Arrays.asList("updatepacketevents", "updatepe", "packetevents");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,27 +32,35 @@ public class LDUpdateProtocolLib implements LDCommand {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendMessage(CommandSender sender, String message) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + "[LibsDisguises] " + ChatColor.RED + message);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
if (updateInProgress.get()) {
|
if (updateInProgress.get()) {
|
||||||
sender.sendMessage(ChatColor.RED + "Update already in progress");
|
sendMessage(sender, "Update already in progress");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED + "Please hold, now downloading ProtocolLib..");
|
sendMessage(sender, "Please hold, now downloading PacketEvents..");
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
File protocolLibFile = null;
|
PacketEventsUpdater updater = new PacketEventsUpdater();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DisguiseUtilities.updateProtocolLib();
|
boolean outcome = updater.doUpdate();
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendMessage(ChatColor.RED + "Download success! Restart server to finish update!");
|
if (outcome) {
|
||||||
|
sendMessage(sender, "Download success! Restart server to finish update!");
|
||||||
|
} else {
|
||||||
|
sendMessage(sender, "Update failed, you may need to update PacketEvents");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.runTask(LibsDisguises.getInstance());
|
}.runTask(LibsDisguises.getInstance());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -62,11 +69,7 @@ public class LDUpdateProtocolLib implements LDCommand {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendMessage(ChatColor.RED +
|
sendMessage(sender, "Update failed, " + ex.getMessage());
|
||||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord" +
|
|
||||||
".gg/EErRhJ4qgx you" +
|
|
||||||
" can join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
|
||||||
sender.sendMessage(ChatColor.RED + "Update failed, " + ex.getMessage());
|
|
||||||
}
|
}
|
||||||
}.runTask(LibsDisguises.getInstance());
|
}.runTask(LibsDisguises.getInstance());
|
||||||
} finally {
|
} finally {
|
||||||
@ -78,6 +81,6 @@ public class LDUpdateProtocolLib implements LDCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LibsMsg getHelp() {
|
public LibsMsg getHelp() {
|
||||||
return LibsMsg.LD_COMMAND_UPDATEPROTOCOLLIB;
|
return LibsMsg.LD_COMMAND_UPDATE_PACKET_EVENTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -57,6 +57,7 @@ public class LDUploadLogs implements LDCommand {
|
|||||||
URL url = new URL("https://api.mclo.gs/1/log");
|
URL url = new URL("https://api.mclo.gs/1/log");
|
||||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
|
||||||
|
try {
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
|
||||||
@ -93,6 +94,9 @@ public class LDUploadLogs implements LDCommand {
|
|||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Unexpected response code " + status);
|
throw new IllegalStateException("Unexpected response code " + status);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
con.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||||||
|
|
||||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (!method.getName().equalsIgnoreCase(arg) || usedOptions.contains(arg)) {
|
if (!method.getMappedName().equalsIgnoreCase(arg) || usedOptions.contains(arg)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
|||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.kyori.adventure.text.TextComponent.Builder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import libsdisg.shaded.net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -21,7 +22,9 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,17 +90,33 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(CommandSender sender, LibsMsg msg, LibsMsg oldVer, String string, boolean forceAbbrev) {
|
private Component createComponent(String text, int section, int max) {
|
||||||
/* if (!NmsVersion.v1_13.isSupported()) {
|
Component component = LibsMsg.CLICK_COPY.getAdv(section);
|
||||||
oldVer.send(sender, string);
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
ComponentBuilder builder = new ComponentBuilder("").append(msg.getBase()).append(" ");
|
if (NmsVersion.v1_15.isSupported()) {
|
||||||
|
component = component.clickEvent(net.kyori.adventure.text.event.ClickEvent.copyToClipboard(text));
|
||||||
|
} else {
|
||||||
|
component = component.clickEvent(net.kyori.adventure.text.event.ClickEvent.suggestCommand(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
LibsMsg hover = NmsVersion.v1_15.isSupported() ? LibsMsg.CLICK_TO_COPY_HOVER_CLIPBOARD : LibsMsg.CLICK_TO_COPY_HOVER;
|
||||||
|
Component hoverText = hover.getAdv(section, max, DisguiseUtilities.getMiniMessage().escapeTags(text));
|
||||||
|
component = component.hoverEvent(net.kyori.adventure.text.event.HoverEvent.showText(hoverText));
|
||||||
|
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(CommandSender sender, LibsMsg msg, LibsMsg oldVer, String string, boolean forceAbbrev) {
|
||||||
|
Builder builder = Component.text().append(msg.getAdv()).appendSpace();
|
||||||
|
|
||||||
if (string.length() > 256 || forceAbbrev) {
|
if (string.length() > 256 || forceAbbrev) {
|
||||||
String[] split = DisguiseUtilities.split(string);
|
String[] split = DisguiseUtilities.split(string);
|
||||||
|
|
||||||
|
// Because the splitter removes the quotes..
|
||||||
|
for (int i = 0; i < split.length; i++) {
|
||||||
|
split[i] = DisguiseUtilities.quote(split[i]);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
if (split[i].length() <= 256) {
|
if (split[i].length() <= 256) {
|
||||||
continue;
|
continue;
|
||||||
@ -113,7 +132,7 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||||||
split[i] = split[i].substring(0, 256);
|
split[i] = split[i].substring(0, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sections = 0;
|
List<String> sections = new ArrayList<>();
|
||||||
StringBuilder current = new StringBuilder();
|
StringBuilder current = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
@ -128,26 +147,26 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sections != 0) {
|
// Have non-final end with a space
|
||||||
builder.append(" ");
|
if (i + 1 < split.length) {
|
||||||
builder.reset();
|
current.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
sections++;
|
sections.add(current.toString());
|
||||||
|
|
||||||
builder.append(LibsMsg.CLICK_COPY.getBase(sections));
|
|
||||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, current.toString()));
|
|
||||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
|
||||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + sections).create()));
|
|
||||||
|
|
||||||
current = new StringBuilder();
|
current = new StringBuilder();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
builder.append(LibsMsg.CLICK_COPY.getBase(string));
|
for (int i = 0; i < sections.size(); i++) {
|
||||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, string));
|
if (i > 0) {
|
||||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.CLICK_TO_COPY_HOVER.getBase()));
|
builder.appendSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.spigot().sendMessage(builder.create());
|
builder.append(createComponent(sections.get(i), i + 1, sections.size()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
builder.append(createComponent(string, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguiseUtilities.sendMessage(sender, builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (help != null) {
|
if (help != null) {
|
||||||
if (help.hasValues() && help.canTranslateValues()) {
|
if (help.hasTabCompletion() && help.canTranslateValues()) {
|
||||||
LibsMsg.DHELP_HELP4.send(sender, help.getName(),
|
LibsMsg.DHELP_HELP4.send(sender, help.getName(),
|
||||||
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
|
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
|
||||||
} else {
|
} else {
|
||||||
@ -79,12 +79,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
||||||
if (!method.isUsable(type.getType())) {
|
if (method.isHidden(type.getType())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
||||||
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(Locale.ENGLISH)))) {
|
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getMappedName().toLowerCase(Locale.ENGLISH)))) {
|
||||||
ignored++;
|
ignored++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -93,18 +93,19 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
ParamInfo info = ParamInfoManager.getParamInfo(method);
|
ParamInfo info = ParamInfoManager.getParamInfo(method);
|
||||||
|
|
||||||
int value = ParamInfoManager.getValue(method);
|
int value = ParamInfoManager.getValue(method);
|
||||||
ChatColor methodColor = ChatColor.YELLOW;
|
LibsMsg methodC = LibsMsg.DHELP_OPTIONS_METHOD_VERY_SPECIFIC;
|
||||||
|
|
||||||
if (value == 1) {
|
if (value == 1) {
|
||||||
methodColor = ChatColor.AQUA;
|
methodC = LibsMsg.DHELP_OPTIONS_METHOD_SOMEWHAT_SPECIFIC;
|
||||||
} else if (value == 2) {
|
} else if (value == 2) {
|
||||||
methodColor = ChatColor.GRAY;
|
methodC = LibsMsg.DHELP_OPTIONS_METHOD_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN +
|
String str =
|
||||||
info.getName() + ChatColor.DARK_RED + ")";
|
LibsMsg.DHELP_OPTIONS_METHOD.get(methodC.get(TranslateType.DISGUISE_OPTIONS.get(method.getMappedName())),
|
||||||
|
info.getName());
|
||||||
|
|
||||||
methods.add(methodColor + str);
|
methods.add(str);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -114,8 +115,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||||||
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(),
|
LibsMsg.DHELP_OPTIONS.send(sender, type.toReadable(), StringUtils.join(methods, LibsMsg.DHELP_OPTIONS_JOINER.getRaw()));
|
||||||
StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
|
||||||
|
|
||||||
if (ignored > 0) {
|
if (ignored > 0) {
|
||||||
LibsMsg.NO_PERMS_USE_OPTIONS.send(sender, ignored);
|
LibsMsg.NO_PERMS_USE_OPTIONS.send(sender, ignored);
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
package me.libraryaddict.disguise.commands.utils;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class DisguiseViewSelfCommand implements CommandExecutor {
|
public class DisguiseViewSelfCommand implements CommandExecutor {
|
||||||
|
private List<Map.Entry<UUID, Long>> warnedTall = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (!(sender instanceof Player)) {
|
||||||
LibsMsg.NO_CONSOLE.send(sender);
|
LibsMsg.NO_CONSOLE.send(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -27,6 +35,15 @@ public class DisguiseViewSelfCommand implements CommandExecutor {
|
|||||||
} else {
|
} else {
|
||||||
DisguiseAPI.setViewDisguiseToggled(player, true);
|
DisguiseAPI.setViewDisguiseToggled(player, true);
|
||||||
LibsMsg.VIEW_SELF_ON.send(sender);
|
LibsMsg.VIEW_SELF_ON.send(sender);
|
||||||
|
|
||||||
|
TargetedDisguise disguise = (TargetedDisguise) DisguiseAPI.getDisguise(player, player);
|
||||||
|
|
||||||
|
// If they're disguised, tall disguises are hidden, it's a tall disguise
|
||||||
|
// Then tell the player, it's not a bug! The disguise is too tall
|
||||||
|
if (disguise != null && !disguise.isTallDisguisesVisible() && disguise.canSee(player) &&
|
||||||
|
DisguiseUtilities.isTallDisguise(disguise)) {
|
||||||
|
LibsMsg.VIEW_SELF_TALL_NOTE.send(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.commands.utils;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.SkinUtils;
|
import me.libraryaddict.disguise.utilities.SkinUtils;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -15,6 +17,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.bukkit.profile.PlayerProfile;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -80,7 +83,7 @@ public class GrabHeadCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(WrappedGameProfile profile) {
|
public void onSuccess(UserProfile profile) {
|
||||||
runnable.cancel();
|
runnable.cancel();
|
||||||
DisguiseUtilities.doSkinUUIDWarning(sender);
|
DisguiseUtilities.doSkinUUIDWarning(sender);
|
||||||
|
|
||||||
@ -92,13 +95,19 @@ public class GrabHeadCommand implements CommandExecutor {
|
|||||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||||
|
|
||||||
|
if (NmsVersion.v1_18.isSupported()) {
|
||||||
|
PlayerProfile playerProfile = ReflectionManager.createProfile(profile);
|
||||||
|
|
||||||
|
meta.setOwnerProfile(playerProfile);
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
Field field = meta.getClass().getDeclaredField("profile");
|
Field field = meta.getClass().getDeclaredField("profile");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(meta, profile.getHandle());
|
field.set(meta, ReflectionManager.convertProfile(profile));
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
skull.setItemMeta(meta);
|
skull.setItemMeta(meta);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.commands.utils;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
@ -68,13 +68,13 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||||||
|
|
||||||
tName = skin.substring(start, end);
|
tName = skin.substring(start, end);
|
||||||
|
|
||||||
if (DisguiseUtilities.hasGameProfile(tName)) {
|
if (DisguiseUtilities.hasUserProfile(tName)) {
|
||||||
tName = null;
|
tName = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String name =
|
String name =
|
||||||
tName != null && tName.toLowerCase(Locale.ROOT).endsWith(":slim") ? tName.substring(0, tName.lastIndexOf(":")) : tName;
|
tName != null && tName.toLowerCase(Locale.ENGLISH).endsWith(":slim") ? tName.substring(0, tName.lastIndexOf(":")) : tName;
|
||||||
|
|
||||||
if (name != null && name.replaceAll("[_a-zA-Z \\d-@#]", "").length() > 0) {
|
if (name != null && name.replaceAll("[_a-zA-Z \\d-@#]", "").length() > 0) {
|
||||||
LibsMsg.SKIN_API_INVALID_NAME.send(sender);
|
LibsMsg.SKIN_API_INVALID_NAME.send(sender);
|
||||||
@ -102,7 +102,7 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(WrappedGameProfile profile) {
|
public void onSuccess(UserProfile profile) {
|
||||||
runnable.cancel();
|
runnable.cancel();
|
||||||
DisguiseUtilities.doSkinUUIDWarning(sender);
|
DisguiseUtilities.doSkinUUIDWarning(sender);
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||||||
if (nName == null) {
|
if (nName == null) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
while (DisguiseUtilities.hasGameProfile("skin" + i)) {
|
while (DisguiseUtilities.hasUserProfile("skin" + i)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getName() == null || !profile.getName().equals(nName)) {
|
if (profile.getName() == null || !profile.getName().equals(nName)) {
|
||||||
profile = ReflectionManager.getGameProfileWithThisSkin(profile.getUUID(), profile.getName(), profile);
|
profile = ReflectionManager.getUserProfileWithThisSkin(profile.getUUID(), profile.getName(), profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseAPI.addGameProfile(nName, profile);
|
DisguiseAPI.addGameProfile(nName, profile);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.commands.utils;
|
package me.libraryaddict.disguise.commands.utils;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
@ -138,7 +138,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(WrappedGameProfile profile) {
|
public void onSuccess(UserProfile profile) {
|
||||||
runnable.cancel();
|
runnable.cancel();
|
||||||
DisguiseUtilities.doSkinUUIDWarning(sender);
|
DisguiseUtilities.doSkinUUIDWarning(sender);
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfo;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -18,10 +18,8 @@ import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
|||||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.AutoGeneratedValue;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
|
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
@ -48,6 +46,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -131,7 +130,7 @@ public abstract class Disguise {
|
|||||||
return multiName.length;
|
return multiName.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@AutoGeneratedValue
|
||||||
public void setDisguiseName(String name) {
|
public void setDisguiseName(String name) {
|
||||||
this.disguiseName = name;
|
this.disguiseName = name;
|
||||||
}
|
}
|
||||||
@ -183,16 +182,16 @@ public abstract class Disguise {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<PacketContainer> packets = DisguiseUtilities.getNamePackets(this, oldName);
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(this)) {
|
for (Player player : DisguiseUtilities.getPerverts(this)) {
|
||||||
if (!DisguiseUtilities.isFancyHiddenTabs() && isPlayerDisguise() &&
|
if (!DisguiseUtilities.isFancyHiddenTabs() && isPlayerDisguise() &&
|
||||||
LibsDisguises.getInstance().getSkinHandler().isSleeping(player, (PlayerDisguise) this)) {
|
LibsDisguises.getInstance().getSkinHandler().isSleeping(player, (PlayerDisguise) this)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PacketContainer packet : packets) {
|
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(this, oldName);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
|
||||||
|
for (PacketWrapper<?> packet : packets) {
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,7 +390,7 @@ public abstract class Disguise {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doActionBar() {
|
protected void doPeriodicTick() {
|
||||||
if (getNotifyBar() == DisguiseConfig.NotifyBar.ACTION_BAR && getEntity() instanceof Player &&
|
if (getNotifyBar() == DisguiseConfig.NotifyBar.ACTION_BAR && getEntity() instanceof Player &&
|
||||||
DisguiseAPI.isNotifyBarShown(getEntity()) && !getEntity().hasPermission("libsdisguises.noactionbar") &&
|
DisguiseAPI.isNotifyBarShown(getEntity()) && !getEntity().hasPermission("libsdisguises.noactionbar") &&
|
||||||
DisguiseAPI.getDisguise(getEntity()) == Disguise.this) {
|
DisguiseAPI.getDisguise(getEntity()) == Disguise.this) {
|
||||||
@ -477,27 +476,7 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTallDisguise() {
|
private boolean isTallDisguise() {
|
||||||
if (getType().isCustom()) {
|
return DisguiseUtilities.isTallDisguise(this);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisguiseValues values = DisguiseValues.getDisguiseValues(getType());
|
|
||||||
|
|
||||||
if (values == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
FakeBoundingBox box = null;
|
|
||||||
|
|
||||||
if (isMobDisguise() && !((MobDisguise) this).isAdult()) {
|
|
||||||
box = values.getBabyBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (box == null) {
|
|
||||||
box = values.getAdultBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
return box != null && !(box.getY() <= 1.7D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -743,23 +722,25 @@ public abstract class Disguise {
|
|||||||
PlayerDisguise disguise = (PlayerDisguise) this;
|
PlayerDisguise disguise = (PlayerDisguise) this;
|
||||||
|
|
||||||
if (disguise.isDisplayedInTab()) {
|
if (disguise.isDisplayedInTab()) {
|
||||||
PacketContainer deleteTab = ReflectionManager.createTablistPacket(disguise, PlayerInfoAction.REMOVE_PLAYER);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!((TargetedDisguise) this).canSee(player)) {
|
if (!((TargetedDisguise) this).canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
PacketWrapper deleteTab =
|
||||||
|
DisguiseUtilities.createTablistPacket(disguise, WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, deleteTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getInternalArmorstandIds().length > 0) {
|
if (getInternalArmorstandIds().length > 0) {
|
||||||
PacketContainer packet = DisguiseUtilities.getDestroyPacket(getInternalArmorstandIds());
|
|
||||||
|
|
||||||
for (Player player : getEntity().getWorld().getPlayers()) {
|
for (Player player : getEntity().getWorld().getPlayers()) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
PacketWrapper packet = DisguiseUtilities.getDestroyPacket(getInternalArmorstandIds());
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,14 +764,15 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isHidePlayer() && getEntity() instanceof Player && ((Player) getEntity()).isOnline()) {
|
if (isHidePlayer() && getEntity() instanceof Player && ((Player) getEntity()).isOnline()) {
|
||||||
PacketContainer addTab = ReflectionManager.updateTablistVisibility((Player) getEntity(), true);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!((TargetedDisguise) this).canSee(player)) {
|
if (!((TargetedDisguise) this).canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
PacketWrapper<?> addTab = DisguiseUtilities.updateTablistVisibility((Player) getEntity(), true);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, addTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,7 +916,9 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (LibsPremium.getUserID().equals("123" + "45") || !LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
if (LibsPremium.getUserID().equals("123" + "45") ||
|
||||||
|
(LibsPremium.getPaidInformation() != null && LibsPremium.getPaidInformation().getUserID().equals("0")) ||
|
||||||
|
!LibsMsg.OWNED_BY.getRaw().contains("'")) {
|
||||||
((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||||
|
|
||||||
if (getEntity() instanceof Player) {
|
if (getEntity() instanceof Player) {
|
||||||
@ -989,14 +973,15 @@ public abstract class Disguise {
|
|||||||
PlayerDisguise disguise = (PlayerDisguise) this;
|
PlayerDisguise disguise = (PlayerDisguise) this;
|
||||||
|
|
||||||
if (disguise.isDisplayedInTab()) {
|
if (disguise.isDisplayedInTab()) {
|
||||||
PacketContainer addTab = ReflectionManager.createTablistAddPackets(disguise);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!((TargetedDisguise) this).canSee(player)) {
|
if (!((TargetedDisguise) this).canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
PacketWrapper<?> addTab = DisguiseUtilities.createTablistAddPackets(disguise);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, addTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1020,14 +1005,14 @@ public abstract class Disguise {
|
|||||||
.scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> DisguiseUtilities.setupFakeDisguise(Disguise.this), 2);
|
.scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> DisguiseUtilities.setupFakeDisguise(Disguise.this), 2);
|
||||||
|
|
||||||
if (isHidePlayer() && getEntity() instanceof Player) {
|
if (isHidePlayer() && getEntity() instanceof Player) {
|
||||||
PacketContainer removeTab = ReflectionManager.updateTablistVisibility((Player) getEntity(), false);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!((TargetedDisguise) this).canSee(player)) {
|
if (!((TargetedDisguise) this).canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, removeTab);
|
PacketWrapper<?> removeTab = DisguiseUtilities.updateTablistVisibility((Player) getEntity(), false);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, removeTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.util.Vector3d;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRelativeMove;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRotation;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityVelocity;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||||
@ -12,6 +13,7 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
|||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -76,7 +78,7 @@ class DisguiseRunnable extends BukkitRunnable {
|
|||||||
if (++actionBarTicks % 15 == 0) {
|
if (++actionBarTicks % 15 == 0) {
|
||||||
actionBarTicks = 0;
|
actionBarTicks = 0;
|
||||||
|
|
||||||
disguise.doActionBar();
|
disguise.doPeriodicTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If entity is no longer valid. Remove it.
|
// If entity is no longer valid. Remove it.
|
||||||
@ -126,98 +128,94 @@ class DisguiseRunnable extends BukkitRunnable {
|
|||||||
doVelocity(vectorY, alwaysSendVelocity);
|
doVelocity(vectorY, alwaysSendVelocity);
|
||||||
|
|
||||||
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
|
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.REL_ENTITY_MOVE);
|
|
||||||
|
|
||||||
packet.getIntegers().write(0, disguise.getEntity().getEntityId());
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
||||||
if (disguise.getEntity() != player) {
|
if (disguise.getEntity() != player) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
WrapperPlayServerEntityRelativeMove packet =
|
||||||
|
new WrapperPlayServerEntityRelativeMove(disguise.getEntity().getEntityId(), 0, 0, 0, true);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, packet);
|
||||||
continue;
|
continue;
|
||||||
} else if (!disguise.isSelfDisguiseVisible() || !(disguise.getEntity() instanceof Player)) {
|
} else if (!disguise.isSelfDisguiseVisible() || !(disguise.getEntity() instanceof Player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer selfPacket = packet.shallowClone();
|
WrapperPlayServerEntityRelativeMove selfPacket =
|
||||||
|
new WrapperPlayServerEntityRelativeMove(DisguiseAPI.getSelfDisguiseId(), 0, 0, 0, true);
|
||||||
|
|
||||||
selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId());
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, selfPacket);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), selfPacket, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doVelocity(Double vectorY, boolean alwaysSendVelocity) {
|
private void doVelocity(Double vectorY, boolean alwaysSendVelocity) {
|
||||||
// If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors.
|
// If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors.
|
||||||
|
if (vectorY == null || !disguise.isVelocitySent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity entity = disguise.getEntity();
|
||||||
|
|
||||||
// If this disguise has velocity sending enabled and the entity is flying.
|
// If this disguise has velocity sending enabled and the entity is flying.
|
||||||
if (disguise.isVelocitySent() && vectorY != null && (alwaysSendVelocity || !disguise.getEntity().isOnGround())) {
|
if (!alwaysSendVelocity && entity.isOnGround()) {
|
||||||
Vector vector = disguise.getEntity().getVelocity();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector vector = entity.getVelocity();
|
||||||
|
|
||||||
// If the entity doesn't have velocity changes already - You know. I really can't wrap my
|
// If the entity doesn't have velocity changes already - You know. I really can't wrap my
|
||||||
// head about the
|
// head about the
|
||||||
// if statement.
|
// if statement.
|
||||||
// But it doesn't seem to do anything wrong..
|
// But it doesn't seem to do anything wrong..
|
||||||
if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && disguise.getEntity().isOnGround())) {
|
if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && entity.isOnGround())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If disguise isn't a experience orb, or the entity isn't standing on the ground
|
// If disguise isn't a experience orb, or the entity isn't standing on the ground
|
||||||
if (disguise.getType() != DisguiseType.EXPERIENCE_ORB || !disguise.getEntity().isOnGround()) {
|
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB && entity.isOnGround()) {
|
||||||
PacketContainer lookPacket = null;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapperPlayServerEntityRotation lookPacket = null;
|
||||||
|
|
||||||
if (disguise.getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) {
|
if (disguise.getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) {
|
||||||
lookPacket = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
|
Location loc = entity.getLocation();
|
||||||
|
float yaw = DisguiseUtilities.getYaw(disguise.getType(), entity.getType(), loc.getYaw());
|
||||||
|
float pitch = DisguiseUtilities.getPitch(disguise.getType(), entity.getType(), loc.getPitch());
|
||||||
|
lookPacket = new WrapperPlayServerEntityRotation(entity.getEntityId(), yaw, pitch, entity.isOnGround());
|
||||||
|
|
||||||
StructureModifier<Object> mods = lookPacket.getModifier();
|
if (disguise.isSelfDisguiseVisible() && entity instanceof Player) {
|
||||||
lookPacket.getIntegers().write(0, disguise.getEntity().getEntityId());
|
WrapperPlayServerEntityRotation selfPacket =
|
||||||
Location loc = disguise.getEntity().getLocation();
|
new WrapperPlayServerEntityRotation(DisguiseAPI.getSelfDisguiseId(), yaw, pitch, entity.isOnGround());
|
||||||
|
|
||||||
mods.write(4, DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(),
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(entity, selfPacket);
|
||||||
(byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
|
||||||
mods.write(5, DisguiseUtilities.getPitch(disguise.getType(), disguise.getEntity().getType(),
|
|
||||||
(byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
|
||||||
|
|
||||||
if (disguise.isSelfDisguiseVisible() && disguise.getEntity() instanceof Player) {
|
|
||||||
PacketContainer selfLookPacket = lookPacket.shallowClone();
|
|
||||||
|
|
||||||
selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), selfLookPacket, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PacketContainer velocityPacket = new PacketContainer(PacketType.Play.Server.ENTITY_VELOCITY);
|
|
||||||
|
|
||||||
StructureModifier<Integer> mods = velocityPacket.getIntegers();
|
|
||||||
|
|
||||||
// Write entity ID
|
|
||||||
mods.write(0, disguise.getEntity().getEntityId());
|
|
||||||
mods.write(1, (int) (vector.getX() * 8000));
|
|
||||||
mods.write(3, (int) (vector.getZ() * 8000));
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
||||||
PacketContainer tempVelocityPacket = velocityPacket.shallowClone();
|
int entityId = entity.getEntityId();
|
||||||
mods = tempVelocityPacket.getIntegers();
|
|
||||||
|
|
||||||
// If the viewing player is the disguised player
|
// If the viewing player is the disguised player
|
||||||
if (disguise.getEntity() == player) {
|
if (entity == player) {
|
||||||
// If not using self disguise, continue
|
// If not using self disguise, continue
|
||||||
if (!disguise.isSelfDisguiseVisible()) {
|
if (!disguise.isSelfDisguiseVisible()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write self disguise ID
|
// Write self disguise ID
|
||||||
mods.write(0, DisguiseAPI.getSelfDisguiseId());
|
entityId = DisguiseAPI.getSelfDisguiseId();
|
||||||
|
} else if (lookPacket != null) {
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player,
|
||||||
|
new WrapperPlayServerEntityRotation(lookPacket.getEntityId(), lookPacket.getYaw(), lookPacket.getPitch(),
|
||||||
|
lookPacket.isOnGround()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mods.write(2, (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D));
|
// The number isn't me trying to be funny
|
||||||
|
WrapperPlayServerEntityVelocity velocity = new WrapperPlayServerEntityVelocity(entityId,
|
||||||
|
new Vector3d(vector.getX(), (vectorY * ReflectionManager.getPing(player)) * 0.069D, vector.getZ()));
|
||||||
|
|
||||||
if (lookPacket != null && player != disguise.getEntity()) {
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, velocity);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, tempVelocityPacket, false);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -226,6 +224,6 @@ class DisguiseRunnable extends BukkitRunnable {
|
|||||||
// If we need to send a packet to update the exp position as it likes to gravitate client
|
// If we need to send a packet to update the exp position as it likes to gravitate client
|
||||||
// sided to
|
// sided to
|
||||||
// players.
|
// players.
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
@ -15,11 +19,13 @@ import java.util.Locale;
|
|||||||
public enum DisguiseType {
|
public enum DisguiseType {
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1) ALLAY,
|
@NmsAddedIn(NmsVersion.v1_19_R1) ALLAY,
|
||||||
|
|
||||||
AREA_EFFECT_CLOUD(3, 0),
|
AREA_EFFECT_CLOUD(3),
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.UNSUPPORTED) ARMADILLO,
|
||||||
|
|
||||||
ARMOR_STAND(78),
|
ARMOR_STAND(78),
|
||||||
|
|
||||||
ARROW(60, 0),
|
ARROW(60),
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_17) AXOLOTL,
|
@NmsAddedIn(NmsVersion.v1_17) AXOLOTL,
|
||||||
|
|
||||||
@ -33,8 +39,12 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
BOAT(1),
|
BOAT(1),
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.UNSUPPORTED) BOGGED,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.UNSUPPORTED) BREEZE,
|
@NmsAddedIn(NmsVersion.UNSUPPORTED) BREEZE,
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.UNSUPPORTED) BREEZE_WIND_CHARGE,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_20_R1) CAMEL,
|
@NmsAddedIn(NmsVersion.v1_20_R1) CAMEL,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14) CAT,
|
@NmsAddedIn(NmsVersion.v1_14) CAT,
|
||||||
@ -45,33 +55,33 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1) CHEST_BOAT,
|
@NmsAddedIn(NmsVersion.v1_19_R1) CHEST_BOAT,
|
||||||
|
|
||||||
COD,
|
@NmsAddedIn(NmsVersion.v1_13) COD,
|
||||||
|
|
||||||
COW,
|
COW,
|
||||||
|
|
||||||
CREEPER,
|
CREEPER,
|
||||||
|
|
||||||
DOLPHIN,
|
@NmsAddedIn(NmsVersion.v1_13) DOLPHIN,
|
||||||
|
|
||||||
DONKEY,
|
DONKEY,
|
||||||
|
|
||||||
DRAGON_FIREBALL(93),
|
DRAGON_FIREBALL(93),
|
||||||
|
|
||||||
DROWNED,
|
@NmsAddedIn(NmsVersion.v1_13) DROWNED,
|
||||||
|
|
||||||
DROPPED_ITEM(2, 1),
|
DROPPED_ITEM(2, "item", 1),
|
||||||
|
|
||||||
EGG(62),
|
EGG(62),
|
||||||
|
|
||||||
ELDER_GUARDIAN,
|
ELDER_GUARDIAN,
|
||||||
|
|
||||||
ENDER_CRYSTAL(51),
|
ENDER_CRYSTAL(51, "end_crystal"),
|
||||||
|
|
||||||
ENDER_DRAGON,
|
ENDER_DRAGON,
|
||||||
|
|
||||||
ENDER_PEARL(65),
|
ENDER_PEARL(65),
|
||||||
|
|
||||||
ENDER_SIGNAL(72),
|
ENDER_SIGNAL(72, "eye_of_ender"),
|
||||||
|
|
||||||
ENDERMAN,
|
ENDERMAN,
|
||||||
|
|
||||||
@ -87,9 +97,9 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
FIREBALL(63),
|
FIREBALL(63),
|
||||||
|
|
||||||
FIREWORK(76),
|
FIREWORK(76, "firework_rocket"),
|
||||||
|
|
||||||
FISHING_HOOK(90),
|
FISHING_HOOK(90, "fishing_bobber"),
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1) FROG,
|
@NmsAddedIn(NmsVersion.v1_19_R1) FROG,
|
||||||
|
|
||||||
@ -127,7 +137,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
LLAMA_SPIT(68),
|
LLAMA_SPIT(68),
|
||||||
|
|
||||||
LEASH_HITCH(77),
|
LEASH_HITCH(77, "leash_knot"),
|
||||||
|
|
||||||
MAGMA_CUBE,
|
MAGMA_CUBE,
|
||||||
|
|
||||||
@ -135,17 +145,17 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
MINECART(10),
|
MINECART(10),
|
||||||
|
|
||||||
MINECART_CHEST(10, 1),
|
MINECART_CHEST(10, "chest_minecart", 1),
|
||||||
|
|
||||||
MINECART_COMMAND(10, 6),
|
MINECART_COMMAND(10, "command_block_minecart", 6),
|
||||||
|
|
||||||
MINECART_FURNACE(10, 2),
|
MINECART_FURNACE(10, "furnace_minecart", 2),
|
||||||
|
|
||||||
MINECART_HOPPER(10, 5),
|
MINECART_HOPPER(10, "hopper_minecart", 5),
|
||||||
|
|
||||||
MINECART_MOB_SPAWNER(10, 4),
|
MINECART_MOB_SPAWNER(10, "spawner_minecart", 4),
|
||||||
|
|
||||||
MINECART_TNT(10, 3),
|
MINECART_TNT(10, "tnt_minecart", 3),
|
||||||
|
|
||||||
MODDED_MISC,
|
MODDED_MISC,
|
||||||
|
|
||||||
@ -153,21 +163,23 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
MULE,
|
MULE,
|
||||||
|
|
||||||
MUSHROOM_COW,
|
MUSHROOM_COW("mooshroom"),
|
||||||
|
|
||||||
OCELOT,
|
OCELOT,
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.UNSUPPORTED) OMINOUS_ITEM_SPAWNER,
|
||||||
|
|
||||||
PAINTING,
|
PAINTING,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14) PANDA,
|
@NmsAddedIn(NmsVersion.v1_14) PANDA,
|
||||||
|
|
||||||
PARROT,
|
PARROT,
|
||||||
|
|
||||||
PHANTOM,
|
@NmsAddedIn(NmsVersion.v1_13) PHANTOM,
|
||||||
|
|
||||||
PIG,
|
PIG,
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_16) PIG_ZOMBIE,
|
@NmsRemovedIn(NmsVersion.v1_16) PIG_ZOMBIE("zombified_piglin"),
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_16) PIGLIN,
|
@NmsAddedIn(NmsVersion.v1_16) PIGLIN,
|
||||||
|
|
||||||
@ -179,15 +191,15 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
POLAR_BEAR,
|
POLAR_BEAR,
|
||||||
|
|
||||||
PRIMED_TNT(50),
|
PRIMED_TNT(50, "tnt"),
|
||||||
|
|
||||||
PUFFERFISH,
|
@NmsAddedIn(NmsVersion.v1_13) PUFFERFISH,
|
||||||
|
|
||||||
RABBIT,
|
RABBIT,
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14) RAVAGER,
|
@NmsAddedIn(NmsVersion.v1_14) RAVAGER,
|
||||||
|
|
||||||
SALMON,
|
@NmsAddedIn(NmsVersion.v1_13) SALMON,
|
||||||
|
|
||||||
SHEEP,
|
SHEEP,
|
||||||
|
|
||||||
@ -209,13 +221,13 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
SNOWBALL(61),
|
SNOWBALL(61),
|
||||||
|
|
||||||
SNOWMAN,
|
SNOWMAN("snow_golem"),
|
||||||
|
|
||||||
SPECTRAL_ARROW(91),
|
SPECTRAL_ARROW(91),
|
||||||
|
|
||||||
SPIDER,
|
SPIDER,
|
||||||
|
|
||||||
SPLASH_POTION(73, 0),
|
SPLASH_POTION(73, "potion"),
|
||||||
|
|
||||||
SQUID,
|
SQUID,
|
||||||
|
|
||||||
@ -227,17 +239,17 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R3) TEXT_DISPLAY,
|
@NmsAddedIn(NmsVersion.v1_19_R3) TEXT_DISPLAY,
|
||||||
|
|
||||||
THROWN_EXP_BOTTLE(75),
|
THROWN_EXP_BOTTLE(75, "experience_bottle"),
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14) TIPPED_ARROW(60),
|
@NmsRemovedIn(NmsVersion.v1_14) TIPPED_ARROW(60),
|
||||||
|
|
||||||
TRIDENT(94, 0),
|
@NmsAddedIn(NmsVersion.v1_13) TRIDENT(94),
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14) TRADER_LLAMA,
|
@NmsAddedIn(NmsVersion.v1_14) TRADER_LLAMA,
|
||||||
|
|
||||||
TROPICAL_FISH,
|
@NmsAddedIn(NmsVersion.v1_13) TROPICAL_FISH,
|
||||||
|
|
||||||
TURTLE,
|
@NmsAddedIn(NmsVersion.v1_13) TURTLE,
|
||||||
|
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
|
|
||||||
@ -289,47 +301,114 @@ public enum DisguiseType {
|
|||||||
return DisguiseType.UNKNOWN;
|
return DisguiseType.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
private EntityType entityType;
|
private EntityType entityType;
|
||||||
|
|
||||||
private Object nmsType;
|
private Object nmsType;
|
||||||
private int objectId = -1, defaultData = 0;
|
@Getter
|
||||||
|
private int defaultData = 0;
|
||||||
|
/**
|
||||||
|
* The TYPE id of this entity. Different from the Object Id send in spawn packets when spawning miscs.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
private int typeId;
|
private int typeId;
|
||||||
|
@Getter
|
||||||
|
private com.github.retrooper.packetevents.protocol.entity.type.EntityType packetEntityType;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private Class<? extends FlagWatcher> watcherClass;
|
private Class<? extends FlagWatcher> watcherClass;
|
||||||
|
|
||||||
|
DisguiseType() {
|
||||||
|
this(null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguiseType(Integer objectId) {
|
||||||
|
this(objectId, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguiseType(String modernMinecraftName) {
|
||||||
|
this(null, modernMinecraftName);
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguiseType(Integer objectId, String modernMinecraftName) {
|
||||||
|
this(objectId, modernMinecraftName, null);
|
||||||
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
DisguiseType(int... ints) {
|
DisguiseType(Integer objectId, String modernMinecraftName, Integer defaultData) {
|
||||||
for (int i = 0; i < ints.length; i++) {
|
if (defaultData != null) {
|
||||||
int value = ints[i];
|
this.defaultData = defaultData;
|
||||||
|
|
||||||
switch (i) {
|
|
||||||
case 0:
|
|
||||||
objectId = value;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
defaultData = value;
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
figureOutEntityType(objectId, modernMinecraftName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void figureOutEntityType(Integer objectId, String modernMinecraftName) throws NoSuchFieldException {
|
||||||
// Why oh why can't isCustom() work :(
|
// Why oh why can't isCustom() work :(
|
||||||
if (name().startsWith("MODDED_")) {
|
if (name().startsWith("MODDED_")) {
|
||||||
setEntityType(EntityType.UNKNOWN);
|
setEntityType(EntityType.UNKNOWN);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NmsAddedIn added = DisguiseType.class.getField(name()).getAnnotation(NmsAddedIn.class);
|
NmsAddedIn added = DisguiseType.class.getField(name()).getAnnotation(NmsAddedIn.class);
|
||||||
|
|
||||||
if (LibsDisguises.getInstance() != null && added != null && !added.value().isSupported()) {
|
if (LibsDisguises.getInstance() != null && added != null && !added.value().isSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setEntityType(EntityType.valueOf(name()));
|
NmsRemovedIn removed = DisguiseType.class.getField(name()).getAnnotation(NmsRemovedIn.class);
|
||||||
|
|
||||||
|
if (LibsDisguises.getInstance() != null && removed != null && removed.value().isSupported()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
|
||||||
|
// We have different resolution strategies here
|
||||||
|
|
||||||
|
// If we're not given a modern name, then the entity type for bukkit is absolute
|
||||||
|
|
||||||
|
// Resolve bukkit type by modern name if it exists, fallback to enum name()
|
||||||
|
// Resolve packetevents entitytype by enum name if it doesnt exist
|
||||||
|
|
||||||
|
// First try to resolve via modern name
|
||||||
|
if (modernMinecraftName != null) {
|
||||||
|
setEntityType(EntityType.fromName(modernMinecraftName));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, try via enum name
|
||||||
|
if (getEntityType() == null) {
|
||||||
|
try {
|
||||||
|
setEntityType(EntityType.valueOf(name()));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (LibsDisguises.getInstance() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't try to load packetevents type unless server is running
|
||||||
|
if (getEntityType() == EntityType.UNKNOWN || LibsDisguises.getInstance() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modernMinecraftName != null) {
|
||||||
|
packetEntityType = EntityTypes.getByName("minecraft:" + modernMinecraftName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPacketEntityType() == null) {
|
||||||
|
packetEntityType = EntityTypes.getByName("minecraft:" + name().toLowerCase(Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
|
||||||
|
// PacketEvents is bugged in that it'll report the wrong entity IDs
|
||||||
|
if (objectId != null && !NmsVersion.v1_14.isSupported()) {
|
||||||
|
packetEntityType = EntityTypes.getByLegacyId(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion(), objectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPacketEntityType() == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Unable to find the packetevents entity type for " + name() + " with EntitType enum of " + getEntityType().name() +
|
||||||
|
" and name of " + getEntityType().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,10 +416,6 @@ public enum DisguiseType {
|
|||||||
return this.nmsType;
|
return this.nmsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultData() {
|
|
||||||
return defaultData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends Entity> getEntityClass() {
|
public Class<? extends Entity> getEntityClass() {
|
||||||
if (entityType != null && getEntityType().getEntityClass() != null) {
|
if (entityType != null && getEntityType().getEntityClass() != null) {
|
||||||
return getEntityType().getEntityClass();
|
return getEntityType().getEntityClass();
|
||||||
@ -349,45 +424,15 @@ public enum DisguiseType {
|
|||||||
return Entity.class;
|
return Entity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityType getEntityType() {
|
|
||||||
return entityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setEntityType(EntityType entityType) {
|
private void setEntityType(EntityType entityType) {
|
||||||
this.entityType = entityType;
|
this.entityType = entityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The object type send in packets when spawning a misc entity. Otherwise, -1.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getObjectId() {
|
|
||||||
return objectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The TYPE id of this entity. Different from the Object Id send in spawn packets when spawning miscs.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getTypeId() {
|
|
||||||
return typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTypeId(Object nmsType, int typeId) {
|
public void setTypeId(Object nmsType, int typeId) {
|
||||||
this.nmsType = nmsType;
|
this.nmsType = nmsType;
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends FlagWatcher> getWatcherClass() {
|
|
||||||
return watcherClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWatcherClass(Class<? extends FlagWatcher> c) {
|
|
||||||
watcherClass = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMisc() {
|
public boolean isMisc() {
|
||||||
return this == DisguiseType.MODDED_MISC || (!isCustom() && getEntityType() != null && !getEntityType().isAlive());
|
return this == DisguiseType.MODDED_MISC || (!isCustom() && getEntityType() != null && !getEntityType().isAlive());
|
||||||
}
|
}
|
||||||
@ -408,6 +453,10 @@ public enum DisguiseType {
|
|||||||
return this == DisguiseType.MODDED_MISC || this == DisguiseType.MODDED_LIVING;
|
return this == DisguiseType.MODDED_MISC || this == DisguiseType.MODDED_LIVING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isArtDisplay() {
|
||||||
|
return this == DisguiseType.ITEM_FRAME || this == DisguiseType.GLOW_ITEM_FRAME || this == DisguiseType.PAINTING;
|
||||||
|
}
|
||||||
|
|
||||||
public String toReadable() {
|
public String toReadable() {
|
||||||
String[] split = name().split("_");
|
String[] split = name().split("_");
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 6/05/2019.
|
|
||||||
*/
|
|
||||||
public enum EntityPose {
|
|
||||||
STANDING,
|
|
||||||
FALL_FLYING,
|
|
||||||
SLEEPING,
|
|
||||||
SWIMMING,
|
|
||||||
SPIN_ATTACK,
|
|
||||||
SNEAKING,
|
|
||||||
LONG_JUMPING,
|
|
||||||
DYING,
|
|
||||||
CROAKING,
|
|
||||||
USING_TONGUE,
|
|
||||||
SITTING,
|
|
||||||
ROARING,
|
|
||||||
SNIFFING,
|
|
||||||
EMERGING,
|
|
||||||
DIGGING
|
|
||||||
}
|
|
@ -1,14 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.github.retrooper.packetevents.protocol.player.Equipment;
|
||||||
import com.comphenix.protocol.wrappers.ComponentConverter;
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityEquipment;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRotation;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityTeleport;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
@ -22,22 +24,27 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
|||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.WatcherValue;
|
import me.libraryaddict.disguise.utilities.reflection.WatcherValue;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodGroupType;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodGroupType;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodHiddenFor;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodIgnoredBy;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodIgnoredBy;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -108,12 +115,14 @@ public class FlagWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer packet =
|
Entity entity = getDisguise().getEntity();
|
||||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
|
|
||||||
.createPacket(getDisguise().getEntity());
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
WrapperPlayServerEntityTeleport teleport =
|
||||||
|
new WrapperPlayServerEntityTeleport(entity.getEntityId(), SpigotConversionUtil.fromBukkitLocation(entity.getLocation()),
|
||||||
|
entity.isOnGround());
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, teleport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,12 +137,14 @@ public class FlagWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer packet =
|
Entity entity = getDisguise().getEntity();
|
||||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
|
|
||||||
.createPacket(getDisguise().getEntity());
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
WrapperPlayServerEntityTeleport teleport =
|
||||||
|
new WrapperPlayServerEntityTeleport(entity.getEntityId(), SpigotConversionUtil.fromBukkitLocation(entity.getLocation()),
|
||||||
|
entity.isOnGround());
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, teleport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,18 +181,14 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendHeadPacket() {
|
private void sendHeadPacket() {
|
||||||
PacketContainer rotateHead = new PacketContainer(Server.ENTITY_HEAD_ROTATION);
|
Entity entity = getDisguise().getEntity();
|
||||||
|
Location loc = entity.getLocation();
|
||||||
StructureModifier<Object> mods = rotateHead.getModifier();
|
|
||||||
|
|
||||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
|
||||||
|
|
||||||
Location loc = getDisguise().getEntity().getLocation();
|
|
||||||
|
|
||||||
mods.write(1, (byte) (int) (loc.getYaw() * 256.0F / 360.0F));
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, rotateHead);
|
WrapperPlayServerEntityRotation packet =
|
||||||
|
new WrapperPlayServerEntityRotation(entity.getEntityId(), loc.getYaw(), loc.getPitch(), entity.isOnGround());
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,9 +350,9 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch = new WatcherValue(index, value);
|
watch = new WatcherValue(index, value, true);
|
||||||
} else {
|
} else {
|
||||||
watch = new WatcherValue(index, watch.getValue());
|
watch = new WatcherValue(index, watch.getValue(), watch.isBukkitReadable());
|
||||||
|
|
||||||
if (id == MetaIndex.ENTITY_META.getIndex()) {
|
if (id == MetaIndex.ENTITY_META.getIndex()) {
|
||||||
doSneakCheck((Byte) watch.getValue());
|
doSneakCheck((Byte) watch.getValue());
|
||||||
@ -377,7 +384,7 @@ public class FlagWatcher {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WatcherValue watch = new WatcherValue(MetaIndex.getMetaIndex(this, id), value);
|
WatcherValue watch = new WatcherValue(MetaIndex.getMetaIndex(this, id), value, true);
|
||||||
|
|
||||||
if (watch == null) {
|
if (watch == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -488,6 +495,16 @@ public class FlagWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Bukkit.isPrimaryThread()) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateNameHeight();
|
||||||
|
}
|
||||||
|
}.runTask(LibsDisguises.getInstance());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Not using this as it's "Smooth" and looks a bit weirder
|
// Not using this as it's "Smooth" and looks a bit weirder
|
||||||
/*int[] ids = getDisguise().getArmorstandIds();
|
/*int[] ids = getDisguise().getArmorstandIds();
|
||||||
|
|
||||||
@ -506,16 +523,16 @@ public class FlagWatcher {
|
|||||||
packets.add(packet);
|
packets.add(packet);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
ArrayList<PacketContainer> packets = DisguiseUtilities.getNamePackets(getDisguise(), new String[0]);
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
if (!DisguiseUtilities.isFancyHiddenTabs() && getDisguise().isPlayerDisguise() &&
|
if (!DisguiseUtilities.isFancyHiddenTabs() && getDisguise().isPlayerDisguise() &&
|
||||||
LibsDisguises.getInstance().getSkinHandler().isSleeping(player, (PlayerDisguise) getDisguise())) {
|
LibsDisguises.getInstance().getSkinHandler().isSleeping(player, (PlayerDisguise) getDisguise())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PacketContainer packet : packets) {
|
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(getDisguise(), new String[0]);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
|
||||||
|
for (PacketWrapper<?> packet : packets) {
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,17 +558,12 @@ public class FlagWatcher {
|
|||||||
return getData(MetaIndex.ENTITY_CUSTOM_NAME_OLD);
|
return getData(MetaIndex.ENTITY_CUSTOM_NAME_OLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<WrappedChatComponent> optional = getData(MetaIndex.ENTITY_CUSTOM_NAME);
|
Optional<Component> optional = getData(MetaIndex.ENTITY_CUSTOM_NAME);
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
return optional.map(DisguiseUtilities::getSimpleString).orElse(null);
|
||||||
BaseComponent[] base = ComponentConverter.fromWrapper(optional.get());
|
|
||||||
|
|
||||||
return DisguiseUtilities.getSimpleString(base);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodHiddenFor(DisguiseType.PLAYER)
|
||||||
public void setCustomName(String name) {
|
public void setCustomName(String name) {
|
||||||
if (name != null && name.length() > 0 && ("159" + "2").equals("%%__USER__%%")) {
|
if (name != null && name.length() > 0 && ("159" + "2").equals("%%__USER__%%")) {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
@ -604,10 +616,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
Optional<WrappedChatComponent> optional =
|
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.of(DisguiseUtilities.getAdventureChat(name)));
|
||||||
Optional.of(WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(name))));
|
|
||||||
|
|
||||||
setData(MetaIndex.ENTITY_CUSTOM_NAME, optional);
|
|
||||||
} else {
|
} else {
|
||||||
setData(MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
|
setData(MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
|
||||||
}
|
}
|
||||||
@ -694,12 +703,12 @@ public class FlagWatcher {
|
|||||||
return getCustomName() != null;
|
return getCustomName() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasValue(MetaIndex no) {
|
public boolean hasValue(MetaIndex metaIndex) {
|
||||||
if (no == null) {
|
if (metaIndex == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return entityValues.containsKey(no.getIndex());
|
return entityValues.containsKey(metaIndex.getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning() {
|
public boolean isBurning() {
|
||||||
@ -860,9 +869,9 @@ public class FlagWatcher {
|
|||||||
WatcherValue watchable;
|
WatcherValue watchable;
|
||||||
|
|
||||||
if (entityValues.containsKey(i) && entityValues.get(i) != null) {
|
if (entityValues.containsKey(i) && entityValues.get(i) != null) {
|
||||||
watchable = new WatcherValue(MetaIndex.getMetaIndex(this, i), entityValues.get(i));
|
watchable = new WatcherValue(MetaIndex.getMetaIndex(this, i), entityValues.get(i), true);
|
||||||
} else if (backupEntityValues.containsKey(i) && backupEntityValues.get(i) != null) {
|
} else if (backupEntityValues.containsKey(i) && backupEntityValues.get(i) != null) {
|
||||||
watchable = new WatcherValue(MetaIndex.getMetaIndex(this, i), backupEntityValues.get(i));
|
watchable = new WatcherValue(MetaIndex.getMetaIndex(this, i), backupEntityValues.get(i), true);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -895,10 +904,22 @@ public class FlagWatcher {
|
|||||||
|
|
||||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetaPacketsEnabled() &&
|
if (isEntityAnimationsAdded() && DisguiseConfig.isMetaPacketsEnabled() &&
|
||||||
(data == MetaIndex.ENTITY_META || data == MetaIndex.LIVING_META)) {
|
(data == MetaIndex.ENTITY_META || data == MetaIndex.LIVING_META)) {
|
||||||
value = addEntityAnimations(data, (byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
|
||||||
|
byte b = (byte) data.getDefault();
|
||||||
|
|
||||||
|
for (EntityData d : ReflectionManager.getEntityWatcher(disguise.getEntity())) {
|
||||||
|
if (d.getIndex() != data.getIndex()) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WatcherValue watch = new WatcherValue(data, value);
|
b = (byte) d.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = addEntityAnimations(data, (byte) value, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
WatcherValue watch = new WatcherValue(data, value, true);
|
||||||
|
|
||||||
if (watch == null) {
|
if (watch == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -908,17 +929,13 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
PacketContainer packet = ReflectionManager.getMetadataPacket(getDisguise().getEntity().getEntityId(), list);
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
if (player == getDisguise().getEntity()) {
|
int entityId =
|
||||||
PacketContainer temp = packet.shallowClone();
|
player == getDisguise().getEntity() ? DisguiseAPI.getSelfDisguiseId() : getDisguise().getEntity().getEntityId();
|
||||||
temp.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, temp);
|
WrapperPlayServerEntityMetadata packet = ReflectionManager.getMetadataPacket(entityId, list);
|
||||||
} else {
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,26 +995,12 @@ public class FlagWatcher {
|
|||||||
itemStack = ReflectionManager.getEquipment(slot, getDisguise().getEntity());
|
itemStack = ReflectionManager.getEquipment(slot, getDisguise().getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
Object itemToSend = ReflectionManager.getNmsItem(itemStack);
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(Server.ENTITY_EQUIPMENT);
|
|
||||||
|
|
||||||
StructureModifier<Object> mods = packet.getModifier();
|
|
||||||
|
|
||||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
|
||||||
|
|
||||||
if (NmsVersion.v1_16.isSupported()) {
|
|
||||||
List<Pair<Object, Object>> list = new ArrayList<>();
|
|
||||||
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot), itemToSend));
|
|
||||||
|
|
||||||
mods.write(1, list);
|
|
||||||
} else {
|
|
||||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
|
||||||
mods.write(2, itemToSend);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
List<Equipment> list = Collections.singletonList(
|
||||||
|
new Equipment(ReflectionManager.getSlot(slot), SpigotConversionUtil.fromBukkitItemStack(itemStack)));
|
||||||
|
WrapperPlayServerEntityEquipment packet = new WrapperPlayServerEntityEquipment(getDisguise().getEntity().getEntityId(), list);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1042,7 +1045,7 @@ public class FlagWatcher {
|
|||||||
} else if (isSwimming()) {
|
} else if (isSwimming()) {
|
||||||
setEntityPose(EntityPose.SWIMMING);
|
setEntityPose(EntityPose.SWIMMING);
|
||||||
} else if (isSneaking()) {
|
} else if (isSneaking()) {
|
||||||
setEntityPose(EntityPose.SNEAKING);
|
setEntityPose(EntityPose.CROUCHING);
|
||||||
} else {
|
} else {
|
||||||
setEntityPose(EntityPose.STANDING);
|
setEntityPose(EntityPose.STANDING);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.disguisetypes; // Its here so I can make use o
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@ -16,6 +17,10 @@ public class LibsEquipment implements EntityEquipment {
|
|||||||
public LibsEquipment(FlagWatcher flagWatcher) {
|
public LibsEquipment(FlagWatcher flagWatcher) {
|
||||||
this.flagWatcher = flagWatcher;
|
this.flagWatcher = flagWatcher;
|
||||||
|
|
||||||
|
for (int i = 0; i < equipment.length; i++) {
|
||||||
|
equipment[i] = new ItemStack(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
import com.github.retrooper.packetevents.protocol.particle.Particle;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
import com.github.retrooper.packetevents.protocol.particle.data.ParticleColorData;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
import com.github.retrooper.packetevents.protocol.particle.type.ParticleTypes;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||||
|
import com.github.retrooper.packetevents.util.Quaternion4f;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3f;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractSkeletonWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractSkeletonWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractVillagerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractVillagerWatcher;
|
||||||
@ -108,29 +115,34 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
|||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.entity.Axolotl;
|
||||||
|
import org.bukkit.entity.Boat;
|
||||||
import org.bukkit.entity.Cat;
|
import org.bukkit.entity.Cat;
|
||||||
|
import org.bukkit.entity.Fox;
|
||||||
import org.bukkit.entity.Frog;
|
import org.bukkit.entity.Frog;
|
||||||
import org.bukkit.entity.Sniffer;
|
import org.bukkit.entity.ItemDisplay;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Llama;
|
||||||
|
import org.bukkit.entity.Ocelot;
|
||||||
|
import org.bukkit.entity.Panda;
|
||||||
|
import org.bukkit.entity.Parrot;
|
||||||
|
import org.bukkit.entity.Rabbit;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.OptionalInt;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MetaIndex<Y> {
|
public class MetaIndex<Y> {
|
||||||
@ -146,10 +158,16 @@ public class MetaIndex<Y> {
|
|||||||
*/
|
*/
|
||||||
public static MetaIndex<Boolean> AGEABLE_BABY = new MetaIndex<>(AgeableWatcher.class, 0, false);
|
public static MetaIndex<Boolean> AGEABLE_BABY = new MetaIndex<>(AgeableWatcher.class, 0, false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the area
|
||||||
|
*/
|
||||||
|
public static MetaIndex<Float> AREA_EFFECT_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 0, 3F);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 = new MetaIndex<>(AreaEffectCloudWatcher.class, 1, Color.BLACK.asRGB());
|
@NmsRemovedIn(NmsVersion.v1_20_R4)
|
||||||
|
public static MetaIndex<Color> AREA_EFFECT_CLOUD_COLOR = new MetaIndex<>(AreaEffectCloudWatcher.class, 1, Color.BLACK);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignore radius and show effect as single point, not area
|
* Ignore radius and show effect as single point, not area
|
||||||
@ -160,8 +178,8 @@ public class MetaIndex<Y> {
|
|||||||
* 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<Particle<?>> AREA_EFFECT_PARTICLE =
|
||||||
NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
new MetaIndex<>(AreaEffectCloudWatcher.class, 3, new Particle<>(ParticleTypes.ENTITY_EFFECT, new ParticleColorData(-1)));
|
||||||
|
|
||||||
@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);
|
||||||
@ -172,30 +190,25 @@ public class MetaIndex<Y> {
|
|||||||
@NmsRemovedIn(NmsVersion.v1_13)
|
@NmsRemovedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 5, 0);
|
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 5, 0);
|
||||||
|
|
||||||
/**
|
|
||||||
* The size of the area
|
|
||||||
*/
|
|
||||||
public static MetaIndex<Float> AREA_EFFECT_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 0, 3F);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand body eular vector
|
* Armorstand body eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0));
|
public static MetaIndex<Vector3f> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2, new Vector3f(0, 0, 0));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand head eular vector
|
* Armorstand head eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_HEAD = new MetaIndex<>(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0));
|
public static MetaIndex<Vector3f> ARMORSTAND_HEAD = 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 = new MetaIndex<>(ArmorStandWatcher.class, 3, new Vector3F(-10, 0, -10));
|
public static MetaIndex<Vector3f> ARMORSTAND_LEFT_ARM = 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 = new MetaIndex<>(ArmorStandWatcher.class, 5, new Vector3F(-1, 0, -1));
|
public static MetaIndex<Vector3f> ARMORSTAND_LEFT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 5, new Vector3f(-1, 0, -1));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armorstand metadata
|
* Armorstand metadata
|
||||||
@ -205,12 +218,12 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* Armorstand right arm eular vector
|
* Armorstand right arm eular vector
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 4, new Vector3F(-15, 0, 10));
|
public static MetaIndex<Vector3f> ARMORSTAND_RIGHT_ARM = 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 = new MetaIndex<>(ArmorStandWatcher.class, 6, new Vector3F(1, 0, 1));
|
public static MetaIndex<Vector3f> ARMORSTAND_RIGHT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 6, new Vector3f(1, 0, 1));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the arrow is a critical strike
|
* If the arrow is a critical strike
|
||||||
@ -228,7 +241,8 @@ public class MetaIndex<Y> {
|
|||||||
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)
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
public static MetaIndex<Integer> AXOLOTL_VARIANT = new MetaIndex<>(AxolotlWatcher.class, 0, 0);
|
public static MetaIndex<Axolotl.Variant> AXOLOTL_VARIANT =
|
||||||
|
new MetaIndex<>(AxolotlWatcher.class, 0, NmsVersion.v1_17.isSupported() ? Axolotl.Variant.LUCY : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_17)
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
public static MetaIndex<Boolean> AXOLOTL_PLAYING_DEAD = new MetaIndex<>(AxolotlWatcher.class, 1, false);
|
public static MetaIndex<Boolean> AXOLOTL_PLAYING_DEAD = new MetaIndex<>(AxolotlWatcher.class, 1, false);
|
||||||
@ -252,8 +266,8 @@ public class MetaIndex<Y> {
|
|||||||
*/
|
*/
|
||||||
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<BlockData> BLOCK_DISPLAY_BLOCK_STATE =
|
public static MetaIndex<WrappedBlockState> BLOCK_DISPLAY_BLOCK_STATE =
|
||||||
new MetaIndex<>(BlockDisplayWatcher.class, 0, NmsVersion.v1_19_R3.isSupported() ? Bukkit.createBlockData(Material.AIR) : null);
|
new MetaIndex<>(BlockDisplayWatcher.class, 0, WrappedBlockState.getDefaultState(StateTypes.AIR));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How damaged the boat is
|
* How damaged the boat is
|
||||||
@ -271,7 +285,12 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* The type of the boat, birch, pine, oak, etc.
|
* The type of the boat, birch, pine, oak, etc.
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> BOAT_TYPE = new MetaIndex<>(BoatWatcher.class, 3, 0);
|
@NmsRemovedIn(NmsVersion.v1_19_R1)
|
||||||
|
public static MetaIndex<TreeSpecies> BOAT_TYPE_OLD = new MetaIndex<>(BoatWatcher.class, 3, TreeSpecies.GENERIC);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_19_R1)
|
||||||
|
public static MetaIndex<Boat.Type> BOAT_TYPE_NEW =
|
||||||
|
new MetaIndex<>(BoatWatcher.class, 3, NmsVersion.v1_19_R1.isSupported() ? Boat.Type.OAK : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<Integer> BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
|
public static MetaIndex<Integer> BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
|
||||||
@ -283,12 +302,8 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Long> CAMEL_LAST_POSE_CHANGED = new MetaIndex<>(CamelWatcher.class, 1, 0L);
|
public static MetaIndex<Long> CAMEL_LAST_POSE_CHANGED = new MetaIndex<>(CamelWatcher.class, 1, 0L);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
@NmsRemovedIn(NmsVersion.v1_19_R1)
|
public static MetaIndex<Cat.Type> CAT_TYPE =
|
||||||
public static MetaIndex<Integer> CAT_TYPE = new MetaIndex<>(CatWatcher.class, 0, 0);
|
new MetaIndex<>(CatWatcher.class, 0, NmsVersion.v1_14.isSupported() ? Cat.Type.BLACK : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1)
|
|
||||||
public static MetaIndex<Cat.Type> CAT_TYPE_NEW =
|
|
||||||
new MetaIndex<>(CatWatcher.class, 0, NmsVersion.v1_19_R1.isSupported() ? Cat.Type.BLACK : null);
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Boolean> CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false);
|
public static MetaIndex<Boolean> CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false);
|
||||||
@ -297,7 +312,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Boolean> CAT_LOOKING_UP = new MetaIndex<>(CatWatcher.class, 2, false);
|
public static MetaIndex<Boolean> CAT_LOOKING_UP = new MetaIndex<>(CatWatcher.class, 2, false);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Integer> CAT_COLLAR = new MetaIndex<>(CatWatcher.class, 3, AnimalColor.RED.ordinal());
|
public static MetaIndex<AnimalColor> CAT_COLLAR = new MetaIndex<>(CatWatcher.class, 3, AnimalColor.RED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If creeper is ignited, about to blow up
|
* If creeper is ignited, about to blow up
|
||||||
@ -322,20 +337,18 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> DISPLAY_POS_ROT_INTERPOLATION_DURATION = new MetaIndex<>(DisplayWatcher.class, 2, 0);
|
public static MetaIndex<Integer> DISPLAY_POS_ROT_INTERPOLATION_DURATION = new MetaIndex<>(DisplayWatcher.class, 2, 0);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R3)
|
@NmsAddedIn(NmsVersion.v1_19_R3)
|
||||||
public static MetaIndex<Vector3f> DISPLAY_TRANSLATION =
|
public static MetaIndex<Vector3f> DISPLAY_TRANSLATION = new MetaIndex<>(DisplayWatcher.class, 3, new Vector3f());
|
||||||
new MetaIndex<>(DisplayWatcher.class, 3, NmsVersion.v1_19_R3.isSupported() ? new Vector3f() : null);
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R3)
|
@NmsAddedIn(NmsVersion.v1_19_R3)
|
||||||
public static MetaIndex<Vector3f> DISPLAY_SCALE =
|
public static MetaIndex<Vector3f> DISPLAY_SCALE = new MetaIndex<>(DisplayWatcher.class, 4, new Vector3f(1F, 1F, 1F));
|
||||||
new MetaIndex<>(DisplayWatcher.class, 4, NmsVersion.v1_19_R3.isSupported() ? new Vector3f(1F, 1F, 1F) : null);
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R3)
|
@NmsAddedIn(NmsVersion.v1_19_R3)
|
||||||
public static MetaIndex<Quaternionf> DISPLAY_LEFT_ROTATION =
|
public static MetaIndex<Quaternion4f> DISPLAY_LEFT_ROTATION =
|
||||||
new MetaIndex<>(DisplayWatcher.class, 5, NmsVersion.v1_19_R3.isSupported() ? new Quaternionf() : null);
|
new MetaIndex<>(DisplayWatcher.class, 5, new Quaternion4f(1F, 1F, 1F, 1F));
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R3)
|
@NmsAddedIn(NmsVersion.v1_19_R3)
|
||||||
public static MetaIndex<Quaternionf> DISPLAY_RIGHT_ROTATION =
|
public static MetaIndex<Quaternion4f> DISPLAY_RIGHT_ROTATION =
|
||||||
new MetaIndex<>(DisplayWatcher.class, 6, NmsVersion.v1_19_R3.isSupported() ? new Quaternionf() : null);
|
new MetaIndex<>(DisplayWatcher.class, 6, new Quaternion4f(1F, 1F, 1F, 1F));
|
||||||
|
|
||||||
public static MetaIndex<Byte> DISPLAY_BILLBOARD_RENDER_CONSTRAINTS = new MetaIndex<>(DisplayWatcher.class, 7, (byte) 0);
|
public static MetaIndex<Byte> DISPLAY_BILLBOARD_RENDER_CONSTRAINTS = new MetaIndex<>(DisplayWatcher.class, 7, (byte) 0);
|
||||||
|
|
||||||
@ -356,7 +369,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* No visible effect
|
* No visible effect
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<BlockPosition> DOLPHIN_TREASURE_POS = new MetaIndex<>(DolphinWatcher.class, 0, BlockPosition.ORIGIN);
|
public static MetaIndex<Vector3i> DOLPHIN_TREASURE_POS = new MetaIndex<>(DolphinWatcher.class, 0, Vector3i.zero());
|
||||||
/**
|
/**
|
||||||
* No visible effect
|
* No visible effect
|
||||||
*/
|
*/
|
||||||
@ -372,7 +385,7 @@ public class MetaIndex<Y> {
|
|||||||
*/
|
*/
|
||||||
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0, new ItemStack(Material.AIR));
|
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
|
|
||||||
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0, Optional.empty());
|
public static MetaIndex<Optional<Vector3i>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0, Optional.empty());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the ender crystal has a plate
|
* If the ender crystal has a plate
|
||||||
@ -393,9 +406,15 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Boolean> ENDERMAN_UNKNOWN = new MetaIndex<>(EndermanWatcher.class, 2, false);
|
public static MetaIndex<Boolean> ENDERMAN_UNKNOWN = new MetaIndex<>(EndermanWatcher.class, 2, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What block the enderman is holding
|
* What block the enderman is holding, uses internal nms int mappings
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0, Optional.empty());
|
public static MetaIndex<WrappedBlockState> ENDERMAN_ITEM =
|
||||||
|
new MetaIndex<>(EndermanWatcher.class, 0, WrappedBlockState.getByGlobalId(0));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bit shifted byte indicating several flags on the entity, sprinting, burning, sneaking, etc
|
||||||
|
*/
|
||||||
|
public static MetaIndex<Byte> ENTITY_META = new MetaIndex<>(FlagWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -403,7 +422,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 = new MetaIndex<>(FlagWatcher.class, 2, Optional.empty());
|
public static MetaIndex<Optional<Component>> ENTITY_CUSTOM_NAME = 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
|
||||||
*/
|
*/
|
||||||
@ -416,20 +435,15 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Boolean> ENTITY_CUSTOM_NAME_VISIBLE = new MetaIndex<>(FlagWatcher.class, 3, false);
|
public static MetaIndex<Boolean> ENTITY_CUSTOM_NAME_VISIBLE = new MetaIndex<>(FlagWatcher.class, 3, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A bit shifted byte indicating several flags on the entity, sprinting, burning, sneaking, etc
|
* If entity can make sounds, no noticable effects
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Byte> ENTITY_META = new MetaIndex<>(FlagWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Boolean> ENTITY_SILENT = new MetaIndex<>(FlagWatcher.class, 4, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If entity is effected by gravity, some visial effects
|
* If entity is effected by gravity, some visial effects
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Boolean> ENTITY_NO_GRAVITY = new MetaIndex<>(FlagWatcher.class, 5, false);
|
public static MetaIndex<Boolean> ENTITY_NO_GRAVITY = new MetaIndex<>(FlagWatcher.class, 5, false);
|
||||||
|
|
||||||
/**
|
|
||||||
* If entity can make sounds, no noticable effects
|
|
||||||
*/
|
|
||||||
public static MetaIndex<Boolean> ENTITY_SILENT = new MetaIndex<>(FlagWatcher.class, 4, false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If entity can make sounds, no noticable effects
|
* If entity can make sounds, no noticable effects
|
||||||
*/
|
*/
|
||||||
@ -440,7 +454,7 @@ public class MetaIndex<Y> {
|
|||||||
@NmsAddedIn(NmsVersion.v1_17)
|
@NmsAddedIn(NmsVersion.v1_17)
|
||||||
public static MetaIndex<Integer> ENTITY_TICKS_FROZEN = new MetaIndex<>(FlagWatcher.class, 7, 0);
|
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);
|
public static MetaIndex<Vector3i> FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0, Vector3i.zero());
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR));
|
public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
@ -454,7 +468,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 = new MetaIndex<>(FireworkWatcher.class, 1, OptionalInt.empty());
|
public static MetaIndex<Optional<Integer>> FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1, Optional.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);
|
||||||
@ -468,7 +482,7 @@ public class MetaIndex<Y> {
|
|||||||
* The type of fox, its coloring
|
* The type of fox, its coloring
|
||||||
*/
|
*/
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Integer> FOX_TYPE = new MetaIndex<>(FoxWatcher.class, 0, 0);
|
public static MetaIndex<Fox.Type> FOX_TYPE = new MetaIndex<>(FoxWatcher.class, 0, NmsVersion.v1_14.isSupported() ? Fox.Type.RED : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Byte> FOX_META = new MetaIndex<>(FoxWatcher.class, 1, (byte) 0);
|
public static MetaIndex<Byte> FOX_META = new MetaIndex<>(FoxWatcher.class, 1, (byte) 0);
|
||||||
@ -484,7 +498,7 @@ public class MetaIndex<Y> {
|
|||||||
new MetaIndex<>(FrogWatcher.class, 0, NmsVersion.v1_19_R1.isSupported() ? Frog.Variant.TEMPERATE : null);
|
new MetaIndex<>(FrogWatcher.class, 0, NmsVersion.v1_19_R1.isSupported() ? Frog.Variant.TEMPERATE : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1)
|
@NmsAddedIn(NmsVersion.v1_19_R1)
|
||||||
public static MetaIndex<OptionalInt> FROG_TONGUE_TARGET = new MetaIndex<>(FrogWatcher.class, 1, OptionalInt.empty());
|
public static MetaIndex<Optional<Integer>> FROG_TONGUE_TARGET = new MetaIndex<>(FrogWatcher.class, 1, Optional.empty());
|
||||||
/**
|
/**
|
||||||
* Changes the face of the ghast
|
* Changes the face of the ghast
|
||||||
*/
|
*/
|
||||||
@ -525,7 +539,7 @@ public class MetaIndex<Y> {
|
|||||||
/**
|
/**
|
||||||
* Color of the horse, uses enum not RGB
|
* Color of the horse, uses enum not RGB
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> HORSE_COLOR = new MetaIndex<>(HorseWatcher.class, 0, 0);
|
public static MetaIndex<Integer> HORSE_COLOR_STYLE = new MetaIndex<>(HorseWatcher.class, 0, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets several bit shifted flags, grazing, rearing, etc
|
* Sets several bit shifted flags, grazing, rearing, etc
|
||||||
@ -553,7 +567,8 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<ItemStack> ITEM_DISPLAY_ITEMSTACK = new MetaIndex<>(ItemDisplayWatcher.class, 0, new ItemStack(Material.AIR));
|
public static MetaIndex<ItemStack> ITEM_DISPLAY_ITEMSTACK = new MetaIndex<>(ItemDisplayWatcher.class, 0, new ItemStack(Material.AIR));
|
||||||
|
|
||||||
public static MetaIndex<Byte> ITEM_DISPLAY_TRANSFORM = new MetaIndex<>(ItemDisplayWatcher.class, 1, (byte) 0);
|
public static MetaIndex<ItemDisplay.ItemDisplayTransform> ITEM_DISPLAY_TRANSFORM = new MetaIndex<>(ItemDisplayWatcher.class, 1,
|
||||||
|
NmsVersion.v1_19_R3.isSupported() ? ItemDisplay.ItemDisplayTransform.NONE : null).byteValues();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The itemstack inside the itemframe
|
* The itemstack inside the itemframe
|
||||||
@ -571,11 +586,6 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Boolean> INTERACTION_RESPONSIVE = new MetaIndex<>(InteractionWatcher.class, 2, false);
|
public static MetaIndex<Boolean> INTERACTION_RESPONSIVE = new MetaIndex<>(InteractionWatcher.class, 2, false);
|
||||||
|
|
||||||
/**
|
|
||||||
* How many arrows sticking out of the living entity, currently used on player
|
|
||||||
*/
|
|
||||||
public static MetaIndex<Integer> LIVING_ARROWS = new MetaIndex<>(LivingWatcher.class, 4, 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main hand of the living entity
|
* The main hand of the living entity
|
||||||
*/
|
*/
|
||||||
@ -586,15 +596,24 @@ public class MetaIndex<Y> {
|
|||||||
*/
|
*/
|
||||||
public static MetaIndex<Float> LIVING_HEALTH = new MetaIndex<>(LivingWatcher.class, 1, 1F);
|
public static MetaIndex<Float> LIVING_HEALTH = new MetaIndex<>(LivingWatcher.class, 1, 1F);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_20_R4)
|
||||||
|
public static MetaIndex<List<Particle<?>>> LIVING_PARTICLES = new MetaIndex<>(LivingWatcher.class, 2, new ArrayList<>());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The RGB color of the potion particles, 0 if not set
|
||||||
|
*/
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_20_R4)
|
||||||
|
public static MetaIndex<Integer> LIVING_POTIONS = new MetaIndex<>(LivingWatcher.class, 2, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the potion effect particles should be faded
|
* If the potion effect particles should be faded
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Boolean> LIVING_POTION_AMBIENT = new MetaIndex<>(LivingWatcher.class, 3, false);
|
public static MetaIndex<Boolean> LIVING_POTION_AMBIENT = new MetaIndex<>(LivingWatcher.class, 3, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RGB color of the potion particles, 0 if not set
|
* How many arrows sticking out of the living entity, currently used on player
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> LIVING_POTIONS = new MetaIndex<>(LivingWatcher.class, 2, 0);
|
public static MetaIndex<Integer> LIVING_ARROWS = new MetaIndex<>(LivingWatcher.class, 4, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many bee stings does the entity have
|
* How many bee stings does the entity have
|
||||||
@ -603,48 +622,48 @@ 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 = new MetaIndex<>(LivingWatcher.class, 6, Optional.empty());
|
public static MetaIndex<Optional<Vector3i>> LIVING_BED_POSITION = new MetaIndex<>(LivingWatcher.class, 6, Optional.empty());
|
||||||
|
|
||||||
|
public static MetaIndex<Integer> LLAMA_STRENGTH = new MetaIndex<>(LlamaWatcher.class, 0, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_20_R4)
|
||||||
public static MetaIndex<Integer> LLAMA_CARPET = new MetaIndex<>(LlamaWatcher.class, 1, -1);
|
public static MetaIndex<Integer> LLAMA_CARPET = new MetaIndex<>(LlamaWatcher.class, 1, -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of the llama, color enum value
|
* The color of the llama, color enum value
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> LLAMA_COLOR = new MetaIndex<>(LlamaWatcher.class, 2, 0);
|
public static MetaIndex<Llama.Color> LLAMA_COLOR = new MetaIndex<>(LlamaWatcher.class, 2, Llama.Color.CREAMY);
|
||||||
|
|
||||||
public static MetaIndex<Integer> LLAMA_STRENGTH = new MetaIndex<>(LlamaWatcher.class, 0, 0);
|
public static MetaIndex<Integer> MINECART_SHAKING_POWER = new MetaIndex<>(MinecartWatcher.class, 0, 0);
|
||||||
|
|
||||||
|
public static MetaIndex<Integer> MINECART_SHAKING_DIRECTION = new MetaIndex<>(MinecartWatcher.class, 1, 1);
|
||||||
|
|
||||||
|
public static MetaIndex<Float> MINECART_SHAKING_MULITPLIER = new MetaIndex<>(MinecartWatcher.class, 2, 0F);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The block id:data combined id, 0 if no block
|
* The block id:data combined id, 0 if no block
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> MINECART_BLOCK = new MetaIndex<>(MinecartWatcher.class, 3, 0);
|
public static MetaIndex<Integer> MINECART_BLOCK = new MetaIndex<>(MinecartWatcher.class, 3, 0);
|
||||||
|
|
||||||
/**
|
|
||||||
* If there is a block inside the minecart
|
|
||||||
*/
|
|
||||||
public static MetaIndex<Boolean> MINECART_BLOCK_VISIBLE = new MetaIndex<>(MinecartWatcher.class, 5, false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How much gap there should be between minecart and block, 6 by default
|
* How much gap there should be between minecart and block, 6 by default
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<Integer> MINECART_BLOCK_Y = new MetaIndex<>(MinecartWatcher.class, 4, 6);
|
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);
|
/**
|
||||||
|
* If there is a block inside the minecart
|
||||||
public static MetaIndex<Float> MINECART_SHAKING_MULITPLIER = new MetaIndex<>(MinecartWatcher.class, 2, 0F);
|
*/
|
||||||
|
public static MetaIndex<Boolean> MINECART_BLOCK_VISIBLE = new MetaIndex<>(MinecartWatcher.class, 5, false);
|
||||||
public static MetaIndex<Integer> MINECART_SHAKING_POWER = new MetaIndex<>(MinecartWatcher.class, 0, 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command run if the minecraft is a command minecart block
|
* The command run if the minecraft is a command minecart block
|
||||||
*/
|
*/
|
||||||
public static MetaIndex<String> MINECART_COMMAND_STRING = new MetaIndex<>(MinecartCommandWatcher.class, 0, "");
|
public static MetaIndex<String> MINECART_COMMAND_STRING = new MetaIndex<>(MinecartCommandWatcher.class, 0, "");
|
||||||
|
|
||||||
public static MetaIndex<WrappedChatComponent> MINECART_COMMAND_LAST_OUTPUT =
|
public static MetaIndex<Component> MINECART_COMMAND_LAST_OUTPUT = new MetaIndex<>(MinecartCommandWatcher.class, 1, Component.empty());
|
||||||
new MetaIndex<>(MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText(""));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the minecart furnace is fueled and burning
|
* If the minecart furnace is fueled and burning
|
||||||
@ -655,7 +674,8 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<String> MUSHROOM_COW_TYPE = new MetaIndex<>(MushroomCowWatcher.class, 0, "RED");
|
public static MetaIndex<String> MUSHROOM_COW_TYPE = new MetaIndex<>(MushroomCowWatcher.class, 0, "RED");
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Integer> OCELOT_TYPE = new MetaIndex<>(OcelotWatcher.class, 0, 0);
|
public static MetaIndex<Ocelot.Type> OCELOT_TYPE =
|
||||||
|
new MetaIndex<>(OcelotWatcher.class, 0, !NmsVersion.v1_14.isSupported() ? Ocelot.Type.WILD_OCELOT : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Boolean> OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false);
|
public static MetaIndex<Boolean> OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false);
|
||||||
@ -673,15 +693,17 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> PANDA_UNKNOWN_2 = new MetaIndex<>(PandaWatcher.class, 2, 0);
|
public static MetaIndex<Integer> PANDA_UNKNOWN_2 = new MetaIndex<>(PandaWatcher.class, 2, 0);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Byte> PANDA_MAIN_GENE = new MetaIndex<>(PandaWatcher.class, 3, (byte) 0);
|
public static MetaIndex<Panda.Gene> PANDA_MAIN_GENE =
|
||||||
|
new MetaIndex<>(PandaWatcher.class, 3, NmsVersion.v1_14.isSupported() ? Panda.Gene.NORMAL : null).byteValues();
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Byte> PANDA_HIDDEN_GENE = new MetaIndex<>(PandaWatcher.class, 4, (byte) 0);
|
public static MetaIndex<Panda.Gene> PANDA_HIDDEN_GENE =
|
||||||
|
new MetaIndex<>(PandaWatcher.class, 4, NmsVersion.v1_14.isSupported() ? Panda.Gene.NORMAL : null).byteValues();
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Byte> PANDA_META = new MetaIndex<>(PandaWatcher.class, 5, (byte) 0);
|
public static MetaIndex<Byte> PANDA_META = new MetaIndex<>(PandaWatcher.class, 5, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Integer> PARROT_VARIANT = new MetaIndex<>(ParrotWatcher.class, 0, 0);
|
public static MetaIndex<Parrot.Variant> PARROT_VARIANT = new MetaIndex<>(ParrotWatcher.class, 0, Parrot.Variant.RED);
|
||||||
|
|
||||||
public static MetaIndex<Integer> PHANTOM_SIZE = new MetaIndex<>(PhantomWatcher.class, 0, 0);
|
public static MetaIndex<Integer> PHANTOM_SIZE = new MetaIndex<>(PhantomWatcher.class, 0, 0);
|
||||||
|
|
||||||
@ -715,29 +737,30 @@ 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<NBTCompound> PLAYER_LEFT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 4, new NBTCompound());
|
||||||
new MetaIndex<>(PlayerWatcher.class, 4, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
|
||||||
|
|
||||||
public static MetaIndex<NbtBase> PLAYER_RIGHT_SHOULDER_ENTITY =
|
public static MetaIndex<NBTCompound> PLAYER_RIGHT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 5, new NBTCompound());
|
||||||
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);
|
||||||
|
|
||||||
public static MetaIndex<Integer> PUFFERFISH_PUFF_STATE = new MetaIndex<>(PufferFishWatcher.class, 0, 0);
|
public static MetaIndex<Integer> PUFFERFISH_PUFF_STATE = new MetaIndex<>(PufferFishWatcher.class, 0, 0);
|
||||||
|
|
||||||
public static MetaIndex<Integer> RABBIT_TYPE = new MetaIndex<>(RabbitWatcher.class, 0, 0);
|
public static MetaIndex<Rabbit.Type> RABBIT_TYPE = new MetaIndex<>(RabbitWatcher.class, 0, Rabbit.Type.BROWN);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public static MetaIndex<Boolean> RAIDER_CASTING_SPELL = new MetaIndex<>(RaiderWatcher.class, 0, false);
|
public static MetaIndex<Boolean> RAIDER_CASTING_SPELL = new MetaIndex<>(RaiderWatcher.class, 0, false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Also has 'is sheared' meta
|
||||||
|
*/
|
||||||
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);
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_17)
|
@NmsRemovedIn(NmsVersion.v1_17)
|
||||||
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1, Optional.empty());
|
public static MetaIndex<Optional<Vector3i>> 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);
|
||||||
|
|
||||||
public static MetaIndex<Direction> SHULKER_FACING = new MetaIndex<>(ShulkerWatcher.class, 0, Direction.DOWN);
|
public static MetaIndex<BlockFace> SHULKER_FACING = new MetaIndex<>(ShulkerWatcher.class, 0, BlockFace.DOWN);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -751,13 +774,12 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
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<Sniffer.State> SNIFFER_STATE =
|
public static MetaIndex<SnifferState> SNIFFER_STATE = new MetaIndex<>(SnifferWatcher.class, 0, SnifferState.IDLING);
|
||||||
new MetaIndex<>(SnifferWatcher.class, 0, NmsVersion.v1_20_R1.isSupported() ? Sniffer.State.IDLING : null);
|
|
||||||
|
|
||||||
public static MetaIndex<Integer> SNIFFER_DROP_SEED_AT_TICK = new MetaIndex<>(SnifferWatcher.class, 1, 0);
|
public static MetaIndex<Integer> SNIFFER_DROP_SEED_AT_TICK = new MetaIndex<>(SnifferWatcher.class, 1, 0);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_16)
|
@NmsAddedIn(NmsVersion.v1_16)
|
||||||
public static MetaIndex<Integer> STRIDER_SADDLE_UNKNOWN = new MetaIndex<>(StriderWatcher.class, 0, 0);
|
public static MetaIndex<Integer> STRIDER_BOOST_TIME = new MetaIndex<>(StriderWatcher.class, 0, 0);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_16)
|
@NmsAddedIn(NmsVersion.v1_16)
|
||||||
public static MetaIndex<Boolean> STRIDER_WARM = new MetaIndex<>(StriderWatcher.class, 1, false);
|
public static MetaIndex<Boolean> STRIDER_WARM = new MetaIndex<>(StriderWatcher.class, 1, false);
|
||||||
@ -774,8 +796,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1, Optional.empty());
|
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1, Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<WrappedChatComponent> TEXT_DISPLAY_TEXT =
|
public static MetaIndex<Component> TEXT_DISPLAY_TEXT = new MetaIndex<>(TextDisplayWatcher.class, 0, Component.empty());
|
||||||
new MetaIndex<>(TextDisplayWatcher.class, 0, WrappedChatComponent.fromText(""));
|
|
||||||
|
|
||||||
public static MetaIndex<Integer> TEXT_DISPLAY_LINE_WIDTH = new MetaIndex<>(TextDisplayWatcher.class, 1, 200);
|
public static MetaIndex<Integer> TEXT_DISPLAY_LINE_WIDTH = new MetaIndex<>(TextDisplayWatcher.class, 1, 200);
|
||||||
|
|
||||||
@ -793,8 +814,8 @@ public class MetaIndex<Y> {
|
|||||||
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);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_20_R3)
|
@NmsAddedIn(NmsVersion.v1_20_R3)
|
||||||
public static MetaIndex<BlockData> TNT_BLOCK_TYPE =
|
public static MetaIndex<WrappedBlockState> TNT_BLOCK_TYPE =
|
||||||
new MetaIndex<>(TNTWatcher.class, 1, NmsVersion.v1_20_R3.isSupported() ? Bukkit.createBlockData(Material.TNT) : null);
|
new MetaIndex<>(TNTWatcher.class, 1, WrappedBlockState.getDefaultState(StateTypes.TNT));
|
||||||
|
|
||||||
public static MetaIndex<Byte> TRIDENT_ENCHANTS = new MetaIndex<>(TridentWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> TRIDENT_ENCHANTS = new MetaIndex<>(TridentWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
@ -803,13 +824,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 = new MetaIndex<>(TurtleWatcher.class, 0, BlockPosition.ORIGIN);
|
public static MetaIndex<Vector3i> TURTLE_HOME_POSITION = new MetaIndex<>(TurtleWatcher.class, 0, Vector3i.zero());
|
||||||
|
|
||||||
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 = new MetaIndex<>(TurtleWatcher.class, 3, BlockPosition.ORIGIN);
|
public static MetaIndex<Vector3i> TURTLE_TRAVEL_POSITION = new MetaIndex<>(TurtleWatcher.class, 3, Vector3i.zero());
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -824,8 +845,8 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0);
|
public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0);
|
||||||
|
|
||||||
@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 =
|
||||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
new MetaIndex<>(VillagerWatcher.class, 0, new VillagerData(VillagerTypes.PLAINS, VillagerProfessions.NONE, 1));
|
||||||
|
|
||||||
public static MetaIndex<Integer> WARDEN_ANGER = new MetaIndex<>(WardenWatcher.class, 0, 0);
|
public static MetaIndex<Integer> WARDEN_ANGER = new MetaIndex<>(WardenWatcher.class, 0, 0);
|
||||||
|
|
||||||
@ -841,41 +862,45 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Boolean> WITHER_SKULL_BLUE = new MetaIndex<>(WitherSkullWatcher.class, 0, false);
|
public static MetaIndex<Boolean> WITHER_SKULL_BLUE = new MetaIndex<>(WitherSkullWatcher.class, 0, false);
|
||||||
|
|
||||||
public static MetaIndex<Boolean> WOLF_BEGGING = new MetaIndex<>(WolfWatcher.class, 1, false);
|
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_15)
|
@NmsRemovedIn(NmsVersion.v1_15)
|
||||||
public static MetaIndex<Float> WOLF_DAMAGE = new MetaIndex<>(WolfWatcher.class, 0, 1F);
|
public static MetaIndex<Float> WOLF_DAMAGE = new MetaIndex<>(WolfWatcher.class, 0, 1F);
|
||||||
|
|
||||||
public static MetaIndex<Integer> WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, 14);
|
public static MetaIndex<Boolean> WOLF_BEGGING = new MetaIndex<>(WolfWatcher.class, 1, false);
|
||||||
|
|
||||||
|
public static MetaIndex<AnimalColor> WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, AnimalColor.RED);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_16)
|
@NmsAddedIn(NmsVersion.v1_16)
|
||||||
public static MetaIndex<Integer> WOLF_ANGER = new MetaIndex<>(WolfWatcher.class, 3, 0);
|
public static MetaIndex<Integer> WOLF_ANGER = new MetaIndex<>(WolfWatcher.class, 3, 0);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_20_R4)
|
||||||
|
public static MetaIndex<Wolf.Variant> WOLF_VARIANT =
|
||||||
|
new MetaIndex<>(WolfWatcher.class, 4, NmsVersion.v1_20_R4.isSupported() ? Wolf.Variant.PALE : null);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_16)
|
@NmsAddedIn(NmsVersion.v1_16)
|
||||||
public static MetaIndex<Boolean> ZOGLIN_BABY = new MetaIndex<>(ZoglinWatcher.class, 0, false);
|
public static MetaIndex<Boolean> ZOGLIN_BABY = new MetaIndex<>(ZoglinWatcher.class, 0, false);
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
|
||||||
public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
|
||||||
|
|
||||||
public static MetaIndex<Boolean> ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false);
|
public static MetaIndex<Boolean> ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
|
||||||
public static MetaIndex<Boolean> ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
|
||||||
|
|
||||||
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 = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
|
public static MetaIndex<Boolean> ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 3, false);
|
||||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shown for villager conversion
|
* Shown for villager conversion
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
|
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
|
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION_OLD = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
|
public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION =
|
||||||
|
new MetaIndex<>(ZombieVillagerWatcher.class, 1, new VillagerData(VillagerTypes.PLAINS, VillagerProfessions.NONE, 1));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
setValues();
|
setValues();
|
||||||
eliminateBlankIndexes();
|
eliminateBlankIndexes();
|
||||||
@ -962,7 +987,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(), getDefault().getClass().getSimpleName(),
|
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(), getDefault().getClass().getSimpleName(),
|
||||||
DisguiseUtilities.getGson().toJson(getDefault()));
|
getDataType().getName(), DisguiseUtilities.getGson().toJson(getDefault()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1167,7 +1192,7 @@ public class MetaIndex<Y> {
|
|||||||
_values = Arrays.copyOf(_values, _values.length + 1);
|
_values = Arrays.copyOf(_values, _values.length + 1);
|
||||||
_values[_values.length - 1] = index;
|
_values[_values.length - 1] = index;
|
||||||
|
|
||||||
index.serializer = DisguiseUtilities.getSerializer(index);
|
index.dataType = ReflectionManager.getEntityDataType(index, field);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1193,9 +1218,12 @@ public class MetaIndex<Y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Class<? extends FlagWatcher> _watcher;
|
private final Class<? extends FlagWatcher> _watcher;
|
||||||
|
@Getter
|
||||||
|
private EntityDataType<?> dataType;
|
||||||
private int _index;
|
private int _index;
|
||||||
private final Y _defaultValue;
|
private final Y _defaultValue;
|
||||||
private WrappedDataWatcher.Serializer serializer;
|
@Getter
|
||||||
|
private boolean byteValues;
|
||||||
|
|
||||||
public MetaIndex(Class<? extends FlagWatcher> watcher, int index, Y defaultValue) {
|
public MetaIndex(Class<? extends FlagWatcher> watcher, int index, Y defaultValue) {
|
||||||
_watcher = watcher;
|
_watcher = watcher;
|
||||||
@ -1207,13 +1235,6 @@ public class MetaIndex<Y> {
|
|||||||
return _defaultValue;
|
return _defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for serializing values to a packet stream
|
|
||||||
*/
|
|
||||||
public WrappedDataWatcher.Serializer getSerializer() {
|
|
||||||
return serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends FlagWatcher> getFlagWatcher() {
|
public Class<? extends FlagWatcher> getFlagWatcher() {
|
||||||
return _watcher;
|
return _watcher;
|
||||||
}
|
}
|
||||||
@ -1221,4 +1242,28 @@ public class MetaIndex<Y> {
|
|||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return _index;
|
return _index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MetaIndex<Y> byteValues() {
|
||||||
|
this.byteValues = true;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItemStack() {
|
||||||
|
return this == ITEMFRAME_ITEM || this == ITEM_DISPLAY_ITEMSTACK || this == ENDER_SIGNAL_ITEM || this == DROPPED_ITEM ||
|
||||||
|
this == FIREBALL_ITEM || this == THROWABLE_ITEM || this == SPLASH_POTION_ITEM || this == FIREWORK_ITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlock() {
|
||||||
|
return this == BLOCK_DISPLAY_BLOCK_STATE || this == TNT_BLOCK_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlockOpt() {
|
||||||
|
return this == ENDERMAN_ITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRotation() {
|
||||||
|
return this == ARMORSTAND_BODY || this == ARMORSTAND_HEAD || this == ARMORSTAND_LEFT_ARM || this == ARMORSTAND_RIGHT_ARM ||
|
||||||
|
this == ARMORSTAND_LEFT_LEG || this == ARMORSTAND_RIGHT_LEG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfo;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
@ -20,7 +21,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class PlayerDisguise extends TargetedDisguise {
|
public class PlayerDisguise extends TargetedDisguise {
|
||||||
private transient LibsProfileLookup currentLookup;
|
private transient LibsProfileLookup currentLookup;
|
||||||
private WrappedGameProfile gameProfile;
|
private UserProfile userProfile;
|
||||||
private String playerName = "Herobrine";
|
private String playerName = "Herobrine";
|
||||||
private String tablistName;
|
private String tablistName;
|
||||||
private String skinToUse;
|
private String skinToUse;
|
||||||
@ -39,11 +40,11 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise(Player player) {
|
public PlayerDisguise(Player player) {
|
||||||
this(ReflectionManager.getGameProfile(player));
|
this(ReflectionManager.getUserProfile(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise(Player player, Player skinToUse) {
|
public PlayerDisguise(Player player, Player skinToUse) {
|
||||||
this(ReflectionManager.getGameProfile(player), ReflectionManager.getGameProfile(skinToUse));
|
this(ReflectionManager.getUserProfile(player), ReflectionManager.getUserProfile(skinToUse));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise(String name) {
|
public PlayerDisguise(String name) {
|
||||||
@ -54,7 +55,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
this();
|
this();
|
||||||
|
|
||||||
if (name.equals(skinToUse)) {
|
if (name.equals(skinToUse)) {
|
||||||
WrappedGameProfile profile = getProfile(skinToUse);
|
UserProfile profile = getProfile(skinToUse);
|
||||||
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
setName(profile.getName());
|
setName(profile.getName());
|
||||||
@ -70,22 +71,22 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
createDisguise();
|
createDisguise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise(WrappedGameProfile gameProfile) {
|
public PlayerDisguise(UserProfile userProfile) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
setName(gameProfile.getName());
|
setName(userProfile.getName());
|
||||||
|
|
||||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), gameProfile.getName(), gameProfile);
|
this.userProfile = ReflectionManager.getUserProfileWithThisSkin(getUUID(), userProfile.getName(), userProfile);
|
||||||
|
|
||||||
createDisguise();
|
createDisguise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise(WrappedGameProfile gameProfile, WrappedGameProfile skinToUse) {
|
public PlayerDisguise(UserProfile userProfile, UserProfile skinToUse) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
setName(gameProfile.getName());
|
setName(userProfile.getName());
|
||||||
|
|
||||||
this.gameProfile = ReflectionManager.getGameProfile(getUUID(), gameProfile.getName());
|
this.userProfile = ReflectionManager.getUserProfile(getUUID(), userProfile.getName());
|
||||||
|
|
||||||
setSkin(skinToUse);
|
setSkin(skinToUse);
|
||||||
|
|
||||||
@ -238,10 +239,10 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
disguise.setWatcher(getWatcher().clone(disguise));
|
disguise.setWatcher(getWatcher().clone(disguise));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLookup == null && gameProfile != null) {
|
if (currentLookup == null && userProfile != null) {
|
||||||
disguise.skinToUse = getSkin();
|
disguise.skinToUse = getSkin();
|
||||||
disguise.gameProfile =
|
disguise.userProfile =
|
||||||
ReflectionManager.getGameProfileWithThisSkin(disguise.getUUID(), getGameProfile().getName(), getGameProfile());
|
ReflectionManager.getUserProfileWithThisSkin(disguise.getUUID(), getUserProfile().getName(), getUserProfile());
|
||||||
} else {
|
} else {
|
||||||
disguise.setSkin(getSkin());
|
disguise.setSkin(getSkin());
|
||||||
}
|
}
|
||||||
@ -257,21 +258,25 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
return disguise;
|
return disguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedGameProfile getGameProfile() {
|
public UserProfile getUserProfile() {
|
||||||
if (gameProfile == null) {
|
if (userProfile == null) {
|
||||||
if (getSkin() != null) {
|
if (getSkin() != null) {
|
||||||
gameProfile = ReflectionManager.getGameProfile(getUUID(), getProfileName());
|
userProfile = ReflectionManager.getUserProfile(getUUID(), getProfileName());
|
||||||
} else {
|
} else {
|
||||||
gameProfile =
|
userProfile =
|
||||||
ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), DisguiseUtilities.getProfileFromMojang(this));
|
ReflectionManager.getUserProfileWithThisSkin(getUUID(), getProfileName(), DisguiseUtilities.getProfileFromMojang(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gameProfile;
|
return userProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGameProfile(WrappedGameProfile gameProfile) {
|
public void setGameProfile(GameProfile userProfile) {
|
||||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), gameProfile.getName(), gameProfile);
|
setUserProfile(ReflectionManager.getUserProfile(userProfile));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserProfile(UserProfile userProfile) {
|
||||||
|
this.userProfile = ReflectionManager.getUserProfileWithThisSkin(getUUID(), this.userProfile.getName(), this.userProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -312,6 +317,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
cLimit = ((NmsVersion.v1_13.isSupported() ? 64 : 16) * 2) + 16;
|
cLimit = ((NmsVersion.v1_13.isSupported() ? 64 : 16) * 2) + 16;
|
||||||
break;
|
break;
|
||||||
case ARMORSTANDS:
|
case ARMORSTANDS:
|
||||||
|
// This limit seems weird, we can do multilines can't we?
|
||||||
|
// Plus newer versions may extend limit
|
||||||
cLimit = 256;
|
cLimit = 256;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -358,14 +365,16 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isDisplayedInTab() && tablistName == null) {
|
if (isDisplayedInTab() && tablistName == null) {
|
||||||
PacketContainer addTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!canSee(player)) {
|
if (!canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
PacketWrapper addTab =
|
||||||
|
DisguiseUtilities.createTablistPacket(this, WrapperPlayServerPlayerInfo.Action.UPDATE_DISPLAY_NAME);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, addTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -383,8 +392,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
setNameVisible(!name.isEmpty(), true);
|
setNameVisible(!name.isEmpty(), true);
|
||||||
playerName = name;
|
playerName = name;
|
||||||
|
|
||||||
if (gameProfile != null) {
|
if (userProfile != null) {
|
||||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), getGameProfile());
|
userProfile = ReflectionManager.getUserProfileWithThisSkin(getUUID(), getProfileName(), getUserProfile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,14 +413,14 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer addTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!canSee(player)) {
|
if (!canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
PacketWrapper addTab = DisguiseUtilities.createTablistPacket(this, WrapperPlayServerPlayerInfo.Action.UPDATE_DISPLAY_NAME);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, addTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,8 +438,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
scoreboardName = null;
|
scoreboardName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameProfile != null) {
|
if (userProfile != null) {
|
||||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), getGameProfile());
|
userProfile = ReflectionManager.getUserProfileWithThisSkin(getUUID(), getProfileName(), getUserProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!startDisguise()) {
|
if (!startDisguise()) {
|
||||||
@ -446,7 +455,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise setSkin(String newSkin) {
|
public PlayerDisguise setSkin(String newSkin) {
|
||||||
WrappedGameProfile profile = getProfile(newSkin);
|
UserProfile profile = getProfile(newSkin);
|
||||||
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
return setSkin(profile);
|
return setSkin(profile);
|
||||||
@ -469,7 +478,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
|
|
||||||
if (newSkin == null) {
|
if (newSkin == null) {
|
||||||
currentLookup = null;
|
currentLookup = null;
|
||||||
gameProfile = null;
|
userProfile = null;
|
||||||
} else {
|
} else {
|
||||||
if (newSkin.length() > 16) {
|
if (newSkin.length() > 16) {
|
||||||
skinToUse = newSkin.substring(0, 16);
|
skinToUse = newSkin.substring(0, 16);
|
||||||
@ -482,22 +491,22 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
if (isDisguiseInUse()) {
|
if (isDisguiseInUse()) {
|
||||||
currentLookup = new LibsProfileLookup() {
|
currentLookup = new LibsProfileLookup() {
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(WrappedGameProfile gameProfile) {
|
public void onLookup(UserProfile userProfile) {
|
||||||
if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty()) {
|
if (currentLookup != this || userProfile == null || userProfile.getTextureProperties().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSkin(gameProfile);
|
setSkin(userProfile);
|
||||||
|
|
||||||
currentLookup = null;
|
currentLookup = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WrappedGameProfile gameProfile =
|
UserProfile userProfile =
|
||||||
DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
|
DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
|
||||||
|
|
||||||
if (gameProfile != null) {
|
if (userProfile != null) {
|
||||||
setSkin(gameProfile);
|
setSkin(userProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -506,33 +515,33 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the GameProfile, without tampering.
|
* Set the UserProfile
|
||||||
*
|
*
|
||||||
* @param gameProfile GameProfile
|
* @param userProfile UserProfile
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PlayerDisguise setSkin(WrappedGameProfile gameProfile) {
|
public PlayerDisguise setSkin(UserProfile userProfile) {
|
||||||
if (gameProfile == null) {
|
if (userProfile == null) {
|
||||||
this.gameProfile = null;
|
this.userProfile = null;
|
||||||
this.skinToUse = null;
|
this.skinToUse = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLookup = null;
|
currentLookup = null;
|
||||||
|
|
||||||
this.skinToUse = gameProfile.getName();
|
this.skinToUse = userProfile.getName();
|
||||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), gameProfile);
|
this.userProfile = ReflectionManager.getUserProfileWithThisSkin(getUUID(), getProfileName(), userProfile);
|
||||||
|
|
||||||
refreshDisguise();
|
refreshDisguise();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WrappedGameProfile getProfile(String string) {
|
private UserProfile getProfile(String string) {
|
||||||
if (string != null && string.length() > 70 && string.startsWith("{\"id\":") && string.endsWith("}") &&
|
if (string != null && string.length() > 70 && (string.startsWith("{\"uuid\":") || string.startsWith("{\"id\":")) &&
|
||||||
string.contains(",\"name\":")) {
|
string.endsWith("}") && string.contains(",\"name\":")) {
|
||||||
try {
|
try {
|
||||||
return DisguiseUtilities.getGson().fromJson(string, WrappedGameProfile.class);
|
return DisguiseUtilities.getGson().fromJson(string, UserProfile.class);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new IllegalStateException("Tried to parse " + string + " to a GameProfile, but it has been formatted incorrectly!");
|
throw new IllegalStateException("Tried to parse " + string + " to a GameProfile, but it has been formatted incorrectly!");
|
||||||
}
|
}
|
||||||
@ -547,16 +556,16 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DisguiseUtilities.isFancyHiddenTabs() || isDisplayedInTab()) {
|
if (DisguiseUtilities.isFancyHiddenTabs() || isDisplayedInTab()) {
|
||||||
PacketContainer addTab = ReflectionManager.createTablistAddPackets(this);
|
|
||||||
PacketContainer deleteTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.REMOVE_PLAYER);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (!canSee(player)) {
|
if (!canSee(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
PacketWrapper addTab = DisguiseUtilities.createTablistAddPackets(this);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
PacketWrapper deleteTab = DisguiseUtilities.createTablistPacket(this, WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER);
|
||||||
|
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, deleteTab);
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, addTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,25 +656,25 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skinToUse != null && gameProfile == null) {
|
if (skinToUse != null && userProfile == null) {
|
||||||
currentLookup = new LibsProfileLookup() {
|
currentLookup = new LibsProfileLookup() {
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(WrappedGameProfile gameProfile) {
|
public void onLookup(UserProfile userProfile) {
|
||||||
if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty()) {
|
if (currentLookup != this || userProfile == null || userProfile.getTextureProperties().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSkin(gameProfile);
|
setSkin(userProfile);
|
||||||
|
|
||||||
currentLookup = null;
|
currentLookup = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WrappedGameProfile gameProfile =
|
UserProfile userProfile =
|
||||||
DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
|
DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
|
||||||
|
|
||||||
if (gameProfile != null) {
|
if (userProfile != null) {
|
||||||
setSkin(gameProfile);
|
setSkin(userProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,31 +1,43 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
public enum RabbitType {
|
import lombok.Getter;
|
||||||
BLACK(2),
|
import lombok.RequiredArgsConstructor;
|
||||||
BROWN(0),
|
import org.bukkit.entity.Rabbit;
|
||||||
GOLD(4),
|
|
||||||
KILLER_BUNNY(99),
|
|
||||||
PATCHES(3),
|
|
||||||
PEPPER(5),
|
|
||||||
WHITE(1);
|
|
||||||
|
|
||||||
public static RabbitType getType(int id) {
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum RabbitType {
|
||||||
|
BLACK(2, Rabbit.Type.BLACK),
|
||||||
|
BROWN(0, Rabbit.Type.BROWN),
|
||||||
|
GOLD(4, Rabbit.Type.GOLD),
|
||||||
|
KILLER_BUNNY(99, Rabbit.Type.THE_KILLER_BUNNY),
|
||||||
|
PATCHES(3, Rabbit.Type.BLACK_AND_WHITE),
|
||||||
|
PEPPER(5, Rabbit.Type.SALT_AND_PEPPER),
|
||||||
|
WHITE(1, Rabbit.Type.WHITE);
|
||||||
|
|
||||||
|
public static Rabbit.Type getType(int id) {
|
||||||
for (RabbitType type : values()) {
|
for (RabbitType type : values()) {
|
||||||
if (type.getTypeId() == id) {
|
if (type.getTypeId() != id) {
|
||||||
return type;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return type.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public static int getTypeId(Rabbit.Type rabbitType) {
|
||||||
private final int type;
|
for (RabbitType type : values()) {
|
||||||
|
if (type.getType() != rabbitType) {
|
||||||
RabbitType(int type) {
|
continue;
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTypeId() {
|
return type.getTypeId();
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new IllegalStateException("Unknown rabbit type " + rabbitType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int typeId;
|
||||||
|
private final Rabbit.Type type;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
@ -52,9 +52,9 @@ public abstract class TargetedDisguise extends Disguise {
|
|||||||
Player player = Bukkit.getPlayerExact(playername);
|
Player player = Bukkit.getPlayerExact(playername);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PacketContainer deleteTab = ReflectionManager.updateTablistVisibility((Player) getEntity(), !canSee(player));
|
PacketWrapper<?> deleteTab = DisguiseUtilities.updateTablistVisibility((Player) getEntity(), !canSee(player));
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, deleteTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,9 +113,9 @@ public abstract class TargetedDisguise extends Disguise {
|
|||||||
Player player = Bukkit.getPlayerExact(playername);
|
Player player = Bukkit.getPlayerExact(playername);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PacketContainer deleteTab = ReflectionManager.updateTablistVisibility((Player) getEntity(), canSee(player));
|
PacketWrapper deleteTab = DisguiseUtilities.updateTablistVisibility((Player) getEntity(), canSee(player));
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, deleteTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 6/05/2019.
|
|
||||||
*/
|
|
||||||
public class VillagerData {
|
|
||||||
private final Villager.Type type;
|
|
||||||
private final Villager.Profession profession;
|
|
||||||
private final int level;
|
|
||||||
|
|
||||||
public VillagerData(Villager.Type type, Villager.Profession profession, int level) {
|
|
||||||
this.type = type;
|
|
||||||
this.profession = profession;
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Villager.Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Villager.Profession getProfession() {
|
|
||||||
return profession;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel() {
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,6 +3,7 @@ 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.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -20,6 +21,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_19_R3)
|
@NmsRemovedIn(NmsVersion.v1_19_R3)
|
||||||
|
@MethodDescription
|
||||||
public void setOwner(UUID uuid) {
|
public void setOwner(UUID uuid) {
|
||||||
setData(MetaIndex.HORSE_OWNER, Optional.of(uuid));
|
setData(MetaIndex.HORSE_OWNER, Optional.of(uuid));
|
||||||
sendData(MetaIndex.HORSE_OWNER);
|
sendData(MetaIndex.HORSE_OWNER);
|
||||||
@ -34,6 +36,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
return isHorseFlag(REPRODUCED);
|
return isHorseFlag(REPRODUCED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription(noVisibleDifference = true)
|
||||||
public void setReproduced(boolean reproduced) {
|
public void setReproduced(boolean reproduced) {
|
||||||
setHorseFlag(REPRODUCED, reproduced);
|
setHorseFlag(REPRODUCED, reproduced);
|
||||||
}
|
}
|
||||||
@ -47,6 +50,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
return isHorseFlag(GRAZING);
|
return isHorseFlag(GRAZING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the horse's head lowered?")
|
||||||
public void setGrazing(boolean grazing) {
|
public void setGrazing(boolean grazing) {
|
||||||
setHorseFlag(GRAZING, grazing);
|
setHorseFlag(GRAZING, grazing);
|
||||||
}
|
}
|
||||||
@ -60,6 +64,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
return isHorseFlag(EATING);
|
return isHorseFlag(EATING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the horse's mouth open?")
|
||||||
public void setEating(boolean mouthOpen) {
|
public void setEating(boolean mouthOpen) {
|
||||||
setHorseFlag(EATING, mouthOpen);
|
setHorseFlag(EATING, mouthOpen);
|
||||||
}
|
}
|
||||||
@ -68,6 +73,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
return isHorseFlag(REARING);
|
return isHorseFlag(REARING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the horse rearing in the air?")
|
||||||
public void setRearing(boolean rear) {
|
public void setRearing(boolean rear) {
|
||||||
setHorseFlag(REARING, rear);
|
setHorseFlag(REARING, rear);
|
||||||
}
|
}
|
||||||
@ -76,6 +82,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
return isHorseFlag(SADDLED);
|
return isHorseFlag(SADDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the horse wearing a saddle?")
|
||||||
public void setSaddled(boolean saddled) {
|
public void setSaddled(boolean saddled) {
|
||||||
setHorseFlag(SADDLED, saddled);
|
setHorseFlag(SADDLED, saddled);
|
||||||
}
|
}
|
||||||
@ -84,6 +91,7 @@ public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
|||||||
return isHorseFlag(TAMED);
|
return isHorseFlag(TAMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the horse tamed?")
|
||||||
public void setTamed(boolean tamed) {
|
public void setTamed(boolean tamed) {
|
||||||
setHorseFlag(TAMED, tamed);
|
setHorseFlag(TAMED, tamed);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ 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.annotations.MethodDescription;
|
||||||
|
|
||||||
public class AgeableWatcher extends InsentientWatcher {
|
public class AgeableWatcher extends InsentientWatcher {
|
||||||
public AgeableWatcher(Disguise disguise) {
|
public AgeableWatcher(Disguise disguise) {
|
||||||
@ -16,6 +17,7 @@ public class AgeableWatcher extends InsentientWatcher {
|
|||||||
return getData(MetaIndex.AGEABLE_BABY);
|
return getData(MetaIndex.AGEABLE_BABY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this a baby?")
|
||||||
public void setBaby(boolean isBaby) {
|
public void setBaby(boolean isBaby) {
|
||||||
setData(MetaIndex.AGEABLE_BABY, isBaby);
|
setData(MetaIndex.AGEABLE_BABY, isBaby);
|
||||||
sendData(MetaIndex.AGEABLE_BABY);
|
sendData(MetaIndex.AGEABLE_BABY);
|
||||||
|
@ -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.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodHiddenFor;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
|
|
||||||
@ -16,6 +18,7 @@ public class AllayWatcher extends InsentientWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1)
|
@NmsAddedIn(NmsVersion.v1_19_R1)
|
||||||
|
@MethodDescription("Is the Allay dancing?")
|
||||||
public void setDancing(boolean dancing) {
|
public void setDancing(boolean dancing) {
|
||||||
setData(MetaIndex.ALLAY_DANCING, dancing);
|
setData(MetaIndex.ALLAY_DANCING, dancing);
|
||||||
sendData(MetaIndex.ALLAY_DANCING);
|
sendData(MetaIndex.ALLAY_DANCING);
|
||||||
@ -26,7 +29,7 @@ public class AllayWatcher extends InsentientWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_19_R1)
|
@NmsAddedIn(NmsVersion.v1_19_R1)
|
||||||
@MethodOnlyUsedBy(value = {}) // Hide from command
|
@MethodHiddenFor(value = {}) // Hide from command
|
||||||
public void setCanDuplicate(boolean canDuplicate) {
|
public void setCanDuplicate(boolean canDuplicate) {
|
||||||
setData(MetaIndex.ALLAY_CAN_DUPLICATE, canDuplicate);
|
setData(MetaIndex.ALLAY_CAN_DUPLICATE, canDuplicate);
|
||||||
sendData(MetaIndex.ALLAY_CAN_DUPLICATE);
|
sendData(MetaIndex.ALLAY_CAN_DUPLICATE);
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
|
import com.github.retrooper.packetevents.protocol.particle.data.ParticleData;
|
||||||
|
import com.github.retrooper.packetevents.protocol.particle.type.ParticleType;
|
||||||
|
import com.github.retrooper.packetevents.protocol.particle.type.ParticleTypes;
|
||||||
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
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 me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||||
import org.apache.commons.lang.math.RandomUtils;
|
import org.apache.commons.lang.math.RandomUtils;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
@ -20,7 +26,7 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
public AreaEffectCloudWatcher(Disguise disguise) {
|
public AreaEffectCloudWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
if (DisguiseConfig.isRandomDisguises()) {
|
if (!NmsVersion.v1_20_R4.isSupported() && DisguiseConfig.isRandomDisguises()) {
|
||||||
setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)));
|
setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,6 +35,7 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.AREA_EFFECT_RADIUS);
|
return getData(MetaIndex.AREA_EFFECT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("How big is this Area Effect Cloud?")
|
||||||
public void setRadius(float radius) {
|
public void setRadius(float radius) {
|
||||||
if (radius > 30) {
|
if (radius > 30) {
|
||||||
radius = 30;
|
radius = 30;
|
||||||
@ -40,14 +47,16 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
sendData(MetaIndex.AREA_EFFECT_RADIUS);
|
sendData(MetaIndex.AREA_EFFECT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_20_R4)
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
int color = getData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
return getData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
||||||
return Color.fromRGB(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
|
@MethodDescription("What's the color of this Area Effect Cloud?")
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_20_R4)
|
||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
setData(MetaIndex.AREA_EFFECT_CLOUD_COLOR, color.asRGB());
|
setData(MetaIndex.AREA_EFFECT_CLOUD_COLOR, color);
|
||||||
sendData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
sendData(MetaIndex.AREA_EFFECT_CLOUD_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,53 +64,54 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public <T> void setParticle(Particle particle, T particleData) {
|
public com.github.retrooper.packetevents.protocol.particle.Particle<?> getParticle() {
|
||||||
setParticle(WrappedParticle.create(particle, particleData));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
|
||||||
public WrappedParticle getParticle() {
|
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
return getData(MetaIndex.AREA_EFFECT_PARTICLE);
|
return getData(MetaIndex.AREA_EFFECT_PARTICLE);
|
||||||
} else {
|
} else {
|
||||||
// Item crack, block crack, block dust, falling dust
|
// Item crack, block crack, block dust, falling dust
|
||||||
int particleId = getData(MetaIndex.AREA_EFFECT_PARTICLE_OLD);
|
int particleId = getData(MetaIndex.AREA_EFFECT_PARTICLE_OLD);
|
||||||
Particle particle = Particle.values()[particleId];
|
|
||||||
|
|
||||||
return WrappedParticle.create(particle, null);
|
return new com.github.retrooper.packetevents.protocol.particle.Particle<ParticleData>(
|
||||||
|
(ParticleType<ParticleData>) ParticleTypes.getById(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion(),
|
||||||
|
particleId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public void setParticle(WrappedParticle particle) {
|
@MethodDescription("What particle is this Area Effect Cloud using?")
|
||||||
|
public void setParticle(com.github.retrooper.packetevents.protocol.particle.Particle particle) {
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
setData(MetaIndex.AREA_EFFECT_PARTICLE, particle);
|
setData(MetaIndex.AREA_EFFECT_PARTICLE, particle);
|
||||||
sendData(MetaIndex.AREA_EFFECT_PARTICLE);
|
sendData(MetaIndex.AREA_EFFECT_PARTICLE);
|
||||||
} else {
|
} else {
|
||||||
setParticleType(particle.getParticle());
|
setParticleType((Particle) SpigotConversionUtil.toBukkitParticle(particle.getType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Particle getParticleType() {
|
public Particle getParticleType() {
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
return getParticle().getParticle();
|
return (Particle) SpigotConversionUtil.toBukkitParticle(getData(MetaIndex.AREA_EFFECT_PARTICLE).getType());
|
||||||
} else {
|
} else {
|
||||||
return Particle.values()[getData(MetaIndex.AREA_EFFECT_PARTICLE_OLD)];
|
return Particle.values()[getData(MetaIndex.AREA_EFFECT_PARTICLE_OLD)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@MethodDescription("What particle type is this Area Effect Cloud using?")
|
||||||
public void setParticleType(Particle particle) {
|
public void setParticleType(Particle particle) {
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
setParticle(WrappedParticle.create(particle, null));
|
setParticle(
|
||||||
|
new com.github.retrooper.packetevents.protocol.particle.Particle(SpigotConversionUtil.fromBukkitParticle(particle)));
|
||||||
} else {
|
} else {
|
||||||
setData(MetaIndex.AREA_EFFECT_PARTICLE_OLD, particle.ordinal());
|
setData(MetaIndex.AREA_EFFECT_PARTICLE_OLD, particle.ordinal());
|
||||||
|
|
||||||
sendData(MetaIndex.AREA_EFFECT_PARTICLE_OLD);
|
sendData(MetaIndex.AREA_EFFECT_PARTICLE_OLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
import com.github.retrooper.packetevents.util.Vector3f;
|
||||||
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.annotations.MethodDescription;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
|
|
||||||
public class ArmorStandWatcher extends LivingWatcher {
|
public class ArmorStandWatcher extends LivingWatcher {
|
||||||
@ -18,6 +19,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getPose(MetaIndex.ARMORSTAND_BODY);
|
return getPose(MetaIndex.ARMORSTAND_BODY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("The body rotation of the ArmorStand")
|
||||||
public void setBody(EulerAngle vector) {
|
public void setBody(EulerAngle vector) {
|
||||||
setPose(MetaIndex.ARMORSTAND_BODY, vector);
|
setPose(MetaIndex.ARMORSTAND_BODY, vector);
|
||||||
}
|
}
|
||||||
@ -26,6 +28,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getPose(MetaIndex.ARMORSTAND_HEAD);
|
return getPose(MetaIndex.ARMORSTAND_HEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("The head rotation of the ArmorStand")
|
||||||
public void setHead(EulerAngle vector) {
|
public void setHead(EulerAngle vector) {
|
||||||
setPose(MetaIndex.ARMORSTAND_HEAD, vector);
|
setPose(MetaIndex.ARMORSTAND_HEAD, vector);
|
||||||
}
|
}
|
||||||
@ -34,6 +37,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getPose(MetaIndex.ARMORSTAND_LEFT_ARM);
|
return getPose(MetaIndex.ARMORSTAND_LEFT_ARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("The left arm rotation of the ArmorStand")
|
||||||
public void setLeftArm(EulerAngle vector) {
|
public void setLeftArm(EulerAngle vector) {
|
||||||
setPose(MetaIndex.ARMORSTAND_LEFT_ARM, vector);
|
setPose(MetaIndex.ARMORSTAND_LEFT_ARM, vector);
|
||||||
}
|
}
|
||||||
@ -42,16 +46,17 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getPose(MetaIndex.ARMORSTAND_LEFT_LEG);
|
return getPose(MetaIndex.ARMORSTAND_LEFT_LEG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("The left leg rotation of the ArmorStand")
|
||||||
public void setLeftLeg(EulerAngle vector) {
|
public void setLeftLeg(EulerAngle vector) {
|
||||||
setPose(MetaIndex.ARMORSTAND_LEFT_LEG, vector);
|
setPose(MetaIndex.ARMORSTAND_LEFT_LEG, vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EulerAngle getPose(MetaIndex<Vector3F> type) {
|
private EulerAngle getPose(MetaIndex<Vector3f> type) {
|
||||||
if (!hasValue(type)) {
|
if (!hasValue(type)) {
|
||||||
return new EulerAngle(0, 0, 0);
|
return new EulerAngle(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3F vec = getData(type);
|
Vector3f vec = getData(type);
|
||||||
|
|
||||||
return new EulerAngle(vec.getX(), vec.getY(), vec.getZ());
|
return new EulerAngle(vec.getX(), vec.getY(), vec.getZ());
|
||||||
}
|
}
|
||||||
@ -60,6 +65,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getPose(MetaIndex.ARMORSTAND_RIGHT_ARM);
|
return getPose(MetaIndex.ARMORSTAND_RIGHT_ARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("The right arm rotation of the ArmorStand")
|
||||||
public void setRightArm(EulerAngle vector) {
|
public void setRightArm(EulerAngle vector) {
|
||||||
setPose(MetaIndex.ARMORSTAND_RIGHT_ARM, vector);
|
setPose(MetaIndex.ARMORSTAND_RIGHT_ARM, vector);
|
||||||
}
|
}
|
||||||
@ -68,6 +74,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getPose(MetaIndex.ARMORSTAND_RIGHT_LEG);
|
return getPose(MetaIndex.ARMORSTAND_RIGHT_LEG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("The right leg rotation of the ArmorStand")
|
||||||
public void setRightLeg(EulerAngle vector) {
|
public void setRightLeg(EulerAngle vector) {
|
||||||
setPose(MetaIndex.ARMORSTAND_RIGHT_LEG, vector);
|
setPose(MetaIndex.ARMORSTAND_RIGHT_LEG, vector);
|
||||||
}
|
}
|
||||||
@ -76,6 +83,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getArmorStandFlag(16);
|
return getArmorStandFlag(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Can this ArmorStand be interacted with?")
|
||||||
public void setMarker(boolean isMarker) {
|
public void setMarker(boolean isMarker) {
|
||||||
setArmorStandFlag(16, isMarker);
|
setArmorStandFlag(16, isMarker);
|
||||||
}
|
}
|
||||||
@ -84,6 +92,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getArmorStandFlag(8);
|
return getArmorStandFlag(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Does this ArmorStand have a base plate?")
|
||||||
public void setNoBasePlate(boolean noBasePlate) {
|
public void setNoBasePlate(boolean noBasePlate) {
|
||||||
setArmorStandFlag(8, noBasePlate);
|
setArmorStandFlag(8, noBasePlate);
|
||||||
}
|
}
|
||||||
@ -92,6 +101,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getArmorStandFlag(2);
|
return getArmorStandFlag(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription
|
||||||
public void setNoGravity(boolean noGravity) {
|
public void setNoGravity(boolean noGravity) {
|
||||||
setArmorStandFlag(2, noGravity);
|
setArmorStandFlag(2, noGravity);
|
||||||
}
|
}
|
||||||
@ -100,6 +110,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getArmorStandFlag(4);
|
return getArmorStandFlag(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Can you see this ArmorStand's arms?")
|
||||||
public void setShowArms(boolean showArms) {
|
public void setShowArms(boolean showArms) {
|
||||||
setArmorStandFlag(4, showArms);
|
setArmorStandFlag(4, showArms);
|
||||||
}
|
}
|
||||||
@ -108,6 +119,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
return getArmorStandFlag(1);
|
return getArmorStandFlag(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this ArmorStand small?")
|
||||||
public void setSmall(boolean isSmall) {
|
public void setSmall(boolean isSmall) {
|
||||||
setArmorStandFlag(1, isSmall);
|
setArmorStandFlag(1, isSmall);
|
||||||
}
|
}
|
||||||
@ -125,8 +137,8 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
sendData(MetaIndex.ARMORSTAND_META);
|
sendData(MetaIndex.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPose(MetaIndex<Vector3F> type, EulerAngle vector) {
|
private void setPose(MetaIndex<Vector3f> type, EulerAngle vector) {
|
||||||
setData(type, new Vector3F((float) vector.getX(), (float) vector.getY(), (float) vector.getZ()));
|
setData(type, new Vector3f((float) vector.getX(), (float) vector.getY(), (float) vector.getZ()));
|
||||||
sendData(type);
|
sendData(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ 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.annotations.MethodDescription;
|
||||||
import org.bukkit.entity.Axolotl;
|
import org.bukkit.entity.Axolotl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,17 +17,19 @@ public class AxolotlWatcher extends AgeableWatcher {
|
|||||||
return getData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
return getData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this Axolotl playing dead?")
|
||||||
public void setPlayingDead(boolean playingDead) {
|
public void setPlayingDead(boolean playingDead) {
|
||||||
setData(MetaIndex.AXOLOTL_PLAYING_DEAD, playingDead);
|
setData(MetaIndex.AXOLOTL_PLAYING_DEAD, playingDead);
|
||||||
sendData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
sendData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Axolotl.Variant getVariant() {
|
public Axolotl.Variant getVariant() {
|
||||||
return Axolotl.Variant.values()[getData(MetaIndex.AXOLOTL_VARIANT)];
|
return getData(MetaIndex.AXOLOTL_VARIANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("What variant of Axolotl is this?")
|
||||||
public void setVariant(Axolotl.Variant variant) {
|
public void setVariant(Axolotl.Variant variant) {
|
||||||
setData(MetaIndex.AXOLOTL_VARIANT, variant.ordinal());
|
setData(MetaIndex.AXOLOTL_VARIANT, variant);
|
||||||
sendData(MetaIndex.AXOLOTL_VARIANT);
|
sendData(MetaIndex.AXOLOTL_VARIANT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ 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.annotations.MethodDescription;
|
||||||
|
|
||||||
public class BatWatcher extends InsentientWatcher {
|
public class BatWatcher extends InsentientWatcher {
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ public class BatWatcher extends InsentientWatcher {
|
|||||||
return getData(MetaIndex.BAT_HANGING) == 1;
|
return getData(MetaIndex.BAT_HANGING) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this bat hanging upside down? Otherwise it's flying.")
|
||||||
public void setHanging(boolean hanging) {
|
public void setHanging(boolean hanging) {
|
||||||
setData(MetaIndex.BAT_HANGING, hanging ? (byte) 1 : (byte) 0);
|
setData(MetaIndex.BAT_HANGING, hanging ? (byte) 1 : (byte) 0);
|
||||||
sendData(MetaIndex.BAT_HANGING);
|
sendData(MetaIndex.BAT_HANGING);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||||
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
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 org.bukkit.Bukkit;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
import org.bukkit.Material;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodMappedAs;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
@ -12,17 +15,28 @@ public class BlockDisplayWatcher extends DisplayWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
// So we're not seeing air
|
// So we're not seeing air
|
||||||
setBlock(Bukkit.createBlockData(Material.STONE));
|
setBlockState(WrappedBlockState.getDefaultState(StateTypes.STONE));
|
||||||
// So its centered
|
// So its centered
|
||||||
setTranslation(new Vector3f(-0.5f, 0f, -0.5f));
|
setTranslation(new Vector3f(-0.5f, 0f, -0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlock() {
|
@MethodMappedAs("getBlock")
|
||||||
|
public WrappedBlockState getBlockState() {
|
||||||
return getData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE);
|
return getData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(BlockData block) {
|
@MethodDescription("What block can players see?")
|
||||||
|
@MethodMappedAs("setBlock")
|
||||||
|
public void setBlockState(WrappedBlockState block) {
|
||||||
setData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE, block);
|
setData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlock() {
|
||||||
|
return SpigotConversionUtil.toBukkitBlockData(getData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(BlockData block) {
|
||||||
|
setData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE, SpigotConversionUtil.fromBukkitBlockData(block));
|
||||||
sendData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE);
|
sendData(MetaIndex.BLOCK_DISPLAY_BLOCK_STATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,31 @@ 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 me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoBoatType;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodMappedAs;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||||
import org.bukkit.TreeSpecies;
|
import org.bukkit.TreeSpecies;
|
||||||
|
import org.bukkit.entity.Boat;
|
||||||
|
|
||||||
public class BoatWatcher extends FlagWatcher {
|
public class BoatWatcher extends FlagWatcher {
|
||||||
public BoatWatcher(Disguise disguise) {
|
public BoatWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
|
if (NmsVersion.v1_19_R1.isSupported()) {
|
||||||
|
setType(Boat.Type.OAK);
|
||||||
|
} else {
|
||||||
setBoatType(TreeSpecies.GENERIC);
|
setBoatType(TreeSpecies.GENERIC);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public float getDamage() {
|
public float getDamage() {
|
||||||
return getData(MetaIndex.BOAT_DAMAGE);
|
return getData(MetaIndex.BOAT_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("No visible difference")
|
||||||
public void setDamage(float dmg) {
|
public void setDamage(float dmg) {
|
||||||
setData(MetaIndex.BOAT_DAMAGE, dmg);
|
setData(MetaIndex.BOAT_DAMAGE, dmg);
|
||||||
sendData(MetaIndex.BOAT_DAMAGE);
|
sendData(MetaIndex.BOAT_DAMAGE);
|
||||||
@ -27,6 +37,7 @@ public class BoatWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.BOAT_RIGHT_PADDLING);
|
return getData(MetaIndex.BOAT_RIGHT_PADDLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the boat's right paddle moving?")
|
||||||
public void setRightPaddling(boolean rightPaddling) {
|
public void setRightPaddling(boolean rightPaddling) {
|
||||||
setData(MetaIndex.BOAT_RIGHT_PADDLING, rightPaddling);
|
setData(MetaIndex.BOAT_RIGHT_PADDLING, rightPaddling);
|
||||||
sendData(MetaIndex.BOAT_RIGHT_PADDLING);
|
sendData(MetaIndex.BOAT_RIGHT_PADDLING);
|
||||||
@ -36,6 +47,7 @@ public class BoatWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.BOAT_LEFT_PADDLING);
|
return getData(MetaIndex.BOAT_LEFT_PADDLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the boat's left paddle moving?")
|
||||||
public void setLeftPaddling(boolean leftPaddling) {
|
public void setLeftPaddling(boolean leftPaddling) {
|
||||||
setData(MetaIndex.BOAT_LEFT_PADDLING, leftPaddling);
|
setData(MetaIndex.BOAT_LEFT_PADDLING, leftPaddling);
|
||||||
sendData(MetaIndex.BOAT_LEFT_PADDLING);
|
sendData(MetaIndex.BOAT_LEFT_PADDLING);
|
||||||
@ -47,17 +59,44 @@ public class BoatWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
|
@MethodDescription("How violently does this boat shake when damaged?")
|
||||||
public void setBoatShake(int number) {
|
public void setBoatShake(int number) {
|
||||||
setData(MetaIndex.BOAT_SHAKE, number);
|
setData(MetaIndex.BOAT_SHAKE, number);
|
||||||
sendData(MetaIndex.BOAT_SHAKE);
|
sendData(MetaIndex.BOAT_SHAKE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeSpecies getBoatType() {
|
@NmsAddedIn(NmsVersion.v1_19_R1)
|
||||||
return TreeSpecies.getByData(getData(MetaIndex.BOAT_TYPE).byteValue());
|
@MethodMappedAs("getBoatType")
|
||||||
|
public Boat.Type getType() {
|
||||||
|
return getData(MetaIndex.BOAT_TYPE_NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_19_R1)
|
||||||
|
@MethodMappedAs("setBoatType")
|
||||||
|
@MethodDescription("What type of wood is this boat made of?")
|
||||||
|
public void setType(Boat.Type type) {
|
||||||
|
setData(MetaIndex.BOAT_TYPE_NEW, type);
|
||||||
|
sendData(MetaIndex.BOAT_TYPE_NEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_19_R1)
|
||||||
|
public TreeSpecies getBoatType() {
|
||||||
|
if (NmsVersion.v1_19_R1.isSupported()) {
|
||||||
|
return ParamInfoBoatType.getSpeciesFromType(getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
return getData(MetaIndex.BOAT_TYPE_OLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NmsRemovedIn(NmsVersion.v1_19_R1)
|
||||||
|
@MethodDescription("What type of wood is this boat made of?")
|
||||||
public void setBoatType(TreeSpecies boatType) {
|
public void setBoatType(TreeSpecies boatType) {
|
||||||
setData(MetaIndex.BOAT_TYPE, (int) boatType.getData());
|
if (NmsVersion.v1_19_R1.isSupported()) {
|
||||||
sendData(MetaIndex.BOAT_TYPE);
|
setType(ParamInfoBoatType.getTypeFromSpecies(boatType));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(MetaIndex.BOAT_TYPE_OLD, boatType);
|
||||||
|
sendData(MetaIndex.BOAT_TYPE_OLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ 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.annotations.MethodDescription;
|
||||||
|
|
||||||
public class CamelWatcher extends AbstractHorseWatcher {
|
public class CamelWatcher extends AbstractHorseWatcher {
|
||||||
public CamelWatcher(Disguise disguise) {
|
public CamelWatcher(Disguise disguise) {
|
||||||
@ -12,6 +13,7 @@ public class CamelWatcher extends AbstractHorseWatcher {
|
|||||||
return getData(MetaIndex.CAMEL_DASHING);
|
return getData(MetaIndex.CAMEL_DASHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this Camel dashing?")
|
||||||
public void setDashing(boolean dashing) {
|
public void setDashing(boolean dashing) {
|
||||||
setData(MetaIndex.CAMEL_DASHING, dashing);
|
setData(MetaIndex.CAMEL_DASHING, dashing);
|
||||||
sendData(MetaIndex.CAMEL_DASHING);
|
sendData(MetaIndex.CAMEL_DASHING);
|
||||||
|
@ -7,6 +7,7 @@ import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.entity.Cat;
|
import org.bukkit.entity.Cat;
|
||||||
@ -27,27 +28,18 @@ public class CatWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Cat.Type getType() {
|
public Cat.Type getType() {
|
||||||
if (NmsVersion.v1_19_R1.isSupported()) {
|
return getData(MetaIndex.CAT_TYPE);
|
||||||
return getData(MetaIndex.CAT_TYPE_NEW);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Cat.Type.values()[getData(MetaIndex.CAT_TYPE)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
|
@MethodDescription("What variant of Cat is this?")
|
||||||
public void setType(Cat.Type type) {
|
public void setType(Cat.Type type) {
|
||||||
if (NmsVersion.v1_19_R1.isSupported()) {
|
setData(MetaIndex.CAT_TYPE, type);
|
||||||
setData(MetaIndex.CAT_TYPE_NEW, type);
|
|
||||||
sendData(MetaIndex.CAT_TYPE_NEW);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setData(MetaIndex.CAT_TYPE, type.ordinal());
|
|
||||||
sendData(MetaIndex.CAT_TYPE);
|
sendData(MetaIndex.CAT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DyeColor getCollarColor() {
|
public DyeColor getCollarColor() {
|
||||||
return AnimalColor.getColorByWool(getData(MetaIndex.CAT_COLLAR)).getDyeColor();
|
return getData(MetaIndex.CAT_COLLAR).getDyeColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -55,16 +47,17 @@ public class CatWatcher extends TameableWatcher {
|
|||||||
setCollarColor(color.getDyeColor());
|
setCollarColor(color.getDyeColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("What's the Cat's collar color?")
|
||||||
public void setCollarColor(DyeColor newColor) {
|
public void setCollarColor(DyeColor newColor) {
|
||||||
if (!isTamed()) {
|
if (!isTamed()) {
|
||||||
setTamed(true);
|
setTamed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newColor == getCollarColor()) {
|
if (hasValue(MetaIndex.CAT_COLLAR) && newColor == getCollarColor()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(MetaIndex.CAT_COLLAR, (int) newColor.getWoolData());
|
setData(MetaIndex.CAT_COLLAR, AnimalColor.getColorByWool(newColor.getWoolData()));
|
||||||
sendData(MetaIndex.CAT_COLLAR);
|
sendData(MetaIndex.CAT_COLLAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +65,7 @@ public class CatWatcher extends TameableWatcher {
|
|||||||
return getData(MetaIndex.CAT_LYING_DOWN);
|
return getData(MetaIndex.CAT_LYING_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the Cat lying down?")
|
||||||
public void setLyingDown(boolean value) {
|
public void setLyingDown(boolean value) {
|
||||||
setData(MetaIndex.CAT_LYING_DOWN, value);
|
setData(MetaIndex.CAT_LYING_DOWN, value);
|
||||||
sendData(MetaIndex.CAT_LYING_DOWN);
|
sendData(MetaIndex.CAT_LYING_DOWN);
|
||||||
@ -81,6 +75,7 @@ public class CatWatcher extends TameableWatcher {
|
|||||||
return getData(MetaIndex.CAT_LOOKING_UP);
|
return getData(MetaIndex.CAT_LOOKING_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is the Cat looking upwards?")
|
||||||
public void setLookingUp(boolean value) {
|
public void setLookingUp(boolean value) {
|
||||||
setData(MetaIndex.CAT_LOOKING_UP, value);
|
setData(MetaIndex.CAT_LOOKING_UP, value);
|
||||||
sendData(MetaIndex.CAT_LOOKING_UP);
|
sendData(MetaIndex.CAT_LOOKING_UP);
|
||||||
|
@ -2,6 +2,7 @@ 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.annotations.MethodDescription;
|
||||||
|
|
||||||
public class ChestedHorseWatcher extends AbstractHorseWatcher {
|
public class ChestedHorseWatcher extends AbstractHorseWatcher {
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ public class ChestedHorseWatcher extends AbstractHorseWatcher {
|
|||||||
return getData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST);
|
return getData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this Horse wearing a chest?")
|
||||||
public void setCarryingChest(boolean carryingChest) {
|
public void setCarryingChest(boolean carryingChest) {
|
||||||
setData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST, carryingChest);
|
setData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST, carryingChest);
|
||||||
sendData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST);
|
sendData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST);
|
||||||
|
@ -3,6 +3,7 @@ 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.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
|
|
||||||
public class CreeperWatcher extends InsentientWatcher {
|
public class CreeperWatcher extends InsentientWatcher {
|
||||||
@ -15,6 +16,7 @@ public class CreeperWatcher extends InsentientWatcher {
|
|||||||
return getData(MetaIndex.CREEPER_IGNITED);
|
return getData(MetaIndex.CREEPER_IGNITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this Creeper puffed up and about to explode")
|
||||||
public void setIgnited(boolean ignited) {
|
public void setIgnited(boolean ignited) {
|
||||||
// If creeper is already ignited and they want to set it to unignited, then resend disguise
|
// If creeper is already ignited and they want to set it to unignited, then resend disguise
|
||||||
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() &&
|
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() &&
|
||||||
@ -33,6 +35,7 @@ public class CreeperWatcher extends InsentientWatcher {
|
|||||||
return getData(MetaIndex.CREEPER_POWERED);
|
return getData(MetaIndex.CREEPER_POWERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Is this Creeper covered in lightning?")
|
||||||
public void setPowered(boolean powered) {
|
public void setPowered(boolean powered) {
|
||||||
setData(MetaIndex.CREEPER_POWERED, powered);
|
setData(MetaIndex.CREEPER_POWERED, powered);
|
||||||
sendData(MetaIndex.CREEPER_POWERED);
|
sendData(MetaIndex.CREEPER_POWERED);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.util.Quaternion4f;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3f;
|
||||||
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;
|
||||||
@ -8,7 +10,6 @@ import org.bukkit.Color;
|
|||||||
import org.bukkit.entity.Display;
|
import org.bukkit.entity.Display;
|
||||||
import org.bukkit.util.Transformation;
|
import org.bukkit.util.Transformation;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
public abstract class DisplayWatcher extends FlagWatcher {
|
public abstract class DisplayWatcher extends FlagWatcher {
|
||||||
public DisplayWatcher(Disguise disguise) {
|
public DisplayWatcher(Disguise disguise) {
|
||||||
@ -16,60 +17,68 @@ public abstract class DisplayWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Transformation getTransformation() {
|
public Transformation getTransformation() {
|
||||||
Vector3f transformation = getData(MetaIndex.DISPLAY_TRANSLATION);
|
return new Transformation(getTranslation(), getLeftRotation(), getScale(), getRightRotation());
|
||||||
Quaternionf leftRotation = getData(MetaIndex.DISPLAY_LEFT_ROTATION);
|
|
||||||
Quaternionf rightRotation = getData(MetaIndex.DISPLAY_RIGHT_ROTATION);
|
|
||||||
Vector3f scale = getData(MetaIndex.DISPLAY_SCALE);
|
|
||||||
|
|
||||||
return new Transformation(transformation, leftRotation, scale, rightRotation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because BlockDisplayWatcher modifies this on startup..
|
// Because BlockDisplayWatcher modifies this on startup..
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setTransformation(Transformation transformation) {
|
public void setTransformation(Transformation transformation) {
|
||||||
setData(MetaIndex.DISPLAY_TRANSLATION, transformation.getTranslation());
|
org.joml.Vector3f trans = transformation.getTranslation();
|
||||||
setData(MetaIndex.DISPLAY_LEFT_ROTATION, transformation.getLeftRotation());
|
Quaternionf rl = transformation.getLeftRotation();
|
||||||
setData(MetaIndex.DISPLAY_RIGHT_ROTATION, transformation.getRightRotation());
|
Quaternionf rr = transformation.getRightRotation();
|
||||||
setData(MetaIndex.DISPLAY_SCALE, transformation.getScale());
|
org.joml.Vector3f scale = transformation.getScale();
|
||||||
|
|
||||||
|
setData(MetaIndex.DISPLAY_TRANSLATION, new Vector3f(trans.x, trans.y, trans.z));
|
||||||
|
setData(MetaIndex.DISPLAY_LEFT_ROTATION, new Quaternion4f(rl.x, rl.y, rl.z, rl.w));
|
||||||
|
setData(MetaIndex.DISPLAY_RIGHT_ROTATION, new Quaternion4f(rr.x, rr.y, rr.z, rr.w));
|
||||||
|
setData(MetaIndex.DISPLAY_SCALE, new Vector3f(scale.x, scale.y, scale.z));
|
||||||
|
|
||||||
sendData(MetaIndex.DISPLAY_TRANSLATION, MetaIndex.DISPLAY_LEFT_ROTATION, MetaIndex.DISPLAY_RIGHT_ROTATION, MetaIndex.DISPLAY_SCALE);
|
sendData(MetaIndex.DISPLAY_TRANSLATION, MetaIndex.DISPLAY_LEFT_ROTATION, MetaIndex.DISPLAY_RIGHT_ROTATION, MetaIndex.DISPLAY_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f getTranslation() {
|
public org.joml.Vector3f getTranslation() {
|
||||||
return getData(MetaIndex.DISPLAY_TRANSLATION);
|
Vector3f vec = getData(MetaIndex.DISPLAY_TRANSLATION);
|
||||||
|
|
||||||
|
return new org.joml.Vector3f(vec.x, vec.y, vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because BlockDisplayWatcher modifies this on startup..
|
// Because BlockDisplayWatcher modifies this on startup..
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setTranslation(Vector3f translation) {
|
public void setTranslation(org.joml.Vector3f translation) {
|
||||||
setData(MetaIndex.DISPLAY_TRANSLATION, translation);
|
setData(MetaIndex.DISPLAY_TRANSLATION, new Vector3f(translation.x, translation.y, translation.z));
|
||||||
sendData(MetaIndex.DISPLAY_TRANSLATION);
|
sendData(MetaIndex.DISPLAY_TRANSLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f getScale() {
|
public org.joml.Vector3f getScale() {
|
||||||
return getData(MetaIndex.DISPLAY_SCALE);
|
Vector3f vec = getData(MetaIndex.DISPLAY_SCALE);
|
||||||
|
|
||||||
|
return new org.joml.Vector3f(vec.x, vec.y, vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale(Vector3f scale) {
|
public void setScale(org.joml.Vector3f scale) {
|
||||||
setData(MetaIndex.DISPLAY_SCALE, scale);
|
setData(MetaIndex.DISPLAY_SCALE, new Vector3f(scale.x, scale.y, scale.z));
|
||||||
sendData(MetaIndex.DISPLAY_SCALE);
|
sendData(MetaIndex.DISPLAY_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Quaternionf getLeftRotation() {
|
public Quaternionf getLeftRotation() {
|
||||||
return getData(MetaIndex.DISPLAY_LEFT_ROTATION);
|
Quaternion4f rot = getData(MetaIndex.DISPLAY_LEFT_ROTATION);
|
||||||
|
|
||||||
|
return new Quaternionf(rot.getX(), rot.getY(), rot.getZ(), rot.getW());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftRotation(Quaternionf rotation) {
|
public void setLeftRotation(Quaternionf rotation) {
|
||||||
setData(MetaIndex.DISPLAY_LEFT_ROTATION, rotation);
|
setData(MetaIndex.DISPLAY_LEFT_ROTATION, new Quaternion4f(rotation.x, rotation.y, rotation.z, rotation.w));
|
||||||
sendData(MetaIndex.DISPLAY_LEFT_ROTATION);
|
sendData(MetaIndex.DISPLAY_LEFT_ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Quaternionf getRightRotation() {
|
public Quaternionf getRightRotation() {
|
||||||
return getData(MetaIndex.DISPLAY_LEFT_ROTATION);
|
Quaternion4f rot = getData(MetaIndex.DISPLAY_RIGHT_ROTATION);
|
||||||
|
|
||||||
|
return new Quaternionf(rot.getX(), rot.getY(), rot.getZ(), rot.getW());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightRotation(Quaternionf rotation) {
|
public void setRightRotation(Quaternionf rotation) {
|
||||||
setData(MetaIndex.DISPLAY_RIGHT_ROTATION, rotation);
|
setData(MetaIndex.DISPLAY_RIGHT_ROTATION, new Quaternion4f(rotation.x, rotation.y, rotation.z, rotation.w));
|
||||||
sendData(MetaIndex.DISPLAY_RIGHT_ROTATION);
|
sendData(MetaIndex.DISPLAY_RIGHT_ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
|||||||
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 me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -18,6 +19,7 @@ public class DroppedItemWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.DROPPED_ITEM);
|
return getData(MetaIndex.DROPPED_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("What Item was dropped?")
|
||||||
public void setItemStack(ItemStack item) {
|
public void setItemStack(ItemStack item) {
|
||||||
setData(MetaIndex.DROPPED_ITEM, item);
|
setData(MetaIndex.DROPPED_ITEM, item);
|
||||||
sendData(MetaIndex.DROPPED_ITEM);
|
sendData(MetaIndex.DROPPED_ITEM);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
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 me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -15,11 +16,11 @@ public class EnderCrystalWatcher extends FlagWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPosition getBeamTarget() {
|
public Vector3i getBeamTarget() {
|
||||||
return getData(MetaIndex.ENDER_CRYSTAL_BEAM).orElse(null);
|
return getData(MetaIndex.ENDER_CRYSTAL_BEAM).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBeamTarget(BlockPosition position) {
|
public void setBeamTarget(Vector3i position) {
|
||||||
setData(MetaIndex.ENDER_CRYSTAL_BEAM, position == null ? Optional.empty() : Optional.of(position));
|
setData(MetaIndex.ENDER_CRYSTAL_BEAM, position == null ? Optional.empty() : Optional.of(position));
|
||||||
sendData(MetaIndex.ENDER_CRYSTAL_BEAM);
|
sendData(MetaIndex.ENDER_CRYSTAL_BEAM);
|
||||||
}
|
}
|
||||||
@ -28,6 +29,7 @@ public class EnderCrystalWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.ENDER_CRYSTAL_PLATE);
|
return getData(MetaIndex.ENDER_CRYSTAL_PLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodDescription("Can you see the Ender Crystal's base plate?")
|
||||||
public void setShowBottom(boolean bool) {
|
public void setShowBottom(boolean bool) {
|
||||||
setData(MetaIndex.ENDER_CRYSTAL_PLATE, bool);
|
setData(MetaIndex.ENDER_CRYSTAL_PLATE, bool);
|
||||||
sendData(MetaIndex.ENDER_CRYSTAL_PLATE);
|
sendData(MetaIndex.ENDER_CRYSTAL_PLATE);
|
||||||
|
@ -1,52 +1,61 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
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.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodMappedAs;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class EndermanWatcher extends InsentientWatcher {
|
public class EndermanWatcher extends InsentientWatcher {
|
||||||
|
|
||||||
public EndermanWatcher(Disguise disguise) {
|
public EndermanWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public ItemStack getItemInMainHand() {
|
public ItemStack getItemInMainHand() {
|
||||||
Optional<WrappedBlockData> value = getData(MetaIndex.ENDERMAN_ITEM);
|
WrappedBlockState value = getHeldBlock();
|
||||||
|
|
||||||
if (value.isPresent()) {
|
if (!NmsVersion.v1_13.isSupported()) {
|
||||||
WrappedBlockData pair = value.get();
|
return ReflectionManager.getItemStackByCombinedId(value.getGlobalId());
|
||||||
return new ItemStack(pair.getType(), 1);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaterialData pair = SpigotConversionUtil.toBukkitMaterialData(value);
|
||||||
|
|
||||||
|
return new ItemStack(pair.getItemType(), 1, pair.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void setItemInMainHand(ItemStack itemstack) {
|
public void setItemInMainHand(ItemStack itemstack) {
|
||||||
setItemInMainHand(itemstack.getType());
|
setItemInMainHand(itemstack.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodMappedAs("setItemInMainHand")
|
||||||
|
public void setHeldBlock(WrappedBlockState state) {
|
||||||
|
setData(MetaIndex.ENDERMAN_ITEM, state);
|
||||||
|
sendData(MetaIndex.ENDERMAN_ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodMappedAs("getItemInMainHand")
|
||||||
|
public WrappedBlockState getHeldBlock() {
|
||||||
|
return getData(MetaIndex.ENDERMAN_ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setItemInMainHand(Material type) {
|
public void setItemInMainHand(Material type) {
|
||||||
if (!type.isBlock()) {
|
if (!type.isBlock()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<WrappedBlockData> optional;
|
WrappedBlockState item = SpigotConversionUtil.fromBukkitMaterialData(new MaterialData(type));
|
||||||
|
|
||||||
if (type == null) {
|
setHeldBlock(item);
|
||||||
optional = Optional.empty();
|
|
||||||
} else {
|
|
||||||
optional = Optional.of(WrappedBlockData.createData(type));
|
|
||||||
}
|
|
||||||
|
|
||||||
setData(MetaIndex.ENDERMAN_ITEM, optional);
|
|
||||||
sendData(MetaIndex.ENDERMAN_ITEM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRelativeMove;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import lombok.Getter;
|
||||||
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.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodMappedAs;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -20,6 +21,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class FallingBlockWatcher extends FlagWatcher {
|
public class FallingBlockWatcher extends FlagWatcher {
|
||||||
private int blockCombinedId = 1;
|
private int blockCombinedId = 1;
|
||||||
|
@Getter
|
||||||
private boolean gridLocked;
|
private boolean gridLocked;
|
||||||
|
|
||||||
public FallingBlockWatcher(Disguise disguise) {
|
public FallingBlockWatcher(Disguise disguise) {
|
||||||
@ -39,10 +41,6 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||||||
return watcher;
|
return watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGridLocked() {
|
|
||||||
return gridLocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGridLocked(boolean gridLocked) {
|
public void setGridLocked(boolean gridLocked) {
|
||||||
if (isGridLocked() == gridLocked) {
|
if (isGridLocked() == gridLocked) {
|
||||||
return;
|
return;
|
||||||
@ -51,33 +49,21 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||||||
this.gridLocked = gridLocked;
|
this.gridLocked = gridLocked;
|
||||||
|
|
||||||
if (getDisguise().isDisguiseInUse() && getDisguise().getEntity() != null) {
|
if (getDisguise().isDisguiseInUse() && getDisguise().getEntity() != null) {
|
||||||
PacketContainer relMove = new PacketContainer(PacketType.Play.Server.REL_ENTITY_MOVE);
|
|
||||||
relMove.getModifier().write(0, getDisguise().getEntity().getEntityId());
|
|
||||||
|
|
||||||
Location loc = getDisguise().getEntity().getLocation();
|
Location loc = getDisguise().getEntity().getLocation();
|
||||||
|
double x = conRel(loc.getX(), loc.getBlockX() + 0.5);
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
double y = conRel(loc.getY(), loc.getBlockY() + (loc.getY() % 1 >= 0.85 ? 1 : loc.getY() % 1 >= 0.35 ? .5 : 0));
|
||||||
StructureModifier<Short> shorts = relMove.getShorts();
|
double z = conRel(loc.getZ(), loc.getBlockZ() + 0.5);
|
||||||
|
|
||||||
shorts.write(0, conRel(loc.getX(), loc.getBlockX() + 0.5));
|
|
||||||
shorts.write(1, conRel(loc.getY(), loc.getBlockY() + (loc.getY() % 1 >= 0.85 ? 1 : loc.getY() % 1 >= 0.35 ? .5 : 0)));
|
|
||||||
shorts.write(2, conRel(loc.getZ(), loc.getBlockZ() + 0.5));
|
|
||||||
} else {
|
|
||||||
StructureModifier<Integer> ints = relMove.getIntegers();
|
|
||||||
|
|
||||||
ints.write(0, (int) conRel(loc.getX(), loc.getBlockX() + 0.5));
|
|
||||||
ints.write(1, (int) conRel(loc.getY(), loc.getBlockY() + (loc.getY() % 1 >= 0.85 ? 1 : loc.getY() % 1 >= 0.35 ? .5 : 0)));
|
|
||||||
ints.write(2, (int) conRel(loc.getZ(), loc.getBlockZ() + 0.5));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
if (player == getDisguise().getEntity()) {
|
int entityId =
|
||||||
PacketContainer temp = relMove.shallowClone();
|
getDisguise().getEntity() == player ? DisguiseAPI.getSelfDisguiseId() : getDisguise().getEntity().getEntityId();
|
||||||
temp.getModifier().write(0, DisguiseAPI.getSelfDisguiseId());
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, temp, isGridLocked());
|
WrapperPlayServerEntityRelativeMove relMov = new WrapperPlayServerEntityRelativeMove(entityId, x, y, z, true);
|
||||||
|
|
||||||
|
if (isGridLocked()) {
|
||||||
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, relMov);
|
||||||
} else {
|
} else {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, relMove, isGridLocked());
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, relMov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,6 +94,16 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MethodMappedAs("getBlockData")
|
||||||
|
public WrappedBlockState getBlockState() {
|
||||||
|
return WrappedBlockState.getByGlobalId(getBlockCombinedId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodMappedAs("setBlockData")
|
||||||
|
public void setBlockState(WrappedBlockState state) {
|
||||||
|
setBlockCombinedId(state.getType().getName(), state.getGlobalId());
|
||||||
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
public BlockData getBlockData() {
|
public BlockData getBlockData() {
|
||||||
return ReflectionManager.getBlockDataByCombinedId(getBlockCombinedId());
|
return ReflectionManager.getBlockDataByCombinedId(getBlockCombinedId());
|
||||||
@ -120,11 +116,15 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.blockCombinedId = ReflectionManager.getCombinedIdByBlockData(data);
|
setBlockCombinedId(data.getMaterial().name(), ReflectionManager.getCombinedIdByBlockData(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBlockCombinedId(String materialName, int combinedId) {
|
||||||
|
this.blockCombinedId = combinedId;
|
||||||
|
|
||||||
if (!getDisguise().isCustomDisguiseName()) {
|
if (!getDisguise().isCustomDisguiseName()) {
|
||||||
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
||||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(data.getMaterial().name(), " ")));
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(materialName, " ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||||
|
@ -8,6 +8,7 @@ import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public class FireworkWatcher extends FlagWatcher {
|
public class FireworkWatcher extends FlagWatcher {
|
||||||
@ -47,7 +48,7 @@ public class FireworkWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public OptionalInt getAttachedEntityOpt() {
|
public Optional<Integer> getAttachedEntityOpt() {
|
||||||
return getData(MetaIndex.FIREWORK_ATTACHED_ENTITY);
|
return getData(MetaIndex.FIREWORK_ATTACHED_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,11 +57,11 @@ public class FireworkWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAttachedEntity(int entityId) {
|
public void setAttachedEntity(int entityId) {
|
||||||
setAttachedEntity(entityId == 0 ? OptionalInt.empty() : OptionalInt.of(entityId));
|
setAttachedEntity(entityId == 0 ? Optional.empty() : Optional.of(entityId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public void setAttachedEntity(OptionalInt entityId) {
|
public void setAttachedEntity(Optional<Integer> entityId) {
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
setData(MetaIndex.FIREWORK_ATTACHED_ENTITY, entityId);
|
setData(MetaIndex.FIREWORK_ATTACHED_ENTITY, entityId);
|
||||||
sendData(MetaIndex.FIREWORK_ATTACHED_ENTITY);
|
sendData(MetaIndex.FIREWORK_ATTACHED_ENTITY);
|
||||||
|
@ -48,12 +48,12 @@ public class FoxWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Fox.Type getType() {
|
public Fox.Type getType() {
|
||||||
return Fox.Type.values()[getData(MetaIndex.FOX_TYPE)];
|
return getData(MetaIndex.FOX_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setType(Fox.Type type) {
|
public void setType(Fox.Type type) {
|
||||||
setData(MetaIndex.FOX_TYPE, type.ordinal());
|
setData(MetaIndex.FOX_TYPE, type);
|
||||||
sendData(MetaIndex.FOX_TYPE);
|
sendData(MetaIndex.FOX_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,23 +22,23 @@ public class HorseWatcher extends AbstractHorseWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return Color.values()[(getData(MetaIndex.HORSE_COLOR) & 0xFF)];
|
return Color.values()[(getData(MetaIndex.HORSE_COLOR_STYLE) & 0xFF)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
setData(MetaIndex.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
setData(MetaIndex.HORSE_COLOR_STYLE, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||||
sendData(MetaIndex.HORSE_COLOR);
|
sendData(MetaIndex.HORSE_COLOR_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
return Style.values()[(getData(MetaIndex.HORSE_COLOR) >>> 8)];
|
return Style.values()[(getData(MetaIndex.HORSE_COLOR_STYLE) >>> 8)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setStyle(Style style) {
|
public void setStyle(Style style) {
|
||||||
setData(MetaIndex.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
setData(MetaIndex.HORSE_COLOR_STYLE, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||||
sendData(MetaIndex.HORSE_COLOR);
|
sendData(MetaIndex.HORSE_COLOR_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getHorseArmor() {
|
public ItemStack getHorseArmor() {
|
||||||
|
@ -28,11 +28,11 @@ public class ItemDisplayWatcher extends DisplayWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemDisplay.ItemDisplayTransform getItemDisplayTransform() {
|
public ItemDisplay.ItemDisplayTransform getItemDisplayTransform() {
|
||||||
return ItemDisplay.ItemDisplayTransform.values()[getData(MetaIndex.ITEM_DISPLAY_TRANSFORM)];
|
return getData(MetaIndex.ITEM_DISPLAY_TRANSFORM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemDisplayTransform(ItemDisplay.ItemDisplayTransform display) {
|
public void setItemDisplayTransform(ItemDisplay.ItemDisplayTransform display) {
|
||||||
setData(MetaIndex.ITEM_DISPLAY_TRANSFORM, (byte) display.ordinal());
|
setData(MetaIndex.ITEM_DISPLAY_TRANSFORM, display);
|
||||||
sendData(MetaIndex.ITEM_DISPLAY_TRANSFORM);
|
sendData(MetaIndex.ITEM_DISPLAY_TRANSFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.github.retrooper.packetevents.PacketEvents;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
@ -18,19 +16,20 @@ import me.libraryaddict.disguise.utilities.reflection.annotations.MethodGroupTyp
|
|||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class LivingWatcher extends FlagWatcher {
|
public class LivingWatcher extends FlagWatcher {
|
||||||
|
@Getter
|
||||||
private double maxHealth;
|
private double maxHealth;
|
||||||
|
@Getter
|
||||||
private boolean maxHealthSet;
|
private boolean maxHealthSet;
|
||||||
private HashSet<String> potionEffects = new HashSet<>();
|
private HashSet<String> potionEffects = new HashSet<>();
|
||||||
@Getter
|
@Getter
|
||||||
@ -52,13 +51,13 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public BlockPosition getBedPosition() {
|
public Vector3i getBedPosition() {
|
||||||
return getData(MetaIndex.LIVING_BED_POSITION).orElse(null);
|
return getData(MetaIndex.LIVING_BED_POSITION).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public void setBedPosition(BlockPosition blockPosition) {
|
public void setBedPosition(Vector3i blockPosition) {
|
||||||
Optional<BlockPosition> optional;
|
Optional<Vector3i> optional;
|
||||||
|
|
||||||
if (blockPosition != null) {
|
if (blockPosition != null) {
|
||||||
optional = Optional.of(blockPosition);
|
optional = Optional.of(blockPosition);
|
||||||
@ -156,40 +155,25 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
setHandFlag(2, setSpinning);
|
setHandFlag(2, setSpinning);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxHealth() {
|
|
||||||
return maxHealth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxHealth(double newHealth) {
|
public void setMaxHealth(double newHealth) {
|
||||||
this.maxHealth = newHealth;
|
this.maxHealth = newHealth;
|
||||||
this.maxHealthSet = true;
|
this.maxHealthSet = true;
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
if (!getDisguise().isDisguiseInUse() || getDisguise().getWatcher() != this) {
|
||||||
PacketContainer packet = new PacketContainer(Server.UPDATE_ATTRIBUTES);
|
return;
|
||||||
|
}
|
||||||
List<WrappedAttribute> attributes = new ArrayList<>();
|
|
||||||
|
|
||||||
Builder builder;
|
|
||||||
builder = WrappedAttribute.newBuilder();
|
|
||||||
builder.attributeKey(NmsVersion.v1_16.isSupported() ? "generic.max_health" : "generic.maxHealth");
|
|
||||||
builder.baseValue(getMaxHealth());
|
|
||||||
builder.packet(packet);
|
|
||||||
|
|
||||||
attributes.add(builder.build());
|
|
||||||
|
|
||||||
Entity entity = getDisguise().getEntity();
|
|
||||||
|
|
||||||
packet.getIntegers().write(0, entity.getEntityId());
|
|
||||||
packet.getAttributeCollectionModifier().write(0, attributes);
|
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
|
WrapperPlayServerUpdateAttributes.Property property =
|
||||||
|
new WrapperPlayServerUpdateAttributes.Property(Attributes.GENERIC_MAX_HEALTH, getMaxHealth(), new ArrayList<>());
|
||||||
|
WrapperPlayServerUpdateAttributes packet = new WrapperPlayServerUpdateAttributes(
|
||||||
|
player == getDisguise().getEntity() ? DisguiseAPI.getSelfDisguiseId() : getDisguise().getEntity().getEntityId(),
|
||||||
|
Collections.singletonList(property));
|
||||||
|
|
||||||
if (player == getDisguise().getEntity()) {
|
if (player == getDisguise().getEntity()) {
|
||||||
PacketContainer p = packet.shallowClone();
|
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(player, packet);
|
||||||
p.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, p, false);
|
|
||||||
} else {
|
} else {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,10 +235,6 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
return potionEffects.contains(type.getName());
|
return potionEffects.contains(type.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMaxHealthSet() {
|
|
||||||
return maxHealthSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PotionEffectType[] getPotionEffects() {
|
public PotionEffectType[] getPotionEffects() {
|
||||||
PotionEffectType[] effects = new PotionEffectType[potionEffects.size()];
|
PotionEffectType[] effects = new PotionEffectType[potionEffects.size()];
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ public class LlamaWatcher extends ChestedHorseWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Llama.Color getColor() {
|
public Llama.Color getColor() {
|
||||||
return Llama.Color.values()[getData(MetaIndex.LLAMA_COLOR)];
|
return getData(MetaIndex.LLAMA_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Llama.Color color) {
|
public void setColor(Llama.Color color) {
|
||||||
setData(MetaIndex.LLAMA_COLOR, color.ordinal());
|
setData(MetaIndex.LLAMA_COLOR, color);
|
||||||
sendData(MetaIndex.LLAMA_COLOR);
|
sendData(MetaIndex.LLAMA_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||||
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;
|
||||||
@ -33,12 +35,25 @@ public class MinecartWatcher extends FlagWatcher {
|
|||||||
sendData(MetaIndex.MINECART_BLOCK, MetaIndex.MINECART_BLOCK_VISIBLE);
|
sendData(MetaIndex.MINECART_BLOCK, MetaIndex.MINECART_BLOCK_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WrappedBlockState getBlock() {
|
||||||
|
return WrappedBlockState.getByGlobalId(getData(MetaIndex.MINECART_BLOCK));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(WrappedBlockState state) {
|
||||||
|
setData(MetaIndex.MINECART_BLOCK, state == null || state.getType() == StateTypes.AIR ? 0 : state.getGlobalId());
|
||||||
|
setData(MetaIndex.MINECART_BLOCK_VISIBLE, state != null && state.getType() != StateTypes.AIR);
|
||||||
|
|
||||||
|
sendData(MetaIndex.MINECART_BLOCK, MetaIndex.MINECART_BLOCK_VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
|
@Deprecated
|
||||||
public BlockData getBlockData() {
|
public BlockData getBlockData() {
|
||||||
return ReflectionManager.getBlockDataByCombinedId(getData(MetaIndex.MINECART_BLOCK));
|
return ReflectionManager.getBlockDataByCombinedId(getData(MetaIndex.MINECART_BLOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_13)
|
@NmsAddedIn(NmsVersion.v1_13)
|
||||||
|
@Deprecated
|
||||||
public void setBlockData(BlockData data) {
|
public void setBlockData(BlockData data) {
|
||||||
setData(MetaIndex.MINECART_BLOCK, ReflectionManager.getCombinedIdByBlockData(data));
|
setData(MetaIndex.MINECART_BLOCK, ReflectionManager.getCombinedIdByBlockData(data));
|
||||||
setData(MetaIndex.MINECART_BLOCK_VISIBLE, data != null && data.getMaterial() != Material.AIR);
|
setData(MetaIndex.MINECART_BLOCK_VISIBLE, data != null && data.getMaterial() != Material.AIR);
|
||||||
|
@ -30,13 +30,13 @@ public class OcelotWatcher extends AgeableWatcher {
|
|||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Ocelot.Type getType() {
|
public Ocelot.Type getType() {
|
||||||
return Ocelot.Type.getType(getData(MetaIndex.OCELOT_TYPE));
|
return getData(MetaIndex.OCELOT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsRemovedIn(NmsVersion.v1_14)
|
@NmsRemovedIn(NmsVersion.v1_14)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setType(Ocelot.Type newType) {
|
public void setType(Ocelot.Type newType) {
|
||||||
setData(MetaIndex.OCELOT_TYPE, newType.getId());
|
setData(MetaIndex.OCELOT_TYPE, newType);
|
||||||
sendData(MetaIndex.OCELOT_TYPE);
|
sendData(MetaIndex.OCELOT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,42 +37,22 @@ public class PandaWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Panda.Gene getMainGene() {
|
public Panda.Gene getMainGene() {
|
||||||
int id = getData(MetaIndex.PANDA_MAIN_GENE);
|
return getData(MetaIndex.PANDA_MAIN_GENE);
|
||||||
|
|
||||||
for (Panda.Gene gene : Panda.Gene.values()) {
|
|
||||||
if (gene.ordinal() != id) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gene;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Panda.Gene.NORMAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodOnlyUsedBy(value = {}) // Hide from command
|
@MethodOnlyUsedBy(value = {}) // Hide from command
|
||||||
public void setMainGene(Panda.Gene gene) {
|
public void setMainGene(Panda.Gene gene) {
|
||||||
setData(MetaIndex.PANDA_MAIN_GENE, (byte) gene.ordinal());
|
setData(MetaIndex.PANDA_MAIN_GENE, gene);
|
||||||
sendData(MetaIndex.PANDA_MAIN_GENE);
|
sendData(MetaIndex.PANDA_MAIN_GENE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Panda.Gene getHiddenGene() {
|
public Panda.Gene getHiddenGene() {
|
||||||
int id = getData(MetaIndex.PANDA_HIDDEN_GENE);
|
return getData(MetaIndex.PANDA_HIDDEN_GENE);
|
||||||
|
|
||||||
for (Panda.Gene gene : Panda.Gene.values()) {
|
|
||||||
if (gene.ordinal() != id) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gene;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Panda.Gene.NORMAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MethodOnlyUsedBy(value = {}) // Hide from command
|
@MethodOnlyUsedBy(value = {}) // Hide from command
|
||||||
public void setHiddenGene(Panda.Gene gene) {
|
public void setHiddenGene(Panda.Gene gene) {
|
||||||
setData(MetaIndex.PANDA_HIDDEN_GENE, (byte) gene.ordinal());
|
setData(MetaIndex.PANDA_HIDDEN_GENE, gene);
|
||||||
sendData(MetaIndex.PANDA_HIDDEN_GENE);
|
sendData(MetaIndex.PANDA_HIDDEN_GENE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ public class ParrotWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Parrot.Variant getVariant() {
|
public Parrot.Variant getVariant() {
|
||||||
return Parrot.Variant.values()[getData(MetaIndex.PARROT_VARIANT)];
|
return getData(MetaIndex.PARROT_VARIANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVariant(Parrot.Variant variant) {
|
public void setVariant(Parrot.Variant variant) {
|
||||||
setData(MetaIndex.PARROT_VARIANT, variant.ordinal());
|
setData(MetaIndex.PARROT_VARIANT, variant);
|
||||||
sendData(MetaIndex.PARROT_VARIANT);
|
sendData(MetaIndex.PARROT_VARIANT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
import com.github.retrooper.packetevents.protocol.nbt.NBTNumber;
|
||||||
|
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||||
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
@ -157,8 +159,8 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
sendData(MetaIndex.PLAYER_SKIN);
|
sendData(MetaIndex.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedGameProfile getSkin() {
|
public UserProfile getSkin() {
|
||||||
return ((PlayerDisguise) getDisguise()).getGameProfile();
|
return ((PlayerDisguise) getDisguise()).getUserProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSkin(String playerName) {
|
public void setSkin(String playerName) {
|
||||||
@ -166,7 +168,7 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setSkin(WrappedGameProfile profile) {
|
public void setSkin(UserProfile profile) {
|
||||||
((PlayerDisguise) getDisguise()).setSkin(profile);
|
((PlayerDisguise) getDisguise()).setSkin(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,43 +183,23 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Parrot.Variant getRightShoulderParrot() {
|
public Parrot.Variant getRightShoulderParrot() {
|
||||||
NbtCompound nbt = (NbtCompound) getData(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY);
|
return getParrot(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY);
|
||||||
|
|
||||||
return Parrot.Variant.values()[nbt.getIntegerOrDefault("Variant")];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightShoulderParrot(Parrot.Variant variant) {
|
public void setRightShoulderParrot(Parrot.Variant variant) {
|
||||||
NbtCompound nbt = NbtFactory.ofCompound("");
|
setParrot(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY, variant);
|
||||||
|
|
||||||
if (variant != null) {
|
|
||||||
nbt.put("id", "minecraft:parrot");
|
|
||||||
nbt.put("Variant", variant.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
setData(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY, nbt);
|
|
||||||
sendData(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Parrot.Variant getLeftShoulderParrot() {
|
public Parrot.Variant getLeftShoulderParrot() {
|
||||||
NbtCompound nbt = (NbtCompound) getData(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY);
|
return getParrot(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY);
|
||||||
|
|
||||||
return Parrot.Variant.values()[nbt.getIntegerOrDefault("Variant")];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftShoulderParrot(Parrot.Variant variant) {
|
public void setLeftShoulderParrot(Parrot.Variant variant) {
|
||||||
NbtCompound nbt = NbtFactory.ofCompound("");
|
setParrot(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY, variant);
|
||||||
|
|
||||||
if (variant != null) {
|
|
||||||
nbt.put("id", "minecraft:parrot");
|
|
||||||
nbt.put("Variant", variant.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
setData(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY, nbt);
|
|
||||||
sendData(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRightShoulderHasParrot() {
|
public boolean isRightShoulderHasParrot() {
|
||||||
return ((NbtCompound) getData(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY)).containsKey("id");
|
return getData(MetaIndex.PLAYER_RIGHT_SHOULDER_ENTITY).getStringTagOrNull("id") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightShoulderHasParrot(boolean hasParrot) {
|
public void setRightShoulderHasParrot(boolean hasParrot) {
|
||||||
@ -233,7 +215,7 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLeftShoulderHasParrot() {
|
public boolean isLeftShoulderHasParrot() {
|
||||||
return ((NbtCompound) getData(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY)).containsKey("id");
|
return getData(MetaIndex.PLAYER_LEFT_SHOULDER_ENTITY).getStringTagOrNull("id") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftShoulderHasParrot(boolean hasParrot) {
|
public void setLeftShoulderHasParrot(boolean hasParrot) {
|
||||||
@ -247,4 +229,28 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
setLeftShoulderParrot(null);
|
setLeftShoulderParrot(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Parrot.Variant getParrot(MetaIndex<NBTCompound> meta) {
|
||||||
|
NBTCompound nbt = getData(meta);
|
||||||
|
|
||||||
|
NBTNumber number = nbt.getNumberTagOrNull("Variant");
|
||||||
|
|
||||||
|
if (number == null) {
|
||||||
|
return Parrot.Variant.RED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Parrot.Variant.values()[number.getAsInt()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParrot(MetaIndex<NBTCompound> meta, Parrot.Variant variant) {
|
||||||
|
NBTCompound nbt = new NBTCompound();
|
||||||
|
|
||||||
|
if (variant != null) {
|
||||||
|
nbt.setTag("id", new NBTString("minecraft:parrot"));
|
||||||
|
nbt.setTag("Variant", new NBTInt(variant.ordinal()));
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(meta, nbt);
|
||||||
|
sendData(meta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||||
|
import org.bukkit.entity.Rabbit;
|
||||||
|
|
||||||
public class RabbitWatcher extends AgeableWatcher {
|
public class RabbitWatcher extends AgeableWatcher {
|
||||||
|
|
||||||
@ -13,17 +14,17 @@ public class RabbitWatcher extends AgeableWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
if (DisguiseConfig.isRandomDisguises()) {
|
if (DisguiseConfig.isRandomDisguises()) {
|
||||||
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
|
setType(Rabbit.Type.values()[DisguiseUtilities.random.nextInt(Rabbit.Type.values().length)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RabbitType getType() {
|
public Rabbit.Type getType() {
|
||||||
return RabbitType.getType(getData(MetaIndex.RABBIT_TYPE));
|
return getData(MetaIndex.RABBIT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setType(RabbitType type) {
|
public void setType(Rabbit.Type type) {
|
||||||
setData(MetaIndex.RABBIT_TYPE, type.getTypeId());
|
setData(MetaIndex.RABBIT_TYPE, type);
|
||||||
sendData(MetaIndex.RABBIT_TYPE);
|
sendData(MetaIndex.RABBIT_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||||
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.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -44,10 +45,9 @@ public class SheepWatcher extends AgeableWatcher {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<WrappedChatComponent> optional = getData(MetaIndex.ENTITY_CUSTOM_NAME);
|
Optional<Component> optional = getData(MetaIndex.ENTITY_CUSTOM_NAME);
|
||||||
|
|
||||||
return optional.filter(wrappedChatComponent -> "{\"text\":\"jeb_\"}".equals(wrappedChatComponent.getJson())).isPresent();
|
|
||||||
|
|
||||||
|
return optional.isPresent() && DisguiseUtilities.serialize(optional.get()).contains("\"jeb_\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRainbowWool(boolean rainbow) {
|
public void setRainbowWool(boolean rainbow) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
@ -24,16 +23,16 @@ public class ShulkerWatcher extends InsentientWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFacingDirection(BlockFace face) {
|
public void setFacingDirection(BlockFace face) {
|
||||||
setData(MetaIndex.SHULKER_FACING, Direction.valueOf(face.name()));
|
setData(MetaIndex.SHULKER_FACING, com.github.retrooper.packetevents.protocol.world.BlockFace.valueOf(face.name()));
|
||||||
sendData(MetaIndex.SHULKER_FACING);
|
sendData(MetaIndex.SHULKER_FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPosition getAttachmentPosition() {
|
public Vector3i getAttachmentPosition() {
|
||||||
return getData(MetaIndex.SHULKER_ATTACHED).orElse(BlockPosition.ORIGIN);
|
return getData(MetaIndex.SHULKER_ATTACHED).orElse(Vector3i.zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttachmentPosition(BlockPosition pos) {
|
public void setAttachmentPosition(Vector3i pos) {
|
||||||
setData(MetaIndex.SHULKER_ATTACHED, Optional.of(pos));
|
setData(MetaIndex.SHULKER_ATTACHED, Optional.ofNullable(pos));
|
||||||
sendData(MetaIndex.SHULKER_ATTACHED);
|
sendData(MetaIndex.SHULKER_ATTACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ public class ShulkerWatcher extends InsentientWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DyeColor getColor() {
|
public DyeColor getColor() {
|
||||||
if (!hasValue(MetaIndex.SHULKER_COLOR)) {
|
if (!hasValue(MetaIndex.SHULKER_COLOR) || getData(MetaIndex.SHULKER_COLOR) == (byte) 16) {
|
||||||
return DyeColor.PURPLE;
|
return DyeColor.PURPLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ public class ShulkerWatcher extends InsentientWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(MetaIndex.SHULKER_COLOR, newColor.getWoolData());
|
setData(MetaIndex.SHULKER_COLOR, newColor == null ? (byte) 16 : newColor.getWoolData());
|
||||||
sendData(MetaIndex.SHULKER_COLOR);
|
sendData(MetaIndex.SHULKER_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
|
||||||
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 org.bukkit.entity.Sniffer;
|
import org.bukkit.entity.Sniffer;
|
||||||
@ -10,11 +11,11 @@ public class SnifferWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Sniffer.State getSnifferState() {
|
public Sniffer.State getSnifferState() {
|
||||||
return getData(MetaIndex.SNIFFER_STATE);
|
return Sniffer.State.valueOf(getData(MetaIndex.SNIFFER_STATE).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSnifferState(Sniffer.State state) {
|
public void setSnifferState(Sniffer.State state) {
|
||||||
setData(MetaIndex.SNIFFER_STATE, state);
|
setData(MetaIndex.SNIFFER_STATE, SnifferState.valueOf(state.name()));
|
||||||
sendData(MetaIndex.SNIFFER_STATE);
|
sendData(MetaIndex.SNIFFER_STATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||||
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
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 me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodMappedAs;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
@ -13,13 +16,26 @@ public class TNTWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_20_R3)
|
@NmsAddedIn(NmsVersion.v1_20_R3)
|
||||||
public BlockData getBlock() {
|
@MethodMappedAs("getBlock")
|
||||||
|
public WrappedBlockState getBlockData() {
|
||||||
return getData(MetaIndex.TNT_BLOCK_TYPE);
|
return getData(MetaIndex.TNT_BLOCK_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_20_R3)
|
@NmsAddedIn(NmsVersion.v1_20_R3)
|
||||||
public void setBlock(BlockData block) {
|
@MethodMappedAs("setBlock")
|
||||||
|
public void setBlockData(WrappedBlockState block) {
|
||||||
setData(MetaIndex.TNT_BLOCK_TYPE, block);
|
setData(MetaIndex.TNT_BLOCK_TYPE, block);
|
||||||
sendData(MetaIndex.TNT_BLOCK_TYPE);
|
sendData(MetaIndex.TNT_BLOCK_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_20_R3)
|
||||||
|
public BlockData getBlock() {
|
||||||
|
return SpigotConversionUtil.toBukkitBlockData(getData(MetaIndex.TNT_BLOCK_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_20_R3)
|
||||||
|
public void setBlock(BlockData block) {
|
||||||
|
setData(MetaIndex.TNT_BLOCK_TYPE, SpigotConversionUtil.fromBukkitBlockData(block));
|
||||||
|
sendData(MetaIndex.TNT_BLOCK_TYPE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.ComponentConverter;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
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.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.entity.Display;
|
import org.bukkit.entity.Display;
|
||||||
import org.bukkit.entity.TextDisplay;
|
import org.bukkit.entity.TextDisplay;
|
||||||
@ -19,14 +16,11 @@ public class TextDisplayWatcher extends DisplayWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
BaseComponent[] base = ComponentConverter.fromWrapper(getData(MetaIndex.TEXT_DISPLAY_TEXT));
|
return DisguiseUtilities.getSimpleString(getData(MetaIndex.TEXT_DISPLAY_TEXT));
|
||||||
|
|
||||||
return DisguiseUtilities.getSimpleString(base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String string) {
|
public void setText(String string) {
|
||||||
setData(MetaIndex.TEXT_DISPLAY_TEXT,
|
setData(MetaIndex.TEXT_DISPLAY_TEXT, DisguiseUtilities.getAdventureChat(string));
|
||||||
WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(string))));
|
|
||||||
sendData(MetaIndex.TEXT_DISPLAY_TEXT);
|
sendData(MetaIndex.TEXT_DISPLAY_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
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.disguisetypes.VillagerData;
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
@ -11,6 +13,8 @@ import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
|||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class VillagerWatcher extends AbstractVillagerWatcher {
|
public class VillagerWatcher extends AbstractVillagerWatcher {
|
||||||
|
|
||||||
public VillagerWatcher(Disguise disguise) {
|
public VillagerWatcher(Disguise disguise) {
|
||||||
@ -39,7 +43,7 @@ public class VillagerWatcher extends AbstractVillagerWatcher {
|
|||||||
|
|
||||||
public Profession getProfession() {
|
public Profession getProfession() {
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
return getVillagerData().getProfession();
|
return Profession.valueOf(getVillagerData().getProfession().getName().getKey().toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Profession.values()[getData(MetaIndex.VILLAGER_PROFESSION) + 1];
|
return Profession.values()[getData(MetaIndex.VILLAGER_PROFESSION) + 1];
|
||||||
@ -48,7 +52,8 @@ public class VillagerWatcher extends AbstractVillagerWatcher {
|
|||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setProfession(Profession profession) {
|
public void setProfession(Profession profession) {
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
setVillagerData(new VillagerData(getType(), profession, getLevel()));
|
setVillagerData(new VillagerData(VillagerTypes.getByName(getType().getKey().toString()),
|
||||||
|
VillagerProfessions.getByName(profession.getKey().toString()), getLevel()));
|
||||||
} else {
|
} else {
|
||||||
setData(MetaIndex.VILLAGER_PROFESSION, profession.ordinal() - 1);
|
setData(MetaIndex.VILLAGER_PROFESSION, profession.ordinal() - 1);
|
||||||
sendData(MetaIndex.VILLAGER_PROFESSION);
|
sendData(MetaIndex.VILLAGER_PROFESSION);
|
||||||
@ -58,13 +63,14 @@ public class VillagerWatcher extends AbstractVillagerWatcher {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public Villager.Type getType() {
|
public Villager.Type getType() {
|
||||||
return getVillagerData().getType();
|
return Villager.Type.valueOf(getVillagerData().getType().getName().getKey().toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public void setType(Villager.Type type) {
|
public void setType(Villager.Type type) {
|
||||||
setVillagerData(new VillagerData(type, getProfession(), getLevel()));
|
setVillagerData(new VillagerData(VillagerTypes.getByName(type.getKey().toString()),
|
||||||
|
VillagerProfessions.getByName(getProfession().getKey().toString()), getLevel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
@ -84,6 +90,7 @@ public class VillagerWatcher extends AbstractVillagerWatcher {
|
|||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public void setLevel(int level) {
|
public void setLevel(int level) {
|
||||||
setVillagerData(new VillagerData(getType(), getProfession(), Math.max(1, Math.min(5, level))));
|
setVillagerData(new VillagerData(VillagerTypes.getByName(getType().getKey().toString()),
|
||||||
|
VillagerProfessions.getByName(getProfession().getKey().toString()), Math.max(1, Math.min(5, level))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class WitherWatcher extends InsentientWatcher {
|
|||||||
|
|
||||||
public void setTargets(int... targets) {
|
public void setTargets(int... targets) {
|
||||||
if (targets.length != 3) {
|
if (targets.length != 3) {
|
||||||
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
|
throw new InvalidParameterException("<red>Expected 3 numbers for wither setTargets. Received " + targets.length + "</red>");
|
||||||
}
|
}
|
||||||
setData(MetaIndex.WITHER_TARGET_1, targets[0]);
|
setData(MetaIndex.WITHER_TARGET_1, targets[0]);
|
||||||
setData(MetaIndex.WITHER_TARGET_2, targets[1]);
|
setData(MetaIndex.WITHER_TARGET_2, targets[1]);
|
||||||
|
@ -15,7 +15,7 @@ public class WolfWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DyeColor getCollarColor() {
|
public DyeColor getCollarColor() {
|
||||||
return AnimalColor.getColorByWool(getData(MetaIndex.WOLF_COLLAR)).getDyeColor();
|
return getData(MetaIndex.WOLF_COLLAR).getDyeColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -28,11 +28,11 @@ public class WolfWatcher extends TameableWatcher {
|
|||||||
setTamed(true);
|
setTamed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newColor == getCollarColor()) {
|
if (hasValue(MetaIndex.WOLF_COLLAR) && newColor == getCollarColor()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(MetaIndex.WOLF_COLLAR, (int) newColor.getWoolData());
|
setData(MetaIndex.WOLF_COLLAR, AnimalColor.getColorByWool(newColor.getWoolData()));
|
||||||
sendData(MetaIndex.WOLF_COLLAR);
|
sendData(MetaIndex.WOLF_COLLAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
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.disguisetypes.VillagerData;
|
|
||||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ZombieVillagerWatcher extends ZombieWatcher {
|
public class ZombieVillagerWatcher extends ZombieWatcher {
|
||||||
@ -38,7 +41,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
|
|||||||
*/
|
*/
|
||||||
public boolean isVillager() {
|
public boolean isVillager() {
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
return getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION).getProfession() != Profession.NONE;
|
return getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION).getProfession() != VillagerProfessions.NONE;
|
||||||
} else {
|
} else {
|
||||||
return getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD) != 0;
|
return getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD) != 0;
|
||||||
}
|
}
|
||||||
@ -56,39 +59,35 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Profession getProfession() {
|
public Profession getProfession() {
|
||||||
return getVillagerData().getProfession();
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
|
return Profession.valueOf(getVillagerData().getProfession().getName().getKey().toUpperCase(Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Profession.values()[getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD) + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@RandomDefaultValue
|
@RandomDefaultValue
|
||||||
public void setProfession(Profession profession) {
|
public void setProfession(Profession profession) {
|
||||||
if (NmsVersion.v1_14.isSupported()) {
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
setVillagerData(new VillagerData(getType(), profession, getLevel()));
|
setVillagerData(new VillagerData(VillagerTypes.getByName(getType().getKey().toString()),
|
||||||
|
VillagerProfessions.getByName(profession.getKey().toString()), getLevel()));
|
||||||
} else {
|
} else {
|
||||||
setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD, profession.ordinal() - 1);
|
setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD, profession.ordinal() - 1);
|
||||||
sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD);
|
sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION_OLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public Villager.Type getType() {
|
public Villager.Type getType() {
|
||||||
return getVillagerData().getType();
|
return Villager.Type.valueOf(getVillagerData().getType().getName().getKey().toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
public void setType(Villager.Type type) {
|
public void setType(Villager.Type type) {
|
||||||
setVillagerData(new VillagerData(type, getProfession(), getLevel()));
|
setVillagerData(new VillagerData(VillagerTypes.getByName(type.getKey().toString()),
|
||||||
}
|
VillagerProfessions.getByName(getProfession().getKey().toString()), getLevel()));
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
|
||||||
public int getLevel() {
|
|
||||||
return getVillagerData().getLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
|
||||||
public void setLevel(int level) {
|
|
||||||
setVillagerData(new VillagerData(getType(), getProfession(), getLevel()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NmsAddedIn(NmsVersion.v1_14)
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
@ -100,4 +99,15 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
|
|||||||
public void setBiome(Villager.Type type) {
|
public void setBiome(Villager.Type type) {
|
||||||
setType(type);
|
setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
|
public int getLevel() {
|
||||||
|
return getVillagerData().getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NmsAddedIn(NmsVersion.v1_14)
|
||||||
|
public void setLevel(int level) {
|
||||||
|
setVillagerData(new VillagerData(VillagerTypes.getByName(getType().getKey().toString()),
|
||||||
|
VillagerProfessions.getByName(getProfession().getKey().toString()), Math.max(1, Math.min(5, level))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -185,7 +185,7 @@ public class LibsPremium {
|
|||||||
String fileInfo =
|
String fileInfo =
|
||||||
String.format("v%s, build %s, created %s", plugin.getVersion(), plugin.getBuildNumber(), plugin.getBuildDate());
|
String.format("v%s, build %s, created %s", plugin.getVersion(), plugin.getBuildNumber(), plugin.getBuildDate());
|
||||||
|
|
||||||
if (plugin.isPremium()) {
|
if (thisPluginIsPaidFor = plugin.isPremium()) {
|
||||||
if (!isValidVersion(version, plugin.getVersion()) || plugin.getUserID() == null || plugin.getDownloadID() == null ||
|
if (!isValidVersion(version, plugin.getVersion()) || plugin.getUserID() == null || plugin.getDownloadID() == null ||
|
||||||
plugin.getUserID().equals("666666")) {
|
plugin.getUserID().equals("666666")) {
|
||||||
DisguiseUtilities.getLogger().warning("You have an old Lib's Disguises jar (" + file.getName() + " " + fileInfo +
|
DisguiseUtilities.getLogger().warning("You have an old Lib's Disguises jar (" + file.getName() + " " + fileInfo +
|
||||||
@ -196,7 +196,6 @@ public class LibsPremium {
|
|||||||
|
|
||||||
paidInformation = plugin;
|
paidInformation = plugin;
|
||||||
|
|
||||||
thisPluginIsPaidFor = true;
|
|
||||||
/* Found a premium Lib's Disguises jar (v5.2.6, build #40, created 16/02/2019) */
|
/* Found a premium Lib's Disguises jar (v5.2.6, build #40, created 16/02/2019) */
|
||||||
DisguiseUtilities.getLogger().info("Found a premium Lib's Disguises jar (" + fileInfo + ")");
|
DisguiseUtilities.getLogger().info("Found a premium Lib's Disguises jar (" + fileInfo + ")");
|
||||||
DisguiseUtilities.getLogger().info("Registered to: " + getSanitizedUser(plugin.getUserID()));
|
DisguiseUtilities.getLogger().info("Registered to: " + getSanitizedUser(plugin.getUserID()));
|
||||||
@ -224,7 +223,7 @@ public class LibsPremium {
|
|||||||
if (bisectHosted) {
|
if (bisectHosted) {
|
||||||
DisguiseUtilities.getLogger().info("Hosted by BisectHosting! Premium enabled!");
|
DisguiseUtilities.getLogger().info("Hosted by BisectHosting! Premium enabled!");
|
||||||
|
|
||||||
paidInformation = new PluginInformation(0, "2", "32453", "2", true, "0", "#1", "0");
|
paidInformation = new PluginInformation(0, "13", "32453", "2", true, "0", "#1", "0");
|
||||||
|
|
||||||
thisPluginIsPaidFor = true;
|
thisPluginIsPaidFor = true;
|
||||||
} else {
|
} else {
|
||||||
@ -253,7 +252,7 @@ public class LibsPremium {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void check(String version, File file) {
|
public static void check(String version, File file) {
|
||||||
thisPluginIsPaidFor = isPremium();
|
thisPluginIsPaidFor = LibsDisguises.getInstance().isNumberedBuild() && isPremium();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pluginInformation = getInformation(file);
|
pluginInformation = getInformation(file);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.mineskin.MineSkinResponse;
|
import me.libraryaddict.disguise.utilities.mineskin.MineSkinResponse;
|
||||||
@ -22,7 +22,7 @@ public class SkinUtils {
|
|||||||
|
|
||||||
void onInfo(LibsMsg msg, Object... args);
|
void onInfo(LibsMsg msg, Object... args);
|
||||||
|
|
||||||
void onSuccess(WrappedGameProfile profile);
|
void onSuccess(UserProfile profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ModelType {
|
public enum ModelType {
|
||||||
@ -85,13 +85,13 @@ public class SkinUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleName(String playerName, ModelType modelType, SkinCallback callback) {
|
public static void handleName(String playerName, ModelType modelType, SkinCallback callback) {
|
||||||
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(playerName, gameProfile1 -> {
|
UserProfile gameProfile = DisguiseUtilities.getProfileFromMojang(playerName, gameProfile1 -> {
|
||||||
// Isn't handled by callback
|
// Isn't handled by callback
|
||||||
if (!Pattern.matches("\\w{1,16}", playerName)) {
|
if (!Pattern.matches("\\w{1,16}", playerName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameProfile1 == null || gameProfile1.getProperties().isEmpty()) {
|
if (gameProfile1 == null || gameProfile1.getTextureProperties().isEmpty()) {
|
||||||
callback.onError(LibsMsg.CANNOT_FIND_PLAYER_NAME, playerName);
|
callback.onError(LibsMsg.CANNOT_FIND_PLAYER_NAME, playerName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ public class SkinUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameProfile.getProperties().isEmpty()) {
|
if (gameProfile.getTextureProperties().isEmpty()) {
|
||||||
callback.onError(LibsMsg.CANNOT_FIND_PLAYER_NAME, playerName);
|
callback.onError(LibsMsg.CANNOT_FIND_PLAYER_NAME, playerName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -113,10 +113,10 @@ public class SkinUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleProfile(GameProfile profile, ModelType modelType, SkinCallback callback) {
|
public static void handleProfile(GameProfile profile, ModelType modelType, SkinCallback callback) {
|
||||||
handleProfile(WrappedGameProfile.fromHandle(profile), modelType, callback);
|
handleProfile(ReflectionManager.getUserProfile(profile), modelType, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleProfile(WrappedGameProfile profile, ModelType modelType, SkinCallback callback) {
|
public static void handleProfile(UserProfile profile, ModelType modelType, SkinCallback callback) {
|
||||||
callback.onSuccess(profile);
|
callback.onSuccess(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,12 +124,12 @@ public class SkinUtils {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
WrappedGameProfile profile = ReflectionManager.getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated"));
|
UserProfile profile = ReflectionManager.getSkullBlob(new UserProfile(uuid, "AutoGenerated"));
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (profile == null || profile.getProperties().isEmpty()) {
|
if (profile == null || profile.getTextureProperties().isEmpty()) {
|
||||||
callback.onError(LibsMsg.CANNOT_FIND_PLAYER_UUID, uuid.toString());
|
callback.onError(LibsMsg.CANNOT_FIND_PLAYER_UUID, uuid.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ public class SkinUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedGameProfile profile = DisguiseUtilities.getGameProfile(param);
|
UserProfile profile = DisguiseUtilities.getUserProfile(param);
|
||||||
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
callback.onInfo(LibsMsg.SKIN_API_USING_EXISTING_NAME);
|
callback.onInfo(LibsMsg.SKIN_API_USING_EXISTING_NAME);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.json;
|
package me.libraryaddict.disguise.utilities.gson;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
@ -0,0 +1,32 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.gson;
|
||||||
|
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
import com.google.gson.JsonSerializer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 27/11/2018.
|
||||||
|
*/
|
||||||
|
public class SerializerChatComponent implements JsonDeserializer<Component>, JsonSerializer<Component> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
if (json.isJsonPrimitive()) {
|
||||||
|
return JSONComponentSerializer.json().deserialize(json.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(Component src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
|
return context.serialize(JSONComponentSerializer.json().serialize(src));
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.json;
|
package me.libraryaddict.disguise.utilities.gson;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.json;
|
package me.libraryaddict.disguise.utilities.gson;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user