Thread.sleep, java error in console below.

Discussion in 'Spigot Plugin Development' started by GibFTW, May 28, 2016.

  1. Here is the error from console.
    Code (Text):
    [14:50:28 ERROR]: Could not load 'plugins\warnedshutodwn.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: permissions are of the wrong type
            at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1031) ~[spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:232) ~[spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:159) ~[spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.craftbukkit.v1_9_R2.CraftServer.loadPlugins(CraftServer.java:297) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.craftbukkit.v1_9_R2.CraftServer.reload(CraftServer.java:744) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.Bukkit.reload(Bukkit.java:539) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.craftbukkit.v1_9_R2.CraftServer.dispatchCommand(CraftServer.java:646) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at org.bukkit.craftbukkit.v1_9_R2.CraftServer.dispatchServerCommand(CraftServer.java:632) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at net.minecraft.server.v1_9_R2.DedicatedServer.aL(DedicatedServer.java:437) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at net.minecraft.server.v1_9_R2.DedicatedServer.D(DedicatedServer.java:400) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at net.minecraft.server.v1_9_R2.MinecraftServer.C(MinecraftServer.java:665) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at net.minecraft.server.v1_9_R2.MinecraftServer.run(MinecraftServer.java:564) [spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
    Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
            at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1029) ~[spigot-latest.jar:git-Spigot-8a048fe-a022dd2]
            ... 15 more
    And here is it's code.
    Code (Text):
    package org.gibftw.shutdown.warned;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    import me.confuser.barapi.BarAPI;

    public class Main extends JavaPlugin {
        @SuppressWarnings("deprecation")
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (command.getName().equalsIgnoreCase("wstop"))
               
            BarAPI.setMessage((Player) Bukkit.getOnlinePlayers(), "§c§lWarning: Sever shutting down..", 20);
            try {
                Thread.sleep(20000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "stop");
            return false;
        }

    }
     
  2. Using Thread#sleep will cause the server to freeze and crash.
    Use a scheduler instead.
     
    • Agree Agree x 2
  3. Seems like your plugin.yml is wrong. Show us that.
     
    • Agree Agree x 1
  4. Send your plugin.yml?

    ps. Thread.sleep will make the entire server's main thread sleep, use a runnable or create a new thread.
     
  5. Code (Text):
    main: org.gibftw.shutdown.warned
    name: WarnedShutdown
    depend: [BarAPI]
    author: GibFTW
    version: 0.1
    commands:
        wshutdown:
    permissions:
        shutdown.*
    Also how do you use a runnable? I'm new to java.
     
  6. Serializator

    Supporter

    You either forgot the colon or it's because you haven't added a description to the permission.
     
  7. Please learn the basics of Java before trying to use an API. You're only going to make mistakes ^^