@EventHandler public void onBlockBreak(BlockBreakEvent event) { if (event.isCancelled() || event.getPlayer() == null) { return; } Player player = event.getPlayer(); String name = player.getName().toLowerCase(); if (CitizensCommunicator.isNPC(player)) { return; } if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { return; } if (!data.isAuthAvailable(name)) { if (!settings.isForcedRegistrationEnabled()) { return; } } event.setCancelled(true); }
public class AuthMeBlockListener implements Listener { private final DataSource data; private Settings settings = Settings.getInstance(); public AuthMeBlockListener(final DataSource data) { this.data = data; } @EventHandler public void onBlockPlace(BlockPlaceEvent event) { if (event.isCancelled() || event.getPlayer() == null) { return; } Player player = event.getPlayer(); String name = player.getName().toLowerCase(); if (CitizensCommunicator.isNPC(player)) { return; } if (PlayerCache.getInstance().isAuthenticated(name)) { return; } if (!data.isAuthAvailable(name)) { if (!settings.isForcedRegistrationEnabled()) { return; } } event.setCancelled(true); } @EventHandler public void onBlockBreak(BlockBreakEvent event) { if (event.isCancelled() || event.getPlayer() == null) { return; } Player player = event.getPlayer(); String name = player.getName().toLowerCase(); if (CitizensCommunicator.isNPC(player)) { return; } if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { return; } if (!data.isAuthAvailable(name)) { if (!settings.isForcedRegistrationEnabled()) { return; } } event.setCancelled(true); } }