use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.
the class WorldEditPlugin method setupBiomes.
// FAWE start
private void setupBiomes(boolean expectFail) {
if (this.adapter.value().isPresent()) {
// The WorldServer get-registries method simply delegates to the MinecraftServer method.
for (final NamespacedKey biome : ((BukkitImplAdapter<?>) adapter.value().get()).getRegisteredBiomes()) {
BiomeType biomeType;
if ((biomeType = BiomeType.REGISTRY.get(biome.toString())) == null) {
// only register once
biomeType = new BiomeType(biome.toString());
BiomeType.REGISTRY.register(biome.toString(), biomeType);
}
biomeType.setLegacyId(adapter.value().get().getInternalBiomeId(biomeType));
}
} else {
if (!expectFail) {
LOGGER.warn("Failed to load biomes via adapter (not present). Will load via bukkit");
}
for (Biome biome : Biome.values()) {
// Custom is bad
if (biome.name().equals("CUSTOM")) {
continue;
}
String lowerCaseBiome = biome.getKey().toString().toLowerCase(Locale.ROOT);
// only register once
if (BiomeType.REGISTRY.get(lowerCaseBiome) == null) {
BiomeType.REGISTRY.register(lowerCaseBiome, new BiomeType(lowerCaseBiome));
}
}
}
}
use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.
the class WorldEditPlugin method loadAdapter.
// FAWE end
private void loadAdapter() {
WorldEdit worldEdit = WorldEdit.getInstance();
// Attempt to load a Bukkit adapter
BukkitImplLoader adapterLoader = new BukkitImplLoader();
try {
adapterLoader.addFromPath(getClass().getClassLoader());
} catch (IOException e) {
LOGGER.warn("Failed to search path for Bukkit adapters");
}
try {
adapterLoader.addFromJar(getFile());
} catch (IOException e) {
LOGGER.warn("Failed to search " + getFile() + " for Bukkit adapters", e);
}
try {
BukkitImplAdapter bukkitAdapter = adapterLoader.loadAdapter();
LOGGER.info("Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter");
this.adapter.newValue(bukkitAdapter);
} catch (AdapterLoadException e) {
Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING);
if (platform instanceof BukkitServerInterface) {
LOGGER.warn(e.getMessage());
} else {
// FAWE start - Identify as FAWE
LOGGER.info("FastAsyncWorldEdit could not find a Bukkit adapter for this MC version, " + "but it seems that you have another implementation of FastAsyncWorldEdit installed ({}) " + "that handles the world editing.", platform.getPlatformName());
// FAWE end
}
this.adapter.invalidate();
}
}
use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.
the class BukkitBlockRegistry method getMaterial.
@Nullable
@Override
public BlockMaterial getMaterial(BlockType blockType) {
// FAWE start - delegate to our internal values
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
BlockMaterial result = adapter.getMaterial(blockType);
if (result != null) {
return result;
}
}
Material mat = BukkitAdapter.adapt(blockType);
if (mat == null) {
return new PassthroughBlockMaterial(null);
}
if (materialMap == null) {
materialMap = new BukkitBlockMaterial[Material.values().length];
}
BukkitBlockMaterial result = materialMap[mat.ordinal()];
if (result == null) {
result = new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), mat);
materialMap[mat.ordinal()] = result;
}
return result;
// FAWE end
}
use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.
the class PaperweightGetBlocks_Copy method storeEntity.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void storeEntity(Entity entity) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag();
entities.add((CompoundTag) adapter.toNative(entity.save(compoundTag)));
}
use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.
the class PaperweightGetBlocks_Copy method storeEntity.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void storeEntity(Entity entity) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag();
entities.add((CompoundTag) adapter.toNative(entity.save(compoundTag)));
}
Aggregations