Solved [1.12.2] Cannot find FAWE "World" type, only bukkit World

Discussion in 'Spigot Plugin Development' started by Ammonium_, Feb 4, 2020.

  1. I'm trying to use the FAWE API to paste a schematic, but it says it requires "com.sk89q.worldedit.world.World", while I only have org.Bukkit.World:
    upload_2020-2-3_18-50-15.png
    Now, I know I should just need to import FAWE's world type, but if I try to import it says that it cannot resolve symbol "World":
    upload_2020-2-3_18-52-3.png
    I found that there IS a type called "BukkitWorld" within com.sk89.worldedit, but it still doesn't accept it:
    upload_2020-2-3_18-56-38.png
    Here's my relevant maven dependencies and repositories:
    upload_2020-2-3_18-53-23.png
    upload_2020-2-3_18-53-39.png
    I already verified they got added correctly, since other things such as EditSession are recognized correctly.
    I am using Spigot 1.12.2

    Can you please help me?
     
    #1 Ammonium_, Feb 4, 2020
    Last edited: Feb 4, 2020
  2. Also, this is inside a PlayerInteractEvent, so whichever World I need to cast it to, I hope it can be casted from player.getWorld(). Would this work?
     
  3. This looks like something you might need
     
  4. This is probably what your looking for:
    Code (Java):
        /**
         * Create a WorldEdit world from a Bukkit world.
         *
         * @param world the Bukkit world
         * @return a WorldEdit world
         */

        public static World adapt(org.bukkit.World world) {
            checkNotNull(world);
            return new BukkitWorld(world);
        }
     
  5. Where can I access that function from though? Because world.adapt() doesn't work. I also already have worldedit-bukkit version 7.1.0 installed. My guess is that it could be due to a version mismatch between worldedit-bukkit 7.1.0 and fawe-api LATEST, but I'm not sure what versions to put in their place.
     
  6. Hey, it worked! At least sorta. It matches the world type, but now it can't resolve method load():
    upload_2020-2-3_19-38-36.png
    I'm getting closer to it. I see there's a .getWriter() method now. Maybe I use .getWriter() and then another similar to .load() ?
     
    #8 Ammonium_, Feb 4, 2020
    Last edited: Feb 4, 2020
  7. Apparently for 1.12.2 you need to use this piece of code instead

    Code (Java):
       
    WorldData worldData = world.getWorldData();
    Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file)).read(worldData);
    // Region region = clipboard.getRegion();

    EditSession extent = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
    AffineTransform transform = new AffineTransform();

    ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, position);
    if (!transform.isIdentity()) copy.setTransform(transform);
    copy.setSourceMask(new ExistingBlockMask(clipboard));
    Operations.completeLegacy(copy);
    extent.flushQueue();
       
    I'll mark this as solved for now
     
  8. since youre using fawe, fawe has an api for schematic loading.
    FaweAPI.load(file).paste