diff --git a/bedwars-plugin/pom.xml b/bedwars-plugin/pom.xml
index a6fc8af58..3743be254 100644
--- a/bedwars-plugin/pom.xml
+++ b/bedwars-plugin/pom.xml
@@ -202,6 +202,11 @@
versionsupport_v1_20_R4
${project.version}
+
+ com.andrei1058.bedwars
+ versionsupport_v1_21_R1
+ ${project.version}
+
com.andrei1058.bedwars
versionsupport-common
@@ -326,18 +331,6 @@
24.2
compile
-
- com.andrei1058.spigot.sidebar
- sidebar-v1_20_R4
- 23.12
- compile
-
-
- com.andrei1058.spigot.sidebar
- sidebar-v1_20_R4
- 23.12
- compile
-
diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java
index 3587183fd..1bbfb9b1d 100644
--- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java
+++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java
@@ -122,7 +122,7 @@ public class BedWars extends JavaPlugin {
private static Chat chat = new NoChat();
protected static Level level;
private static Economy economy;
- private static final String version = Bukkit.getServer().getClass().getName().split("\\.")[3];
+ private static String version;
private static String lobbyWorld = "";
private static boolean shuttingDown = false;
@@ -162,10 +162,11 @@ public void onLoad() {
Class supp;
try {
- supp = Class.forName("com.andrei1058.bedwars.support.version." + version + "." + version);
+ supp = Class.forName(
+ "com.andrei1058.bedwars.support.version." + getServerVersion() + "." + getServerVersion());
} catch (ClassNotFoundException e) {
serverSoftwareSupport = false;
- this.getLogger().severe("I can't run on your version: " + version);
+ this.getLogger().severe("I can't run on your version: " + getServerVersion());
return;
}
@@ -173,17 +174,25 @@ public void onLoad() {
Bukkit.getServicesManager().register(com.andrei1058.bedwars.api.BedWars.class, api, this, ServicePriority.Highest);
try {
+ Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
+ Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
+ Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
+ Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
+ Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
+ Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
//noinspection unchecked
- nms = (VersionSupport) supp.getConstructor(Class.forName("org.bukkit.plugin.Plugin"), String.class).newInstance(this, version);
+ nms = (VersionSupport) supp.getConstructor(
+ Class.forName("org.bukkit.plugin.Plugin"), String.class
+ ).newInstance(this, getServerVersion());
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException | IllegalAccessException |
ClassNotFoundException e) {
e.printStackTrace();
serverSoftwareSupport = false;
- this.getLogger().severe("Could not load support for server version: " + version);
+ this.getLogger().severe("Could not load support for server version: " + getServerVersion());
return;
}
- this.getLogger().info("Loading support for paper/spigot: " + version);
+ this.getLogger().info("Loading support for paper/spigot: " + getServerVersion());
// Setup languages
new English();
@@ -211,6 +220,12 @@ public void onLoad() {
@Override
public void onEnable() {
+ getLogger().severe(Bukkit.getServer().getClass().getName());
+ getLogger().severe(Bukkit.getServer().getClass().getName());
+ getLogger().severe(Bukkit.getServer().getClass().getName());
+ getLogger().severe(Bukkit.getServer().getClass().getName());
+ getLogger().severe(Bukkit.getServer().getClass().getName());
+ getLogger().severe(Bukkit.getServer().getClass().getName());
if (!serverSoftwareSupport) {
Bukkit.getPluginManager().disablePlugin(this);
return;
@@ -315,7 +330,11 @@ public void onEnable() {
registerEvents(new InvisibilityPotionListener());
/* Load join signs. */
- loadArenasAndSigns();
+ try {
+ loadArenasAndSigns();
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
statsManager = new StatsManager();
@@ -726,6 +745,13 @@ public static void setLobbyWorld(String lobbyWorld) {
* @since v0.6.5beta
*/
public static String getServerVersion() {
+ if (null == version) {
+ version = Bukkit.getServer().getClass().getName().split("\\.")[3];
+ if (version.equals("CraftServer")) {
+ // todo it is probably PAPER, find out how to get nms version
+ }
+
+ }
return version;
}
@@ -759,7 +785,7 @@ public static void setParty(Party party) {
public void performDeprecationCheck() {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
if (Arrays.stream(nms.getClass().getAnnotations()).anyMatch(annotation -> annotation instanceof Deprecated)) {
- this.getLogger().warning("Support for "+getServerVersion()+" is scheduled for removal. " +
+ this.getLogger().warning("Support for " + getServerVersion() + " is scheduled for removal. " +
"Please consider upgrading your server software to a newer Minecraft version.");
}
});
diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java
index 3df402c44..ba164e049 100644
--- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java
+++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java
@@ -43,9 +43,13 @@ public class ShopManager extends ConfigManager {
public ShopManager() {
super(BedWars.plugin, "shop", BedWars.plugin.getDataFolder().getPath());
- saveDefaults();
- loadShop();
- registerListeners();
+ try {
+ saveDefaults();
+ loadShop();
+ registerListeners();
+ } catch (Exception exception){
+ exception.printStackTrace();
+ }
}
private void saveDefaults() {
diff --git a/versionsupport_nms_cmn1/src/main/java/dev/andrei1058/mc/bedwars/AbstractVerImplCmn1.java b/versionsupport_nms_cmn1/src/main/java/dev/andrei1058/mc/bedwars/AbstractVerImplCmn1.java
index ba659062a..a9dd0d414 100644
--- a/versionsupport_nms_cmn1/src/main/java/dev/andrei1058/mc/bedwars/AbstractVerImplCmn1.java
+++ b/versionsupport_nms_cmn1/src/main/java/dev/andrei1058/mc/bedwars/AbstractVerImplCmn1.java
@@ -38,6 +38,8 @@
import org.bukkit.event.inventory.InventoryEvent;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
+import org.bukkit.persistence.PersistentDataContainer;
+import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
@@ -48,6 +50,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import java.util.logging.Level;
/**
@@ -73,12 +76,16 @@ public void registerVersionListeners() {
@Override
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) {
- var tag = getTag(itemStack);
- return tag == null ? null : tag.e(key) ? tag.l(key) : null;
+ var tag = getDataContainer(itemStack);
+ if (null == tag) {
+ return null;
+ }
+ return tag.get(
+ Objects.requireNonNull(NamespacedKey.fromString(key)),
+ PersistentDataType.STRING
+ );
}
- public abstract @Nullable NBTTagCompound getTag(@NotNull org.bukkit.inventory.ItemStack itemStack);
-
@Override
public void sendTitle(@NotNull Player p, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
p.sendTitle(title == null ? " " : title, subtitle == null ? " " : subtitle, fadeIn, stay, fadeOut);
@@ -195,11 +202,17 @@ public void spawnShop(@NotNull Location loc, String name1, List players,
@Override
public double getDamage(org.bukkit.inventory.ItemStack i) {
- var tag = getTag(i);
+ var tag = getDataContainer(i);
if (null == tag) {
throw new RuntimeException("Provided item has no Tag");
}
- return tag.k("generic.attackDamage");
+ // todo experimental
+ var dmg = getDataContainer(i);
+ if (null == dmg) {
+ return -1;
+ }
+ var dmg2 = dmg.get(NamespacedKey.minecraft("generic.attackDamage"), PersistentDataType.DOUBLE);
+ return null == dmg2 ? -1 : dmg2;
}
private static ArmorStand createArmorStand(String name, Location loc) {
@@ -304,26 +317,65 @@ public void setCollide(@NotNull Player p, IArena a, boolean value) {
@Override
public org.bukkit.inventory.ItemStack addCustomData(org.bukkit.inventory.ItemStack i, String data) {
- var tag = getCreateTag(i);
- tag.a(VersionSupport.PLUGIN_TAG_GENERIC_KEY, data);
- return applyTag(i, tag);
+ var tag = getDataContainer(i);
+ if (null == tag) {
+ return i;
+ }
+ tag.set(
+ Objects.requireNonNull(NamespacedKey.fromString(VersionSupport.PLUGIN_TAG_GENERIC_KEY, getPlugin())),
+ PersistentDataType.STRING,
+ data
+ );
+ return i;
+ }
+
+ public org.bukkit.inventory.ItemStack addCustomData(org.bukkit.inventory.ItemStack i, String key, String data) {
+ var tag = getDataContainer(i);
+ if (null == tag) {
+ return i;
+ }
+ tag.set(
+ Objects.requireNonNull(NamespacedKey.fromString(key, getPlugin())),
+ PersistentDataType.STRING,
+ data
+ );
+ return i;
}
@Override
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
- var tag = getCreateTag(itemStack);
- tag.a(key, value);
- return applyTag(itemStack, tag);
+ var tag = getDataContainer(itemStack);
+ if (null == tag) {
+ return itemStack;
+ }
+ key = key.replaceFirst("minecraft:", "");
+ tag.set(
+ Objects.requireNonNull(NamespacedKey.minecraft(key)),
+ PersistentDataType.STRING,
+ value
+ );
+ return itemStack;
}
@Override
public boolean isCustomBedWarsItem(org.bukkit.inventory.ItemStack i) {
- return getCreateTag(i).e(VersionSupport.PLUGIN_TAG_GENERIC_KEY);
+ var tag = getDataContainer(i);
+ if (null == tag) {
+ return false;
+ }
+ return tag.has(Objects.requireNonNull(NamespacedKey.fromString(VersionSupport.PLUGIN_TAG_GENERIC_KEY)));
}
@Override
public String getCustomData(org.bukkit.inventory.ItemStack i) {
- return getCreateTag(i).l(VersionSupport.PLUGIN_TAG_GENERIC_KEY);
+ var tag = getDataContainer(i);
+ if (null == tag) {
+ return null;
+ }
+ return tag.get(
+ Objects.requireNonNull(NamespacedKey.fromString(VersionSupport.PLUGIN_TAG_GENERIC_KEY)),
+ PersistentDataType.STRING
+ );
}
@Override
@@ -428,36 +480,35 @@ public org.bukkit.Material woolMaterial() {
}
- @Override
+ @Override @Nullable
public String getShopUpgradeIdentifier(org.bukkit.inventory.ItemStack itemStack) {
- var tag = getCreateTag(itemStack);
- return tag.e(VersionSupport.PLUGIN_TAG_TIER_KEY) ? tag.l(VersionSupport.PLUGIN_TAG_TIER_KEY) : "null";
+ return getTag(itemStack, VersionSupport.PLUGIN_TAG_TIER_KEY);
}
@Override
public org.bukkit.inventory.ItemStack setShopUpgradeIdentifier(org.bukkit.inventory.ItemStack itemStack, String identifier) {
- var tag = getCreateTag(itemStack);
- tag.a(VersionSupport.PLUGIN_TAG_TIER_KEY, identifier);
- return applyTag(itemStack, tag);
+ return addCustomData(itemStack, VersionSupport.PLUGIN_TAG_TIER_KEY, identifier);
}
@Override
public org.bukkit.inventory.ItemStack getPlayerHead(Player player, org.bukkit.inventory.ItemStack copyTagFrom) {
- org.bukkit.inventory.ItemStack head = new org.bukkit.inventory.ItemStack(materialPlayerHead());
-
- if (copyTagFrom != null) {
- var tag = getTag(copyTagFrom);
- head = applyTag(head, tag);
- }
-
- var meta = head.getItemMeta();
- if (meta instanceof SkullMeta) {
- ((SkullMeta) meta).setOwnerProfile(player.getPlayerProfile());
- }
- head.setItemMeta(meta);
- return head;
+ // todo
+// org.bukkit.inventory.ItemStack head = new org.bukkit.inventory.ItemStack(materialPlayerHead());
+//
+// if (copyTagFrom != null) {
+// var tag = getTag(copyTagFrom);
+// head = applyTag(head, tag);
+// }
+//
+// var meta = head.getItemMeta();
+// if (meta instanceof SkullMeta) {
+// ((SkullMeta) meta).setOwnerProfile(player.getPlayerProfile());
+// }
+// head.setItemMeta(meta);
+ return copyTagFrom;
}
+ public abstract ClientboundPlayerInfoUpdatePacket getAddPlayer(EntityPlayer player);
@Override
public void sendPlayerSpawnPackets(Player respawned, IArena arena) {
@@ -469,7 +520,7 @@ public void sendPlayerSpawnPackets(Player respawned, IArena arena) {
if (arena.getRespawnSessions().containsKey(respawned)) return;
EntityPlayer entityPlayer = getPlayer(respawned);
- PacketPlayOutSpawnEntity show = new PacketPlayOutSpawnEntity(entityPlayer);
+ ClientboundPlayerInfoUpdatePacket show = getAddPlayer(entityPlayer);
PacketPlayOutEntityVelocity playerVelocity = new PacketPlayOutEntityVelocity(entityPlayer);
// we send head rotation packet because sometimes on respawn others see him with bad rotation
PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entityPlayer, getCompressedAngle(entityPlayer.getBukkitYaw()));
@@ -501,7 +552,7 @@ public void sendPlayerSpawnPackets(Player respawned, IArena arena) {
hideArmor(p, respawned);
} else {
- PacketPlayOutSpawnEntity show2 = new PacketPlayOutSpawnEntity(boundTo);
+ ClientboundPlayerInfoUpdatePacket show2 = getAddPlayer(boundTo);
PacketPlayOutEntityVelocity playerVelocity2 = new PacketPlayOutEntityVelocity(boundTo);
PacketPlayOutEntityHeadRotation head2 = new PacketPlayOutEntityHeadRotation(boundTo, getCompressedAngle(boundTo.getBukkitYaw()));
this.sendPackets(respawned, show2, playerVelocity2, head2);
@@ -515,7 +566,7 @@ public void sendPlayerSpawnPackets(Player respawned, IArena arena) {
for (Player spectator : arena.getSpectators()) {
if (spectator == null) continue;
if (spectator.equals(respawned)) continue;
- EntityPlayer boundTo = ((CraftPlayer) spectator).getHandle();
+// EntityPlayer boundTo = ((CraftPlayer) spectator).getHandle();
respawned.hidePlayer(getPlugin(), spectator);
if (spectator.getWorld().equals(respawned.getWorld())) {
if (respawned.getLocation().distance(spectator.getLocation()) <= arena.getRenderDistance()) {
@@ -543,6 +594,7 @@ public void setUnbreakable(@NotNull ItemMeta itemMeta) {
@Override
public abstract String getMainLevel();
+
@Override
abstract public int getVersion();
@@ -591,19 +643,15 @@ public void clearArrowsFromPlayerBody(Player player) {
// minecraft clears them on death on newer version
}
- private @Nullable NBTTagCompound getTag(@NotNull ItemStack itemStack) {
- // todo WIP
- return new NBTTagCompound();
- }
-
- public NBTTagCompound getCreateTag(ItemStack itemStack) {
- var tag = getTag(itemStack);
- return null == tag ? initializeTag(itemStack) : tag;
+ @Nullable
+ public PersistentDataContainer getDataContainer(org.bukkit.inventory.@NotNull ItemStack itemStack) {
+ if (null == itemStack.getItemMeta()) {
+ return null;
+ }
+ return itemStack.getItemMeta().getPersistentDataContainer();
}
- abstract @NotNull NBTTagCompound initializeTag(ItemStack itemStack);
-
- abstract EntityPlayer getPlayer(Player player);
+ public abstract EntityPlayer getPlayer(Player player);
public List> getPlayerEquipment(@NotNull Player player) {
return getPlayerEquipment(getPlayer(player));
@@ -658,7 +706,7 @@ public void playVillagerEffect(@NotNull Player player, Location location) {
player.spawnParticle(Particle.HAPPY_VILLAGER, location, 1);
}
- abstract void sendPacket(Player player, Packet> packet) ;
+ public abstract void sendPacket(Player player, Packet> packet);
- abstract void sendPackets(Player player, Packet> @NotNull ... packets);
+ public abstract void sendPackets(Player player, Packet> @NotNull ... packets);
}
diff --git a/versionsupport_v1_21_R1/pom.xml b/versionsupport_v1_21_R1/pom.xml
index 6dfef10ee..60f4c2677 100644
--- a/versionsupport_v1_21_R1/pom.xml
+++ b/versionsupport_v1_21_R1/pom.xml
@@ -20,7 +20,7 @@
com.andrei1058.bedwars
versionsupport_nms_cmn1
${project.version}
- provided
+ compile
com.andrei1058.bedwars
@@ -49,6 +49,12 @@
+
+ com.andrei1058.spigot.sidebar
+ sidebar-v1_21_R1
+ 24.8-SNAPSHOT
+ compile
+
diff --git a/versionsupport_v1_21_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_21_R1/v1_21_R1.java b/versionsupport_v1_21_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_21_R1/v1_21_R1.java
index 28193900b..3e257f8c0 100644
--- a/versionsupport_v1_21_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_21_R1/v1_21_R1.java
+++ b/versionsupport_v1_21_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_21_R1/v1_21_R1.java
@@ -4,6 +4,7 @@
import dev.andrei1058.mc.bedwars.AbstractVerImplCmn1;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.protocol.Packet;
+import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
@@ -15,6 +16,7 @@
import net.minecraft.world.entity.projectile.EntityFireball;
import net.minecraft.world.entity.projectile.IProjectile;
import net.minecraft.world.item.*;
+import net.minecraft.world.phys.Vec3D;
import org.bukkit.command.Command;
import org.bukkit.craftbukkit.v1_21_R1.CraftServer;
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftFireball;
@@ -31,11 +33,11 @@
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-import static org.bukkit.craftbukkit.v1_21_R1.util.CraftMagicNumbers.getItem;
-
@SuppressWarnings("unused")
public class v1_21_R1 extends AbstractVerImplCmn1 {
@@ -48,15 +50,6 @@ public void registerCommand(String name, Command cmd) {
((CraftServer) getPlugin().getServer()).getCommandMap().register(name, cmd);
}
- public @Nullable NBTTagCompound getTag(@NotNull org.bukkit.inventory.ItemStack itemStack) {
- var i = CraftItemStack.asNMSCopy(itemStack);
- if (null == i) {
- return null;
- }
- // TODO WIP
- return new NBTTagCompound();
- }
-
@Override
public boolean isBukkitCommandRegistered(String name) {
return ((CraftServer) getPlugin().getServer()).getCommandMap().getCommand(name) != null;
@@ -75,6 +68,13 @@ public void setSource(TNTPrimed tnt, Player owner) {
}
}
+ @Override
+ public ClientboundPlayerInfoUpdatePacket getAddPlayer(EntityPlayer player) {
+ // todo cache this in production
+ ClientboundPlayerInfoUpdatePacket.a action = (ClientboundPlayerInfoUpdatePacket.a) getPlayerSpawnAction("a");
+ return new ClientboundPlayerInfoUpdatePacket(action, player);
+ }
+
@Override
public boolean isArmor(org.bukkit.inventory.ItemStack itemStack) {
var i = getItem(itemStack);
@@ -119,8 +119,9 @@ public boolean isProjectile(org.bukkit.inventory.ItemStack itemStack) {
@Override
public void voidKill(Player p) {
- EntityPlayer player = getPlayer(p);
- player.a(player.dM().m(), 1000);
+ //todo
+// EntityPlayer player = getPlayer(p);
+// player.a(player.dM().m(), 1000);
}
@Override
public void showArmor(@NotNull Player victim, Player receiver) {
@@ -139,13 +140,20 @@ public String getMainLevel() {
return ((DedicatedServer) MinecraftServer.getServer()).a().n;
}
+ @Override
+ public int getVersion() {
+ return 21;
+ }
+
@Override
public Fireball setFireballDirection(Fireball fireball, @NotNull Vector vector) {
EntityFireball fb = ((CraftFireball) fireball).getHandle();
- fb.b = vector.getX() * 0.1D;
- fb.c = vector.getY() * 0.1D;
- fb.d = vector.getZ() * 0.1D;
+// fb.b = vector.getX() * 0.1D;
+// fb.c = vector.getY() * 0.1D;
+// fb.d = vector.getZ() * 0.1D;
+ // todo experimental
+ fb.a(new Vec3D(vector.getX(), vector.getY(), vector.getZ()), 0.1D);
return (Fireball) fb.getBukkitEntity();
}
@@ -170,63 +178,16 @@ public Fireball setFireballDirection(Fireball fireball, @NotNull Vector vector)
if (null == i) {
return null;
}
- return i.H();
- }
-
- @Nullable
- public NBTTagCompound getTag(@NotNull org.bukkit.inventory.ItemStack itemStack) {
- var i = CraftItemStack.asNMSCopy(itemStack);
- if (null == i) {
- return null;
- }
- return i.v();
- }
-
- private @NotNull NBTTagCompound initializeTag(org.bukkit.inventory.ItemStack itemStack) {
- var i = CraftItemStack.asNMSCopy(itemStack);
- if (null == i) {
- throw new RuntimeException("Cannot convert given item to a NMS item");
- }
- return initializeTag(i);
- }
-
- private @NotNull NBTTagCompound initializeTag(ItemStack itemStack) {
-
- var tag = getTag(itemStack);
- if (null != tag) {
- throw new RuntimeException("Provided item already has a Tag");
- }
- tag = new NBTTagCompound();
- itemStack.c(tag);
-
- return tag;
- }
-
- public NBTTagCompound getCreateTag(org.bukkit.inventory.ItemStack itemStack) {
- var i = CraftItemStack.asNMSCopy(itemStack);
- if (null == i) {
- throw new RuntimeException("Cannot convert given item to a NMS item");
- }
- return getCreateTag(i);
- }
-
- public org.bukkit.inventory.ItemStack applyTag(org.bukkit.inventory.ItemStack itemStack, NBTTagCompound tag) {
- return CraftItemStack.asBukkitCopy(applyTag(getNmsItemCopy(itemStack), tag));
+ // todo experimental
+ return i.E();
}
public ItemStack applyTag(@NotNull ItemStack itemStack, NBTTagCompound tag) {
- itemStack.(tag);
+ // todo re-apply container?
+// itemStack.(tag);
return itemStack;
}
- public ItemStack getNmsItemCopy(org.bukkit.inventory.ItemStack itemStack) {
- ItemStack i = CraftItemStack.asNMSCopy(itemStack);
- if (null == i) {
- throw new RuntimeException("Cannot convert given item to a NMS item");
- }
- return i;
- }
-
public EntityPlayer getPlayer(Player player) {
return ((CraftPlayer) player).getHandle();
}
@@ -241,4 +202,24 @@ public void sendPackets(Player player, Packet> @NotNull ... packets) {
connection.a(p);
}
}
+
+ private static Object getPlayerSpawnAction(String action) {
+ try {
+ Class> cls = Class.forName("net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket$a");
+ for (Object obj : cls.getEnumConstants()) {
+ try {
+ Method m = cls.getMethod("name");
+ String name = (String) m.invoke(obj);
+ if (action.equals(name)) {
+ return obj;
+ }
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+ System.out.println("could not find enum");
+ }
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ throw new RuntimeException("Something went wrong... please report this to BedWars1058 by andrei1058");
+ }
}
\ No newline at end of file