Cleanup some listener code.

This commit is contained in:
DNx5 2015-11-26 03:37:55 +07:00
parent c83e983dea
commit 2162a4abe4
5 changed files with 17 additions and 19 deletions

View File

@ -20,7 +20,6 @@ public class AuthMeBlockListener implements Listener {
* @param instance AuthMe
*/
public AuthMeBlockListener(AuthMe instance) {
this.instance = instance;
}
@ -31,8 +30,9 @@ public class AuthMeBlockListener implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if (Utils.checkAuth(event.getPlayer()))
if (Utils.checkAuth(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -43,8 +43,7 @@ public class AuthMeBlockListener implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if (player == null || Utils.checkAuth(player)) {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
event.setCancelled(true);

View File

@ -183,12 +183,12 @@ public class AuthMeEntityListener implements Listener {
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile projectile = event.getEntity();
Player player = null;
if (projectile == null) {
if (event.getEntity() == null) {
return;
}
Player player = null;
Projectile projectile = event.getEntity();
if (shooterIsProjectileSource) {
ProjectileSource shooter = projectile.getShooter();
if (shooter == null || !(shooter instanceof Player)) {

View File

@ -93,12 +93,15 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage().split(" ")[0].toLowerCase();
if (Settings.useEssentialsMotd && cmd.equals("/motd"))
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
return;
if (Settings.allowCommands.contains(cmd))
}
if (Settings.allowCommands.contains(cmd)) {
return;
if (Utils.checkAuth(event.getPlayer()))
}
if (Utils.checkAuth(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -167,12 +170,8 @@ public class AuthMePlayerListener implements Listener {
*
* @param event PlayerMoveEvent
*/
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
if (event.isCancelled()) {
return;
}
if (Settings.isMovementAllowed && Settings.getMovementRadius <= 0) {
return;
}

View File

@ -30,9 +30,9 @@ public class AuthMePlayerListener16 implements Listener {
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerEditBook(PlayerEditBookEvent event) {
Player player = event.getPlayer();
if (player == null || Utils.checkAuth(player))
if (Utils.checkAuth(event.getPlayer())) {
return;
}
event.setCancelled(true);
}

View File

@ -30,9 +30,9 @@ public class AuthMePlayerListener18 implements Listener {
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Player player = event.getPlayer();
if (player == null || Utils.checkAuth(player))
if (Utils.checkAuth(event.getPlayer())) {
return;
}
event.setCancelled(true);
}