Skip to content

Commit

Permalink
Added MC 1.21 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jun 17, 2024
1 parent 371e496 commit 37fc9af
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/net/coreprotect/utility/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,10 @@ public BlockState copy() {
return null;
}

@Override
public BlockState copy(Location location) {
// TODO Auto-generated method stub
return null;
}

}

0 comments on commit 37fc9af

Please sign in to comment.