Files
src
build.gradle
settings.gradle
Code
16 776
src/main/java/com/kodari/glowing/GlowingPlugin.java
package com.kodari.glowing;
import com.kodari.glowing.command.GlowCommand;
import com.kodari.glowing.command.GlowingCommand;
import com.kodari.glowing.listener.GlowInventoryListener;
import com.kodari.glowing.listener.PlayerConnectionListener;
import com.kodari.glowing.menu.GlowMenu;
import com.kodari.glowing.service.GlowService;
import com.kodari.glowing.storage.GlowStorage;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public final class GlowingPlugin extends JavaPlugin {
private GlowStorage storage;
private GlowService glowService;
private GlowMenu glowMenu;
@Override
public void onEnable() {
saveDefaultConfig();
storage = new GlowStorage(this);
storage.load();
Economy economy = findEconomy();
glowService = new GlowService(this, storage, economy);
glowMenu = new GlowMenu(this, glowService);
getCommand("glowing").setExecutor(new GlowingCommand(glowMenu));
getCommand("glow").setExecutor(new GlowCommand(glowMenu));
Bukkit.getPluginManager().registerEvents(new GlowInventoryListener(glowMenu, glowService), this);
Bukkit.getPluginManager().registerEvents(new PlayerConnectionListener(this, glowService), this);
Bukkit.getOnlinePlayers().forEach(glowService::applyActiveGlow);
}
@Override
public void onDisable() {
if (glowService != null) {
Bukkit.getOnlinePlayers().forEach(glowService::clearVisualGlow);
}
if (storage != null) {
storage.save();
}
}
private Economy findEconomy() {
RegisteredServiceProvider<Economy> registration = Bukkit.getServicesManager().getRegistration(Economy.class);
return registration == null ? null : registration.getProvider();
}
}