Not suppose to build in chunk

Discussion in 'Plugin Development' started by immensebuttpain, Feb 3, 2014.

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

    immensebuttpain

    This is the code:
    Code:java
    1. @EventHandler(priority = EventPriority.LOW)
    2. public void onBlockPlace(BlockPlaceEvent evt) {
    3. CacheEvent cacheEvent = sC.getCacheEvent();
    4. if (cacheEvent == null || !cacheEvent.isActive()) {
    5. return;
    6. }
    7. Chunk eventChunk = cacheEvent.getEventChunk();
    8. Chunk chunk = evt.getBlock().getChunk();
    9. if (chunk == eventChunk) {
    10. evt.setCancelled(true);
    11. evt.getPlayer().sendMessage(String.format(StarCache.chatFormat, "You cannot place blocks in the StarCache's chunk."));
    12. }
    13. }

    You're not suppose to be able to build in the chunk of the starcache but you can, not sure what the issue is.
    This works:
    Code:java
    1. @EventHandler(priority = EventPriority.LOW)
    2. public void onBlockBreak(BlockBreakEvent evt) {
    3. CacheEvent cacheEvent = sC.getCacheEvent();
    4. if (cacheEvent == null || !cacheEvent.isActive()) {
    5. return;
    6. }
    7. Block evtBlock = evt.getBlock();
    8. if (evtBlock.equals(cacheEvent.getStarCache())) {
    9. evt.setCancelled(true);
    10. evt.getPlayer().sendMessage(String.format(StarCache.chatFormat, "You cannot break the StarCache."));
    11. }
    12. }

    That makes it so you can't break the chest it's self.
    Can someone please help asap?
    The chunkevent works because the chest spawns in the correct chunk.
     
Thread Status:
Not open for further replies.

Share This Page