41 lines
1.0 KiB
Java
41 lines
1.0 KiB
Java
package ee.lunasqu.redstoneoutput;
|
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
public class Main extends JavaPlugin {
|
|
private FileConfiguration config;
|
|
|
|
public static Main plugin;
|
|
public Connection service;
|
|
|
|
public Connection getConnection() {
|
|
if (service == null || !service.isAlive()) return null;
|
|
return service;
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
config = this.getConfig();
|
|
config.addDefault("host", "127.0.0.1");
|
|
config.addDefault("port", 62002);
|
|
config.options().copyDefaults(true);
|
|
this.saveConfig();
|
|
|
|
plugin = this;
|
|
getServer().getPluginManager().registerEvents(new EventListener(), this);
|
|
this.getCommand("rspi").setExecutor(new RemoteCommand());
|
|
this.connect();
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
if (service != null && service.isAlive()) service.die();
|
|
}
|
|
|
|
public void connect () {
|
|
service = new Connection(this.config.getString("host"), this.config.getInt("port"));
|
|
service.runTaskAsynchronously(this);
|
|
}
|
|
}
|