Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Add adapters for EntityType
Dieser Commit ist enthalten in:
Ursprung
e0e7778536
Commit
96388df4b0
@ -34,6 +34,8 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
@ -244,7 +246,7 @@ public class BukkitAdapter {
|
||||
if (!itemType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||
}
|
||||
return Material.getMaterial(itemType.getId().replace("minecraft:", "").toUpperCase());
|
||||
return Material.getMaterial(itemType.getId().substring(10).toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,7 +260,7 @@ public class BukkitAdapter {
|
||||
if (!blockType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||
}
|
||||
return Material.getMaterial(blockType.getId().replace("minecraft:", "").toUpperCase());
|
||||
return Material.getMaterial(blockType.getId().substring(10).toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -272,6 +274,23 @@ public class BukkitAdapter {
|
||||
return GameModes.get(gameMode.name().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit EntityType from a Bukkit one.
|
||||
*
|
||||
* @param entityType Bukkit EntityType
|
||||
* @return WorldEdit EntityType
|
||||
*/
|
||||
public static EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
||||
return EntityTypes.get(entityType.getName().toLowerCase());
|
||||
}
|
||||
|
||||
public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
||||
if (!entityType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
||||
}
|
||||
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Material to a BlockType
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren