From 37fc9af300b3bcab6dcb549dc7255acb4c982b57 Mon Sep 17 00:00:00 2001 From: Intelli Date: Mon, 17 Jun 2024 17:30:18 -0600 Subject: [PATCH] Added MC 1.21 support --- .../net/coreprotect/bukkit/BukkitAdapter.java | 2 +- .../database/rollback/Rollback.java | 9 ++++++- .../database/rollback/RollbackUtil.java | 3 +-- .../player/PlayerInteractListener.java | 5 ++-- .../java/net/coreprotect/utility/Util.java | 26 +++++++++++-------- .../worldedit/WorldEditBlockState.java | 6 +++++ 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java index a2955511..9818afd7 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java @@ -271,7 +271,7 @@ public boolean isSignFront(SignChangeEvent event) { @Override public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack) { PotionData data = arrow.getBasePotionData(); - if (data.getType() != PotionType.UNCRAFTABLE) { + if (data.getType() != PotionType.valueOf("UNCRAFTABLE")) { itemStack = new ItemStack(Material.TIPPED_ARROW); PotionMeta meta = (PotionMeta) itemStack.getItemMeta(); meta.setBasePotionData(data); diff --git a/src/main/java/net/coreprotect/database/rollback/Rollback.java b/src/main/java/net/coreprotect/database/rollback/Rollback.java index 666f4623..7e848722 100644 --- a/src/main/java/net/coreprotect/database/rollback/Rollback.java +++ b/src/main/java/net/coreprotect/database/rollback/Rollback.java @@ -649,7 +649,14 @@ else if ((rowType == Material.END_CRYSTAL)) { } if (!exists) { - Entity entity = block.getLocation().getWorld().spawnEntity(location1, EntityType.ENDER_CRYSTAL); + EntityType END_CRYSTAL = null; + try { + END_CRYSTAL = EntityType.valueOf("END_CRYSTAL"); // 1.21+ + } + catch (Exception e) { + END_CRYSTAL = EntityType.valueOf("ENDER_CRYSTAL"); // <= 1.20 + } + Entity entity = block.getLocation().getWorld().spawnEntity(location1, END_CRYSTAL); EnderCrystal enderCrystal = (EnderCrystal) entity; enderCrystal.setShowingBottom((rowData != 0)); PaperAdapter.ADAPTER.teleportAsync(entity, location1); diff --git a/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java b/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java index 0ee37fb0..921a2164 100644 --- a/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java +++ b/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java @@ -7,7 +7,6 @@ import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Builder; import org.bukkit.Material; -import org.bukkit.Tag; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.Jukebox; @@ -93,7 +92,7 @@ else if (type != null && type.equals(Material.ITEM_FRAME)) { else if (type != null && type.equals(Material.JUKEBOX)) { Jukebox jukebox = (Jukebox) container; if (jukebox != null) { - if (action == 1 && Tag.ITEMS_MUSIC_DISCS.isTagged(itemstack.getType())) { + if (action == 1 && itemstack.getType().name().startsWith("MUSIC_DISC")) { itemstack.setAmount(1); } else { diff --git a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java index 84506c27..6faf5c3f 100755 --- a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java +++ b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java @@ -11,7 +11,6 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -684,10 +683,10 @@ else if (type == Material.JUKEBOX) { ItemStack mainHand = player.getInventory().getItemInMainHand(); ItemStack offHand = player.getInventory().getItemInOffHand(); - if (event.getHand().equals(EquipmentSlot.HAND) && mainHand != null && Tag.ITEMS_MUSIC_DISCS.isTagged(mainHand.getType())) { + if (event.getHand().equals(EquipmentSlot.HAND) && mainHand != null && mainHand.getType().name().startsWith("MUSIC_DISC")) { handItem = mainHand; } - else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Tag.ITEMS_MUSIC_DISCS.isTagged(offHand.getType())) { + else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && offHand.getType().name().startsWith("MUSIC_DISC")) { handItem = offHand; } else { diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index aa3aa602..625cd1bb 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -917,26 +917,30 @@ else if (internal) { } public static Material getEntityMaterial(EntityType type) { - switch (type) { - case ARMOR_STAND: + switch (type.name()) { + case "ARMOR_STAND": return Material.ARMOR_STAND; - case ITEM_FRAME: + case "ITEM_FRAME": return Material.ITEM_FRAME; - case ENDER_CRYSTAL: + case "END_CRYSTAL": + case "ENDER_CRYSTAL": return Material.END_CRYSTAL; - case ENDER_PEARL: + case "ENDER_PEARL": return Material.ENDER_PEARL; - case SPLASH_POTION: + case "POTION": + case "SPLASH_POTION": return Material.SPLASH_POTION; - case THROWN_EXP_BOTTLE: + case "EXPERIENCE_BOTTLE": + case "THROWN_EXP_BOTTLE": return Material.EXPERIENCE_BOTTLE; - case TRIDENT: + case "TRIDENT": return Material.TRIDENT; - case FIREWORK: + case "FIREWORK_ROCKET": + case "FIREWORK": return Material.FIREWORK_ROCKET; - case EGG: + case "EGG": return Material.EGG; - case SNOWBALL: + case "SNOWBALL": return Material.SNOWBALL; default: return BukkitAdapter.ADAPTER.getFrameType(type); diff --git a/src/main/java/net/coreprotect/worldedit/WorldEditBlockState.java b/src/main/java/net/coreprotect/worldedit/WorldEditBlockState.java index c7737ffb..86c1a3db 100644 --- a/src/main/java/net/coreprotect/worldedit/WorldEditBlockState.java +++ b/src/main/java/net/coreprotect/worldedit/WorldEditBlockState.java @@ -211,4 +211,10 @@ public BlockState copy() { return null; } + @Override + public BlockState copy(Location location) { + // TODO Auto-generated method stub + return null; + } + }