Skip to content

Commit

Permalink
Fixed the ability to spawn end crystals on other islands (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Nov 11, 2022
1 parent 4816833 commit 33f7418
Showing 1 changed file with 14 additions and 2 deletions.
@@ -1,6 +1,7 @@
package com.bgsoftware.superiorskyblock.world;

import com.bgsoftware.common.reflection.ReflectMethod;
import com.bgsoftware.superiorskyblock.core.Materials;
import com.bgsoftware.superiorskyblock.core.ServerVersion;
import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -23,6 +24,8 @@ public class BukkitItems {
private static final ReflectMethod<ItemStack> GET_ITEM_IN_OFF_HAND = new ReflectMethod<>(PlayerInventory.class, "getItemInOffHand");
private static final ReflectMethod<ItemStack> SET_ITEM_IN_OFF_HAND = new ReflectMethod<>(PlayerInventory.class, "setItemInOffHand", ItemStack.class);

private static final Material END_CRYSTAL_ITEM_TYPE = Materials.getMaterialSafe("END_CRYSTAL");

private BukkitItems() {

}
Expand Down Expand Up @@ -86,8 +89,17 @@ else if (event instanceof PlayerInteractEvent)

@SuppressWarnings("deprecation")
public static EntityType getEntityType(ItemStack itemStack) {
if (!isValidAndSpawnEgg(itemStack))
return itemStack.getType() == Material.ARMOR_STAND ? EntityType.ARMOR_STAND : EntityType.UNKNOWN;
if (!isValidAndSpawnEgg(itemStack)) {
Material itemType = itemStack.getType();

if (itemType == Material.ARMOR_STAND) {
return EntityType.ARMOR_STAND;
} else if (itemType == END_CRYSTAL_ITEM_TYPE) {
return EntityType.ENDER_CRYSTAL;
}

return EntityType.UNKNOWN;
}

if (ServerVersion.isLegacy()) {
try {
Expand Down

0 comments on commit 33f7418

Please sign in to comment.