@@ -108,7 +108,7 @@ public final class SyncInv extends JavaPlugin {
108108 * Sync data with all servers in a group when a player logs out
109109 */
110110 private boolean syncWithGroupOnLogout ;
111-
111+
112112 /**
113113 * Store player data even if the player never joined the server
114114 */
@@ -147,7 +147,7 @@ public final class SyncInv extends JavaPlugin {
147147 */
148148 @ Getter
149149 private int newestMap = 0 ;
150-
150+
151151 // Unknown player storing
152152 private Method methodGetOfflinePlayer = null ;
153153 private Method methodGetHandle = null ;
@@ -160,12 +160,6 @@ public final class SyncInv extends JavaPlugin {
160160 // Offline player health setting
161161 private Method methodSetHealth ;
162162
163- // Persistent data syncing
164- private Method methodDeserializeCompound = null ;
165- private Method methodPdcSerialize = null ;
166- private Method methodGetRaw = null ;
167- private Method methodPutAll = null ;
168-
169163 // Map syncing
170164 private Field fieldWorldMap ;
171165 private Field fieldMapColor ;
@@ -177,7 +171,7 @@ public final class SyncInv extends JavaPlugin {
177171 public void onEnable () {
178172 // Plugin startup logic
179173 loadConfig ();
180-
174+
181175 playerDataFolder = new File (getServer ().getWorlds ().get (0 ).getWorldFolder (), "playerdata" );
182176 try {
183177 methodGetOfflinePlayer = getServer ().getClass ().getMethod ("getOfflinePlayer" , GameProfile .class );
@@ -296,7 +290,7 @@ public void loadConfig() {
296290 syncWithGroupOnLogout = getConfig ().getBoolean ("sync-with-group-on-logout" );
297291
298292 storeUnknownPlayers = getConfig ().getBoolean ("store-unknown-players" );
299-
293+
300294 queryTimeout = getConfig ().getInt ("query-timeout" );
301295 applyTimedOutQueries = getConfig ().getBoolean ("apply-timed-out-queries" );
302296
@@ -317,19 +311,6 @@ && getConfig().contains("sync-" + syncType.getKey(), true)) {
317311 getLogger ().log (Level .INFO , "Hooked into " + openInv .getName () + " " + openInv .getDescription ().getVersion ());
318312 }
319313
320- if (shouldSync (SyncType .PERSISTENT_DATA )) {
321- try {
322- String basePackage = getServer ().getClass ().getPackage ().getName ();
323- Class <?> c = Class .forName (basePackage + ".util.CraftNBTTagConfigSerializer" );
324- methodDeserializeCompound = c .getMethod ("deserialize" , Object .class );
325- } catch (ClassNotFoundException | NoSuchMethodException e ) {
326- if (shouldSync (SyncType .PERSISTENT_DATA )) {
327- getLogger ().log (Level .WARNING , "Could not load static method required for persistent data syncing. Disabling it!" , e );
328- disableSync (SyncType .PERSISTENT_DATA );
329- }
330- }
331- }
332-
333314 if (getServer ().getMap ((short ) 0 ) == null ) {
334315 getServer ().createMap (getServer ().getWorlds ().get (0 ));
335316 }
@@ -401,14 +382,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
401382
402383 /**
403384 * Get a language message from the config and replace variables in it
404- * @param key The key of the message (lang.<key>)
385+ * @param key The key of the message (lang.<key>)
405386 * @param replacements An array of variables to be replaced with certain strings in the format [var,repl,var,repl,...]
406387 * @return The message string with colorcodes and variables replaced
407388 */
408389 public String getLang (String key , String ... replacements ) {
409390 String msg = ChatColor .translateAlternateColorCodes ('&' , getConfig ().getString ("lang." + key , getName () + ": &cMissing language key &6" + key ));
410391 for (int i = 0 ; i + 1 < replacements .length ; i += 2 ) {
411- msg = msg .replace ("%" + replacements [i ] + "%" , replacements [i + 1 ]);
392+ msg = msg .replace ("%" + replacements [i ] + "%" , replacements [i + 1 ]);
412393 }
413394 return msg ;
414395 }
@@ -424,10 +405,10 @@ public boolean isLocked(UUID playerId) {
424405
425406 /**
426407 * Get the date when a player last logged out
427- * @param playerId The UUID of the player
428- * @param online Whether or not it should return the current time if the player is online
429- * @return The timestamp of his last known data on the server in milliseconds;
430- * 0 if the file doesn't exist or an error occurs. (Take a look at {File#lastModified})
408+ * @param playerId The UUID of the player
409+ * @param online Whether or not it should return the current time if the player is online
410+ * @return The timestamp of his last known data on the server in milliseconds;
411+ * 0 if the file doesn't exist or an error occurs. (Take a look at {File#lastModified})
431412 */
432413 public long getLastSeen (UUID playerId , boolean online ) {
433414 if (online ) {
@@ -457,7 +438,7 @@ public long getLastSeen(UUID playerId, boolean online) {
457438 * @param playerId The UUID of the player
458439 * @param timeStamp The timestamp to set as the last modify time of the file in
459440 * milliseconds.
460- * @return true if the time was successfully set
441+ * @return true if the time was successfully set
461442 */
462443 public boolean setLastSeen (UUID playerId , long timeStamp ) {
463444 File playerDat = getPlayerDataFile (playerId );
@@ -512,7 +493,7 @@ public boolean applyTimedOutQueries() {
512493 /**
513494 * Connect a player to a bungee server
514495 * @param playerId The UUID of the player
515- * @param server The name of the server
496+ * @param server The name of the server
516497 */
517498 public void connectToServer (UUID playerId , String server ) {
518499 Player player = getServer ().getPlayer (playerId );
@@ -526,7 +507,7 @@ public void connectToServer(UUID playerId, String server) {
526507
527508 /**
528509 * Apply a PlayerData object to its player
529- * @param data The data to apply
510+ * @param data The data to apply
530511 */
531512 public void applyData (PlayerData data , Runnable finished ) {
532513 if (data == null )
@@ -731,7 +712,7 @@ public void applyData(PlayerData data, Runnable finished) {
731712 } catch (NullPointerException ignored ) {
732713 // world is not known
733714 }
734- for (Iterator <Advancement > it = getServer ().advancementIterator (); it .hasNext ();) {
715+ for (Iterator <Advancement > it = getServer ().advancementIterator (); it .hasNext (); ) {
735716 Advancement advancement = it .next ();
736717 Map <String , Long > awarded = data .getAdvancementProgress ().get (advancement .getKey ().toString ());
737718 if (awarded != null ) {
@@ -889,20 +870,13 @@ private void forceRender(MapView map) {
889870 map .addRenderer (new EmptyRenderer ());
890871 }
891872
892- private static class EmptyRenderer extends MapRenderer {
893- @ Override
894- public void render (@ NotNull MapView map , @ NotNull MapCanvas canvas , @ NotNull Player player ) {
895-
896- }
897- }
898-
899873 private void cacheData (PlayerData data , Runnable finished ) {
900874 playerDataCache .put (data .getPlayerId (), new AbstractMap .SimpleEntry <>(data , finished ));
901875 }
902876
903877 /**
904878 * Get data that was cached which should be applied on a player's login
905- * @param player The player to get the data for
879+ * @param player The player to get the data for
906880 * @return A cache entry containing the PlayerData and the notification Runnable when applied successfully
907881 */
908882 public Map .Entry <PlayerData , Runnable > getCachedData (Player player ) {
@@ -922,7 +896,7 @@ private boolean createNewEmptyData(UUID playerId) {
922896 if (playerDat .exists ()) {
923897 return false ;
924898 }
925-
899+
926900 try {
927901 playerDat .getParentFile ().mkdirs ();
928902 Files .copy (getResource ("empty.dat" ), playerDat .toPath ());
@@ -932,7 +906,7 @@ private boolean createNewEmptyData(UUID playerId) {
932906 }
933907 return false ;
934908 }
935-
909+
936910 public PlayerData getData (Player player ) {
937911 PlayerData data = new PlayerData (player , getLastSeen (player .getUniqueId (), player .isOnline ()));
938912
@@ -947,7 +921,7 @@ public PlayerData getData(Player player) {
947921 }
948922
949923 if (shouldSync (SyncType .ADVANCEMENTS )) {
950- for (Iterator <Advancement > it = getServer ().advancementIterator (); it .hasNext ();) {
924+ for (Iterator <Advancement > it = getServer ().advancementIterator (); it .hasNext (); ) {
951925 Advancement advancement = it .next ();
952926 AdvancementProgress progress = player .getAdvancementProgress (advancement );
953927 Map <String , Long > awarded = new HashMap <>();
@@ -1059,7 +1033,7 @@ public PlayerData getData(Player player) {
10591033
10601034 /**
10611035 * The sound to play when a player gets unlocked, should match the vanilla levelup
1062- * @param playerId The uuid of the Player to play the sound to
1036+ * @param playerId The uuid of the Player to play the sound to
10631037 */
10641038 public void playLoadSound (UUID playerId ) {
10651039 Player player = getServer ().getPlayer (playerId );
@@ -1070,7 +1044,7 @@ public void playLoadSound(UUID playerId) {
10701044
10711045 /**
10721046 * The sound to play when a player gets unlocked, should match the vanilla levelup
1073- * @param player The Player to play the sound to
1047+ * @param player The Player to play the sound to
10741048 */
10751049 public void playLoadSound (Player player ) {
10761050 player .playSound (player .getLocation (), Sound .ENTITY_PLAYER_LEVELUP , 0.7f , 1 );
@@ -1097,7 +1071,7 @@ public void checkMap(int id) {
10971071 * Make sure that a task runs on the primary thread
10981072 */
10991073 public void runSync (Runnable run ) {
1100- if (getServer ().isPrimaryThread () || disabling ) {
1074+ if (getServer ().isPrimaryThread () || disabling ) {
11011075 run .run ();
11021076 } else {
11031077 getServer ().getScheduler ().runTask (this , run );
@@ -1108,7 +1082,7 @@ public void runSync(Runnable run) {
11081082 * Make sure that a task does not run on the primary thread
11091083 */
11101084 public void runAsync (Runnable run ) {
1111- if (!getServer ().isPrimaryThread () && !disabling ) {
1085+ if (!getServer ().isPrimaryThread () && !disabling ) {
11121086 getServer ().getScheduler ().runTaskAsynchronously (this , run );
11131087 } else {
11141088 run .run ();
@@ -1165,4 +1139,9 @@ public UUID getWorldId(MapView map) {
11651139 }
11661140 return null ;
11671141 }
1142+
1143+ private static class EmptyRenderer extends MapRenderer {
1144+ @ Override
1145+ public void render (@ NotNull MapView map , @ NotNull MapCanvas canvas , @ NotNull Player player ) {}
1146+ }
11681147}
0 commit comments