This commit is contained in:
Dereku 2023-03-10 05:29:18 +07:00
commit 3e4f244552
6 changed files with 291 additions and 0 deletions

View file

@ -0,0 +1,31 @@
package net.rubeta.legacyping;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.util.logging.Level;
public final class LegacyPing extends JavaPlugin {
private ServerThread serverThread;
@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);
}
}
@Override
public void onDisable() {
if (this.serverThread != null) {
this.serverThread.shutdown();
}
}
}