Removes #getConsole in SongodaPlugin

This commit is contained in:
Christian Koop 2022-06-26 02:33:09 +02:00
parent eb10b3f70a
commit 4bc0e991ab
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -24,7 +24,6 @@ public abstract class SongodaPlugin extends JavaPlugin {
protected Config config = new Config(this);
protected long dataLoadDelay = 20L;
protected ConsoleCommandSender console = Bukkit.getConsoleSender();
private boolean emergencyStop = false;
static {
@ -84,12 +83,14 @@ public abstract class SongodaPlugin extends JavaPlugin {
@Override
public final void onEnable() {
if (emergencyStop) {
if (this.emergencyStop) {
setEnabled(false);
return;
}
CommandSender console = Bukkit.getConsoleSender();
console.sendMessage(" "); // blank line to separate chatter
console.sendMessage(ChatColor.GREEN + "=============================");
console.sendMessage(String.format("%s%s %s by %sSongoda <3!", ChatColor.GRAY,
@ -98,15 +99,15 @@ public abstract class SongodaPlugin extends JavaPlugin {
ChatColor.GREEN, "Enabling", ChatColor.GRAY));
try {
locale = Locale.loadDefaultLocale(this, "en_US");
this.locale = Locale.loadDefaultLocale(this, "en_US");
// plugin setup
onPluginEnable();
// Load Data.
Bukkit.getScheduler().runTaskLater(this, this::onDataLoad, dataLoadDelay);
Bukkit.getScheduler().runTaskLater(this, this::onDataLoad, this.dataLoadDelay);
if (emergencyStop) {
if (this.emergencyStop) {
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
console.sendMessage(" ");
return;
@ -129,10 +130,12 @@ public abstract class SongodaPlugin extends JavaPlugin {
@Override
public final void onDisable() {
if (emergencyStop) {
if (this.emergencyStop) {
return;
}
CommandSender console = Bukkit.getConsoleSender();
console.sendMessage(" "); // blank line to separate chatter
console.sendMessage(ChatColor.GREEN + "=============================");
console.sendMessage(String.format("%s%s %s by %sSongoda <3!", ChatColor.GRAY,
@ -146,12 +149,8 @@ public abstract class SongodaPlugin extends JavaPlugin {
console.sendMessage(" "); // blank line to separate chatter
}
public ConsoleCommandSender getConsole() {
return console;
}
public Locale getLocale() {
return locale;
return this.locale;
}
/**
@ -164,13 +163,13 @@ public abstract class SongodaPlugin extends JavaPlugin {
* @return true if the locale exists and was loaded successfully
*/
public boolean setLocale(String localeName, boolean reload) {
if (locale != null && locale.getName().equals(localeName)) {
return !reload || locale.reloadMessages();
if (this.locale != null && this.locale.getName().equals(localeName)) {
return !reload || this.locale.reloadMessages();
}
Locale l = Locale.loadLocale(this, localeName);
if (l != null) {
locale = l;
this.locale = l;
return true;
}
@ -215,7 +214,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
}
protected void emergencyStop() {
emergencyStop = true;
this.emergencyStop = true;
Bukkit.getPluginManager().disablePlugin(this);
}