Files
src
build.gradle
README.md
settings.gradle
Code
41 3,344
src/main/java/com/zenemotes/ZENEmotes.java
package com.zenemotes;
import com.zenemotes.animation.AnimationManager;
import com.zenemotes.command.CommandManager;
import com.zenemotes.config.ConfigManager;
import com.zenemotes.emote.EmoteManager;
import com.zenemotes.hook.PlaceholderAPIHook;
import com.zenemotes.hook.ProtocolLibHook;
import com.zenemotes.inventory.gui.GUIListener;
import com.zenemotes.inventory.gui.GUIManager;
import com.zenemotes.list.EmoteListener;
import com.zenemotes.util.UpdateChecker;
import com.zenemotes.util.ColorUtil;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public final class ZENEmotes extends JavaPlugin {
private ConfigManager configManager;
private EmoteManager emoteManager;
private AnimationManager animationManager;
private CommandManager commandManager;
private GUIManager guiManager;
private ProtocolLibHook protocolLibHook;
@Override
public void onEnable() {
long start = System.currentTimeMillis();
// Load configuration
this.configManager = new ConfigManager(this);
this.configManager.loadConfigs();
// Initialize GUI system
this.guiManager = new GUIManager();
GUIListener guiListener = new GUIListener(guiManager);
Bukkit.getPluginManager().registerEvents(guiListener, this);
// Initialize core managers
this.emoteManager = new EmoteManager(this);
this.animationManager = new AnimationManager(this);
// Initialize optional hooks
this.protocolLibHook = new ProtocolLibHook(this);
this.protocolLibHook.setup();
// Register commands
this.commandManager = new CommandManager(this);
this.commandManager.registerCommands();
// Register listeners
Bukkit.getPluginManager().registerEvents(new EmoteListener(this), this);
// PlaceholderAPI hook
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPIHook(this).register();
getLogger().info("PlaceholderAPI hook registered.");
}
// Update checker
if (configManager.getConfig().getBoolean("update-checker", true)) {
new UpdateChecker(this, 12345).check(latest -> {
getLogger().warning("A new update is available! Current: " + getDescription().getVersion() + " Latest: " + latest);
Bukkit.getConsoleSender().sendMessage(ColorUtil.colorize(
"<gold>[ZENEmotes] Update available: " + getDescription().getVersion() + " โ " + latest
));
});
}
getLogger().info("ZENEmotes v" + getDescription().getVersion() +
" enabled in " + (System.currentTimeMillis() - start) + "ms.");
getLogger().info("Loaded " + emoteManager.getRegistry().getTotalEmotes() + " emotes and " +
animationManager.getAllAnimations().size() + " animations.");
}
@Override
public void onDisable() {
// Stop all active emotes
if (emoteManager != null) {
emoteManager.getActiveEmotes().forEach((uuid, state) -> {
org.bukkit.entity.Player player = Bukkit.getPlayer(uuid);
if (player != null && player.isOnline()) {
emoteManager.stopEmote(player);
}
});
}
// Stop all active animations
if (animationManager != null) {
Bukkit.getOnlinePlayers().forEach(animationManager::stopAnimation);
}
getLogger().info("ZENEmotes disabled.");
}
public void reloadPlugin() {
onDisable();
onEnable();
}
}