My plugin crashes clients and corrupts maps...why?

Discussion in 'Plugin Development' started by Lookatmego, Sep 14, 2011.

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


    This new plugin ive been working on basically does what the title is the main class:

    and the blocklistener:

    soo any idea?i dont know whats causing it i also have no idea what to do to stop it please help thanks

    (ps. the point of the plugin is to check if the random number chosen is 1-10 if it is any of those numbers it drops the designated food item if it is above 10 then drops air meaning drops nothing at all.....)
  2. Offline


    This is your issue:
    b.getWorld().dropItemNaturally(event.getBlock().getLocation(), new ItemStack(Material.AIR, 0));
    A stack of air is a null item and will cause a client to crash because it can't process an item that's trying to exist yet it doesn't.

    Edit: You can probably remove that line entirely. I also suggest that long chunk of if statements to contain else if rather than if so that it doesn't have to do all the work every time.

    By that I mean the line where it says:

    if (rand == 1)

    if (rand == 2)

    if (rand == 3)

    if (rand == 4)

    I suggest making it like this:

    if (rand == 1)

    else if (rand == 2)

    else if (rand ==3)

    else if (rand ==4)

  3. Offline


    hmm i thought that would cause a problem so how would i make it so if the random number is bigger than 10 it drops nothing??
  4. Offline


    Simply don't have a statement for a number bigger than 10. If it's bigger than 10, there will be nothing for it to do, therefore nothing will drop.
  5. Offline


    alright thanks dude!:D
  6. Offline


    No problem! :D
  7. Offline


    that or just use switch :p
  8. Offline


    That's what I was thinkin'

  9. Offline


    that is also what i was thinking :D
Thread Status:
Not open for further replies.

Share This Page