1111import de .minebench .syncinv .listeners .PlayerConnectionValidateLoginListener ;
1212import de .minebench .syncinv .listeners .PlayerFreezeListener ;
1313import de .minebench .syncinv .listeners .PlayerJoinListener ;
14- import de .minebench .syncinv .listeners .PlayerLoginListener ;
1514import de .minebench .syncinv .listeners .PlayerQuitListener ;
15+ import de .minebench .syncinv .listeners .PlayerLoginListener ;
1616import de .minebench .syncinv .messenger .Message ;
1717import de .minebench .syncinv .messenger .MessageType ;
1818import de .minebench .syncinv .messenger .PlayerDataQuery ;
5050import java .lang .reflect .Field ;
5151import java .lang .reflect .InvocationTargetException ;
5252import java .lang .reflect .Method ;
53- import java .nio .charset .StandardCharsets ;
5453import java .nio .file .Files ;
5554import java .util .AbstractMap ;
5655import java .util .Date ;
@@ -177,8 +176,8 @@ public void onEnable() {
177176 loadConfig ();
178177
179178 playerDataFolder = getServer ().getMinecraftVersion ().startsWith ("1." )
180- ? new File (getServer ().getWorlds ().get ( 0 ).getWorldFolder (), "playerdata" )
181- : new File (new File (getServer ().getWorlds ().get ( 0 ).getWorldFolder (), "players" ), "data" );
179+ ? new File (getServer ().getWorlds ().getFirst ( ).getWorldFolder (), "playerdata" )
180+ : new File (new File (getServer ().getWorlds ().getFirst ( ).getWorldFolder (), "players" ), "data" );
182181
183182 MethodHandle tempUUIDGetterHandle = null ;
184183 try {
@@ -410,7 +409,7 @@ && getConfig().contains("sync-" + syncType.getKey(), true)) {
410409 }
411410
412411 if (getServer ().getMap ((short ) 0 ) == null ) {
413- getServer ().createMap (getServer ().getWorlds ().get ( 0 ));
412+ getServer ().createMap (getServer ().getWorlds ().getFirst ( ));
414413 }
415414 try {
416415 MapView map = null ;
@@ -483,10 +482,10 @@ public boolean isLocked(UUID playerId) {
483482
484483 /**
485484 * Get the date when a player last logged out
486- * @param playerId The UUID of the player
487- * @param online Whether or not it should return the current time if the player is online
488- * @return The timestamp of his last known data on the server in milliseconds;
489- * 0 if the file doesn't exist or an error occurs. (Take a look at {File#lastModified})
485+ * @param playerId The UUID of the player
486+ * @param online Whether or not it should return the current time if the player is online
487+ * @return The timestamp of his last known data on the server in milliseconds;
488+ * 0 if the file doesn't exist or an error occurs. (Take a look at {File#lastModified})
490489 */
491490 public long getLastSeen (UUID playerId , boolean online ) {
492491 if (online ) {
@@ -536,7 +535,7 @@ public boolean setLastSeen(UUID playerId, long timeStamp) {
536535 }
537536 // Workaround for systems that don't allow modifying the dat directly
538537 try {
539- Files .write (lastSeen .toPath (), String .valueOf (timeStamp ). getBytes ( StandardCharsets . UTF_8 ));
538+ Files .writeString (lastSeen .toPath (), String .valueOf (timeStamp ));
540539 return true ;
541540 } catch (IOException e ) {
542541 getLogger ().log (Level .SEVERE , "Unable to store lastseen file for " + playerId , e );
@@ -585,7 +584,7 @@ public void connectToServer(UUID playerId, String server) {
585584
586585 /**
587586 * Apply a PlayerData object to its player
588- * @param data The data to apply
587+ * @param data The data to apply
589588 */
590589 public void applyData (PlayerData data , Runnable finished ) {
591590 if (data == null )
@@ -929,27 +928,32 @@ private void forceRender(MapView map) {
929928 map .addRenderer (new EmptyRenderer ());
930929 }
931930
931+ /**
932+ * @return Reference to the OpenInv plugin to load data for the query option
933+ */
932934 public OpenInv getOpenInv () {
933- return this . openInv ;
935+ return openInv ;
934936 }
935937
938+ /**
939+ * @return The messenger for communications between the servers
940+ */
936941 public ServerMessenger getMessenger () {
937- return this . messenger ;
942+ return messenger ;
938943 }
939944
945+ /**
946+ * @return The amount of seconds we should wait for a query to stopTimeout
947+ */
940948 public int getQueryTimeout () {
941- return this . queryTimeout ;
949+ return queryTimeout ;
942950 }
943951
952+ /**
953+ * @return The id of the newest map that was seen on this server
954+ */
944955 public int getNewestMap () {
945- return this .newestMap ;
946- }
947-
948- private static class EmptyRenderer extends MapRenderer {
949- @ Override
950- public void render (@ NotNull MapView map , @ NotNull MapCanvas canvas , @ NotNull Player player ) {
951-
952- }
956+ return newestMap ;
953957 }
954958
955959 private void cacheData (PlayerData data , Runnable finished ) {
@@ -958,7 +962,7 @@ private void cacheData(PlayerData data, Runnable finished) {
958962
959963 /**
960964 * Get data that was cached which should be applied on a player's login
961- * @param player The player to get the data for
965+ * @param player The player to get the data for
962966 * @return A cache entry containing the PlayerData and the notification Runnable when applied successfully
963967 */
964968 public Map .Entry <PlayerData , Runnable > getCachedData (Player player ) {
@@ -967,7 +971,7 @@ public Map.Entry<PlayerData, Runnable> getCachedData(Player player) {
967971
968972 /**
969973 * Remove the cached data of a player
970- * @param player The player to remove the data for
974+ * @param player The player to remove the data for
971975 */
972976 public void removeCachedData (Player player ) {
973977 playerDataCache .invalidate (player .getUniqueId ());
@@ -1124,7 +1128,7 @@ public PlayerData getData(Player player) {
11241128
11251129 /**
11261130 * The sound to play when a player gets unlocked, should match the vanilla levelup
1127- * @param playerId The uuid of the Player to play the sound to
1131+ * @param playerId The uuid of the Player to play the sound to
11281132 */
11291133 public void playLoadSound (UUID playerId ) {
11301134 Player player = getServer ().getPlayer (playerId );
@@ -1135,7 +1139,7 @@ public void playLoadSound(UUID playerId) {
11351139
11361140 /**
11371141 * The sound to play when a player gets unlocked, should match the vanilla levelup
1138- * @param player The Player to play the sound to
1142+ * @param player The Player to play the sound to
11391143 */
11401144 public void playLoadSound (Player player ) {
11411145 player .playSound (player .getLocation (), Sound .ENTITY_PLAYER_LEVELUP , 0.7f , 1 );
@@ -1150,7 +1154,7 @@ public void checkMap(int id) {
11501154 logDebug ("Checking map " + id );
11511155 try {
11521156 while (getServer ().getMap (id ) == null ) {
1153- MapView map = getServer ().createMap (getServer ().getWorlds ().get ( 0 ));
1157+ MapView map = getServer ().createMap (getServer ().getWorlds ().getFirst ( ));
11541158 logDebug ("Created map " + map .getId ());
11551159 }
11561160 } catch (Exception e ) {
@@ -1235,4 +1239,10 @@ private enum FilterMode {
12351239 DENY ,
12361240 ALLOW
12371241 }
1242+
1243+ private static class EmptyRenderer extends MapRenderer {
1244+ @ Override
1245+ public void render (@ NotNull MapView map , @ NotNull MapCanvas canvas , @ NotNull Player player ) {
1246+ }
1247+ }
12381248}
0 commit comments