- 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
@@ -19,8 +19,6 @@ public final class Settings {
public static boolean isPermissionCheckEnabled;
public static boolean isTeleportToSpawnEnabled;
public static boolean isAllowRestrictedIp;
public static boolean isSaveQuitLocationEnabled;
public static boolean protectInventoryBeforeLogInEnabled;
public static boolean isStopEnabled;
public static boolean reloadSupport;
public static boolean noTeleport;
@@ -45,8 +43,6 @@ public final class Settings {
isPermissionCheckEnabled = load(PluginSettings.ENABLE_PERMISSION_CHECK);
isTeleportToSpawnEnabled = load(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN);
isAllowRestrictedIp = load(RestrictionSettings.ENABLE_RESTRICTED_USERS);
isSaveQuitLocationEnabled = load(RestrictionSettings.SAVE_QUIT_LOCATION);
isRemoveSpeedEnabled = load(RestrictionSettings.REMOVE_SPEED);
getUnloggedinGroup = load(SecuritySettings.UNLOGGEDIN_GROUP);
getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
@@ -43,9 +43,9 @@ public class SpawnLoader implements Reloadable {
* Constructor.
*
* @param pluginFolder The AuthMe data folder
* @param settings The setting instance
* @param pluginHooks The plugin hooks instance
* @param dataSource The plugin auth database instance
* @param settings The setting instance
* @param pluginHooks The plugin hooks instance
* @param dataSource The plugin auth database instance
*/
@Inject
public SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
@@ -83,6 +83,7 @@ public class SpawnLoader implements Reloadable {
* Set the AuthMe spawn point.
*
* @param location The location to use
*
* @return True upon success, false otherwise
*/
public boolean setSpawn(Location location) {
@@ -102,6 +103,7 @@ public class SpawnLoader implements Reloadable {
* Set the AuthMe first spawn location.
*
* @param location The location to use
*
* @return True upon success, false otherwise
*/
public boolean setFirstSpawn(Location location) {
@@ -140,7 +142,9 @@ public class SpawnLoader implements Reloadable {
* depending on the spawn priority setting.
*
* @param player The player to retrieve the spawn point for
*
* @return The spawn location, or the default spawn location upon failure
*
* @see RestrictionSettings#SPAWN_PRIORITY
*/
public Location getSpawnLocation(Player player) {
@@ -187,8 +191,9 @@ public class SpawnLoader implements Reloadable {
/**
* Save the location under the given prefix.
*
* @param prefix The prefix to save the spawn under
* @param prefix The prefix to save the spawn under
* @param location The location to persist
*
* @return True upon success, false otherwise
*/
private boolean setLocation(String prefix, Location location) {
@@ -214,11 +219,26 @@ public class SpawnLoader implements Reloadable {
return false;
}
/**
* Return player's location if player is alive, or player's spawn location if dead.
*
* @param player player to retrieve
*
* @return location of the given player if alive, spawn location if dead.
*/
public Location getPlayerLocationOrSpawn(Player player) {
if (player.isOnline() && player.isDead()) {
return getSpawnLocation(player);
}
return player.getLocation();
}
/**
* Build a {@link Location} object from the given path in the file configuration.
*
* @param configuration The file configuration to read from
* @param pathPrefix The path to get the spawn point from
* @param pathPrefix The path to get the spawn point from
*
* @return Location corresponding to the values in the path
*/
private static Location getLocationFromConfiguration(FileConfiguration configuration, String pathPrefix) {
@@ -240,7 +260,8 @@ public class SpawnLoader implements Reloadable {
* under the given path.
*
* @param configuration The file configuration to use
* @param pathPrefix The path to verify
* @param pathPrefix The path to verify
*
* @return True if all spawn fields are present, false otherwise
*/
private static boolean containsAllSpawnFields(FileConfiguration configuration, String pathPrefix) {
@@ -257,7 +278,8 @@ public class SpawnLoader implements Reloadable {
* Retrieve a property as a float from the given file configuration.
*
* @param configuration The file configuration to use
* @param path The path of the property to retrieve
* @param path The path of the property to retrieve
*
* @return The float
*/
private static float getFloat(FileConfiguration configuration, String path) {