- Renamed JsonCache to PlayerDataStorage

* the methods inside it renamed to fit with class name
  * cache folder changed into playerdata
- Renamed LimboPlayer to PlayerData
- Added fly speed to PlayerData
- Removed player's name from PlayerData object
- Added getPlayerLocationOrSpawn method in spawn loader.
This commit is contained in:
DNx5
2016-07-03 21:52:46 +07:00
parent 7ea0763966
commit deffcb3e2b
26 changed files with 554 additions and 220 deletions
@@ -2,7 +2,7 @@ package fr.xephi.authme.util;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.events.AbstractTeleportEvent;
import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
@@ -94,14 +94,14 @@ public class TeleportationService implements Reloadable {
*
* @param player the player
* @param auth corresponding PlayerAuth object
* @param limbo corresponding LimboPlayer object
* @param limbo corresponding PlayerData object
*/
public void teleportOnLogin(final Player player, PlayerAuth auth, LimboPlayer limbo) {
public void teleportOnLogin(final Player player, PlayerAuth auth, PlayerData limbo) {
if (settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
return;
}
// The world in LimboPlayer is from where the player comes, before any teleportation by AuthMe
// The world in PlayerData is from where the player comes, before any teleportation by AuthMe
String worldName = limbo.getLoc().getWorld().getName();
if (mustForceSpawnAfterLogin(worldName)) {
teleportToSpawn(player, true);
@@ -72,7 +72,16 @@ public final class Utils {
}
}
/**
* Get player's UUID if can, name otherwise.
*
* @param player Player to retrieve
*
* @return player's UUID or Name in String.
*/
public static String getUUIDorName(OfflinePlayer player) {
// We may made this configurable in future
// so we can have uuid support.
try {
return player.getUniqueId().toString();
} catch (Exception ignore) {
@@ -80,6 +89,13 @@ public final class Utils {
}
}
/**
* Compile Pattern sneaky without throwing Exception.
*
* @param pattern pattern string to compile
*
* @return the given regex compiled into Pattern object.
*/
public static Pattern safePatternCompile(String pattern) {
try {
return Pattern.compile(pattern);