@@ -172,100 +172,49 @@ public void grumpException(RuntimeException e) {
172172 private String mcVersionString ;
173173 private String updateCheck ;
174174 private Response updateResponse ;
175+ private final StringBuilder startupBuilder = new StringBuilder ();
176+ private final StringBuilder startupExceptionBuilder = new StringBuilder ();
177+ private final Handler handler = new Handler () {
178+ @ Override
179+ public void publish (LogRecord record ) {
180+ if (record .getMessage () != null && record .getMessage ().contains ("Loaded class {0}" )) {
181+ return ;
182+ }
183+ startupBuilder .append ('[' ).append (record .getLevel ().getName ()).append ("] " ).append (record .getMessage ()).append ('\n' );
184+ if (record .getThrown () != null ) {
185+ StringWriter stringWriter = new StringWriter ();
186+ PrintWriter printWriter = new PrintWriter (stringWriter );
187+ record .getThrown ().printStackTrace (printWriter );
188+ startupExceptionBuilder .append ('[' ).append (record .getLevel ().getName ()).append ("] " ).append (record .getMessage ()).append ('\n' )
189+ .append (stringWriter ).append ('\n' );
190+ }
191+ }
192+
193+ @ Override
194+ public void flush () {
195+ }
196+
197+ @ Override
198+ public void close () throws SecurityException {
199+ }
200+ };
175201
176202 public AbstractFactionsPlugin () {
177203 instance = this ;
178204 }
179205
180206 @ Override
181207 public void onLoad () {
208+ getLogger ().addHandler (handler );
209+ getLogger ().info ("=== Starting up! ===" );
210+ this .loadSuccessful = false ;
182211 this .onPluginLoad ();
183212 try {
184213 Class .forName ("com.sk89q.worldguard.WorldGuard" );
185214 Worldguard .onLoad ();
186215 } catch (Exception ignored ) {
187216 // eh
188217 }
189- }
190-
191- @ Override
192- public void onEnable () {
193- this .loadSuccessful = false ;
194- StringBuilder startupBuilder = new StringBuilder ();
195- StringBuilder startupExceptionBuilder = new StringBuilder ();
196- Handler handler = new Handler () {
197- @ Override
198- public void publish (LogRecord record ) {
199- if (record .getMessage () != null && record .getMessage ().contains ("Loaded class {0}" )) {
200- return ;
201- }
202- startupBuilder .append ('[' ).append (record .getLevel ().getName ()).append ("] " ).append (record .getMessage ()).append ('\n' );
203- if (record .getThrown () != null ) {
204- StringWriter stringWriter = new StringWriter ();
205- PrintWriter printWriter = new PrintWriter (stringWriter );
206- record .getThrown ().printStackTrace (printWriter );
207- startupExceptionBuilder .append ('[' ).append (record .getLevel ().getName ()).append ("] " ).append (record .getMessage ()).append ('\n' )
208- .append (stringWriter ).append ('\n' );
209- }
210- }
211-
212- @ Override
213- public void flush () {
214- }
215-
216- @ Override
217- public void close () throws SecurityException {
218- }
219- };
220- getLogger ().addHandler (handler );
221- getLogger ().info ("=== Starting up! ===" );
222- long timeEnableStart = System .currentTimeMillis ();
223-
224- if (!this .grumpyExceptions .isEmpty ()) {
225- this .grumpyExceptions .forEach (e -> getLogger ().log (Level .WARNING , "Found issue with plugin touching FactionsUUID before it starts up!" , e ));
226- }
227-
228- UpdateCheck update = new UpdateCheck ("FactionsUUID" , this .getDescription ().getVersion (), this .getServer ().getName (), this .getServer ().getVersion ());
229- update .meow = this .getClass ().getDeclaredMethods ().length ;
230-
231- byte [] m = Bukkit .getMotd ().getBytes (StandardCharsets .UTF_8 );
232- if (m .length == 0 ) {
233- m = new byte []{0x6b , 0x69 , 0x74 , 0x74 , 0x65 , 0x6e };
234- }
235- int u = intOr (update .spigotId = "%%__USER__%%" , 987654321 ), n = intOr ("%%__NONCE__%%" , 1234567890 ), x = 0 , p = Math .min (Bukkit .getMaxPlayers (), 65535 );
236- long ms = (0x4fac & 0xffffL );
237- if (n != 1234567890 ) {
238- ms += (n & 0xffffffffL ) << 32 ;
239- x = 4 ;
240- }
241- for (int i = 0 ; x < 6 ; i ++, x ++) {
242- if (i == m .length ) {
243- i = 0 ;
244- }
245- ms += ((m [i ] & 0xFFL ) << (8 + (8 * (6 - x ))));
246- }
247- this .serverUUID = new UUID (ms , ((0xaf & 0xffL ) << 56 ) + ((0xac & 0xffL ) << 48 ) + (u & 0xffffffffL ) + ((p & 0xffffL ) << 32 ));
248-
249- // Version party
250- Pattern versionPattern = Pattern .compile ("(\\ d{2}|1)\\ .(\\ d{1,2})(?:\\ .(\\ d{1,2}))?" );
251- Matcher versionMatcher = versionPattern .matcher (this .getServer ().getVersion ());
252- if (versionMatcher .find ()) {
253- String major = versionMatcher .group (1 );
254- String minor = versionMatcher .group (2 );
255- String patchS = versionMatcher .group (3 );
256- this .mcVersionString = major + '.' + minor + (patchS == null ? "" : ('.' + patchS ));
257- }
258-
259- getLogger ().info ("" );
260- getLogger ().info ("Factions UUID!" );
261- getLogger ().info ("Version " + this .getDescription ().getVersion ());
262- getLogger ().info ("Loading as a " + this .pluginType () + " plugin" );
263- getLogger ().info ("" );
264- getLogger ().info ("Need support? https://factions.support/help/" );
265- getLogger ().info ("" );
266-
267- this .getLogger ().info ("Server UUID " + this .serverUUID );
268-
269218 try {
270219 Class <?> nameAndIdClass = Class .forName ("net.minecraft.server.players.NameAndId" );
271220 Method getOffline = this .getServer ().getClass ().getDeclaredMethod ("getOfflinePlayer" , nameAndIdClass );
@@ -293,7 +242,7 @@ public void close() throws SecurityException {
293242 }
294243 Path oldPath = dataPath .getParent ().resolve ("Factions" );
295244 if (Files .exists (oldPath )) {
296- this .getLogger ().info ("No FUUID data folder exists, but found older Factions folder. Migrating..." );
245+ this .getLogger ().info ("No FactionsUUID data folder exists, but found older Factions folder. Migrating..." );
297246 try {
298247 Files .walkFileTree (oldPath , new SimpleFileVisitor <>() {
299248 @ Override
@@ -328,6 +277,54 @@ public void close() throws SecurityException {
328277 if (this .conf ().data ().json ().useEfficientStorage ()) {
329278 getLogger ().info ("Using space efficient (less readable) storage." );
330279 }
280+ }
281+
282+ @ Override
283+ public void onEnable () {
284+ if (!this .grumpyExceptions .isEmpty ()) {
285+ this .grumpyExceptions .forEach (e -> getLogger ().log (Level .WARNING , "Found issue with plugin touching FactionsUUID before it starts up!" , e ));
286+ }
287+
288+ UpdateCheck update = new UpdateCheck ("FactionsUUID" , this .getDescription ().getVersion (), this .getServer ().getName (), this .getServer ().getVersion ());
289+ update .meow = this .getClass ().getDeclaredMethods ().length ;
290+
291+ byte [] m = Bukkit .getMotd ().getBytes (StandardCharsets .UTF_8 );
292+ if (m .length == 0 ) {
293+ m = new byte []{0x6b , 0x69 , 0x74 , 0x74 , 0x65 , 0x6e };
294+ }
295+ int u = intOr (update .spigotId = "%%__USER__%%" , 987654321 ), n = intOr ("%%__NONCE__%%" , 1234567890 ), x = 0 , p = Math .min (Bukkit .getMaxPlayers (), 65535 );
296+ long ms = (0x4fac & 0xffffL );
297+ if (n != 1234567890 ) {
298+ ms += (n & 0xffffffffL ) << 32 ;
299+ x = 4 ;
300+ }
301+ for (int i = 0 ; x < 6 ; i ++, x ++) {
302+ if (i == m .length ) {
303+ i = 0 ;
304+ }
305+ ms += ((m [i ] & 0xFFL ) << (8 + (8 * (6 - x ))));
306+ }
307+ this .serverUUID = new UUID (ms , ((0xaf & 0xffL ) << 56 ) + ((0xac & 0xffL ) << 48 ) + (u & 0xffffffffL ) + ((p & 0xffffL ) << 32 ));
308+
309+ // Version party
310+ Pattern versionPattern = Pattern .compile ("(\\ d{2}|1)\\ .(\\ d{1,2})(?:\\ .(\\ d{1,2}))?" );
311+ Matcher versionMatcher = versionPattern .matcher (this .getServer ().getVersion ());
312+ if (versionMatcher .find ()) {
313+ String major = versionMatcher .group (1 );
314+ String minor = versionMatcher .group (2 );
315+ String patchS = versionMatcher .group (3 );
316+ this .mcVersionString = major + '.' + minor + (patchS == null ? "" : ('.' + patchS ));
317+ }
318+
319+ getLogger ().info ("" );
320+ getLogger ().info ("Factions UUID!" );
321+ getLogger ().info ("Version " + this .getDescription ().getVersion ());
322+ getLogger ().info ("Loading as a " + this .pluginType () + " plugin" );
323+ getLogger ().info ("" );
324+ getLogger ().info ("Need support? https://factions.support/help/" );
325+ getLogger ().info ("" );
326+
327+ this .getLogger ().info ("Server UUID " + this .serverUUID );
331328
332329 this .landRaidControl = LandRaidControl .getByName (this .conf ().factions ().landRaidControl ().getSystem ());
333330
@@ -442,17 +439,19 @@ public void close() throws SecurityException {
442439 new BukkitRunnable () {
443440 @ Override
444441 public void run () {
442+ getLogger ().info ("=== Second phase begins! ===" );
445443 Econ .setup ();
446444 vaultPerms = new VaultPerms ();
447445 // Grand metrics adventure!
448446 setupMetrics ();
449447 getLogger ().removeHandler (handler );
450448 startupLog = startupBuilder .toString ();
451449 startupExceptionLog = startupExceptionBuilder .toString ();
450+ getLogger ().info ("=== Done! ===" );
452451 }
453452 }.runTask (this );
454453
455- getLogger ().info ("=== Initial start took " + ( System . currentTimeMillis () - timeEnableStart ) + "ms ! ===" );
454+ getLogger ().info ("=== Initial start complete ! ===" );
456455 this .loadSuccessful = true ;
457456
458457 this .updateCheck = new Gson ().toJson (update );
0 commit comments