4646
4747public class ServerExpansion extends PlaceholderExpansion implements Cacheable , Configurable {
4848
49- private final ServerUtils serverUtils ;
49+ private ServerUtils serverUtils = null ;
5050
5151 private final Map <String , SimpleDateFormat > dateFormats = new HashMap <>();
5252 private final Runtime runtime = Runtime .getRuntime ();
53- private final String variant ;
5453
5554 // config stuff
5655 private String serverName ;
@@ -65,12 +64,6 @@ public class ServerExpansion extends PlaceholderExpansion implements Cacheable,
6564
6665 private final String VERSION = getClass ().getPackage ().getImplementationVersion ();
6766
68- public ServerExpansion () {
69- this .serverUtils = new ServerUtils ();
70-
71- this .variant = serverUtils .getServerVariant ();
72- }
73-
7467 @ Override
7568 public boolean canRegister () {
7669 serverName = this .getString ("server_name" , "A Minecraft Server" );
@@ -84,7 +77,7 @@ public boolean canRegister() {
8477 public void clear () {
8578 serverUtils .clear ();
8679 dateFormats .clear ();
87-
80+ serverUtils = null ;
8881 cache .invalidateAll ();
8982 }
9083
@@ -114,8 +107,11 @@ public Map<String, Object> getDefaults() {
114107 }
115108
116109 @ Override
117- public String onRequest (OfflinePlayer p , String identifier ) {
110+ public String onRequest (OfflinePlayer p , @ NotNull String identifier ) {
118111 final int MB = 1048576 ;
112+ if (serverUtils == null ) {
113+ serverUtils = new ServerUtils ();
114+ }
119115
120116 switch (identifier ) {
121117 // Players placeholders
@@ -152,7 +148,7 @@ public String onRequest(OfflinePlayer p, String identifier) {
152148 case "name" :
153149 return serverName == null ? "" : serverName ;
154150 case "variant" :
155- return variant ;
151+ return serverUtils . getServerVariant () ;
156152 // -----
157153
158154 // Other placeholders
0 commit comments