Files
src
build.gradle
Code
13 800
src/main/java/com/notally/nanick/NANickPlugin.java
package com.notally.nanick;
import com.notally.nanick.commands.NicknameCommand;
import com.notally.nanick.commands.HelpCommand;
import com.notally.nanick.listeners.ChatListener;
import com.notally.nanick.managers.NicknameManager;
import com.notally.nanick.managers.ConfigManager;
import com.notally.nanick.integrations.TabIntegration;
import com.notally.nanick.integrations.PlaceholderIntegration;
import com.notally.nanick.utils.VersionUtils;
import com.notally.nanick.utils.TextUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class NANickPlugin extends JavaPlugin {
private NicknameManager nicknameManager;
private ConfigManager configManager;
private TabIntegration tabIntegration;
private PlaceholderIntegration placeholderIntegration;
@Override
public void onEnable() {
showStartupBanner();
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.nicknameManager = new NicknameManager(this);
registerCommands();
registerListeners();
setupIntegrations();
getLogger().info("NA-NICK v" + getDescription().getVersion() + " has been enabled!");
getLogger().info("Running on " + (VersionUtils.isPaper() ? "Paper" : "Spigot") + " " + VersionUtils.getVersion());
getLogger().info("Legacy mode: " + (VersionUtils.isLegacy() ? "enabled" : "disabled"));
}
@Override
public void onDisable() {
if (nicknameManager != null) {
nicknameManager.saveData();
}
getLogger().info("NA-NICK has been disabled!");
}
private void showStartupBanner() {
String[] banner = {
"",
"&6███╗ ██╗ █████╗ ███╗ ██╗██╗ ██████╗██╗ ██╗",
"&6████╗ ██║██╔══██╗ ████╗ ██║██║██╔════╝██║ ██╔╝",
"&6██╔██╗ ██║███████║█████╗██╔██╗ ██║██║██║ █████╔╝ ",
"&6██║╚██╗██║██╔══██║╚════╝██║╚██╗██║██║██║ ██╔═██╗ ",
"&6██║ ╚████║██║ ██║ ██║ ╚████║██║╚██████╗██║ ██╗",
"&6╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═══╝╚═╝ ╚═════╝╚═╝ ╚═╝",
"",
"&eAdvanced Nickname Plugin with TAB & Chat Integration",
"&7Version: &a" + getDescription().getVersion(),
"&7Author: &bNotAlly",
""
};
for (String line : banner) {
Bukkit.getConsoleSender().sendMessage(TextUtils.colorize(line));
}
}
private void registerCommands() {
getCommand("nickname").setExecutor(new NicknameCommand(this));
getCommand("na-nick-help").setExecutor(new HelpCommand(this));
}
private void registerListeners() {
getServer().getPluginManager().registerEvents(new ChatListener(this), this);
}
private void setupIntegrations() {
if (getServer().getPluginManager().getPlugin("TAB") != null) {
this.tabIntegration = new TabIntegration(this);
getLogger().info("TAB integration enabled!");
}
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
this.placeholderIntegration = new PlaceholderIntegration(this);
this.placeholderIntegration.register();
getLogger().info("PlaceholderAPI integration enabled!");
}
}
public NicknameManager getNicknameManager() {
return nicknameManager;
}
public ConfigManager getConfigManager() {
return configManager;
}
public TabIntegration getTabIntegration() {
return tabIntegration;
}
public PlaceholderIntegration getPlaceholderIntegration() {
return placeholderIntegration;
}
public String colorize(String text) {
return TextUtils.colorize(text);
}
}