Files
src
build.gradle
Code
23 1,420
src/main/java/com/example/customroles/CustomRoles.java
package com.example.customroles;
import com.example.customroles.command.RoleCommand;
import com.example.customroles.hook.RolePlaceholder;
import com.example.customroles.inventory.gui.GUIListener;
import com.example.customroles.inventory.gui.GUIManager;
import com.example.customroles.listener.ChatListener;
import com.example.customroles.manager.RoleManager;
import com.example.customroles.manager.StorageManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class CustomRoles extends JavaPlugin {
private RoleManager roleManager;
private StorageManager storageManager;
private GUIManager guiManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.storageManager = new StorageManager(this);
this.roleManager = new RoleManager(this);
this.guiManager = new GUIManager();
this.storageManager.load();
getCommand("role").setExecutor(new RoleCommand(this));
if (getConfig().getBoolean("enable-chat-format", true)) {
Bukkit.getPluginManager().registerEvents(new ChatListener(this), this);
}
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new RolePlaceholder(this).register();
getLogger().info("PlaceholderAPI hook enabled!");
}
int interval = getConfig().getInt("auto-save-interval", 5);
if (interval > 0) {
Bukkit.getScheduler().runTaskTimer(this, () -> storageManager.save(), interval * 60 * 20L, interval * 60 * 20L);
}
Bukkit.getScheduler().runTaskTimer(this, () -> roleManager.checkExpiredRoles(), 20L, 20L * 60);
getLogger().info("CustomRoles enabled successfully!");
}
@Override
public void onDisable() {
if (storageManager != null) {
storageManager.save();
}
getLogger().info("CustomRoles disabled successfully!");
}
}