Fixed the ability to open containers of chunk loaders

This commit is contained in:
OmerBenGera 2020-09-19 15:44:16 +03:00
parent 4885ddc4f0
commit c43b83a491
1 changed files with 11 additions and 0 deletions

View File

@ -11,8 +11,10 @@ import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.Optional;
@ -82,4 +84,13 @@ public final class BlocksListener implements Listener {
plugin.getNMSAdapter().updateSpawner(e.getBlock().getLocation(), false);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onLoaderInteract(PlayerInteractEvent e){
if(e.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if(plugin.getLoaders().getChunkLoader(e.getClickedBlock().getLocation()).isPresent())
e.setCancelled(true);
}
}