Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Mar 21, 2019
1 parent 551ad4d commit 6535458
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/main/java/de/cubeside/connection/GlobalClientBukkit.java
Expand Up @@ -15,11 +15,10 @@ class GlobalClientBukkit extends GlobalClient implements Listener {
private final GlobalClientPlugin plugin;
private boolean stoppingServer;

public GlobalClientBukkit(GlobalClientPlugin connectionPlugin, String host, int port, String account, String password) {
public GlobalClientBukkit(GlobalClientPlugin connectionPlugin) {
super(connectionPlugin.getLogger());
plugin = connectionPlugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
setServer(host, port, account, password);
}

@Override
Expand Down Expand Up @@ -72,7 +71,9 @@ protected void onServerDisconnected(GlobalServer server) {
plugin.getServer().getPluginManager().callEvent(new GlobalServerDisconnectedEvent(server));
}

protected void onServerStop() {
@Override
public void shutdown() {
this.stoppingServer = true;
super.shutdown();
}
}
14 changes: 7 additions & 7 deletions src/main/java/de/cubeside/connection/GlobalClientPlugin.java
Expand Up @@ -12,11 +12,8 @@ public class GlobalClientPlugin extends JavaPlugin {
@Override
public void onEnable() {
saveDefaultConfig();
String account = getConfig().getString("client.account");
String password = getConfig().getString("client.password");
String host = getConfig().getString("server.host");
int port = getConfig().getInt("server.port");
globalClient = new GlobalClientBukkit(this, host, port, account, password);
globalClient = new GlobalClientBukkit(this);
reconnectClient();
messageAPI = new PlayerMessageImplementation(this);
getServer().getServicesManager().register(ConnectionAPI.class, globalClient, this, ServicePriority.Normal);
getServer().getServicesManager().register(PlayerMessageAPI.class, messageAPI, this, ServicePriority.Normal);
Expand All @@ -25,7 +22,6 @@ public void onEnable() {
@Override
public void onDisable() {
if (globalClient != null) {
globalClient.onServerStop();
globalClient.shutdown();
}
globalClient = null;
Expand All @@ -38,12 +34,16 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;
}
reloadConfig();
reconnectClient();
return true;
}

public void reconnectClient() {
String account = getConfig().getString("client.account");
String password = getConfig().getString("client.password");
String host = getConfig().getString("server.host");
int port = getConfig().getInt("server.port");
globalClient.setServer(host, port, account, password);
return true;
}

public ConnectionAPI getConnectionAPI() {
Expand Down

0 comments on commit 6535458

Please sign in to comment.