+command to restart threads.
This commit is contained in:
parent
56d4318dbe
commit
060afeeb36
4 changed files with 47 additions and 11 deletions
|
|
@ -1,5 +1,8 @@
|
|||
package net.rubeta.legacyping;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
|
@ -14,6 +17,10 @@ public final class LegacyPing extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
this.saveDefaultConfig();
|
||||
this.startThreads();
|
||||
}
|
||||
|
||||
private void startThreads() {
|
||||
final FileConfiguration config = this.getConfig();
|
||||
final String host = config.getString("host", "0.0.0.0");
|
||||
final List<Integer> ports = config.getIntegerList("port");
|
||||
|
|
@ -33,4 +40,17 @@ public final class LegacyPing extends JavaPlugin {
|
|||
public void onDisable() {
|
||||
this.threads.forEach(ServerThread::shutdown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.isOp()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.threads.forEach(ServerThread::shutdown);
|
||||
this.threads.clear();
|
||||
this.startThreads();
|
||||
sender.sendMessage(ChatColor.GOLD + "Restarted");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue