Compare commits
3 Commits
888e7f5870
...
cdd37df717
Author | SHA1 | Date |
---|---|---|
|
cdd37df717 | |
|
e5b845fdfe | |
|
8e944a55e5 |
5
pom.xml
5
pom.xml
|
@ -85,6 +85,11 @@
|
||||||
<artifactId>KraSocketClient</artifactId>
|
<artifactId>KraSocketClient</artifactId>
|
||||||
<version>1.2-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>earth.krakatoa</groupId>
|
||||||
|
<artifactId>KraCore</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
@ -9,6 +9,10 @@ import earth.krakatao.protocol.KraSocketClientProtocol;
|
||||||
import earth.krakatao.protocol.KraSocketClientProtocolDest;
|
import earth.krakatao.protocol.KraSocketClientProtocolDest;
|
||||||
import earth.krakatao.protocol.KraSocketClientProtocolMessage;
|
import earth.krakatao.protocol.KraSocketClientProtocolMessage;
|
||||||
import earth.krakatao.protocol.KraSocketClientProtocolStatus;
|
import earth.krakatao.protocol.KraSocketClientProtocolStatus;
|
||||||
|
import earth.krakatoa.core.config.MongoConfig;
|
||||||
|
import earth.krakatoa.core.config.RedisConfig;
|
||||||
|
import earth.krakatoa.core.mongo.MongoManager;
|
||||||
|
import earth.krakatoa.core.redis.RedisManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,7 +24,6 @@ import net.krakatoaapi.config.ConfigHandler;
|
||||||
import net.krakatoaapi.listener.PlayerJoinListener;
|
import net.krakatoaapi.listener.PlayerJoinListener;
|
||||||
import net.krakatoaapi.listener.PlayerQuitListener;
|
import net.krakatoaapi.listener.PlayerQuitListener;
|
||||||
import net.krakatoaapi.listener.SocketClientMessageListener;
|
import net.krakatoaapi.listener.SocketClientMessageListener;
|
||||||
import net.krakatoaapi.mongo.MongoManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
@ -33,12 +36,14 @@ public class KrakatoaAPI extends JavaPlugin {
|
||||||
private static KrakatoaAPI instance;
|
private static KrakatoaAPI instance;
|
||||||
|
|
||||||
private ConfigHandler configHandler;
|
private ConfigHandler configHandler;
|
||||||
private MongoManager mongoManager;
|
|
||||||
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 RedisManager redisManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
|
@ -72,10 +77,15 @@ public class KrakatoaAPI extends JavaPlugin {
|
||||||
|
|
||||||
this.kraSocketClient.getSocketClient().connect();
|
this.kraSocketClient.getSocketClient().connect();
|
||||||
|
|
||||||
this.mongoManager = new MongoManager(this.configHandler.getMongodbHost(),
|
this.mongoManager = new MongoManager(new MongoConfig(this.configHandler.getMongodbHost(),
|
||||||
this.configHandler.getMongodbPort(), this.configHandler.getMongodbUsername(),
|
this.configHandler.getMongodbPort(), this.configHandler.getMongodbUsername(),
|
||||||
this.configHandler.getMongodbPassword());
|
this.configHandler.getMongodbPassword(),
|
||||||
this.mongoManager.connect(this.configHandler.getMongodbDatabase());
|
this.configHandler.getMongodbDatabase()));
|
||||||
|
this.mongoManager.connect();
|
||||||
|
|
||||||
|
this.redisManager = new RedisManager(
|
||||||
|
new RedisConfig(this.configHandler.getRedisHost(), this.getConfigHandler().getRedisPort()));
|
||||||
|
this.redisManager.connect();
|
||||||
|
|
||||||
loadListeners();
|
loadListeners();
|
||||||
loadCommands();
|
loadCommands();
|
||||||
|
@ -97,6 +107,8 @@ public class KrakatoaAPI extends JavaPlugin {
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
|
|
||||||
|
this.mongoManager.shutdown();
|
||||||
|
|
||||||
this.kraSocketClient.getSocketClient().getConnection().close();
|
this.kraSocketClient.getSocketClient().getConnection().close();
|
||||||
this.kraSocketClient.getSocketClient().getConnection().closeConnection(1, "");
|
this.kraSocketClient.getSocketClient().getConnection().closeConnection(1, "");
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ public class ConfigHandler {
|
||||||
private String mongodbUsername;
|
private String mongodbUsername;
|
||||||
private String mongodbPassword;
|
private String mongodbPassword;
|
||||||
|
|
||||||
|
private String redisHost;
|
||||||
|
private String redisPort;
|
||||||
|
|
||||||
public void load() throws IOException, InvalidConfigurationException {
|
public void load() throws IOException, InvalidConfigurationException {
|
||||||
File file = new File(defaultConfigPath, "kraSettings.yaml");
|
File file = new File(defaultConfigPath, "kraSettings.yaml");
|
||||||
|
|
||||||
|
@ -47,5 +50,8 @@ public class ConfigHandler {
|
||||||
mongodbDatabase = fileConfiguration.getString("mongodb.database");
|
mongodbDatabase = fileConfiguration.getString("mongodb.database");
|
||||||
mongodbUsername = fileConfiguration.getString("mongodb.username");
|
mongodbUsername = fileConfiguration.getString("mongodb.username");
|
||||||
mongodbPassword = fileConfiguration.getString("mongodb.password");
|
mongodbPassword = fileConfiguration.getString("mongodb.password");
|
||||||
|
|
||||||
|
redisHost = fileConfiguration.getString("redis.host");
|
||||||
|
redisPort = fileConfiguration.getString("redis.port");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,9 @@ public class PlayerJoinListener implements Listener {
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
// TODO: server != lobby -> send player to last location
|
// TODO: server != lobby -> send player to last location
|
||||||
|
/*
|
||||||
|
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
||||||
|
.getRedissonClient()
|
||||||
|
.getMap("player:" + uuid); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
package net.krakatoaapi.mongo;
|
|
||||||
|
|
||||||
import com.mongodb.async.client.MongoClient;
|
|
||||||
import com.mongodb.async.client.MongoClients;
|
|
||||||
import com.mongodb.async.client.MongoDatabase;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
public class MongoManager {
|
|
||||||
|
|
||||||
private final String hostname;
|
|
||||||
private final int port;
|
|
||||||
private final String username;
|
|
||||||
private final String password;
|
|
||||||
|
|
||||||
// TODO: look - deprecated
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private MongoDatabase mongoDatabase;
|
|
||||||
@Getter
|
|
||||||
private MongoClient mongoClient;
|
|
||||||
//@Getter
|
|
||||||
//private MongoCollection<Document> players;
|
|
||||||
|
|
||||||
public MongoManager(String hostname, int port, String username, String password) {
|
|
||||||
this.hostname = hostname;
|
|
||||||
this.port = port;
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void connect(String database) {
|
|
||||||
mongoClient = MongoClients.create(
|
|
||||||
"mongodb://" + username + ":" + password + "@" + hostname + ":" + port + "/?authSource="
|
|
||||||
+ database);
|
|
||||||
|
|
||||||
mongoDatabase = mongoClient.getDatabase(database);
|
|
||||||
//players = mongoDatabase.getCollection("players");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue