diff --git a/nms/interface/pom.xml b/nms/interface/pom.xml
index da55f96..849d9fb 100644
--- a/nms/interface/pom.xml
+++ b/nms/interface/pom.xml
@@ -17,6 +17,7 @@
org.spigotmc
spigot-api
+ 1.18.1-R0.1-SNAPSHOT
diff --git a/nms/reflection/pom.xml b/nms/reflection/pom.xml
index 253819d..e9056fe 100644
--- a/nms/reflection/pom.xml
+++ b/nms/reflection/pom.xml
@@ -17,6 +17,7 @@
org.spigotmc
spigot-api
+ 1.18.1-R0.1-SNAPSHOT
de.epiceric
diff --git a/nms/v1_17_1_R1/pom.xml b/nms/v1_17_1_R1/pom.xml
deleted file mode 100644
index 91a9155..0000000
--- a/nms/v1_17_1_R1/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- ShopChest-parent
- de.epiceric
- 1.14.0-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- shopchest-nms-v1_17_1_R1
- 1.0.0
-
-
- 1.17.1-R0.1-SNAPSHOT
-
-
-
-
- org.spigotmc
- spigot
- remapped-mojang
-
-
- de.epiceric
- shopchest-nms-interface
- provided
-
-
-
-
-
-
- net.md-5
- specialsource-maven-plugin
-
-
-
-
-
\ No newline at end of file
diff --git a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeArmorStandImpl.java b/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeArmorStandImpl.java
deleted file mode 100644
index 4eebd1c..0000000
--- a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeArmorStandImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_1_R1;
-
-import de.epiceric.shopchest.nms.FakeArmorStand;
-import io.netty.buffer.Unpooled;
-import net.md_5.bungee.api.chat.TextComponent;
-import net.md_5.bungee.chat.ComponentSerializer;
-import net.minecraft.network.FriendlyByteBuf;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.entity.decoration.ArmorStand;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Optional;
-
-public class FakeArmorStandImpl extends FakeEntityImpl implements FakeArmorStand {
-
- private final static byte INVISIBLE_FLAG = 0b100000;
- private final static byte MARKER_FLAG = 0b10000;
- private final static EntityDataAccessor DATA_SHARED_FLAGS_ID;
- private final static EntityDataAccessor> DATA_CUSTOM_NAME;
- private final static EntityDataAccessor DATA_CUSTOM_NAME_VISIBLE;
- private final static float MARKER_ARMOR_STAND_OFFSET = 1.975f;
-
- static {
- try {
- final Field dataSharedFlagsId = Entity.class.getDeclaredField("Z"); // DATA_SHARED_FLAGS_ID
- dataSharedFlagsId.setAccessible(true);
- DATA_SHARED_FLAGS_ID = forceCast(dataSharedFlagsId.get(null));
- final Field dataCustomNameField = Entity.class.getDeclaredField("aJ"); // DATA_CUSTOM_NAME
- dataCustomNameField.setAccessible(true);
- DATA_CUSTOM_NAME = forceCast(dataCustomNameField.get(null));
- final Field dataCustomNameVisibleField = Entity.class.getDeclaredField("aK"); // DATA_CUSTOM_NAME_VISIBLE
- dataCustomNameVisibleField.setAccessible(true);
- DATA_CUSTOM_NAME_VISIBLE = forceCast(dataCustomNameVisibleField.get(null));
- } catch (ReflectiveOperationException e){
- throw new RuntimeException(e);
- }
- }
-
- public FakeArmorStandImpl() {
- super();
- }
-
- @Override
- public void sendData(String name, Iterable receivers) {
- sendData(receivers, name);
- }
-
- @Override
- protected EntityType> getEntityType() {
- return EntityType.ARMOR_STAND;
- }
-
- @Override
- protected float getSpawnOffSet() {
- return MARKER_ARMOR_STAND_OFFSET;
- }
-
- @Override
- protected int getDataItemCount() {
- return 4;
- }
-
- @Override
- protected void addSpecificData(List> packedItems, String name) {
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_SHARED_FLAGS_ID, INVISIBLE_FLAG));
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_CUSTOM_NAME, Optional.ofNullable(
- Component.Serializer.fromJson(
- ComponentSerializer.toString(
- TextComponent.fromLegacyText(name)
- )
- )
- )));
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_CUSTOM_NAME_VISIBLE, true));
- packedItems.add(new SynchedEntityData.DataItem<>(ArmorStand.DATA_CLIENT_FLAGS, MARKER_FLAG));
- }
-
- @Override
- public void setLocation(Location location, Iterable receivers) {
- final FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
- buffer.writeVarInt(entityId);
- buffer.writeDouble(location.getX());
- buffer.writeDouble(location.getY() + MARKER_ARMOR_STAND_OFFSET);
- buffer.writeDouble(location.getZ());
- buffer.writeByte(0);
- buffer.writeByte(0);
- buffer.writeBoolean(false);
- final ClientboundTeleportEntityPacket positionPacket = new ClientboundTeleportEntityPacket(buffer);
- sendPacket(positionPacket, receivers);
- }
-
-}
diff --git a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeEntityImpl.java b/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeEntityImpl.java
deleted file mode 100644
index f0a280f..0000000
--- a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeEntityImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_1_R1;
-
-import de.epiceric.shopchest.nms.FakeEntity;
-import net.minecraft.network.protocol.Packet;
-import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
-import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.phys.Vec3;
-import org.bukkit.Location;
-import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public abstract class FakeEntityImpl implements FakeEntity {
-
- private final static AtomicInteger ENTITY_COUNTER;
- private final static EntityDataAccessor DATA_NO_GRAVITY;
- private final static EntityDataAccessor DATA_SILENT;
- private final static Field packedItemField;
-
- static {
- try {
- final Field entityCounterField = Entity.class.getDeclaredField("b"); // ENTITY_COUNTER
- entityCounterField.setAccessible(true);
- ENTITY_COUNTER = (AtomicInteger) entityCounterField.get(null);
- final Field dataNoGravityField = Entity.class.getDeclaredField("aM"); // DATA_NO_GRAVITY
- dataNoGravityField.setAccessible(true);
- DATA_NO_GRAVITY = forceCast(dataNoGravityField.get(null));
- final Field dataSilentField = Entity.class.getDeclaredField("aL"); // DATA_SILENT
- dataSilentField.setAccessible(true);
- DATA_SILENT = forceCast(dataSilentField.get(null));
- packedItemField = ClientboundSetEntityDataPacket.class.getDeclaredField("b"); // packedItems
- packedItemField.setAccessible(true);
- }catch (ReflectiveOperationException e){
- throw new RuntimeException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected static T forceCast(Object o){
- return (T) o;
- }
-
- protected final int entityId;
-
- public FakeEntityImpl() {
- entityId = ENTITY_COUNTER.incrementAndGet();
- }
-
- @Override
- public int getEntityId() {
- return entityId;
- }
-
- protected void sendPacket(Packet> packet, Iterable receivers){
- for(Player receiver : receivers){
- ((CraftPlayer)receiver).getHandle().connection.send(packet);
- }
- }
-
- @Override
- public void spawn(UUID uuid, Location location, Iterable receivers) {
- final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(
- entityId,
- uuid,
- location.getX(),
- location.getY() + getSpawnOffSet(),
- location.getZ(),
- 0f,
- 0f,
- getEntityType(),
- 0,
- Vec3.ZERO
- );
- sendPacket(spawnPacket, receivers);
- }
-
- @Override
- public void remove(Iterable receivers) {
- final ClientboundRemoveEntitiesPacket removePacket = new ClientboundRemoveEntitiesPacket(entityId);
- sendPacket(removePacket, receivers);
- }
-
- protected void sendData(Iterable receivers, T data){
- // Create packet
- final SynchedEntityData entityData = new SynchedEntityData(null);
- final ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(entityId, entityData, false);
- final List> packedItems = new ArrayList<>(2 + getDataItemCount());
-
- // Setup data
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_NO_GRAVITY, true));
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_SILENT, true));
- addSpecificData(packedItems, data);
-
- try {
- packedItemField.set(dataPacket, packedItems);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- // Send packet
- sendPacket(dataPacket, receivers);
- }
-
- protected abstract EntityType> getEntityType();
-
- protected float getSpawnOffSet(){
- return 0f;
- }
-
- protected abstract int getDataItemCount();
-
- protected abstract void addSpecificData(List> packedItems, T data);
-
-}
diff --git a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeItemImpl.java b/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeItemImpl.java
deleted file mode 100644
index 6807965..0000000
--- a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/FakeItemImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_1_R1;
-
-import de.epiceric.shopchest.nms.FakeItem;
-import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.entity.item.ItemEntity;
-import net.minecraft.world.phys.Vec3;
-import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-public class FakeItemImpl extends FakeEntityImpl implements FakeItem {
-
- private final static EntityDataAccessor DATA_ITEM;
-
- static {
- try{
- final Field dataItemField = ItemEntity.class.getDeclaredField("c"); // DATA_ITEM
- dataItemField.setAccessible(true);
- DATA_ITEM = forceCast(dataItemField.get(null));
- }catch (ReflectiveOperationException e){
- throw new RuntimeException(e);
- }
- }
-
- public FakeItemImpl() {
- super();
- }
-
- @Override
- public void sendData(ItemStack item, Iterable receivers) {
- sendData(receivers, item);
- }
-
- @Override
- public void resetVelocity(Iterable receivers) {
- final ClientboundSetEntityMotionPacket velocityPacket = new ClientboundSetEntityMotionPacket(entityId, Vec3.ZERO);
- sendPacket(velocityPacket, receivers);
- }
-
- @Override
- protected EntityType> getEntityType() {
- return EntityType.ITEM;
- }
-
- @Override
- protected int getDataItemCount() {
- return 1;
- }
-
- @Override
- protected void addSpecificData(List> packedItems, ItemStack data) {
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_ITEM, CraftItemStack.asNMSCopy(data)));
- }
-}
diff --git a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/PlatformImpl.java b/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/PlatformImpl.java
deleted file mode 100644
index 5d41eb8..0000000
--- a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/PlatformImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_1_R1;
-
-import de.epiceric.shopchest.nms.FakeArmorStand;
-import de.epiceric.shopchest.nms.FakeItem;
-import de.epiceric.shopchest.nms.Platform;
-import de.epiceric.shopchest.nms.TextComponentHelper;
-
-public class PlatformImpl implements Platform {
-
- @Override
- public FakeArmorStand createFakeArmorStand() {
- return new FakeArmorStandImpl();
- }
-
- @Override
- public FakeItem createFakeItem() {
- return new FakeItemImpl();
- }
-
- @Override
- public TextComponentHelper getTextComponentHelper() {
- return new TextComponentHelperImpl();
- }
-
-}
diff --git a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/TextComponentHelperImpl.java b/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/TextComponentHelperImpl.java
deleted file mode 100644
index 90bc670..0000000
--- a/nms/v1_17_1_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_1_R1/TextComponentHelperImpl.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_1_R1;
-
-import de.epiceric.shopchest.nms.TextComponentHelper;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.Tag;
-import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-public class TextComponentHelperImpl implements TextComponentHelper {
- @Override
- public String getNbt(ItemStack itemStack) {
- final Tag tag = CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag()).get("tag");
- return tag == null ? null : tag.getAsString();
- }
-}
diff --git a/nms/v1_17_R1/pom.xml b/nms/v1_17_R1/pom.xml
deleted file mode 100644
index 51c5387..0000000
--- a/nms/v1_17_R1/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- ShopChest-parent
- de.epiceric
- 1.14.0-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- shopchest-nms-v1_17_R1
- 1.0.0
-
-
- 1.17-R0.1-SNAPSHOT
-
-
-
-
- org.spigotmc
- spigot
- remapped-mojang
-
-
- de.epiceric
- shopchest-nms-interface
- provided
-
-
-
-
-
-
- net.md-5
- specialsource-maven-plugin
-
-
-
-
-
\ No newline at end of file
diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java
deleted file mode 100644
index ca940fa..0000000
--- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_R1;
-
-import de.epiceric.shopchest.nms.FakeArmorStand;
-import io.netty.buffer.Unpooled;
-import net.md_5.bungee.api.chat.TextComponent;
-import net.md_5.bungee.chat.ComponentSerializer;
-import net.minecraft.network.FriendlyByteBuf;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.entity.decoration.ArmorStand;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Optional;
-
-public class FakeArmorStandImpl extends FakeEntityImpl implements FakeArmorStand {
-
- private final static byte INVISIBLE_FLAG = 0b100000;
- private final static byte MARKER_FLAG = 0b10000;
- private final static EntityDataAccessor DATA_SHARED_FLAGS_ID;
- private final static EntityDataAccessor> DATA_CUSTOM_NAME;
- private final static EntityDataAccessor DATA_CUSTOM_NAME_VISIBLE;
- private final static float MARKER_ARMOR_STAND_OFFSET = 1.975f;
-
- static {
- try {
- final Field dataSharedFlagsId = Entity.class.getDeclaredField("Z"); // DATA_SHARED_FLAGS_ID
- dataSharedFlagsId.setAccessible(true);
- DATA_SHARED_FLAGS_ID = FakeEntityImpl.forceCast(dataSharedFlagsId.get(null));
- final Field dataCustomNameField = Entity.class.getDeclaredField("aJ"); // DATA_CUSTOM_NAME
- dataCustomNameField.setAccessible(true);
- DATA_CUSTOM_NAME = FakeEntityImpl.forceCast(dataCustomNameField.get(null));
- final Field dataCustomNameVisibleField = Entity.class.getDeclaredField("aK"); // DATA_CUSTOM_NAME_VISIBLE
- dataCustomNameVisibleField.setAccessible(true);
- DATA_CUSTOM_NAME_VISIBLE = FakeEntityImpl.forceCast(dataCustomNameVisibleField.get(null));
- } catch (ReflectiveOperationException e){
- throw new RuntimeException(e);
- }
- }
-
- public FakeArmorStandImpl() {
- super();
- }
-
- @Override
- public void sendData(String name, Iterable receivers) {
- sendData(receivers, name);
- }
-
- @Override
- protected EntityType> getEntityType() {
- return EntityType.ARMOR_STAND;
- }
-
- @Override
- protected float getSpawnOffSet() {
- return MARKER_ARMOR_STAND_OFFSET;
- }
-
- @Override
- protected int getDataItemCount() {
- return 4;
- }
-
- @Override
- protected void addSpecificData(List> packedItems, String name) {
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_SHARED_FLAGS_ID, INVISIBLE_FLAG));
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_CUSTOM_NAME, Optional.ofNullable(
- Component.Serializer.fromJson(
- ComponentSerializer.toString(
- TextComponent.fromLegacyText(name)
- )
- )
- )));
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_CUSTOM_NAME_VISIBLE, true));
- packedItems.add(new SynchedEntityData.DataItem<>(ArmorStand.DATA_CLIENT_FLAGS, MARKER_FLAG));
- }
-
- @Override
- public void setLocation(Location location, Iterable receivers) {
- final FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
- buffer.writeVarInt(entityId);
- buffer.writeDouble(location.getX());
- buffer.writeDouble(location.getY() + MARKER_ARMOR_STAND_OFFSET);
- buffer.writeDouble(location.getZ());
- buffer.writeByte(0);
- buffer.writeByte(0);
- buffer.writeBoolean(false);
- final ClientboundTeleportEntityPacket positionPacket = new ClientboundTeleportEntityPacket(buffer);
- sendPacket(positionPacket, receivers);
- }
-
-}
diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java
deleted file mode 100644
index f40539a..0000000
--- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_R1;
-
-import de.epiceric.shopchest.nms.FakeEntity;
-import net.minecraft.network.protocol.Packet;
-import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
-import net.minecraft.network.protocol.game.ClientboundRemoveEntityPacket;
-import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.phys.Vec3;
-import org.bukkit.Location;
-import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public abstract class FakeEntityImpl implements FakeEntity {
-
- private final static AtomicInteger ENTITY_COUNTER;
- private final static EntityDataAccessor DATA_NO_GRAVITY;
- private final static EntityDataAccessor DATA_SILENT;
- private final static Field packedItemField;
-
- static {
- try {
- final Field entityCounterField = Entity.class.getDeclaredField("b"); // ENTITY_COUNTER
- entityCounterField.setAccessible(true);
- ENTITY_COUNTER = (AtomicInteger) entityCounterField.get(null);
- final Field dataNoGravityField = Entity.class.getDeclaredField("aM"); // DATA_NO_GRAVITY
- dataNoGravityField.setAccessible(true);
- DATA_NO_GRAVITY = forceCast(dataNoGravityField.get(null));
- final Field dataSilentField = Entity.class.getDeclaredField("aL"); // DATA_SILENT
- dataSilentField.setAccessible(true);
- DATA_SILENT = forceCast(dataSilentField.get(null));
- packedItemField = ClientboundSetEntityDataPacket.class.getDeclaredField("b"); // packedItems
- packedItemField.setAccessible(true);
- }catch (ReflectiveOperationException e){
- throw new RuntimeException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected static T forceCast(Object o){
- return (T) o;
- }
-
- protected final int entityId;
-
- public FakeEntityImpl() {
- entityId = ENTITY_COUNTER.incrementAndGet();
- }
-
- @Override
- public int getEntityId() {
- return entityId;
- }
-
- protected void sendPacket(Packet> packet, Iterable receivers){
- for(Player receiver : receivers){
- ((CraftPlayer)receiver).getHandle().connection.send(packet);
- }
- }
-
- @Override
- public void spawn(UUID uuid, Location location, Iterable receivers) {
- final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(
- entityId,
- uuid,
- location.getX(),
- location.getY() + getSpawnOffSet(),
- location.getZ(),
- 0f,
- 0f,
- getEntityType(),
- 0,
- Vec3.ZERO
- );
- sendPacket(spawnPacket, receivers);
- }
-
- @Override
- public void remove(Iterable receivers) {
- final ClientboundRemoveEntityPacket removePacket = new ClientboundRemoveEntityPacket(entityId);
- sendPacket(removePacket, receivers);
- }
-
- protected void sendData(Iterable receivers, T data){
- // Create packet
- final SynchedEntityData entityData = new SynchedEntityData(null);
- final ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(entityId, entityData, false);
- final List> packedItems = new ArrayList<>(2 + getDataItemCount());
-
- // Setup data
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_NO_GRAVITY, true));
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_SILENT, true));
- addSpecificData(packedItems, data);
-
- try {
- packedItemField.set(dataPacket, packedItems);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- // Send packet
- sendPacket(dataPacket, receivers);
- }
-
- protected abstract EntityType> getEntityType();
-
- protected float getSpawnOffSet(){
- return 0f;
- }
-
- protected abstract int getDataItemCount();
-
- protected abstract void addSpecificData(List> packedItems, T data);
-
-}
diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeItemImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeItemImpl.java
deleted file mode 100644
index f21cdcf..0000000
--- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeItemImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_R1;
-
-import de.epiceric.shopchest.nms.FakeItem;
-import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.world.entity.EntityType;
-import net.minecraft.world.entity.item.ItemEntity;
-import net.minecraft.world.phys.Vec3;
-import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-public class FakeItemImpl extends FakeEntityImpl implements FakeItem {
-
- private final static EntityDataAccessor DATA_ITEM;
-
- static {
- try{
- final Field dataItemField = ItemEntity.class.getDeclaredField("c"); // DATA_ITEM
- dataItemField.setAccessible(true);
- DATA_ITEM = forceCast(dataItemField.get(null));
- }catch (ReflectiveOperationException e){
- throw new RuntimeException(e);
- }
- }
-
- public FakeItemImpl() {
- super();
- }
-
- @Override
- public void sendData(ItemStack item, Iterable receivers) {
- sendData(receivers, item);
- }
-
- @Override
- public void resetVelocity(Iterable receivers) {
- final ClientboundSetEntityMotionPacket velocityPacket = new ClientboundSetEntityMotionPacket(entityId, Vec3.ZERO);
- sendPacket(velocityPacket, receivers);
- }
-
- @Override
- protected EntityType> getEntityType() {
- return EntityType.ITEM;
- }
-
- @Override
- protected int getDataItemCount() {
- return 1;
- }
-
- @Override
- protected void addSpecificData(List> packedItems, ItemStack data) {
- packedItems.add(new SynchedEntityData.DataItem<>(DATA_ITEM, CraftItemStack.asNMSCopy(data)));
- }
-}
diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/PlatformImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/PlatformImpl.java
deleted file mode 100644
index ae2af9e..0000000
--- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/PlatformImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_R1;
-
-import de.epiceric.shopchest.nms.FakeArmorStand;
-import de.epiceric.shopchest.nms.FakeItem;
-import de.epiceric.shopchest.nms.Platform;
-import de.epiceric.shopchest.nms.TextComponentHelper;
-
-public class PlatformImpl implements Platform {
-
- @Override
- public FakeArmorStand createFakeArmorStand() {
- return new FakeArmorStandImpl();
- }
-
- @Override
- public FakeItem createFakeItem() {
- return new FakeItemImpl();
- }
-
- @Override
- public TextComponentHelper getTextComponentHelper() {
- return new TextComponentHelperImpl();
- }
-
-}
diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/TextComponentHelperImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/TextComponentHelperImpl.java
deleted file mode 100644
index 8a00849..0000000
--- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/TextComponentHelperImpl.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.epiceric.shopchest.nms.v1_17_R1;
-
-import de.epiceric.shopchest.nms.TextComponentHelper;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.Tag;
-import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
-
-public class TextComponentHelperImpl implements TextComponentHelper {
- @Override
- public String getNbt(ItemStack itemStack) {
- final Tag tag = CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag()).get("tag");
- return tag == null ? null : tag.getAsString();
- }
-}
diff --git a/plugin/pom.xml b/plugin/pom.xml
index fd50fb3..c17cd74 100644
--- a/plugin/pom.xml
+++ b/plugin/pom.xml
@@ -15,6 +15,7 @@
org.spigotmc
spigot-api
+ 1.18.1-R0.1-SNAPSHOT
com.github.MilkBowl
@@ -88,14 +89,6 @@
de.epiceric
shopchest-nms-reflection
-
- de.epiceric
- shopchest-nms-v1_17_R1
-
-
- de.epiceric
- shopchest-nms-v1_17_1_R1
-
de.epiceric
shopchest-nms-v1_18_R1
diff --git a/plugin/src/main/java/de/epiceric/shopchest/ShopChest.java b/plugin/src/main/java/de/epiceric/shopchest/ShopChest.java
index 579aee7..d14267f 100644
--- a/plugin/src/main/java/de/epiceric/shopchest/ShopChest.java
+++ b/plugin/src/main/java/de/epiceric/shopchest/ShopChest.java
@@ -195,17 +195,8 @@ public class ShopChest extends JavaPlugin {
case "v1_16_R1":
case "v1_16_R2":
case "v1_16_R3":
- platform = new PlatformImpl(new ShopChestDebug(getLogger(), this::debug, this::debug));
- break;
case "v1_17_R1":
- // Need to have an implementation for 1.17.1 and 1.17 -> Change in the name of EntityDestroyPacket
- // TODO Check CraftMagicNumbers (And create a dedicated class to load Platform)
- if(Bukkit.getBukkitVersion().equals("1.17.1-R0.1-SNAPSHOT")){
- platform = new de.epiceric.shopchest.nms.v1_17_1_R1.PlatformImpl();
- }
- else {
- platform = new de.epiceric.shopchest.nms.v1_17_R1.PlatformImpl();
- }
+ platform = new PlatformImpl(new ShopChestDebug(getLogger(), this::debug, this::debug));
break;
case "v1_18_R1":
platform = new de.epiceric.shopchest.nms.v1_18_R1.PlatformImpl();
diff --git a/plugin/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/plugin/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
index 7604bcb..2e4b0bc 100644
--- a/plugin/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
+++ b/plugin/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
@@ -32,6 +32,7 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.block.Barrel;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@@ -781,7 +782,7 @@ public class ShopInteractListener implements Listener {
new Replacement(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
- plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.name(), finalNewAmount, newProduct.getItemStack().toString(), vendorName));
+ plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.getName(), finalNewAmount, newProduct.getItemStack().toString(), vendorName));
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.SOMEONE_BOUGHT, new Replacement(Placeholder.AMOUNT, String.valueOf(finalNewAmount)),
@@ -833,7 +834,7 @@ public class ShopInteractListener implements Listener {
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
- plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.name(), finalNewAmount1, newProduct.getItemStack().toString(), "ADMIN"));
+ plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.getName(), finalNewAmount1, newProduct.getItemStack().toString(), "ADMIN"));
});
}
} else {
@@ -975,7 +976,7 @@ public class ShopInteractListener implements Listener {
new Replacement(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
- plugin.getLogger().info(String.format("%s sold %d of %s from %s", executor.name(), finalNewAmount, newProduct.getItemStack().toString(), vendorName));
+ plugin.getLogger().info(String.format("%s sold %d of %s from %s", executor.getName(), finalNewAmount, newProduct.getItemStack().toString(), vendorName));
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.SOMEONE_SOLD, new Replacement(Placeholder.AMOUNT, String.valueOf(finalNewAmount)),
@@ -1028,7 +1029,7 @@ public class ShopInteractListener implements Listener {
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
- plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.name(), finalNewAmount, newProduct.getItemStack().toString(), "ADMIN"));
+ plugin.getLogger().info(String.format("%s bought %d of %s from %s", executor.getName(), finalNewAmount, newProduct.getItemStack().toString(), "ADMIN"));
}
} else {
diff --git a/pom.xml b/pom.xml
index 0020036..541bfa5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,8 +13,6 @@
plugin
nms/interface
nms/reflection
- nms/v1_17_R1
- nms/v1_17_1_R1
nms/v1_18_R1