Search in sources :

Example 1 with BukkitImplAdapter

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));
            }
        }
    }
}
Also used : BiomeType(com.sk89q.worldedit.world.biome.BiomeType) Biome(org.bukkit.block.Biome) NamespacedKey(org.bukkit.NamespacedKey) BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter)

Example 2 with BukkitImplAdapter

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();
    }
}
Also used : WorldEdit(com.sk89q.worldedit.WorldEdit) Platform(com.sk89q.worldedit.extension.platform.Platform) BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) BukkitImplLoader(com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader) IOException(java.io.IOException) AdapterLoadException(com.sk89q.worldedit.bukkit.adapter.AdapterLoadException)

Example 3 with BukkitImplAdapter

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
}
Also used : PassthroughBlockMaterial(com.sk89q.worldedit.world.registry.PassthroughBlockMaterial) BlockMaterial(com.sk89q.worldedit.world.registry.BlockMaterial) PassthroughBlockMaterial(com.sk89q.worldedit.world.registry.PassthroughBlockMaterial) BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) PassthroughBlockMaterial(com.sk89q.worldedit.world.registry.PassthroughBlockMaterial) BlockMaterial(com.sk89q.worldedit.world.registry.BlockMaterial) Material(org.bukkit.Material) Nullable(javax.annotation.Nullable)

Example 4 with BukkitImplAdapter

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)));
}
Also used : BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) PaperweightLazyCompoundTag(com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt.PaperweightLazyCompoundTag) CompoundTag(com.sk89q.jnbt.CompoundTag)

Example 5 with BukkitImplAdapter

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)));
}
Also used : BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) CompoundTag(com.sk89q.jnbt.CompoundTag) PaperweightLazyCompoundTag(com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag)

Aggregations

BukkitImplAdapter (com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter)8 CompoundTag (com.sk89q.jnbt.CompoundTag)3 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)2 WorldUnloadedException (com.fastasyncworldedit.bukkit.util.WorldUnloadedException)1 FaweException (com.fastasyncworldedit.core.internal.exception.FaweException)1 WorldEdit (com.sk89q.worldedit.WorldEdit)1 WorldEditException (com.sk89q.worldedit.WorldEditException)1 AdapterLoadException (com.sk89q.worldedit.bukkit.adapter.AdapterLoadException)1 BukkitImplLoader (com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader)1 UnsupportedVersionEditException (com.sk89q.worldedit.bukkit.adapter.UnsupportedVersionEditException)1 PaperweightLazyCompoundTag (com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag)1 PaperweightLazyCompoundTag (com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1.nbt.PaperweightLazyCompoundTag)1 PaperweightLazyCompoundTag (com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt.PaperweightLazyCompoundTag)1 Platform (com.sk89q.worldedit.extension.platform.Platform)1 CompoundBinaryTag (com.sk89q.worldedit.util.nbt.CompoundBinaryTag)1 BiomeType (com.sk89q.worldedit.world.biome.BiomeType)1 BlockMaterial (com.sk89q.worldedit.world.registry.BlockMaterial)1 PassthroughBlockMaterial (com.sk89q.worldedit.world.registry.PassthroughBlockMaterial)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1