1.8.8 Pasting schem using FAWE

Discussion in 'Spigot Plugin Development' started by christianboo2, Jan 12, 2020.

  1. Im tryna paste a schem using fawe, this is the coide i got:
    Code (Java):
        public static void pasteSchem() {
            try {
                File schem = new File("map.schematic");
                EditSession editSession = ClipboardFormats.findByFile(schem).load(schem).paste(FaweAPI.getWorld(""), new Vector(1100, 132, 1045), false, true, null);
                editSession.commit();
                System.out.println("schem pasted");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    I get this error however(see image) upload_2020-1-12_21-23-26.png
    I use gradle, this is my build.gradle
    Code (Text):
    plugins {
        id 'java'
    }

    group 'com.aj3douglas'
    version '1.0-SNAPSHOT'

    sourceCompatibility = 1.8

    repositories {
        mavenCentral()
        maven {
            url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'

            // As of Gradle 5.1, you can limit this to only those
            // dependencies you expect from it
            content {
                includeGroup 'org.bukkit'
                includeGroup 'org.spigotmc'
            }
        }
        maven { url ='http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/' }
    }

    dependencies {
        compileOnly 'org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT'
        compileOnly 'com.boydti:fawe-api:latest'
    }
     
    How would i fix the error?
     
    #1 christianboo2, Jan 12, 2020
    Last edited: Jan 12, 2020
  2. Forgot to mention, im on 1.8.8
     
    • Funny Funny x 1
  3. Your are trying to set it to a empty world name, set the world name here.
    Code (Text):
    FaweAPI.getWorld("")
     
  4. It doesnt work even with a worldname. Its an error i get when i build the jar in my IDE
     
  5. So yea, im lost
     
  6. you need to import worldedit too. import it after fawe.
     
  7. I have, look at my build.gradle
     
  8. I did this not too long ago... Let me spoonfeed:

    Code (Java):
    public Clipboard getSchematic(String name) {
            if (!name.contains(".schem")) name += ".schem";
            File file = new File(main.getServer().getPluginManager().getPlugin("WorldEdit").getDataFolder(), "schematics" + File.separator + name);
            ClipboardFormat format = ClipboardFormats.findByFile(file);
            try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
                return reader.read();
            } catch (IOException ex) {
                System.err.println("There was an error loading schematic \"" + name + "\" at " + file.getPath());
            }
            return null;
        }
    Pasting:

    Code (Java):
        private void paste(Clipboard schematic, Player player, Location loc) {
            try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(loc.getWorld()), -1)) {
                ClipboardHolder holder = new ClipboardHolder(schematic);
                holder.setTransform(getRotation());
                Operation operation = holder
                        .createPaste(editSession)
                        .to(BlockVector3.at(
                                loc.getX() + API.getDouble("Brushes." + name + ".X"),
                                loc.getY() + API.getDouble("Brushes." + name + ".Y"),
                                loc.getZ() + API.getDouble("Brushes." + name + ".Z")))
                        .ignoreAirBlocks(API.getBool("Brushes." + name + ".Ignore_Air"))
                        .build();
                Operations.complete(operation);
                WorldEdit.getInstance().getSessionManager().findByName(player.getName()).remember(editSession);
            } catch (WorldEditException e) {
                API.getInstance().log(LogLevel.ERROR, "Schematic \"" + schematic + "\" failed to load", e);
            } catch (NullPointerException e) {
                API.getInstance().log(LogLevel.WARN, "Player \"" + player.getName() +
                        "\" has left the server while painting.", e);
            }
        }
     
    Bit of a mess, but that should be enough for you to paste schematics.

    Worth pointing out that this uses worldedit, but it also works with FAWE because of how FAWE is setup.
     
  9. no you didnt. you imported fawe and bukkit. you need to import regular worldedit too.

    also, FaweAPI.load(file).paste(editSession, Vector loc, boolean noAir)

    /e
    and its also useless. it completely negates the purpose of having fawe. forcibly using fawe to perform a decrepid way of pasting a schematic... may as well just uninstall fawe lol

    /e2 also didnt read his issue. hes missing worldedit class files. providing him a worldedit copy pasta will just.. make his error worse lol
     
    #9 Warren1001, Jan 13, 2020
    Last edited: Jan 13, 2020
  10. I added worldedit as a dependancy and this happens
    https://i.imgur.com/cXlySI1.png
     
  11. /e and you made sure to import worldedit AFTER fawe? you want fawe classes to be loaded first. otherwise worldedit classes take dominance and you miss out on fawe's added methods
    /e2 tbh im not even sure what your image says, the quality is too low
     
    #11 Warren1001, Jan 13, 2020
    Last edited: Jan 13, 2020
  12. Using WorldEdit still uses fawe? Fawe still uses the same methods as WorldEdit, but it uses it's own api. This way, although this works with worldedit, it works faster with FAWE. I understand his question asked for FAWE, but he didn't highlight that FAWE was specifically used, so I gave him an alternative.