Crashes the server everytime

Discussion in 'Plugin Development' started by MooshViolet, Dec 26, 2015.

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

    MooshViolet

    This event crashes the server everytime.
    Basically this plugin stores xp in an xp bottle when a player crafts it with an empty bottle.
    When they right click the bottle, it gives them the xp back.
    here is the event:
    Code:
    @EventHandler
      public void onPlayerInteract(PlayerInteractEvent e)
      {
        Player p = e.getPlayer();
        if (e.getItem() == null) {
          return;
        }
        if ((p.getItemInHand().getType() != Material.EXP_BOTTLE) || (!p.getItemInHand().hasItemMeta()))
        {
          e.setCancelled(false);
          return;
        }
        if ((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK))
        {
          if ((((String)p.getItemInHand().getItemMeta().getLore().get(0)).contains("XP")) &&
            (p.getItemInHand().getType() == Material.EXP_BOTTLE))
          {
            e.setCancelled(true);
            String xpraw = (String)p.getItemInHand().getItemMeta().getLore().get(0);
            String xpstring = ChatColor.stripColor(xpraw).replace("XP:", "");
            int xp = Integer.parseInt(xpstring);
            int xpold = Exp.getTotExp(p);
            Exp.setTotExp(p, xp + xpold);
            p.setItemInHand(new ItemStack(Material.GLASS_BOTTLE));
            System.out.println(p.getName() + " succesfully used a custom Experience Bottle!");
            return;
          }
          return;
        }
      }
     
  2. Offline

    teej107

    @MooshViolet I fail to see how that could crash the server. Does it actually crash the server or does it just throw errors in the console?
     
  3. Offline

    MooshViolet

    Whenever i right click it, I am unable to perform commands. It does not completely crash, but commands do not work, however I can type in chat. Its very weird.
    Edit: @teej107 I looked at the console and I got the created message:
    Code:
    26.12 12:38:11 [Server] INFO MooshViolet succesfully crafted a custom Experience Bottle!
    Edit #2: So the server ended up crashing and this is what came up:
    Error Logs (open)

    [​IMG]
    26.12 12:39:23 [Server] INFO Stopping server 26.12 12:39:23 [Server] INFO Startup script './start.sh' does not exist! Stopping server. 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.ref.Reference$ReferenceHandler.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.lang.Object.wait(Object.java:503) 26.12 12:39:23 [Server] ERROR java.lang.Object.wait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 2 | Suspended: false | Native: false | State: WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Reference Handler 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.lang.ref.ReferenceQueue.remove(Unknown Source) 26.12 12:39:23 [Server] ERROR java.lang.ref.ReferenceQueue.remove(Unknown Source) 26.12 12:39:23 [Server] ERROR java.lang.Object.wait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 3 | Suspended: false | Native: false | State: WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Finalizer 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 5 | Suspended: false | Native: false | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Signal Dispatcher 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.util.TimerThread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.TimerThread.mainLoop(Unknown Source) 26.12 12:39:23 [Server] ERROR java.lang.Object.wait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 11 | Suspended: false | Native: false | State: TIMED_WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Snooper Timer 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.DedicatedServer$1.run(DedicatedServer.java:54) 26.12 12:39:23 [Server] ERROR java.lang.Thread.sleep(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 15 | Suspended: false | Native: false | State: TIMED_WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Server Infinisleeper 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) 26.12 12:39:23 [Server] ERROR java.util.concurrent.FutureTask.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:52) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:759) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PlayerInteractManager.interact(PlayerInteractManager.java:463) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:228) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) 26.12 12:39:23 [Server] ERROR java.lang.reflect.Method.invoke(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 26.12 12:39:23 [Server] ERROR nl.DJRenzo.Plugin.PListener.onPlayerInteract(PListener.java:50) 26.12 12:39:23 [Server] ERROR nl.DJRenzo.Plugin.Exp.setTotExp(Exp.java:52) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer.giveExp(CraftPlayer.java:772) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.EntityHuman.giveExp(EntityHuman.java:1480) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.EntityHuman.addScore(EntityHuman.java:460) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.EntityHuman.getScore(EntityHuman.java:452) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.DataWatcher.getInt(DataWatcher.java:69) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR Locked on:eek:rg.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) 26.12 12:39:23 [Server] ERROR Thread is waiting on monitor(s): 26.12 12:39:23 [Server] ERROR PID: 14 | Suspended: false | Native: false | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Server thread 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 16 | Suspended: false | Native: false | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: DestroyJavaVM 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.v1_8_R3.util.TerminalConsoleWriterThread.run(TerminalConsoleWriterThread.java:25) 26.12 12:39:23 [Server] ERROR com.mojang.util.QueueLogAppender.getNextLogEvent(QueueLogAppender.java:77) 26.12 12:39:23 [Server] ERROR java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.locks.LockSupport.park(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.misc.Unsafe.park(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 18 | Suspended: false | Native: false | State: WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Thread-4 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.DedicatedServer$2.run(DedicatedServer.java:81) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:2257) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:2269) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:2333) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLineSimple(ConsoleReader.java:3183) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2145) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:198) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:261) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.libs.jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:248) 26.12 12:39:23 [Server] ERROR java.io.BufferedInputStream.read(Unknown Source) 26.12 12:39:23 [Server] ERROR java.io.BufferedInputStream.fill(Unknown Source) 26.12 12:39:23 [Server] ERROR java.io.FileInputStream.read(Unknown Source) 26.12 12:39:23 [Server] ERROR java.io.FileInputStream.readBytes(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR Locked on:eek:rg.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:198) 26.12 12:39:23 [Server] ERROR Locked on:eek:rg.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:261) 26.12 12:39:23 [Server] ERROR Locked on:java.io.BufferedInputStream.read(Unknown Source) 26.12 12:39:23 [Server] ERROR Thread is waiting on monitor(s): 26.12 12:39:23 [Server] ERROR PID: 17 | Suspended: false | Native: true | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Server console handler 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR org.spigotmc.WatchdogThread.run(WatchdogThread.java:76) 26.12 12:39:23 [Server] ERROR sun.management.ThreadImpl.dumpAllThreads(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.management.ThreadImpl.dumpThreads0(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 20 | Suspended: false | Native: false | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Spigot Watchdog Thread 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.util.TimerThread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.TimerThread.mainLoop(Unknown Source) 26.12 12:39:23 [Server] ERROR java.lang.Object.wait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 21 | Suspended: false | Native: false | State: TIMED_WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Spigot Metrics Thread 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.Native.epollWait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 24 | Suspended: false | Native: true | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Netty Epoll Server IO #0 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.Native.epollWait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 25 | Suspended: false | Native: true | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Netty Epoll Server IO #1 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194) 26.12 12:39:23 [Server] ERROR io.netty.channel.epoll.Native.epollWait(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 26 | Suspended: false | Native: false | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Netty Epoll Server IO #2 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.locks.LockSupport.park(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.misc.Unsafe.park(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 39 | Suspended: false | Native: false | State: WAITING 26.12 12:39:23 [Server] ERROR Current Thread: Chunk I/O Executor Thread-1 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.locks.LockSupport.park(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.misc.Unsafe.park(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 40 | Suspended: false | Native: false | State: WAITING 26.12 12:39:23 [Server] ERROR Current Thread: pool-4-thread-1 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.FileIOThread.run(FileIOThread.java:28) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.FileIOThread.c(FileIOThread.java:52) 26.12 12:39:23 [Server] ERROR java.lang.Thread.sleep(Native Method) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 41 | Suspended: false | Native: false | State: TIMED_WAITING 26.12 12:39:23 [Server] ERROR Current Thread: File IO Thread 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR Entire Thread Dump: 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR java.lang.Thread.run(Unknown Source) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) 26.12 12:39:23 [Server] ERROR java.util.concurrent.FutureTask.run(Unknown Source) 26.12 12:39:23 [Server] ERROR java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:52) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:759) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.PlayerInteractManager.interact(PlayerInteractManager.java:463) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:228) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) 26.12 12:39:23 [Server] ERROR org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) 26.12 12:39:23 [Server] ERROR java.lang.reflect.Method.invoke(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 26.12 12:39:23 [Server] ERROR sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 26.12 12:39:23 [Server] ERROR nl.DJRenzo.Plugin.PListener.onPlayerInteract(PListener.java:50) 26.12 12:39:23 [Server] ERROR nl.DJRenzo.Plugin.Exp.setTotExp(Exp.java:52) 26.12 12:39:23 [Server] ERROR org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer.giveExp(CraftPlayer.java:772) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.EntityHuman.giveExp(EntityHuman.java:1480) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.EntityHuman.addScore(EntityHuman.java:460) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.EntityHuman.getScore(EntityHuman.java:452) 26.12 12:39:23 [Server] ERROR net.minecraft.server.v1_8_R3.DataWatcher.getInt(DataWatcher.java:69) 26.12 12:39:23 [Server] ERROR Stack: 26.12 12:39:23 [Server] ERROR PID: 14 | Suspended: false | Native: false | State: RUNNABLE 26.12 12:39:23 [Server] ERROR Current Thread: Server thread 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR Server thread dump (Look for plugins here before reporting to Spigot!): 26.12 12:39:23 [Server] ERROR ------------------------------ 26.12 12:39:23 [Server] ERROR Spigot version: git-Spigot-db6de12-d3e0b6f (MC: 1.8.8) 26.12 12:39:23 [Server] ERROR Be sure to include ALL relevant console errors and Minecraft crash reports 26.12 12:39:23 [Server] ERROR Please report this to http://www.spigotmc.org/ 26.12 12:39:23 [Server] ERROR The server has stopped responding!

    However, that is the only thing that comes up
     
  4. Offline

    Zombie_Striker

    @MooshViolet
    Do you reference any other method or class? Are you Messing around with files/reflection? Are you creating un-ending loops?
     
  5. Offline

    mcdorli

    1.: One line if's are useful
    Code:
    if (true)
        System.out.println("true");
    
    2.: java naming conventions
    3.: a tab should be out of 4 spaces
    4.: You have unnecessary "()"-s
    5.: Just use p.getItemInHand().getItemMeta().getLores().contains()
    6.: What if the item doesn't have a lore?
    7.: Why do you return at the end?
     
    Zombie_Striker likes this.
  6. Offline

    MooshViolet

    Here is updated code.
    I ran some debug messages.
    I got the message that the event was cancelled.
    However, after that, the server is still crashing.

    Here is the event:
    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
                if ((p.getItemInHand().getType() == Material.EXP_BOTTLE)&& (p.getItemInHand().hasItemMeta())) {
                    if ((e.getAction() == Action.RIGHT_CLICK_AIR)|| (e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
                       
                        if (((String) p.getItemInHand().getItemMeta().getLore().get(0)).contains("XP")&& (p.getItemInHand().getType() == Material.EXP_BOTTLE)) {
                            e.setCancelled(true);
                            p.sendMessage("The event was cancelled");
                            String xpraw = (String) p.getItemInHand().getItemMeta().getLore().get(0);
                            String xpstring = ChatColor.stripColor(xpraw).replace("XP:", "");
                            int xp = Integer.parseInt(xpstring);
                            int xpold = Exp.getTotExp(p);
                            Exp.setTotExp(p, xp + xpold);
                            p.sendMessage("You succesfully used a custom Experience Bottle!");
                    }
                }
            }
        }
    Here is the method I call setTotExp:
    Code:
      public static void setTotExp(Player player, int exp)
      {
        if (exp < 0) {
          throw new IllegalArgumentException("Experience may not be negative!");
        }
        player.setExp(0.0F);
        player.setLevel(0);
        player.setTotalExperience(0);
       
        int amount = exp;
        while (amount > 0) {
          int expToLevel = getExpAtLevel(player.getLevel());
          amount -= expToLevel;
          if (amount >= 0){
            player.giveExp(expToLevel);
          }else{
            amount += expToLevel;
            player.giveExp(amount);
            amount = 0;
          }
        }
      }
     
  7. Offline

    teej107

    @MooshViolet You do know there is a method to set the exp level of a player to right?

    EDIT: Add in debug statements. Also I'm sure there is a better way to accomplish what you want. What does the getExpAtLevel do?
     
  8. Offline

    MooshViolet

    I did add debug messages which was stated in the previous post
    The console says I am getting an error at these lines:
    Code:
    Exp.setTotExp(p, xp + xpold);
    and this one in the SetTotExp:
    Code:
    amount += expToLevel;
     
  9. Offline

    Xerox262

    What exactly is your goal with that last method? Is there a reason you can't do
    player.setExp(player.getExp() + amount);
     
  10. Offline

    MooshViolet

    Have you not experienced Bukkit's messed up experience system?
    Bukkit has a corrupt system in which the xp does not work.
    You can find multiple complaints
     
  11. Offline

    Xerox262

    Player#setExp(int); worked when I tried it, what part of it doesn't work for you?
     
  12. Offline

    MooshViolet

    off topic
    it is because i am manipulating experience because getTotalExperience does not work when dealing with enchanting

    The console says I am getting an error at these lines:
    Code:
    Exp.setTotExp(p, xp + xpold);
    and this one in the SetTotExp:
    Code:
    amount += expToLevel;
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  13. Offline

    Xerox262

    @MooshViolet Instead of setting amount to 0 why aren't you breaking at the bottom of the else in the while loop, also try printing the amount to see what it is at the end, odds are it never gets below 0 and that's why the loop doesn't end
     
Thread Status:
Not open for further replies.

Share This Page