Compare commits
3 Commits
1.0.0-SNAP
...
1.0.3-SNAP
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
542884dfe9 | ||
|
|
2e80b57a53 | ||
|
|
4141bcdfb1 |
7
pom.xml
7
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.limework.core</groupId>
|
<groupId>net.limework.core</groupId>
|
||||||
<artifactId>LimeworkSpigotCore</artifactId>
|
<artifactId>LimeworkSpigotCore</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.3-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -112,5 +112,10 @@
|
|||||||
<version>19.0.0</version>
|
<version>19.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongodb-driver-sync</artifactId>
|
||||||
|
<version>4.0.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -2,6 +2,7 @@ package net.limework.core;
|
|||||||
|
|
||||||
import net.limework.core.guis.ControlGui;
|
import net.limework.core.guis.ControlGui;
|
||||||
import net.limework.core.hooks.SkriptHook;
|
import net.limework.core.hooks.SkriptHook;
|
||||||
|
import net.limework.core.managers.DataSourcesManager;
|
||||||
import net.limework.core.managers.RedisManager;
|
import net.limework.core.managers.RedisManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@@ -10,11 +11,15 @@ public class LimeworkSpigotCore extends JavaPlugin {
|
|||||||
//Redis manager
|
//Redis manager
|
||||||
private RedisManager rm;
|
private RedisManager rm;
|
||||||
|
|
||||||
|
//data
|
||||||
|
private DataSourcesManager dsm;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
rm = new RedisManager(this);
|
rm = new RedisManager(this);
|
||||||
|
getServer().getPluginCommand("reloadredis").setExecutor(rm);
|
||||||
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
||||||
new SkriptHook(this);
|
new SkriptHook(this);
|
||||||
} else {
|
} else {
|
||||||
@@ -29,6 +34,9 @@ public class LimeworkSpigotCore extends JavaPlugin {
|
|||||||
getLogger().info("SOMETHING WENT WRONG WHEN LOADING control gui.");
|
getLogger().info("SOMETHING WENT WRONG WHEN LOADING control gui.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
dsm = new DataSourcesManager(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,10 +44,15 @@ public class LimeworkSpigotCore extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
rm.shutdown();
|
rm.shutdown();
|
||||||
|
dsm.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RedisManager getRm() {
|
public RedisManager getRm() {
|
||||||
return rm;
|
return rm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DataSourcesManager getDsm() {
|
||||||
|
return dsm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.limework.core.managers;
|
||||||
|
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoClients;
|
||||||
|
import net.limework.core.LimeworkSpigotCore;
|
||||||
|
import org.bukkit.configuration.Configuration;
|
||||||
|
|
||||||
|
public class DataSourcesManager {
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
|
|
||||||
|
|
||||||
|
public DataSourcesManager(LimeworkSpigotCore plugin) {
|
||||||
|
Configuration config = plugin .getConfig();
|
||||||
|
if (config.getBoolean("Mongodb.enabled")){
|
||||||
|
mongoClient = MongoClients.create(config.getString("Mongodb.url"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown(){
|
||||||
|
mongoClient.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MongoClient getMongoClient() {
|
||||||
|
return mongoClient;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,16 @@ package net.limework.core.managers;
|
|||||||
import net.limework.Data.Encryption;
|
import net.limework.Data.Encryption;
|
||||||
import net.limework.core.LimeworkSpigotCore;
|
import net.limework.core.LimeworkSpigotCore;
|
||||||
import net.limework.core.events.RedisMessageEvent;
|
import net.limework.core.events.RedisMessageEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.Configuration;
|
import org.bukkit.configuration.Configuration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.cryptomator.siv.UnauthenticCiphertextException;
|
import org.cryptomator.siv.UnauthenticCiphertextException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import redis.clients.jedis.BinaryJedis;
|
import redis.clients.jedis.BinaryJedis;
|
||||||
import redis.clients.jedis.BinaryJedisPubSub;
|
import redis.clients.jedis.BinaryJedisPubSub;
|
||||||
@@ -19,7 +25,7 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
public class RedisManager extends BinaryJedisPubSub implements Runnable, CommandExecutor {
|
||||||
|
|
||||||
private LimeworkSpigotCore plugin;
|
private LimeworkSpigotCore plugin;
|
||||||
|
|
||||||
@@ -27,7 +33,6 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
|||||||
private ExecutorService RedisService;
|
private ExecutorService RedisService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//sub
|
//sub
|
||||||
private BinaryJedis subscribeJedis;
|
private BinaryJedis subscribeJedis;
|
||||||
private List<String> channels;
|
private List<String> channels;
|
||||||
@@ -51,13 +56,16 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
|||||||
config.getString("Redis.Password"),
|
config.getString("Redis.Password"),
|
||||||
config.getBoolean("Redis.useSSL"));
|
config.getBoolean("Redis.useSSL"));
|
||||||
RedisService = Executors.newFixedThreadPool(config.getInt("Redis.Threads"));
|
RedisService = Executors.newFixedThreadPool(config.getInt("Redis.Threads"));
|
||||||
try{this.subscribeJedis = this.jedisPool.getResource(); }catch (Exception ignored){}
|
try {
|
||||||
|
this.subscribeJedis = this.jedisPool.getResource();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
this.channels = config.getStringList("Channels");
|
this.channels = config.getStringList("Channels");
|
||||||
encryption = new Encryption(config);
|
encryption = new Encryption(config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(){
|
public void start() {
|
||||||
this.RedisService.execute(this);
|
this.RedisService.execute(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +100,9 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
message("&e[Jedis] &cConnection to redis has failed! &ereconnecting...");
|
message("&e[Jedis] &cConnection to redis has failed! &ereconnecting...");
|
||||||
if (this.subscribeJedis != null){this.subscribeJedis.close();}
|
if (this.subscribeJedis != null) {
|
||||||
|
this.subscribeJedis.close();
|
||||||
|
}
|
||||||
isRedisOnline.set(false);
|
isRedisOnline.set(false);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -130,7 +140,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
|||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
this.isShuttingDown.set(true);
|
this.isShuttingDown.set(true);
|
||||||
if (this.subscribeJedis != null){
|
if (this.subscribeJedis != null) {
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
this.subscribeJedis.close();
|
this.subscribeJedis.close();
|
||||||
}
|
}
|
||||||
@@ -161,4 +171,15 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
|||||||
public Encryption getEncryption() {
|
public Encryption getEncryption() {
|
||||||
return encryption;
|
return encryption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
sender.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&'
|
||||||
|
, "&c&lYou can not execute this command!!!!!!")));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
start();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,3 +15,7 @@ Channels:
|
|||||||
- "Channel1"
|
- "Channel1"
|
||||||
- "Channel2"
|
- "Channel2"
|
||||||
- "Channel3"
|
- "Channel3"
|
||||||
|
|
||||||
|
Mongodb:
|
||||||
|
enabled: false
|
||||||
|
url: ""
|
||||||
@@ -9,3 +9,6 @@ commands:
|
|||||||
control:
|
control:
|
||||||
description: "server control"
|
description: "server control"
|
||||||
permission: "admin.use"
|
permission: "admin.use"
|
||||||
|
reloadredis:
|
||||||
|
description: "server control"
|
||||||
|
permission: "admin.use"
|
||||||
Reference in New Issue
Block a user