@@ -142,7 +142,6 @@ public static String getPasteKey() {
142142 *
143143 * @return String
144144 */
145- @ SuppressWarnings ("WeakerAccess" )
146145 public static String getPrismName () {
147146 return pluginName ;
148147 }
@@ -310,6 +309,7 @@ public void onEnable() {
310309
311310 pluginName = this .getDescription ().getName ();
312311 pluginVersion = this .getDescription ().getVersion ();
312+ messenger = new Messenger (pluginName );
313313 log ("Initializing Prism " + pluginVersion + ". Originally by Viveleroi; maintained by the AddstarMC Network" );
314314 loadConfig (); // Load configuration, or install if new
315315 if (!getConfig ().getBoolean ("prism.suppress-paper-message" , false )) {
@@ -343,7 +343,7 @@ public void onEnable() {
343343 testConnection = prismDataSource .getConnection ();
344344 if (testConnection == null ) {
345345 notifyDisabled ();
346- Bukkit .getScheduler ().runTask (instance , () -> instance .onDisable ());
346+ Bukkit .getScheduler ().runTask (instance , () -> instance .enableFailedDatabase ());
347347 updating .cancel ();
348348 return ;
349349 }
@@ -354,7 +354,7 @@ public void onEnable() {
354354 }
355355 } else {
356356 notifyDisabled ();
357- Bukkit .getScheduler ().runTask (instance , () -> instance .onDisable ());
357+ Bukkit .getScheduler ().runTask (instance , () -> instance .enableFailedDatabase ());
358358 updating .cancel ();
359359 return ;
360360 }
@@ -386,10 +386,25 @@ public void onEnable() {
386386
387387 private void notifyDisabled () {
388388 final String [] dbDisabled = new String [3 ];
389- dbDisabled [0 ] = "Prism will disable itself because it couldn't connect to a database." ;
389+ dbDisabled [0 ] = "Prism will disable most commands because it couldn't connect to a database." ;
390390 dbDisabled [1 ] = "If you're using MySQL, check your config. Be sure MySQL is running." ;
391391 dbDisabled [2 ] = "For help - try our Discord Channel or the Wiki on Github." ;
392392 logSection (dbDisabled );
393+
394+ }
395+
396+ private void enableFailedDatabase () {
397+ if (isEnabled ()) {
398+ PluginCommand command = getCommand ("prism" );
399+ if (command != null ) {
400+ PrismCommands commands = new PrismCommands (this ,true );
401+ command .setExecutor (commands );
402+ command .setTabCompleter (commands );
403+ } else {
404+ warn ("Command Executor Error: Check plugin.yml" );
405+ Bukkit .getPluginManager ().disablePlugin (instance );
406+ }
407+ }
393408 }
394409
395410 private void enabled () {
@@ -423,7 +438,7 @@ private void enabled() {
423438 // Add commands
424439 PluginCommand command = getCommand ("prism" );
425440 if (command != null ) {
426- PrismCommands commands = new PrismCommands (this );
441+ PrismCommands commands = new PrismCommands (this , false );
427442 command .setExecutor (commands );
428443 command .setTabCompleter (commands );
429444 } else {
@@ -451,7 +466,6 @@ private void enabled() {
451466 registerParameter (new WorldParameter ());
452467
453468 // Init re-used classes
454- messenger = new Messenger (pluginName );
455469 oreMonitor = new OreMonitor (instance );
456470 useMonitor = new UseMonitor (instance );
457471
@@ -562,7 +576,6 @@ public PurgeManager getPurgeManager() {
562576 /**
563577 * Clears the Query Cache.
564578 */
565- @ SuppressWarnings ("WeakerAccess" )
566579 public void endExpiredQueryCaches () {
567580 getServer ().getScheduler ().scheduleSyncRepeatingTask (this , () -> {
568581 final java .util .Date date = new java .util .Date ();
@@ -602,7 +615,6 @@ public void endExpiredPreviews() {
602615 /**
603616 * Remove expired locations.
604617 */
605- @ SuppressWarnings ("WeakerAccess" )
606618 public void removeExpiredLocations () {
607619 getServer ().getScheduler ().scheduleSyncRepeatingTask (this , () -> {
608620 final java .util .Date date = new java .util .Date ();
0 commit comments