mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 11:15:19 +01:00
Removed some unnecessary player check.
This commit is contained in:
parent
d692530035
commit
e387a801f7
@ -54,7 +54,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if(Utils.checkAuth(player)) {
|
||||
if (Utils.checkAuth(player)) {
|
||||
for (Player p : Utils.getOnlinePlayers()) {
|
||||
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
|
||||
event.getRecipients().remove(p); // TODO: it should be configurable
|
||||
@ -206,32 +206,26 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
final String name = event.getName().toLowerCase();
|
||||
final Player player = Utils.getPlayer(name);
|
||||
if (player == null || Utils.isNPC(player)) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if forceSingleSession is set to true, so kick player that has
|
||||
// joined with same nick of online player
|
||||
if (Settings.isForceSingleSessionEnabled && player.isOnline()) {
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, m.getString("same_nick"));
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Settings.isForceSingleSessionEnabled) {
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||
event.setKickMessage(m.retrieveSingle(MessageKey.USERNAME_ALREADY_ONLINE_ERROR));
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null && PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
Utils.addNormal(player, limbo.getGroup());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if (event.getPlayer() == null) {
|
||||
if (event.getPlayer() == null || Utils.isUnrestricted(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -266,10 +260,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String name = player.getName().toLowerCase();
|
||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||
|
||||
@ -333,7 +323,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!Utils.checkAuth(player) && Settings.delayJoinLeaveMessages) {
|
||||
if (Settings.delayJoinLeaveMessages && !Utils.checkAuth(player)) {
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
|
||||
@ -346,7 +336,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!Settings.isForceSingleSessionEnabled) && (event.getReason().contains(m.getString("same_nick")))) {
|
||||
if ((!Settings.isForceSingleSessionEnabled)
|
||||
&& (event.getReason().equals(m.retrieveSingle(MessageKey.USERNAME_ALREADY_ONLINE_ERROR)))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -357,31 +348,34 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
if (Utils.checkAuth(event.getPlayer()))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || Utils.checkAuth(player))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
|
||||
if (Utils.checkAuth(event.getPlayer()))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
if (Utils.checkAuth(player))
|
||||
if (Utils.checkAuth(player)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
/*
|
||||
@ -389,7 +383,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
* real, cause no packet is send to server by client for the main inv
|
||||
*/
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.closeInventory();
|
||||
@ -414,46 +407,51 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (!(damager instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (Utils.checkAuth((Player) damager))
|
||||
if (Utils.checkAuth((Player) damager)) {
|
||||
return;
|
||||
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || Utils.checkAuth(player))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if (Utils.checkAuth(event.getPlayer()))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||
if (Utils.checkAuth(event.getPlayer()))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (Utils.checkAuth(event.getPlayer()))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || Utils.checkAuth(player))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
Location spawn = plugin.getSpawnLocation(player);
|
||||
if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) {
|
||||
@ -467,13 +465,14 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL))
|
||||
return;
|
||||
if (Utils.checkAuth(player))
|
||||
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
if (causeByAuthMe.containsKey(name)) {
|
||||
@ -485,17 +484,17 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onPlayerShear(PlayerShearEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || Utils.checkAuth(player))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || Utils.checkAuth(player))
|
||||
if (Utils.checkAuth(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user