Inventory - Set hotbar

Discussion in 'Plugin Development' started by Machyy26, Jun 12, 2018.

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

    Machyy26

    Hello, I want to do a simple plugin on my own server. When somebody connects he get Nether star with world selector on slot 0. I want to set his slot when he join on 0.

    I have this:
    Code:
        public void onPlayerJoin(PlayerJoinEvent event) {
    
             event.getPlayer().getInventory().setHeldItemSlot(0);
             System.out.print("1.");
        }
    But it does not working. If i connect to the server im not getting any print in console... If i write "plugins" into console, my plugin is Green so thats mean it could work but not... What can I do please?
     
  2. Offline

    Zombie_Striker

    @Machyy26
    Are you registering the class as a Listener? Are you sure you have @EventHandler above the event?
     
  3. Offline

    Machyy26

    Thank you very much now it is working but only at my local server. On main server i have this error:

    Error (open)
    Code:
    [08:09:27] [Server thread/ERROR]: Could not load 'plugins/SwitchBar.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/pajda/SwitchBar/SwitchBar has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[minecraft_server.jar:git-Paper-1431]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[minecraft_server.jar:git-Paper-1431]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [minecraft_server.jar:git-Paper-1431]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:318) [minecraft_server.jar:git-Paper-1431]
        at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:226) [minecraft_server.jar:git-Paper-1431]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:616) [minecraft_server.jar:git-Paper-1431]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
    Caused by: java.lang.UnsupportedClassVersionError: me/pajda/SwitchBar/SwitchBar has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_151]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:1.8.0_151]
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_151]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:152) ~[minecraft_server.jar:git-Paper-1431]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:104) ~[minecraft_server.jar:git-Paper-1431]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_151]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_151]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_151]
        at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_151]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:82) ~[minecraft_server.jar:git-Paper-1431]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[minecraft_server.jar:git-Paper-1431]
        ... 6 more


    Where I can change the version of that or how can i fix it please. Thank you.

    // Ok i found this
    Code:
    Java SE 10 = 54,
    Java SE 9 = 53,
    Java SE 8 = 52,
    Java SE 7 = 51,
    Java SE 6.0 = 50,
    Java SE 5.0 = 49,
    JDK 1.4 = 48,
    JDK 1.3 = 47,
    JDK 1.2 = 46,
    JDK 1.1 = 45
    and i Change that. Now it is working thank you very much Zombie_Striker.
     
    Last edited: Jun 12, 2018
  4. Code:
        public void onPlayerJoin(PlayerJoinEvent event) {
    
             event.getPlayer().getInventory().setHeldItemSlot(0);
             System.out.print("1.");
        }
    The code above should work, the error should not be here.
    Do you use the novelties of java 10 as "var test =" test ""?

    Or try to update java in the main server.
     
  5. Offline

    Artellet

    Update your servers Java version.
     
Thread Status:
Not open for further replies.

Share This Page