Files
src
build.gradle
manifest.kod
settings.gradle
Code
20 1,297
src/main/java/com/chromasmp/ChromaSMP.java
package com.chromasmp;
import com.chromasmp.ability.AbilityManager;
import com.chromasmp.command.ChromaCommand;
import com.chromasmp.data.PlayerDataStore;
import com.chromasmp.data.PlayerManager;
import com.chromasmp.element.FusionManager;
import com.chromasmp.item.OrbItemFactory;
import com.chromasmp.listener.AbilityListener;
import com.chromasmp.listener.CombatListener;
import com.chromasmp.listener.OrbListener;
import com.chromasmp.listener.PlayerConnectionListener;
import com.chromasmp.passive.PassiveManager;
import com.chromasmp.util.CooldownManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
public final class ChromaSMP extends JavaPlugin {
private PlayerDataStore dataStore;
private PlayerManager playerManager;
private CooldownManager cooldownManager;
private OrbItemFactory orbItemFactory;
private FusionManager fusionManager;
private AbilityManager abilityManager;
@Override
public void onEnable() {
saveDefaultConfig();
dataStore = new PlayerDataStore(this);
playerManager = new PlayerManager(this, dataStore);
cooldownManager = new CooldownManager();
orbItemFactory = new OrbItemFactory(this);
fusionManager = new FusionManager(this, playerManager, orbItemFactory);
abilityManager = new AbilityManager(this, playerManager, cooldownManager, orbItemFactory, fusionManager);
Bukkit.getPluginManager().registerEvents(new PlayerConnectionListener(playerManager), this);
Bukkit.getPluginManager().registerEvents(new OrbListener(playerManager, orbItemFactory), this);
Bukkit.getPluginManager().registerEvents(new CombatListener(this, playerManager, orbItemFactory), this);
Bukkit.getPluginManager().registerEvents(new AbilityListener(abilityManager), this);
new PassiveManager(this, playerManager).start();
ChromaCommand command = new ChromaCommand(this, playerManager, orbItemFactory, fusionManager);
getCommand("chroma").setExecutor(command);
getCommand("chroma").setTabCompleter(command);
registerCatalystRecipe();
}
private void registerCatalystRecipe() {
ItemStack result = orbItemFactory.createCatalyst();
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "awakening_catalyst"), result);
recipe.shape(getConfig().getStringList("items.catalyst-recipe.shape").toArray(new String[0]));
Material netherStar = Material.matchMaterial(getConfig().getString("items.catalyst-recipe.nether-star", "NETHER_STAR"));
Material ancientDebris = Material.matchMaterial(getConfig().getString("items.catalyst-recipe.ancient-debris", "ANCIENT_DEBRIS"));
Material amethyst = Material.matchMaterial(getConfig().getString("items.catalyst-recipe.amethyst", "AMETHYST_SHARD"));
if (netherStar != null && ancientDebris != null && amethyst != null) {
recipe.setIngredient('N', netherStar);
recipe.setIngredient('A', ancientDebris);
recipe.setIngredient('C', amethyst);
Bukkit.addRecipe(recipe);
}
}
@Override
public void onDisable() {
if (playerManager != null) {
playerManager.saveAllAsync();
}
}
public PlayerManager getPlayerManager() {
return playerManager;
}
public OrbItemFactory getOrbItemFactory() {
return orbItemFactory;
}
}