debug msg
parent
ea1f9801d8
commit
f02ea6ea5e
|
@ -34,104 +34,104 @@ import java.util.UUID;
|
||||||
@Getter
|
@Getter
|
||||||
public class KrakatoaAPI extends JavaPlugin {
|
public class KrakatoaAPI extends JavaPlugin {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static KrakatoaAPI instance;
|
private static KrakatoaAPI instance;
|
||||||
|
|
||||||
private ConfigHandler configHandler;
|
private ConfigHandler configHandler;
|
||||||
private KraSocketClientProtocol kraSocketClientProtocol;
|
private KraSocketClientProtocol kraSocketClientProtocol;
|
||||||
private KraSocketClient kraSocketClient;
|
private KraSocketClient kraSocketClient;
|
||||||
private KraSocketClientEventInitiater kraSocketClientEventInitiater;
|
private KraSocketClientEventInitiater kraSocketClientEventInitiater;
|
||||||
private KraSocketClientEventInterface kraSocketClientEventInterface;
|
private KraSocketClientEventInterface kraSocketClientEventInterface;
|
||||||
|
|
||||||
private MongoManager mongoManager;
|
private MongoManager mongoManager;
|
||||||
private RedisManager redisManager;
|
private RedisManager redisManager;
|
||||||
|
|
||||||
private Formatter formatter;
|
private Formatter formatter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
this.configHandler = new ConfigHandler();
|
this.configHandler = new ConfigHandler();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.configHandler.load();
|
this.configHandler.load();
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.kraSocketClientProtocol = new KraSocketClientProtocol();
|
||||||
|
|
||||||
|
KraSocketClientConfig kraSocketClientConfig = new KraSocketClientConfig(
|
||||||
|
this.configHandler.getWebSocketProtocol(), this.configHandler.getWebSocketHost(),
|
||||||
|
this.configHandler.getWebSocketPort(), this.configHandler.getWebSocketAccessKey(),
|
||||||
|
CloudNetDriver.getInstance().getComponentName(),
|
||||||
|
this.configHandler.getWebSocketAckTimeouts());
|
||||||
|
|
||||||
|
this.kraSocketClientEventInitiater = new KraSocketClientEventInitiater();
|
||||||
|
this.kraSocketClientEventInterface = new SocketClientMessageListener();
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.kraSocketClient = new KraSocketClient(kraSocketClientConfig,
|
||||||
|
this.kraSocketClientEventInterface, this.kraSocketClientProtocol);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.kraSocketClient.getSocketClient().connect();
|
||||||
|
|
||||||
|
this.getLogger().info("testaa lol");
|
||||||
|
|
||||||
|
this.mongoManager = new MongoManager(new MongoConfig(this.configHandler.getMongodbHost(),
|
||||||
|
this.configHandler.getMongodbPort(), this.configHandler.getMongodbUsername(),
|
||||||
|
this.configHandler.getMongodbPassword(),
|
||||||
|
this.configHandler.getMongodbDatabase()));
|
||||||
|
this.mongoManager.connect();
|
||||||
|
|
||||||
|
this.redisManager = new RedisManager(
|
||||||
|
new RedisConfig(this.configHandler.getRedisHost(), this.getConfigHandler().getRedisPort()));
|
||||||
|
this.redisManager.connect();
|
||||||
|
|
||||||
|
this.formatter = new Formatter();
|
||||||
|
|
||||||
|
loadListeners();
|
||||||
|
loadCommands();
|
||||||
|
|
||||||
|
// call to proxy that the server is only for the auto restart system
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
|
||||||
|
KraSocketClientProtocolMessage kraSocketClientProtocolMessage = new KraSocketClientProtocolMessage(
|
||||||
|
KraSocketClientProtocolStatus.SEND.getStatus(), 0,
|
||||||
|
KraSocketClientProtocolDest.PROXY.getStatus(),
|
||||||
|
UUID.fromString("c7b023ac-0303-4275-923d-3a1028e887a0"),
|
||||||
|
(short) 59739,
|
||||||
|
CloudNetDriver.getInstance().getComponentName(), null);
|
||||||
|
|
||||||
|
this.kraSocketClient.getSocketClient().SendMessage(kraSocketClientProtocolMessage);
|
||||||
|
}, 3 * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.kraSocketClientProtocol = new KraSocketClientProtocol();
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
super.onDisable();
|
||||||
|
|
||||||
KraSocketClientConfig kraSocketClientConfig = new KraSocketClientConfig(
|
this.mongoManager.shutdown();
|
||||||
this.configHandler.getWebSocketProtocol(), this.configHandler.getWebSocketHost(),
|
|
||||||
this.configHandler.getWebSocketPort(), this.configHandler.getWebSocketAccessKey(),
|
|
||||||
CloudNetDriver.getInstance().getComponentName(),
|
|
||||||
this.configHandler.getWebSocketAckTimeouts());
|
|
||||||
|
|
||||||
this.kraSocketClientEventInitiater = new KraSocketClientEventInitiater();
|
this.kraSocketClient.getSocketClient().getConnection().close();
|
||||||
this.kraSocketClientEventInterface = new SocketClientMessageListener();
|
this.kraSocketClient.getSocketClient().getConnection().closeConnection(1, "");
|
||||||
|
|
||||||
try {
|
instance = null;
|
||||||
this.kraSocketClient = new KraSocketClient(kraSocketClientConfig,
|
|
||||||
this.kraSocketClientEventInterface, this.kraSocketClientProtocol);
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.kraSocketClient.getSocketClient().connect();
|
public void loadListeners() {
|
||||||
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
|
List.of(new PlayerJoinListener(), new PlayerQuitListener()).forEach(listener -> {
|
||||||
|
pluginManager.registerEvents(listener, this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.getLogger().info("testaa");
|
public void loadCommands() {
|
||||||
|
Objects.requireNonNull(getCommand("krakatoa")).setExecutor(new KrakataoCommand());
|
||||||
this.mongoManager = new MongoManager(new MongoConfig(this.configHandler.getMongodbHost(),
|
}
|
||||||
this.configHandler.getMongodbPort(), this.configHandler.getMongodbUsername(),
|
|
||||||
this.configHandler.getMongodbPassword(),
|
|
||||||
this.configHandler.getMongodbDatabase()));
|
|
||||||
this.mongoManager.connect();
|
|
||||||
|
|
||||||
this.redisManager = new RedisManager(
|
|
||||||
new RedisConfig(this.configHandler.getRedisHost(), this.getConfigHandler().getRedisPort()));
|
|
||||||
this.redisManager.connect();
|
|
||||||
|
|
||||||
this.formatter = new Formatter();
|
|
||||||
|
|
||||||
loadListeners();
|
|
||||||
loadCommands();
|
|
||||||
|
|
||||||
// call to proxy that the server is only for the auto restart system
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
|
|
||||||
KraSocketClientProtocolMessage kraSocketClientProtocolMessage = new KraSocketClientProtocolMessage(
|
|
||||||
KraSocketClientProtocolStatus.SEND.getStatus(), 0,
|
|
||||||
KraSocketClientProtocolDest.PROXY.getStatus(),
|
|
||||||
UUID.fromString("c7b023ac-0303-4275-923d-3a1028e887a0"),
|
|
||||||
(short) 59739,
|
|
||||||
CloudNetDriver.getInstance().getComponentName(), null);
|
|
||||||
|
|
||||||
this.kraSocketClient.getSocketClient().SendMessage(kraSocketClientProtocolMessage);
|
|
||||||
}, 3 * 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
super.onDisable();
|
|
||||||
|
|
||||||
this.mongoManager.shutdown();
|
|
||||||
|
|
||||||
this.kraSocketClient.getSocketClient().getConnection().close();
|
|
||||||
this.kraSocketClient.getSocketClient().getConnection().closeConnection(1, "");
|
|
||||||
|
|
||||||
instance = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadListeners() {
|
|
||||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
|
||||||
List.of(new PlayerJoinListener(), new PlayerQuitListener()).forEach(listener -> {
|
|
||||||
pluginManager.registerEvents(listener, this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCommands() {
|
|
||||||
Objects.requireNonNull(getCommand("krakatoa")).setExecutor(new KrakataoCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue