Solved WorldGuard Error

Discussion in 'Plugin Help/Development/Requests' started by iClaw, Mar 22, 2015.

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

    iClaw

    I'm trying to code a skyblock kind of plugin but i get this error in my console:
    Code:
    [19:40:40] [Server thread/ERROR]: Could not load 'plugins\SkyFactory.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/sk89q/worldguard/protection/databases/ProtectionDatabaseException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins(CraftServer.java:288) [craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.<init>(CraftServer.java:250) [craftbukkit.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.PlayerList.<init>(PlayerList.java:69) [craftbukkit.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:133) [craftbukkit.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:484) [craftbukkit.jar:git-Bukkit-33d5de3]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0]
    Caused by: java.lang.NoClassDefFoundError: com/sk89q/worldguard/protection/databases/ProtectionDatabaseException
        at java.lang.Class.forName0(Native Method) ~[?:1.7.0]
        at java.lang.Class.forName(Unknown Source) ~[?:1.7.0]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:40) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        ... 9 more
    Caused by: java.lang.ClassNotFoundException: com.sk89q.worldguard.protection.databases.ProtectionDatabaseException
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:77) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0]
        at java.lang.Class.forName0(Native Method) ~[?:1.7.0]
        at java.lang.Class.forName(Unknown Source) ~[?:1.7.0]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:40) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[craftbukkit.jar:git-Bukkit-33d5de3]
        ... 9 more
    [19:40:40] [Server thread/INFO]: [MultiWorld] Loading MultiWorld v5.2.6
    And this is my class:
    Code:
    package com.skyfactory;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.sk89q.worldguard.bukkit.BukkitUtil;
    import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
    import com.sk89q.worldguard.domains.DefaultDomain;
    import com.sk89q.worldguard.protection.managers.RegionManager;
    import com.sk89q.worldguard.protection.managers.storage.StorageException;
    import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
    
    public class Main extends JavaPlugin implements Listener{
        FileConfiguration c = getConfig();
        @Override
        public void onEnable(){
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            if(c.get("nextisland-x") == null){
                c.set("nextisland-x", 400);
                c.set("nextisland-z", 400);
                c.set("nextisland-region-name", "island");
            }
            saveConfig();
        }
        @Override
        public void onDisable() {
          saveConfig();
          saveRegions((World) Bukkit.getWorlds());
          saveDefaultConfig();
        }
        private static WorldGuardPlugin getWorldGuard() {
            Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
            if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
                return null;
            }
        
            return (WorldGuardPlugin) plugin;
        }
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player p = (Player)sender;
            if(cmd.getName().equalsIgnoreCase("island")){
                if(c.getBoolean(p.getName() + ".hasisland") == true){
                    World world = Bukkit.getWorld("thornmc");
                    if(world == null){
                        return true;
                    }
                    if(c.get(p.getName() + ".home.x") == null){
                        int x = c.getInt(p.getName() + ".start-x");
                        int y = c.getInt(p.getName() + ".start-y");
                        int z = c.getInt(p.getName() + ".start-z");
                        p.teleport(new Location(world, x, y, z));
                        p.sendMessage("§bSkyFactory > §7Teleported to your island.");
                        return true;
                    }else{
                        int x = c.getInt(p.getName() + ".home-x");
                        int y = c.getInt(p.getName() + ".home-y");
                        int z = c.getInt(p.getName() + ".home-z");
                        p.teleport(new Location(world, x, y, z));
                        p.sendMessage("§bSkyFactory > §7Teleported to your island.");
                    }
                    return true;
                }else{
                    World world = Bukkit.getWorld("thornmc");
                    if(world == null){
                        return true;
                    }
                    int nextislandX = c.getInt("nextisland-x");
                    int nextislandZ = c.getInt("nextisland-z");
                    Block block = world.getBlockAt(nextislandX, 120, nextislandZ);
                    Block block2 = world.getBlockAt(nextislandX, 119, nextislandZ);
                    block2.setType(Material.BEDROCK);
                    block.setType(Material.GRASS);
                    Block b1 = world.getBlockAt(nextislandX, 121, nextislandZ);
                    Block b2 = world.getBlockAt(nextislandX, 122, nextislandZ);
                    Block b3 = world.getBlockAt(nextislandX, 123, nextislandZ);
                    Block b4 = world.getBlockAt(nextislandX, 124, nextislandZ);
                    Block b5 = world.getBlockAt(nextislandX, 125, nextislandZ);
                    Block bb = world.getBlockAt(nextislandX, 127, nextislandZ);
                    Block bb1 = world.getBlockAt(nextislandX, 126, nextislandZ);
                    Block b6 = world.getBlockAt(nextislandX + 1, 125, nextislandZ);
                    Block b7 = world.getBlockAt(nextislandX - 1, 125, nextislandZ);
                    Block b8 = world.getBlockAt(nextislandX, 125, nextislandZ + 1);
                    Block b9 = world.getBlockAt(nextislandX, 125, nextislandZ - 1);
                    Block b10 = world.getBlockAt(nextislandX + 1, 125, nextislandZ + 1);
                    Block b11 = world.getBlockAt(nextislandX - 1, 125, nextislandZ - 1);
                    Block b12 = world.getBlockAt(nextislandX + 1, 125, nextislandZ - 1);
                    Block b13 = world.getBlockAt(nextislandX - 1, 125, nextislandZ + 1);
                    Block b14 = world.getBlockAt(nextislandX + 1, 126, nextislandZ);
                    Block b15 = world.getBlockAt(nextislandX - 1, 126, nextislandZ);
                    Block b16 = world.getBlockAt(nextislandX, 126, nextislandZ + 1);
                    Block b17 = world.getBlockAt(nextislandX, 126, nextislandZ - 1);
                    Block b22 = world.getBlockAt(nextislandX + 1, 124, nextislandZ);
                    Block b23 = world.getBlockAt(nextislandX - 1, 124, nextislandZ);
                    Block b24 = world.getBlockAt(nextislandX, 124, nextislandZ + 1);
                    Block b25 = world.getBlockAt(nextislandX, 124, nextislandZ - 1);
                    Block b26 = world.getBlockAt(nextislandX + 1, 124, nextislandZ + 1);
                    Block b27 = world.getBlockAt(nextislandX - 1, 124, nextislandZ - 1);
                    Block b28 = world.getBlockAt(nextislandX + 1, 124, nextislandZ - 1);
                    Block b29 = world.getBlockAt(nextislandX - 1, 124, nextislandZ + 1);
                    b1.setType(Material.LOG);
                    b2.setType(Material.LOG);
                    b3.setType(Material.LOG);
                    b4.setType(Material.LOG);
                    b5.setType(Material.LOG);
                    b6.setType(Material.LEAVES);
                    b7.setType(Material.LEAVES);
                    b8.setType(Material.LEAVES);
                    b9.setType(Material.LEAVES);
                    b10.setType(Material.LEAVES);
                    b11.setType(Material.LEAVES);
                    b12.setType(Material.LEAVES);
                    b13.setType(Material.LEAVES);
                    b14.setType(Material.LEAVES);
                    b15.setType(Material.LEAVES);
                    b16.setType(Material.LEAVES);
                    b17.setType(Material.LEAVES);
                    b22.setType(Material.LEAVES);
                    b23.setType(Material.LEAVES);
                    b24.setType(Material.LEAVES);
                    b25.setType(Material.LEAVES);
                    b26.setType(Material.LEAVES);
                    b27.setType(Material.LEAVES);
                    b28.setType(Material.LEAVES);
                    b29.setType(Material.LEAVES);
                    bb.setType(Material.LEAVES);
                    bb1.setType(Material.LEAVES);
                    c.set(p.getName() + ".hasisland", true);
                    c.set(p.getName() + ".start-x", nextislandX);
                    c.set(p.getName() + ".start-y", 128);
                    c.set(p.getName() + ".start-z", nextislandZ);
                    p.teleport(new Location(world, nextislandX, 128, nextislandZ));
                    ItemStack hoe = new ItemStack(Material.WOOD_HOE);
                    p.getInventory().clear();
                    p.getInventory().addItem(hoe);
                    p.sendMessage("§bSkyFactory > §7Island created.");
                    p.sendMessage("§bSkyFactory > §7Use your hoe for a higher change of dropping saplings when breaking leaves.");
                    p.sendMessage("§bSkyFactory > §7Invite your friends by typing §e/invite <player>");
                    p.sendMessage("§bSkyFactory > §7Donate at §ebuy.thornmc.net §7to get more perks!");
                    if(p.hasPermission("use.plus")){
                        DefaultDomain owners = new DefaultDomain();
                        c.set("nextisland-x", c.getInt("nextisland-x") + 275);
                        c.set("nextisland-z", c.getInt("nextisland-z") + 275);
                        int regminX = c.getInt("nextisland-x") - 135;
                        int regmaxX = c.getInt("nextisland-x") + 135;
                        int regminZ = c.getInt("nextisland-z") - 135;
                        int regmaxZ = c.getInt("nextisland-z") + 135;
                        Location l1 = new Location(world, regminX, 120, regmaxX);
                        Location l2 = new Location(world, regminZ, 120, regmaxZ);
                        Block minX = Bukkit.getWorld("thornmc").getBlockAt(l1);
                        Block maxY = Bukkit.getWorld("thornmc").getBlockAt(l2);
                        com.sk89q.worldedit.BlockVector minpoint = BukkitUtil.toVector(minX).toBlockVector();
                        com.sk89q.worldedit.BlockVector maxpoint = BukkitUtil.toVector(maxY).toBlockVector();
                        ProtectedCuboidRegion region = new ProtectedCuboidRegion(c.getString("nextisland-region-name"), minpoint, maxpoint);
                        getWorldGuard().getRegionManager(p.getWorld()).addRegion(region);
                        owners.addPlayer(getWorldGuard().wrapPlayer(p));
                         region.setOwners(owners);
                        saveRegions(world);
                        c.set("nextisland-region-name", "island1" + 1);
                        return true;
                    }else{
                        DefaultDomain owners = new DefaultDomain();
                        c.set("nextisland-x", c.getInt("nextisland-x") + 275);
                        c.set("nextisland-z", c.getInt("nextisland-z") + 275);
                        int regminX = c.getInt("nextisland-x") - 80;
                        int regmaxX = c.getInt("nextisland-x") + 80;
                        int regminZ = c.getInt("nextisland-z") - 80;
                        int regmaxZ = c.getInt("nextisland-z") + 80;
                        Location l1 = new Location(world, regminX, 120, regmaxX);
                        Location l2 = new Location(world, regminZ, 120, regmaxZ);
                        Block minX = Bukkit.getWorld("thornmc").getBlockAt(l1);
                        Block maxY = Bukkit.getWorld("thornmc").getBlockAt(l2);
                        com.sk89q.worldedit.BlockVector minpoint = BukkitUtil.toVector(minX).toBlockVector();
                        com.sk89q.worldedit.BlockVector maxpoint = BukkitUtil.toVector(maxY).toBlockVector();
                        ProtectedCuboidRegion region = new ProtectedCuboidRegion(c.getString("nextisland-region-name"), minpoint, maxpoint);
                        getWorldGuard().getRegionManager(p.getWorld()).addRegion(region);
                        owners.addPlayer(getWorldGuard().wrapPlayer(p));
                         region.setOwners(owners);
                        saveRegions(world);
                        c.set("nextisland-region-name", "island1" + 1);
                        return true;
                    }
                   
                }
            }
            return true;
        }
        public static void saveRegions(World world){
        RegionManager regionManager = getWorldGuard().getRegionManager(world);
            try {
                regionManager.save();
            } catch (StorageException e) {
                e.printStackTrace();
            }
        }
    }
    
     
  2. Offline

    mine-care

    @iClaw check before casting (see my signature). On disable you cast World to a array of worlds,
    Is the compile version (of worldguard) the same as the one on the server? Have you put a dependency in Plugin.yml?
     
  3. Offline

    iClaw

Thread Status:
Not open for further replies.

Share This Page