#765 Replace Utils usages with TeleportService + misc householding

- Remove some legacy settings
- Move Utils "addNormal" method to AuthGroupHandler

(Reapplied changes from orphaned fe29089)
This commit is contained in:
ljacqu
2016-07-03 19:53:44 +02:00
parent 7ea0763966
commit 7788ad6230
13 changed files with 78 additions and 64 deletions
@@ -1,15 +1,10 @@
package fr.xephi.authme.util;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.regex.Pattern;
/**
@@ -17,41 +12,9 @@ import java.util.regex.Pattern;
*/
public final class Utils {
private static AuthMe plugin = AuthMe.getInstance();
private Utils() {
}
/**
* TODO: This method requires better explanation.
* <p>
* Set the normal group of a player.
*
* @param player The player.
* @param group The normal group.
*
* @return True on success, false on failure.
*/
public static boolean addNormal(Player player, String group) {
if (!Settings.isPermissionCheckEnabled) {
return false;
}
// Get the permissions manager, and make sure it's valid
PermissionsManager permsMan = plugin.getPermissionsManager();
if (permsMan == null) {
ConsoleLogger.showError("Failed to access permissions manager instance, aborting.");
return false;
}
// Remove old groups
permsMan.removeGroups(player, Arrays.asList(Settings.unRegisteredGroup,
Settings.getRegisteredGroup, Settings.getUnloggedinGroup));
// Add the normal group, return the result
return permsMan.addGroup(player, group);
}
@Deprecated
public static boolean isUnrestricted(Player player) {
// TODO ljacqu 20160602: Checking for Settings.isAllowRestrictedIp is wrong! Nothing in the config suggests
@@ -60,18 +23,6 @@ public final class Utils {
&& Settings.getUnrestrictedName.contains(player.getName().toLowerCase());
}
@Deprecated
public static void teleportToSpawn(Player player) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawn);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
player.teleport(tpEvent.getTo());
}
}
}
public static String getUUIDorName(OfflinePlayer player) {
try {
return player.getUniqueId().toString();