2
0
Эх сурвалжийг харах

improve readme and game profile builder

Daniel Nägele 1 жил өмнө
parent
commit
eef0efbfa9

+ 0 - 3
README.md

@@ -7,9 +7,6 @@ MissileWars is a famous, fun and fast minigame spigot-plugin for Minecraft
 You can download the latest jar in the [latest release](https://github.com/Butzlabben/missilewars/releases/latest) or build it yourself (
 see [BUILDING](#building))
 
-However, if you [buy the resource](https://www.spigotmc.org/resources/62947) and leave a review,
-you will also receive an extra map and some more missiles.
-
 ## Building
 
 To build MissileWars, you need to install the Java 17 JDK. Then you can build it via the Maven Wrapper.

+ 1 - 1
missilewars-plugin/pom.xml

@@ -26,7 +26,7 @@
         <version>1.0</version>
     </parent>
 
-    <version>4.6.0-beta.1</version>
+    <version>4.6.0-beta.2</version>
 
     <modelVersion>4.0.0</modelVersion>
 

+ 5 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/GameProfileBuilder.java

@@ -74,6 +74,9 @@ public class GameProfileBuilder {
 
         try {
             GameProfile result = gson.fromJson(json, GameProfile.class);
+            if (result == null) {
+                throw new IllegalStateException("Serialized game profile lookup result for UUID " + uuid + " is null");
+            }
             cache.put(uuid, new CachedProfile(result));
             return result;
         } catch (Exception exception) {
@@ -161,11 +164,12 @@ public class GameProfileBuilder {
         }
     }
 
+    @Getter
     public static class CachedProfile {
 
-        @Getter
         private final GameProfile profile;
 
+
         public CachedProfile(GameProfile profile) {
             this.profile = profile;
         }

+ 22 - 24
missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PlayerGuiFactory.java

@@ -62,8 +62,7 @@ public class PlayerGuiFactory {
             if (offlinePlayer.getName() != null) {
                 names.put(stat.getUuid(), offlinePlayer.getName());
                 stat.setName(offlinePlayer.getName());
-            }
-            if (GameProfileBuilder.getCache().containsKey(stat.getUuid())) {
+            } else if (GameProfileBuilder.getCache().containsKey(stat.getUuid())) {
                 String name = GameProfileBuilder.getCache().get(stat.getUuid()).getProfile().getName();
                 names.put(stat.getUuid(), name);
                 stat.setName(name);
@@ -74,31 +73,30 @@ public class PlayerGuiFactory {
     public void openWhenReady(Player player) {
         int realSize = stats.size();
         int currentSize = names.size();
-        if (realSize > currentSize) {
-            if (Config.isContactAuth()) {
-                player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_FETCHING_PLAYERS)
-                        .replace("%current_size%", Integer.toString(currentSize))
-                        .replace("%real_size%", Integer.toString(realSize)));
-                ForkJoinPool.commonPool().execute(() -> {
-                    List<UUID> missing = getMissingUUIDs();
-                    int maxFetches = Math.min(missing.size(), MAX_FETCHES);
-                    for (int i = 0; i < maxFetches; i++) {
-                        UUID uuid = missing.get(i);
-                        try {
-                            GameProfile profile = GameProfileBuilder.fetch(uuid);
-                            names.put(uuid, profile.getName());
-                        } catch (IOException e) {
-                            names.put(uuid, "Error getting name");
-                            if (!e.getMessage().contains("Could not connect to mojang servers for unknown player"))
-                                Logger.WARN.log("Could not fetch name for " + uuid.toString() + ". Reason: " + e.getMessage());
-                        }
+        if (realSize > currentSize && Config.isContactAuth()) {
+            player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_FETCHING_PLAYERS)
+                    .replace("%current_size%", Integer.toString(currentSize))
+                    .replace("%real_size%", Integer.toString(realSize)));
+            ForkJoinPool.commonPool().execute(() -> {
+                List<UUID> missing = getMissingUUIDs();
+                int maxFetches = Math.min(missing.size(), MAX_FETCHES);
+                for (int i = 0; i < maxFetches; i++) {
+                    UUID uuid = missing.get(i);
+                    try {
+                        GameProfile profile = GameProfileBuilder.fetch(uuid);
+                        names.put(uuid, profile.getName());
+                    } catch (IOException e) {
+                        names.put(uuid, "Error getting name");
+                        if (!e.getMessage().contains("Could not connect to mojang servers for unknown player"))
+                            Logger.WARN.log("Could not fetch name for " + uuid.toString() + ". Reason: " + e.getMessage());
                     }
+                }
 
-                    openWhenReady(player);
-                });
-                return;
-            }
+                openWhenReady(player);
+            });
+            return;
         }
+
         for (PlayerStats stat : stats) {
             stat.setName(names.get(stat.getUuid()));
             if (stat.getName() == null || stat.getName().equals("")) {