how do you tell if a PlayerInteractEvent is a BlockPlaceEvent?

Discussion in 'Plugin Development' started by d3x, Apr 18, 2011.

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

    d3x

    I am having troubles with people lag jumping on my server, they wait in protected areas until there is a little lag then build a pillar to get them up somewhere they could not normally get. Should be a easy fix I thought: in onBlockPlace check if it's against air and teleport them to the ground if it is. BUT onBlockPlace() and onBlockBreak() no don't fire when the block is being placed on air so they are out.
    onPlayerInteract() has no way to tell if the client was simply clicking the air with a block in their hand or actually sending the block place packets so that's also out. Do I need to get into CB or does some genius out there have an idea for a work around?

    https://gist.github.com/926019
     
  2. Well, assuming that the first block they place still triggers onBlockPlace(), you could try teleporting them back to ground level a second after they try to place a block in a protected area. If you make it cancel if a player moves about 2 blocks horizontally, it shouldn't affect legitimate players too much.
     
  3. Offline

    nisovin

    If they're taking advantage of the lag then this won't help anyway. Why would you think that your plugin would work through lag while the protection plugin you use doesn't?
     
  4. Offline

    d3x

    Yes it will. I didn't.

    I plan to teleport them to the ground when they place a block on air, just as the code in the gist suggests. If you can't even take the time to read a post don't both replying please.
     
  5. Offline

    nisovin

    Edit: Decided to remove my comment, because after some thought I think what you're trying to do could work. It still seems prone to similar lag-related problems to me though.
     
Thread Status:
Not open for further replies.

Share This Page