RediSkript/src/main/java/net/limework/rediskript/RediSkript.java

44 lines
1.2 KiB
Java
Raw Normal View History

package net.limework.rediskript;
2020-11-28 08:02:14 +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;
import org.bukkit.command.PluginCommand;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
2020-06-28 14:40:53 +00:00
import org.bukkit.plugin.java.JavaPlugin;
public class RediSkript extends JavaPlugin {
2020-06-28 14:40:53 +00:00
//Redis manager
private RedisManager rm;
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();
startRedis(false);
PluginCommand command = getServer().getPluginCommand("reloadredis");
assert command != null;
command.setExecutor(new CommandReloadRedis(this));
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
//using HIGHEST event priority so it shuts down last and code can still execute well in "on script unload" and "on skript unload" events
@EventHandler(priority = EventPriority.LOWEST)
2020-07-06 18:38:54 +00:00
public void onDisable() {
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
}