Skip to content

Commit

Permalink
Added feature to make the proxy kick players on a restart.
Browse files Browse the repository at this point in the history
  • Loading branch information
redwallhp committed Feb 14, 2018
1 parent 2e23c79 commit 8a1a040
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ restart-times:

warn-restart-on-join: true
warn-restart-on-inventory-open: true
bungee-disconnect-on-restart: false
sprint-max-time: 40
countdown:
maxTime: 15
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>nu.nerd</groupId>
<artifactId>KitchenSink</artifactId>
<name>KitchenSink</name>
<version>0.14.0</version>
<version>0.14.1</version>
<packaging>jar</packaging>
<description>A plugin for miscellaneous functionality that hasn't found a home elsewhere.</description>
<url>https://github.com/NerdNu/KitchenSink</url>
Expand Down
2 changes: 2 additions & 0 deletions src/nu/nerd/kitchensink/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class Configuration {
public boolean DISABLE_PEARL_DROPS_IN_END;
public boolean DISABLE_PLAYER_DAMAGE_TO_VILLAGERS;
public boolean NORMALIZE_CHAT;
public boolean BUNGEE_DISCONNECT_ON_RESTART;

public Configuration(KitchenSink instance) {
plugin = instance;
Expand Down Expand Up @@ -169,6 +170,7 @@ public void load() {
DISABLE_PEARL_DROPS_IN_END = plugin.getConfig().getBoolean("disable-pearl-drops-in-end", false);
DISABLE_PLAYER_DAMAGE_TO_VILLAGERS = plugin.getConfig().getBoolean("disable-player-damage-to-villagers", false);
NORMALIZE_CHAT = plugin.getConfig().getBoolean("normalize-chat", true);
BUNGEE_DISCONNECT_ON_RESTART = plugin.getConfig().getBoolean("bungee-disconnect-on-restart", false);
}

protected void setCountDownSetting(countdown setting, Object value) {
Expand Down
17 changes: 17 additions & 0 deletions src/nu/nerd/kitchensink/KitchenSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.TreeMap;
import java.util.logging.Logger;

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import nu.nerd.kitchensink.ServerListPing17.StatusResponse;

import org.bukkit.Art;
Expand Down Expand Up @@ -177,6 +179,13 @@ public void onDisable() {
recipeList.remove(r);
}
}

if (config.BUNGEE_DISCONNECT_ON_RESTART) {
for (Player player : getServer().getOnlinePlayers()) {
proxyKick(player);
}
}

}

@Override
Expand Down Expand Up @@ -1011,4 +1020,12 @@ public static Block getTargetBlock(LivingEntity entity) {
}
return null;
}

public void proxyKick(Player player) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("KickPlayer");
out.writeUTF(player.getName());
out.writeUTF("Server closed");
player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
}
}

0 comments on commit 8a1a040

Please sign in to comment.