mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-27 11:07:36 +01:00
change Utils to static class.
This commit is contained in:
parent
e1893ce85b
commit
4e275eeb1d
@ -57,7 +57,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
private final Logger authmeLogger = Logger.getLogger("AuthMe");
|
private final Logger authmeLogger = Logger.getLogger("AuthMe");
|
||||||
public Management management;
|
public Management management;
|
||||||
public NewAPI api;
|
public NewAPI api;
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
public SendMailSSL mail;
|
public SendMailSSL mail;
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
private Messages m;
|
private Messages m;
|
||||||
@ -535,7 +534,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Save Player Data
|
// Save Player Data
|
||||||
public void savePlayer(Player player) {
|
public void savePlayer(Player player) {
|
||||||
if ((utils.isNPC(player)) || (Utils.getInstance().isUnrestricted(player))) {
|
if ((Utils.isNPC(player)) || (Utils.isUnrestricted(player))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
@ -552,7 +551,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
if (!Settings.noTeleport) {
|
if (!Settings.noTeleport) {
|
||||||
player.teleport(limbo.getLoc());
|
player.teleport(limbo.getLoc());
|
||||||
}
|
}
|
||||||
this.utils.addNormal(player, limbo.getGroup());
|
Utils.addNormal(player, limbo.getGroup());
|
||||||
player.setOp(limbo.getOperator());
|
player.setOp(limbo.getOperator());
|
||||||
limbo.getTimeoutTaskId().cancel();
|
limbo.getTimeoutTaskId().cancel();
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
|
@ -21,16 +21,12 @@ import java.util.Iterator;
|
|||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private static boolean getOnlinePlayersIsCollection;
|
private static boolean getOnlinePlayersIsCollection;
|
||||||
private String currentGroup;
|
|
||||||
private static Utils singleton;
|
private static Utils singleton;
|
||||||
private static Method getOnlinePlayers;
|
private static Method getOnlinePlayers;
|
||||||
public final AuthMe plugin;
|
public static AuthMe plugin;
|
||||||
|
|
||||||
public Utils(AuthMe plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
plugin = AuthMe.getInstance();
|
||||||
try {
|
try {
|
||||||
Method m = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
|
Method m = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
|
||||||
getOnlinePlayersIsCollection = m.getReturnType() == Collection.class;
|
getOnlinePlayersIsCollection = m.getReturnType() == Collection.class;
|
||||||
@ -38,17 +34,18 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroup(Player player, GroupType group) {
|
public static void setGroup(Player player, GroupType group) {
|
||||||
setGroup(player.getName(), group);
|
setGroup(player.getName(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void setGroup(String player, GroupType group) {
|
public static void setGroup(String player, GroupType group) {
|
||||||
if (!Settings.isPermissionCheckEnabled)
|
if (!Settings.isPermissionCheckEnabled)
|
||||||
return;
|
return;
|
||||||
if (plugin.permission == null)
|
if (plugin.permission == null)
|
||||||
return;
|
return;
|
||||||
String name = player;
|
String name = player;
|
||||||
|
String currentGroup;
|
||||||
try {
|
try {
|
||||||
World world = null;
|
World world = null;
|
||||||
currentGroup = plugin.permission.getPrimaryGroup(world, name);
|
currentGroup = plugin.permission.getPrimaryGroup(world, name);
|
||||||
@ -88,11 +85,10 @@ public class Utils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean addNormal(Player player, String group) {
|
public static boolean addNormal(Player player, String group) {
|
||||||
if (!useGroupSystem()) {
|
if (!useGroupSystem()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -123,20 +119,15 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnrestricted(Player player) {
|
public static boolean isUnrestricted(Player player) {
|
||||||
return Settings.isAllowRestrictedIp && !(Settings.getUnrestrictedName == null || Settings.getUnrestrictedName.isEmpty()) && (Settings.getUnrestrictedName.contains(player.getName()));
|
return Settings.isAllowRestrictedIp && !(Settings.getUnrestrictedName == null || Settings.getUnrestrictedName.isEmpty()) && (Settings.getUnrestrictedName.contains(player.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Utils getInstance() {
|
private static boolean useGroupSystem() {
|
||||||
singleton = new Utils(AuthMe.getInstance());
|
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean useGroupSystem() {
|
|
||||||
return Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty();
|
return Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packCoords(double x, double y, double z, String w,
|
public static void packCoords(double x, double y, double z, String w,
|
||||||
final Player pl) {
|
final Player pl) {
|
||||||
World theWorld;
|
World theWorld;
|
||||||
if (w.equals("unavailableworld")) {
|
if (w.equals("unavailableworld")) {
|
||||||
@ -216,7 +207,7 @@ public class Utils {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNPC(final Entity player) {
|
public static boolean isNPC(final Entity player) {
|
||||||
try {
|
try {
|
||||||
if (player.hasMetadata("NPC")) {
|
if (player.hasMetadata("NPC")) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,7 +19,6 @@ public class API {
|
|||||||
|
|
||||||
public static final String newline = System.getProperty("line.separator");
|
public static final String newline = System.getProperty("line.separator");
|
||||||
public static AuthMe instance;
|
public static AuthMe instance;
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public API(AuthMe instance) {
|
public API(AuthMe instance) {
|
||||||
@ -65,7 +64,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isaNPC(Player player) {
|
public boolean isaNPC(Player player) {
|
||||||
return utils.isNPC(player);
|
return Utils.isNPC(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +74,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isNPC(Player player) {
|
public boolean isNPC(Player player) {
|
||||||
return utils.isNPC(player);
|
return Utils.isNPC(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +84,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean isUnrestricted(Player player) {
|
public static boolean isUnrestricted(Player player) {
|
||||||
return Utils.getInstance().isUnrestricted(player);
|
return Utils.isUnrestricted(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -22,7 +22,6 @@ public class NewAPI {
|
|||||||
public static final String newline = System.getProperty("line.separator");
|
public static final String newline = System.getProperty("line.separator");
|
||||||
public static NewAPI singleton;
|
public static NewAPI singleton;
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
|
|
||||||
public NewAPI(AuthMe plugin) {
|
public NewAPI(AuthMe plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -68,7 +67,7 @@ public class NewAPI {
|
|||||||
* @return true if player is a npc
|
* @return true if player is a npc
|
||||||
*/
|
*/
|
||||||
public boolean isNPC(Player player) {
|
public boolean isNPC(Player player) {
|
||||||
return utils.isNPC(player);
|
return Utils.isNPC(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +76,7 @@ public class NewAPI {
|
|||||||
* @return true if the player is unrestricted
|
* @return true if the player is unrestricted
|
||||||
*/
|
*/
|
||||||
public boolean isUnrestricted(Player player) {
|
public boolean isUnrestricted(Player player) {
|
||||||
return Utils.getInstance().isUnrestricted(player);
|
return Utils.isUnrestricted(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLastLocation(Player player) {
|
public Location getLastLocation(Player player) {
|
||||||
|
@ -464,7 +464,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Player target = Bukkit.getPlayer(name);
|
Player target = Bukkit.getPlayer(name);
|
||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
Utils.getInstance().setGroup(name, GroupType.UNREGISTERED);
|
Utils.setGroup(name, GroupType.UNREGISTERED);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (target.isOnline()) {
|
if (target.isOnline()) {
|
||||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
|
@ -84,7 +84,7 @@ public class UnregisterCommand implements CommandExecutor {
|
|||||||
player.saveData();
|
player.saveData();
|
||||||
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
|
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
|
||||||
if (!Settings.getRegisteredGroup.isEmpty())
|
if (!Settings.getRegisteredGroup.isEmpty())
|
||||||
Utils.getInstance().setGroup(player, GroupType.UNREGISTERED);
|
Utils.setGroup(player, GroupType.UNREGISTERED);
|
||||||
LimboCache.getInstance().addLimboPlayer(player);
|
LimboCache.getInstance().addLimboPlayer(player);
|
||||||
int delay = Settings.getRegistrationTimeout * 20;
|
int delay = Settings.getRegistrationTimeout * 20;
|
||||||
int interval = Settings.getWarnMessageInterval;
|
int interval = Settings.getWarnMessageInterval;
|
||||||
@ -99,7 +99,7 @@ public class UnregisterCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Settings.unRegisteredGroup.isEmpty()) {
|
if (!Settings.unRegisteredGroup.isEmpty()) {
|
||||||
Utils.getInstance().setGroup(player, Utils.GroupType.UNREGISTERED);
|
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
|
||||||
}
|
}
|
||||||
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
|
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
|
||||||
// check if Player cache File Exist and delete it, preventing
|
// check if Player cache File Exist and delete it, preventing
|
||||||
|
@ -28,7 +28,7 @@ public class AuthMeBlockListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Utils.getInstance().isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class AuthMeBlockListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Utils.getInstance().isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class AuthMeChestShopListener implements Listener {
|
|||||||
Player player = event.getClient();
|
Player player = event.getClient();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Utils.getInstance().isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import org.bukkit.event.entity.*;
|
|||||||
public class AuthMeEntityListener implements Listener {
|
public class AuthMeEntityListener implements Listener {
|
||||||
|
|
||||||
public AuthMe instance;
|
public AuthMe instance;
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
|
|
||||||
public AuthMeEntityListener(AuthMe instance) {
|
public AuthMeEntityListener(AuthMe instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
@ -28,11 +27,11 @@ public class AuthMeEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.getInstance().isUnrestricted((Player) entity)) {
|
if (Utils.isUnrestricted((Player) entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(entity))
|
if (Utils.isNPC(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
@ -61,7 +60,7 @@ public class AuthMeEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(entity))
|
if (Utils.isNPC(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
@ -111,7 +110,7 @@ public class AuthMeEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(entity))
|
if (Utils.isNPC(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
@ -138,7 +137,7 @@ public class AuthMeEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(entity))
|
if (Utils.isNPC(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
@ -167,7 +166,7 @@ public class AuthMeEntityListener implements Listener {
|
|||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Utils.getInstance().isUnrestricted(player) || utils.isNPC(player))
|
if (Utils.isUnrestricted(player) || Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||||
@ -191,7 +190,7 @@ public class AuthMeEntityListener implements Listener {
|
|||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Utils.getInstance().isUnrestricted(player) || utils.isNPC(player))
|
if (Utils.isUnrestricted(player) || Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||||
|
@ -39,7 +39,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
private Messages m = Messages.getInstance();
|
private Messages m = Messages.getInstance();
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||||
private List<String> antibot = new ArrayList<>();
|
private List<String> antibot = new ArrayList<>();
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -89,7 +88,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -125,7 +124,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -161,7 +160,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -197,7 +196,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -233,7 +232,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
@ -270,7 +269,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player))
|
if (Utils.isUnrestricted(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -305,7 +304,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isNPC(player) || utils.isUnrestricted(player)) {
|
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +422,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||||
if (limbo != null && PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
if (limbo != null && PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||||
utils.addNormal(player, limbo.getGroup());
|
Utils.addNormal(player, limbo.getGroup());
|
||||||
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,7 +439,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||||
|
|
||||||
if (utils.isNPC(player) || utils.isUnrestricted(player)) {
|
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,11 +603,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(player))
|
if (Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
@ -632,11 +631,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(player))
|
if (Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||||
@ -663,11 +662,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(player)) {
|
if (Utils.isNPC(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,10 +689,10 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
final Player player = (Player) event.getPlayer();
|
final Player player = (Player) event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (utils.isNPC(player))
|
if (Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||||
return;
|
return;
|
||||||
@ -728,11 +727,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(player))
|
if (Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||||
@ -758,11 +757,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = (Player) damager;
|
Player player = (Player) damager;
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isNPC(player)) {
|
if (Utils.isNPC(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +785,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isNPC(player) || utils.isUnrestricted(player)) {
|
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +809,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player) || utils.isNPC(player))
|
if (Utils.isUnrestricted(player) || Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||||
@ -833,7 +832,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +855,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
if (utils.isUnrestricted(player)) {
|
if (Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
@ -879,7 +878,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player) || utils.isNPC(player))
|
if (Utils.isUnrestricted(player) || Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
@ -911,7 +910,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
|
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (utils.isUnrestricted(player) || utils.isNPC(player))
|
if (Utils.isUnrestricted(player) || Utils.isNPC(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
|
@ -38,7 +38,6 @@ public class AsyncronousJoin {
|
|||||||
protected DataSource database;
|
protected DataSource database;
|
||||||
protected AuthMe plugin;
|
protected AuthMe plugin;
|
||||||
protected String name;
|
protected String name;
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
private Messages m = Messages.getInstance();
|
private Messages m = Messages.getInstance();
|
||||||
private JsonCache playerBackup;
|
private JsonCache playerBackup;
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ public class AsyncronousJoin {
|
|||||||
AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
|
AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
|
||||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||||
|
|
||||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player)) {
|
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +162,7 @@ public class AsyncronousJoin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!Settings.unRegisteredGroup.isEmpty()) {
|
if (!Settings.unRegisteredGroup.isEmpty()) {
|
||||||
utils.setGroup(player, Utils.GroupType.UNREGISTERED);
|
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
|
||||||
}
|
}
|
||||||
if (!Settings.isForcedRegistrationEnabled) {
|
if (!Settings.isForcedRegistrationEnabled) {
|
||||||
return;
|
return;
|
||||||
@ -205,9 +204,9 @@ public class AsyncronousJoin {
|
|||||||
if (!LimboCache.getInstance().hasLimboPlayer(name))
|
if (!LimboCache.getInstance().hasLimboPlayer(name))
|
||||||
LimboCache.getInstance().addLimboPlayer(player);
|
LimboCache.getInstance().addLimboPlayer(player);
|
||||||
if (database.isAuthAvailable(name)) {
|
if (database.isAuthAvailable(name)) {
|
||||||
utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||||
} else {
|
} else {
|
||||||
utils.setGroup(player, GroupType.UNREGISTERED);
|
Utils.setGroup(player, GroupType.UNREGISTERED);
|
||||||
}
|
}
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void packQuitLocation() {
|
protected void packQuitLocation() {
|
||||||
Utils.getInstance().packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void teleportBackFromSpawn() {
|
protected void teleportBackFromSpawn() {
|
||||||
@ -166,7 +166,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
Utils.forceGM(player);
|
Utils.forceGM(player);
|
||||||
|
|
||||||
// Restore Permission Group
|
// Restore Permission Group
|
||||||
Utils.getInstance().setGroup(player, GroupType.LOGGEDIN);
|
Utils.setGroup(player, GroupType.LOGGEDIN);
|
||||||
|
|
||||||
// Cleanup no longer used temporary data
|
// Cleanup no longer used temporary data
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
|
@ -25,7 +25,6 @@ public class AsyncronousLogout {
|
|||||||
protected DataSource database;
|
protected DataSource database;
|
||||||
protected boolean canLogout = true;
|
protected boolean canLogout = true;
|
||||||
private Messages m = Messages.getInstance();
|
private Messages m = Messages.getInstance();
|
||||||
private Utils utils = Utils.getInstance();
|
|
||||||
private JsonCache playerBackup;
|
private JsonCache playerBackup;
|
||||||
|
|
||||||
public AsyncronousLogout(Player player, AuthMe plugin,
|
public AsyncronousLogout(Player player, AuthMe plugin,
|
||||||
@ -79,7 +78,7 @@ public class AsyncronousLogout {
|
|||||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
LimboCache.getInstance().addLimboPlayer(player);
|
LimboCache.getInstance().addLimboPlayer(player);
|
||||||
utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
// create cache file for handling lost of inventories on unlogged in
|
// create cache file for handling lost of inventories on unlogged in
|
||||||
|
@ -22,7 +22,6 @@ public class AsyncronousQuit {
|
|||||||
protected AuthMe plugin;
|
protected AuthMe plugin;
|
||||||
protected DataSource database;
|
protected DataSource database;
|
||||||
protected Player player;
|
protected Player player;
|
||||||
protected Utils utils = Utils.getInstance();
|
|
||||||
private String name;
|
private String name;
|
||||||
private ItemStack[] armor = null;
|
private ItemStack[] armor = null;
|
||||||
private ItemStack[] inv = null;
|
private ItemStack[] inv = null;
|
||||||
@ -43,7 +42,7 @@ public class AsyncronousQuit {
|
|||||||
public void process() {
|
public void process() {
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player)) {
|
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ public class AsyncronousQuit {
|
|||||||
armor = limbo.getArmour();
|
armor = limbo.getArmour();
|
||||||
}
|
}
|
||||||
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
|
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
|
||||||
utils.addNormal(player, limbo.getGroup());
|
Utils.addNormal(player, limbo.getGroup());
|
||||||
needToChange = true;
|
needToChange = true;
|
||||||
isOp = limbo.getOperator();
|
isOp = limbo.getOperator();
|
||||||
isFlying = limbo.isFlying();
|
isFlying = limbo.isFlying();
|
||||||
|
@ -31,7 +31,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
if (!Settings.getRegisteredGroup.isEmpty()) {
|
if (!Settings.getRegisteredGroup.isEmpty()) {
|
||||||
Utils.getInstance().setGroup(player, Utils.GroupType.REGISTERED);
|
Utils.setGroup(player, Utils.GroupType.REGISTERED);
|
||||||
}
|
}
|
||||||
m.send(player, "vb_nonActiv");
|
m.send(player, "vb_nonActiv");
|
||||||
int time = Settings.getRegistrationTimeout * 20;
|
int time = Settings.getRegistrationTimeout * 20;
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.Utils;
|
import fr.xephi.authme.Utils;
|
||||||
@ -21,6 +13,13 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
for (String command : Settings.forceRegisterCommands) {
|
for (String command : Settings.forceRegisterCommands) {
|
||||||
try {
|
try {
|
||||||
player.performCommand(command.replace("%p", player.getName()));
|
player.performCommand(command.replace("%p", player.getName()));
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String command : Settings.forceRegisterCommandsAsConsole) {
|
for (String command : Settings.forceRegisterCommandsAsConsole) {
|
||||||
@ -71,10 +70,8 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
}
|
}
|
||||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
try {
|
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||||
if (player.isInsideVehicle())
|
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
} catch (NullPointerException npe) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +105,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.getRegisteredGroup.isEmpty()) {
|
if (!Settings.getRegisteredGroup.isEmpty()) {
|
||||||
Utils.getInstance().setGroup(player, Utils.GroupType.REGISTERED);
|
Utils.setGroup(player, Utils.GroupType.REGISTERED);
|
||||||
}
|
}
|
||||||
m.send(player, "registered");
|
m.send(player, "registered");
|
||||||
if (!Settings.getmailAccount.isEmpty())
|
if (!Settings.getmailAccount.isEmpty())
|
||||||
|
Loading…
Reference in New Issue
Block a user