3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-19 09:20:08 +01:00

Fix error on adapting custom entities / entity types (#2674)

chore/fix: entity type adaption, more in line with upstream
Dieser Commit ist enthalten in:
Pierre Maurice Schwang 2024-04-12 20:55:58 +02:00 committet von GitHub
Ursprung a0ef151341
Commit c1e2f23f94
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -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());
} }
/** /**