Added MC 1.21 support

This commit is contained in:
Intelli 2024-06-17 17:30:18 -06:00
parent 371e496351
commit 37fc9af300
6 changed files with 33 additions and 18 deletions

View File

@ -271,7 +271,7 @@ public class BukkitAdapter implements BukkitInterface {
@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);

View File

@ -649,7 +649,14 @@ public class Rollback extends RollbackUtil {
}
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);

View File

@ -7,7 +7,6 @@ import java.util.Map;
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 @@ public class RollbackUtil extends Lookup {
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 {

View File

@ -11,7 +11,6 @@ import java.util.concurrent.ConcurrentHashMap;
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 @@ public final class PlayerInteractListener extends Queue implements Listener {
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 {

View File

@ -917,26 +917,30 @@ public class Util extends Queue {
}
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);

View File

@ -211,4 +211,10 @@ public final class WorldEditBlockState implements BlockState {
return null;
}
@Override
public BlockState copy(Location location) {
// TODO Auto-generated method stub
return null;
}
}