Bungee reload functionality

This commit is contained in:
Rsl1122 2017-09-27 18:44:06 +03:00
parent 3c5868170f
commit e6bac8b13e
3 changed files with 25 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import com.djrapitops.plugin.BungeePlugin;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.command.commands.ReloadCommand;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
import main.java.com.djrapitops.plan.locale.Locale;
@ -63,10 +64,12 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
initDatabase();
registerCommand(new ReloadCommand(this));
String ip = variableHolder.getIp();
if ("0.0.0.0".equals(ip)) {
Log.error("IP setting still 0.0.0.0 - Config AlternativeIP/IP that connects to the Proxy server.");
disablePlugin();
Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
Log.info("Player Analytics partially enabled (Use /planbungee to reload config)");
return;
}
@ -172,4 +175,10 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
public UUID getServerUuid() {
return serverInfoManager.getServerUUID();
}
@Override
public void restart() {
onDisable();
onEnable();
}
}

View File

@ -43,4 +43,6 @@ public interface IPlan extends IPlugin {
InputStream getResource(String resource);
IConfig getIConfig() throws IOException;
void restart();
}

View File

@ -5,6 +5,8 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
@ -16,7 +18,7 @@ import main.java.com.djrapitops.plan.locale.Msg;
*/
public class ReloadCommand extends SubCommand {
private final Plan plugin;
private final IPlan plugin;
/**
* Subcommand constructor.
@ -32,6 +34,15 @@ public class ReloadCommand extends SubCommand {
this.plugin = plugin;
}
public ReloadCommand(PlanBungee plugin) {
super("planbungee",
CommandType.CONSOLE,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_RELOAD).toString());
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
plugin.restart();