Обновление - теперь больше слушателей портов
This commit is contained in:
parent
d3a21672fd
commit
520e143a37
4 changed files with 20 additions and 14 deletions
|
|
@ -4,28 +4,31 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class LegacyPing extends JavaPlugin {
|
||||
private ServerThread serverThread;
|
||||
private final List<ServerThread> threads = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.saveDefaultConfig();
|
||||
final FileConfiguration config = this.getConfig();
|
||||
try {
|
||||
this.serverThread = new ServerThread(this.getServer(), config.getString("host", "0.0.0.0"), config.getInt("port", 25566));
|
||||
this.serverThread.start();
|
||||
} catch (IOException e) {
|
||||
this.getLogger().log(Level.WARNING, "Failed to create ServerSocket", e);
|
||||
this.getPluginLoader().disablePlugin(this);
|
||||
final String host = config.getString("host", "0.0.0.0");
|
||||
final List<Integer> ports = config.getIntegerList("port");
|
||||
for (int port : ports) {
|
||||
try {
|
||||
this.threads.add(new ServerThread(this.getServer(), host, port));
|
||||
} catch (IOException e) {
|
||||
this.getLogger().log(Level.WARNING, "Failed to create ServerSocket", e);
|
||||
}
|
||||
}
|
||||
this.threads.forEach(Thread::start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (this.serverThread != null) {
|
||||
this.serverThread.shutdown();
|
||||
}
|
||||
this.threads.forEach(ServerThread::shutdown);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue