mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-14 22:35:54 +01:00
Merge pull request #52 from games647/performance
[WIP] Improve performance by correct order of some checks. (i.e. check if t…
This commit is contained in:
commit
4324a1a89a
@ -175,15 +175,18 @@ public class Utils {
|
|||||||
if (player == null || Utils.isUnrestricted(player)) {
|
if (player == null || Utils.isUnrestricted(player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plugin.database.isAuthAvailable(name)) {
|
|
||||||
if (!Settings.isForcedRegistrationEnabled) {
|
if (!Settings.isForcedRegistrationEnabled) {
|
||||||
|
if (!plugin.database.isAuthAvailable(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -66,9 +65,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
if (Utils.checkAuth(event.getPlayer()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
if (msg.equalsIgnoreCase("/worldedit cui"))
|
if (msg.equalsIgnoreCase("/worldedit cui"))
|
||||||
return;
|
return;
|
||||||
@ -81,8 +77,10 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (Settings.allowCommands.contains(cmd))
|
if (Settings.allowCommands.contains(cmd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setMessage("/notloggedin");
|
if (!Utils.checkAuth(event.getPlayer())) {
|
||||||
event.setCancelled(true);
|
event.setMessage("/notloggedin");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
@ -246,48 +244,34 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED)
|
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Settings.countriesBlacklist.isEmpty()) {
|
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable
|
||||||
|
&& !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
||||||
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
||||||
if (((code == null) || (Settings.countriesBlacklist.contains(code) && !isAuthAvailable)) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
|
||||||
event.setKickMessage(m.send("country_banned")[0]);
|
event.setKickMessage(m.send("country_banned")[0]);
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.enableProtection && !Settings.countries.isEmpty()) {
|
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable
|
||||||
|
&& !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
||||||
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
||||||
if (((code == null) || (!Settings.countries.contains(code) && !isAuthAvailable)) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
if (((code == null) || !Settings.countries.contains(code))) {
|
||||||
event.setKickMessage(m.send("country_banned")[0]);
|
event.setKickMessage(m.send("country_banned")[0]);
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.isKickNonRegisteredEnabled && !Settings.antiBotInAction) {
|
|
||||||
if (!isAuthAvailable) {
|
|
||||||
event.setKickMessage(m.send("reg_only")[0]);
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Add message to the messages file!!!
|
// TODO: Add message to the messages file!!!
|
||||||
if (Settings.antiBotInAction) {
|
if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) {
|
||||||
if (!isAuthAvailable) {
|
if (Settings.antiBotInAction) {
|
||||||
event.setKickMessage("AntiBot service in action! You actually need to be registered!");
|
event.setKickMessage("AntiBot service in action! You actually need to be registered!");
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
}
|
event.setKickMessage(m.send("reg_only")[0]);
|
||||||
|
|
||||||
if (isAuthAvailable && plugin.database.getType() != DataSource.DataSourceType.FILE) {
|
|
||||||
PlayerAuth auth = plugin.database.getAuth(name);
|
|
||||||
if (auth.getRealName() != null && !auth.getRealName().isEmpty()
|
|
||||||
&& !auth.getRealName().equalsIgnoreCase("Player") && !auth.getRealName().equalsIgnoreCase(name)) {
|
|
||||||
event.setKickMessage(m.send("same_nick")[0]);
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
if (Settings.banUnsafeIp)
|
|
||||||
plugin.getServer().banIP(player.getAddress().getAddress().getHostAddress());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,7 +356,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
|
|
||||||
plugin.management.performQuit(player, false);
|
plugin.management.performQuit(player, false);
|
||||||
|
|
||||||
if (plugin.database.isAuthAvailable(name) && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
|
if (!PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +414,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user