1.8.8 FAWE usage

Discussion in 'Spigot Plugin Development' started by CodingCyClone, Jul 13, 2021.

  1. I am trying to use FAWE (fast async world edit) as a dependency in a plugin so that I can copy, paste, and rotate different structures. The issue is I am not sure what sort of dependencies I need since I also have have regular world edit inside my plugin folder which I think I still need. That being said so far I have added these to my POM...
    Code (Text):
    <!-- FAWE -->
    <repository>
      <id>IntellectualSites</id>
      <url>https://mvn.intellectualsites.com/content/groups/public/</url>
    </repository>

    <!-- FAWE API -->
    <dependency>
      <groupId>com.fastasyncworldedit</groupId>
      <artifactId>FAWE-Bukkit</artifactId>
      <version>1.17-47</version>
    </dependency>

    Then inside my onEnable method I added this but I am not sure what its called so I cant register it (its not called FAWE)
    Code (Text):
    if(this.getServer().getPluginManager().getPlugin("FAWE") == null){
                getServer().getPluginManager().disablePlugin(this);
    }
    new

    Anyways after I figure out how to register it how can I paste schematics at a certain locations as well as rotate and save other schematics with their coordinates and the world?
     
  2. This thread provides you with an example of how to paste a schematic.
     
  3. Firstly I need to correctly register FAWE also do I also need to keep regular world edit in my plugin folder?
     
  4. Afaik FAWE does no longer require WorldEdit to be installed on the server. The FAWE API is very similar to WorldEdits API, which you can find here, and in this thread, you can see how to rotate your clipboard. This thread provides you with an example of how to save schematics. You can also find a tutorial on how to properly install the plugin on their wiki page.
     
    • Informative Informative x 1
  5. Ok thank you but how do I register the plugin? Also when I use this pasteSchamtic method I get multiple errors one for
    World weWorld = new BukkitWorld(loc.getWorld()); where it wants it to be World and not BukkitWorld so should I cast it to (World)? The next error occurs from the Vector where all the locations are underlined and lastly the .paste command is completely underlined.
    Code (Text):
    public boolean pasteSchematic(String schematicName, Location loc, boolean noAir) {
            World weWorld = new BukkitWorld(loc.getWorld());

            File file = new File(getDataFolder() + File.separator + "schematics" + File.separator + schematicName + ".schematic");
            if (!file.exists()) {
                return false;
            }
            boolean allowUndo = false;
            Vector vec = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
            try {
                EditSession editSession = ClipboardFormats.findByFile(file)
                        .load(file)
                        .paste(weWorld, vec, allowUndo, !noAir, (Transform) null);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return false;
            }
            return true;
        }
     
  6. Maybe the other peoples projects were using a version other than 1.8?
     
  7. It could be that the api has changed eversince. However, there are methods in the BukkitAdapter class that should provide you with methods to convert between worlds. For the Vector part you might be implementing the wrong vector. Try using org.bukkit.util.Vector. The method parameters of the paste method may have changed over time, remove the parameters and hold down control and hover over the method to see what you need to provide the method with. Maybe their wiki page can help you out. You can also have a look at the paste method in their java docs.
     
  8. Do I need to register anything I have asked this like 4 times and I really need to know since that is important. Anyways I managed to get the errors to go away by changing a lot does this look like it will work? Also what does the !noAir boolean value mean?
    Code (Text):
        public boolean pasteSchematic(String schematicName, Location loc, boolean noAir) {
            BukkitWorld world = new BukkitWorld(loc.getWorld());

            File file = new File(getDataFolder() + File.separator + "schematics" + File.separator + schematicName + ".schematic");
            if (!file.exists()) {
                return false;
            }
            boolean allowUndo = true;
            BlockVector3 vec = new BlockVector3() {
                @Override
                public int getX() {
                    return loc.getBlockX();
                }

                @Override
                public int getY() {
                    return loc.getBlockY();
                }

                @Override
                public int getZ() {
                    return loc.getBlockZ();
                }
            };
            try {
                EditSession editSession = ClipboardFormats.findByFile(file)
                        .load(file)
                        //.paste(weWorld, vec);
                        .paste(world, vec, allowUndo, !noAir, null);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return false;
            }
            return true;
        }

    Edit as expected I got an error in console which caused my plugin to disable
    Code (Text):
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/sk89q/worldedit/math/BlockVector3
    Caused by: java.lang.NoClassDefFoundError: com/sk89q/worldedit/math/BlockVector3
     
    #8 CodingCyClone, Jul 13, 2021
    Last edited: Jul 13, 2021
  9. the noair boolean probably decides about whether the air blocks within the schematic will be placed as well or not. However, I have provided you with various links to wiki pages. I am pretty confident you do not need to register anything. The NoClassDefFoundError is thrown either because you do not depend on the plugin, the API you're using is outdated or the plugin on your server is outdated.

    Edit: There either will be an implementation of BlockVector3 or this is the wrong parameter for what you want to do to begin with.
     
    #9 Sxlver_, Jul 13, 2021
    Last edited: Jul 14, 2021
  10. As an update I downloaded it and then I added the dependency my self by getting the plugins folder. The problem now is that
    import com.sk89q.worldedit.world.World; does not exist and it keeps giving me an error since it does not want the regular org.bukkit.World import. (The other imports work just for some reason the one I need does not exist)
     
  11. Here is what I have so far but like I still have an error with "world" since its telling me it requires com.sk89q.worldedit.world.World even though that does no exist as an import statement.
    Code (Text):
    public boolean pasteSchematic(String schematicName, Location loc, boolean noAir) {
            World world = (World) new BukkitWorld(loc.getWorld());

            File file = new File(getDataFolder() + File.separator + "schematics" + File.separator + schematicName + ".schematic");
            if (!file.exists()) {
                return false;
            }
            boolean allowUndo = true;
            Vector vec = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
            try {
                EditSession editSession = ClipboardFormats.findByFile(file)
                        .load(file)
                        .paste(world, vec);
                        //.paste(world, vec, allowUndo, !noAir, (Transform) null);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return false;
            }
            return true;
        }
     
  12. Code (Text):
    BukkitAdapter.adapt(World world);
    At least that is what it's like in the usual WorldEdit API. If that's not the case for you you may wanna check the docs/wiki page if you can find something.
     
    #12 Sxlver_, Jul 14, 2021
    Last edited: Jul 14, 2021
  13. I dont see BukkitAdapter as a useable call. I managed to get that com.sk89q.worldedit.world.World error inside intelliJ to go away by adding regular world edit as a dependency but when ever I load my plugin I get a console error saying it cant find the class any ideas? (No errors inside IntelliJ)
    Code (Text):
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/sk89q/worldedit/world/World
     
  14. You most likely get this error because this is a WorldEdit thing and because WorldEdit isn't installed it cannot find this class obviously. try using FaweAPI.getWorld.
    source