mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Fix error on adapting custom entities / entity types (#2674)
chore/fix: entity type adaption, more in line with upstream
This commit is contained in:
parent
a0ef151341
commit
c1e2f23f94
@ -31,6 +31,8 @@ import com.sk89q.worldedit.world.item.ItemType;
|
|||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -186,10 +188,12 @@ public interface IBukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
||||||
if (!entityType.getId().startsWith("minecraft:")) {
|
NamespacedKey entityKey = NamespacedKey.fromString(entityType.toString());
|
||||||
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
if (entityKey == null) {
|
||||||
|
throw new IllegalArgumentException("Entity key '" + entityType + "' does not map to Bukkit");
|
||||||
}
|
}
|
||||||
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase(Locale.ROOT));
|
|
||||||
|
return Registry.ENTITY_TYPE.get(entityKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -343,7 +347,7 @@ public interface IBukkitAdapter {
|
|||||||
* @return WorldEdit EntityType
|
* @return WorldEdit EntityType
|
||||||
*/
|
*/
|
||||||
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
||||||
return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT));
|
return EntityTypes.get(entityType.getKey().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user