Files
src
build.gradle
Code
25 2,262
src/main/java/com/shardascension/ShardAscension.java
package com.shardascension;
import com.shardascension.commands.AscensionGiveCommand;
import com.shardascension.commands.AscensionResetCommand;
import com.shardascension.commands.CrownCommand;
import com.shardascension.commands.CrownMenuCommand;
import com.shardascension.config.ConfigManager;
import com.shardascension.inventory.gui.GUIListener;
import com.shardascension.inventory.gui.GUIManager;
import com.shardascension.listeners.ArmorAbilityListener;
import com.shardascension.listeners.CraftListener;
import com.shardascension.listeners.FragmentListener;
import com.shardascension.listeners.SwordAbilityListener;
import com.shardascension.managers.AbilityManager;
import com.shardascension.managers.CooldownManager;
import com.shardascension.managers.CrownManager;
import com.shardascension.managers.ItemManager;
import com.shardascension.managers.WorldLimitManager;
import com.cryptomorin.xseries.XMaterial;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class ShardAscension extends JavaPlugin {
private ConfigManager configManager;
private ItemManager itemManager;
private CooldownManager cooldownManager;
private WorldLimitManager worldLimitManager;
private AbilityManager abilityManager;
private CrownManager crownManager;
private GUIManager guiManager;
@Override
public void onEnable() {
saveDefaultConfig();
configManager = new ConfigManager(this);
itemManager = new ItemManager(this);
cooldownManager = new CooldownManager();
worldLimitManager = new WorldLimitManager(this);
abilityManager = new AbilityManager(this, itemManager, cooldownManager, configManager);
crownManager = new CrownManager(this, cooldownManager, configManager);
guiManager = new GUIManager();
registerListeners();
registerCommands();
registerRecipes();
abilityManager.startScheduler();
}
@Override
public void onDisable() {
worldLimitManager.save();
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new FragmentListener(this, itemManager, configManager), this);
Bukkit.getPluginManager().registerEvents(new SwordAbilityListener(this, itemManager, abilityManager, cooldownManager, configManager), this);
Bukkit.getPluginManager().registerEvents(new ArmorAbilityListener(this, itemManager, abilityManager), this);
Bukkit.getPluginManager().registerEvents(new CraftListener(this, itemManager, worldLimitManager), this);
}
private void registerCommands() {
getCommand("ascensiongive").setExecutor(new AscensionGiveCommand(itemManager));
getCommand("ascensionreset").setExecutor(new AscensionResetCommand(this, worldLimitManager));
getCommand("crown").setExecutor(new CrownCommand(this, itemManager, crownManager, guiManager));
getCommand("crownmenu").setExecutor(new CrownMenuCommand(this, crownManager, guiManager));
}
public void registerRecipes() {
ItemStack fragment = itemManager.createFragment();
Material stickMat = XMaterial.matchXMaterial("STICK").map(XMaterial::parseMaterial).orElse(null);
if (stickMat == null) return;
NamespacedKey helmetKey = new NamespacedKey(this, "shard_helmet");
Bukkit.removeRecipe(helmetKey);
ShapedRecipe helmetRecipe = new ShapedRecipe(helmetKey, itemManager.createHelmet());
helmetRecipe.shape("FFF", "F F");
helmetRecipe.setIngredient('F', new RecipeChoice.ExactChoice(fragment));
Bukkit.addRecipe(helmetRecipe);
NamespacedKey chestKey = new NamespacedKey(this, "shard_chestplate");
Bukkit.removeRecipe(chestKey);
ShapedRecipe chestRecipe = new ShapedRecipe(chestKey, itemManager.createChestplate());
chestRecipe.shape("F F", "FFF", "FFF");
chestRecipe.setIngredient('F', new RecipeChoice.ExactChoice(fragment));
Bukkit.addRecipe(chestRecipe);
NamespacedKey legKey = new NamespacedKey(this, "shard_leggings");
Bukkit.removeRecipe(legKey);
ShapedRecipe legRecipe = new ShapedRecipe(legKey, itemManager.createLeggings());
legRecipe.shape("FFF", "F F", "F F");
legRecipe.setIngredient('F', new RecipeChoice.ExactChoice(fragment));
Bukkit.addRecipe(legRecipe);
NamespacedKey bootKey = new NamespacedKey(this, "shard_boots");
Bukkit.removeRecipe(bootKey);
ShapedRecipe bootRecipe = new ShapedRecipe(bootKey, itemManager.createBoots());
bootRecipe.shape("F F", "F F");
bootRecipe.setIngredient('F', new RecipeChoice.ExactChoice(fragment));
Bukkit.addRecipe(bootRecipe);
NamespacedKey swordKey = new NamespacedKey(this, "shard_sword");
Bukkit.removeRecipe(swordKey);
ShapedRecipe swordRecipe = new ShapedRecipe(swordKey, itemManager.createSword());
swordRecipe.shape(" F ", " F ", " S ");
swordRecipe.setIngredient('F', new RecipeChoice.ExactChoice(fragment));
swordRecipe.setIngredient('S', new RecipeChoice.MaterialChoice(stickMat));
Bukkit.addRecipe(swordRecipe);
}
}