Solved WorldEdit API issues

Discussion in 'Plugin Development' started by acdavis02, Dec 16, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    acdavis02

    Hello,

    I am trying to develop a plugin that will reset mines for a prison server.
    So far I have coded the selection tool that will set the area for the mine. Now I trying to put in the code that will allow Mods to manually reset the mine. But I'm stumped on this error and can't find my issue. It says it's with my CuboidSelection, But I don't see to find any issue with it. Heres the error and the code.

    Error
    Code:
    [16:11:21 INFO]: Adventum issued server command: /resetmine test1
    [16:11:21 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'resetmine' in plugin PrisonMines v1.0-beta
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_141]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_141]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
    Caused by: java.lang.NullPointerException: The world was unloaded and the reference is unavailable
            at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) ~[Spigot18.jar:git-Spigot-db6de12-18fbb24]
            at com.sk89q.worldedit.bukkit.BukkitWorld.getWorld(BukkitWorld.java:131) ~[?:?]
            at com.sk89q.worldedit.bukkit.BukkitWorld.getMaxY(BukkitWorld.java:366) ~[?:?]
            at com.sk89q.worldedit.regions.CuboidRegion.recalculate(CuboidRegion.java:115) ~[?:?]
            at com.sk89q.worldedit.regions.CuboidRegion.<init>(CuboidRegion.java:72) ~[?:?]
            at com.sk89q.worldedit.regions.selector.CuboidRegionSelector.<init>(CuboidRegionSelector.java:60) ~[?:?]
            at com.sk89q.worldedit.bukkit.selections.CuboidSelection.<init>(CuboidSelection.java:52) ~[?:?]
            at com.sk89q.worldedit.bukkit.selections.CuboidSelection.<init>(CuboidSelection.java:36) ~[?:?]
            at me.adventum.mines.PrisonMines.onCommand(PrisonMines.java:127) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[Spigot18.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
    Code
    Code:
    if (cmd.getName().equalsIgnoreCase("resetmine")) {
                Player p = (Player) sender;
                if (!(p.hasPermission(prisonMod))) {
                    p.sendMessage(noPerm);
                    return true;
                }
                if (args.length != 1) {
                    p.sendMessage(noArgs);
                    return true;
                }
                String mname = args[0];
                // Selection s;
                World w = Bukkit.getWorld((String) this.getConfig().get("mines." + mname + ".world"));
                Location min = new Location(Bukkit.getWorld((String) this.getConfig().get("mines." + mname + ".world")),
                        this.getConfig().getDouble("mines." + mname + ".min.X"),
                        this.getConfig().getDouble("mines." + mname + ".min.Y"),
                        this.getConfig().getDouble("mines." + mname + ".min.Z"));
                Location max = new Location(Bukkit.getWorld((String) this.getConfig().get("mines." + mname + ".world")),
                        this.getConfig().getDouble("mines." + mname + ".max.X"),
                        this.getConfig().getDouble("mines." + mname + ".max.Y"),
                        this.getConfig().getDouble("mines." + mname + ".max.Z"));
    
                CuboidSelection cs = new CuboidSelection(w, max, min);
                area.add(cs);
                for (CuboidSelection ss : area) {
                    CuboidRegion cr = new CuboidRegion(BukkitUtil.getLocalWorld(ss.getWorld()), ss.getNativeMinimumPoint(),
                            ss.getNativeMaximumPoint());
                    EditSession session = new EditSession(BukkitUtil.getLocalWorld(ss.getWorld()), cr.getArea());
                    try {
                        session.setBlocks(cr, new BaseBlock(0));
                    } catch (MaxChangedBlocksException e) {
                        e.printStackTrace();
                    }
                }
                return true;
            }
            return true;
        }
    Thanks for any help!
     
  2. Offline

    Caderape2

    @acdavis02
    Are you sure this is the good name for the world ?
    Use config.getString() method.
     
  3. Offline

    acdavis02

    Thank you! That was my issue!
     
Thread Status:
Not open for further replies.

Share This Page