2020-10-29 08:01:36 +00:00
|
|
|
package net.limework.rediskript;
|
2020-11-28 08:02:14 +00:00
|
|
|
|
2020-10-29 08:01:36 +00:00
|
|
|
import net.limework.rediskript.commands.CommandReloadRedis;
|
|
|
|
import net.limework.rediskript.managers.RedisManager;
|
2020-11-28 08:02:14 +00:00
|
|
|
import net.limework.rediskript.skript.SkriptHook;
|
2020-10-23 13:55:04 +00:00
|
|
|
import org.bukkit.command.PluginCommand;
|
2020-10-29 07:47:18 +00:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
2020-06-28 14:40:53 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2020-10-22 10:30:41 +00:00
|
|
|
public class RediSkript extends JavaPlugin {
|
2020-06-28 14:40:53 +00:00
|
|
|
|
|
|
|
//Redis manager
|
|
|
|
private RedisManager rm;
|
|
|
|
|
2020-10-24 09:32:40 +00:00
|
|
|
public void startRedis(boolean reload) {
|
|
|
|
if (reload) { reloadConfig(); }
|
|
|
|
rm = new RedisManager(this);
|
|
|
|
rm.start();
|
|
|
|
}
|
2020-06-28 14:40:53 +00:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
saveDefaultConfig();
|
2020-11-02 10:09:18 +00:00
|
|
|
startRedis(false);
|
2020-10-23 13:55:04 +00:00
|
|
|
|
2020-11-02 10:09:18 +00:00
|
|
|
PluginCommand command = getServer().getPluginCommand("reloadredis");
|
|
|
|
assert command != null;
|
|
|
|
command.setExecutor(new CommandReloadRedis(this));
|
2020-10-23 13:55:04 +00:00
|
|
|
|
2020-11-02 10:09:18 +00:00
|
|
|
new SkriptHook(this);
|
2020-06-28 14:40:53 +00:00
|
|
|
}
|
2020-06-28 14:41:22 +00:00
|
|
|
|
2020-07-06 18:38:54 +00:00
|
|
|
@Override
|
2020-10-29 07:47:18 +00:00
|
|
|
//using HIGHEST event priority so it shuts down last and code can still execute well in "on script unload" and "on skript unload" events
|
2020-11-03 09:29:06 +00:00
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
2020-07-06 18:38:54 +00:00
|
|
|
public void onDisable() {
|
2020-10-23 11:34:30 +00:00
|
|
|
if (rm != null) {
|
|
|
|
rm.shutdown();
|
|
|
|
}
|
2020-07-06 18:38:54 +00:00
|
|
|
}
|
2020-06-28 14:40:53 +00:00
|
|
|
public RedisManager getRm() {
|
|
|
|
return rm;
|
|
|
|
}
|
2020-07-06 18:38:54 +00:00
|
|
|
}
|