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