Files
src
build.gradle
settings.gradle
Code
28 2,091
src/main/java/com/aspectsmp/AspectSMP.java
package com.aspectsmp;
import com.aspectsmp.command.AbilityCommand;
import com.aspectsmp.command.AnnounceCommand;
import com.aspectsmp.command.AspectCommand;
import com.aspectsmp.command.ReviveCommand;
import com.aspectsmp.data.DataManager;
import com.aspectsmp.gui.AspectInfoGUI;
import com.aspectsmp.gui.ReviveGUI;
import com.aspectsmp.inventory.gui.GUIListener;
import com.aspectsmp.inventory.gui.GUIManager;
import com.aspectsmp.listener.CombatListener;
import com.aspectsmp.listener.CraftListener;
import com.aspectsmp.listener.PlayerListener;
import com.aspectsmp.manager.AspectManager;
import com.aspectsmp.manager.PhaseManager;
import com.aspectsmp.task.PassiveTask;
import com.aspectsmp.util.ItemUtil;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
public class AspectSMP extends JavaPlugin {
private DataManager dataManager;
private AspectManager aspectManager;
private PhaseManager phaseManager;
private GUIManager guiManager;
private AspectInfoGUI aspectInfoGUI;
private ReviveGUI reviveGUI;
@Override
public void onEnable() {
ItemUtil.init(this);
this.dataManager = new DataManager(this);
this.aspectManager = new AspectManager(this);
this.phaseManager = new PhaseManager(this);
this.phaseManager.syncStoredPhase();
this.guiManager = new GUIManager();
this.aspectInfoGUI = new AspectInfoGUI();
this.reviveGUI = new ReviveGUI(this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
Bukkit.getPluginManager().registerEvents(new CombatListener(this), this);
Bukkit.getPluginManager().registerEvents(new CraftListener(this), this);
AspectCommand aspectCommand = new AspectCommand(this);
getCommand("aspect").setExecutor(aspectCommand);
getCommand("aspect").setTabCompleter(aspectCommand);
getCommand("ability1").setExecutor(new AbilityCommand(this, AbilityCommand.Type.ABILITY1));
getCommand("ability2").setExecutor(new AbilityCommand(this, AbilityCommand.Type.ABILITY2));
getCommand("terrainattack").setExecutor(new AbilityCommand(this, AbilityCommand.Type.TERRAIN));
getCommand("announce").setExecutor(new AnnounceCommand(this));
getCommand("revive").setExecutor(new ReviveCommand(this));
registerCustomRecipes();
new PassiveTask(this).runTaskTimer(this, 100L, 100L);
}
@Override
public void onDisable() {
if (dataManager != null) dataManager.save();
}
private void registerCustomRecipes() {
NamespacedKey templateKey = new NamespacedKey(this, "crown_template");
ShapedRecipe templateRecipe = new ShapedRecipe(templateKey, ItemUtil.createCrownTemplate());
templateRecipe.shape("PPP", "PHN", "NNN");
templateRecipe.setIngredient('P', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("PRISMARINE_SHARD").map(XMaterial::parseMaterial).orElse(Material.PRISMARINE_SHARD)));
templateRecipe.setIngredient('H', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("HEART_OF_THE_SEA").map(XMaterial::parseMaterial).orElse(Material.HEART_OF_THE_SEA)));
templateRecipe.setIngredient('N', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("NETHERITE_INGOT").map(XMaterial::parseMaterial).orElse(Material.NETHERITE_INGOT)));
Bukkit.addRecipe(templateRecipe);
NamespacedKey crownKey = new NamespacedKey(this, "aspect_crown");
ShapedRecipe crownRecipe = new ShapedRecipe(crownKey, ItemUtil.createAspectCrown());
crownRecipe.shape("TBT", "BNB", "TBT");
crownRecipe.setIngredient('T', new RecipeChoice.ExactChoice(ItemUtil.createCrownTemplate()));
crownRecipe.setIngredient('B', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("NETHERITE_BLOCK").map(XMaterial::parseMaterial).orElse(Material.NETHERITE_BLOCK)));
crownRecipe.setIngredient('N', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("NETHER_STAR").map(XMaterial::parseMaterial).orElse(Material.NETHER_STAR)));
Bukkit.addRecipe(crownRecipe);
NamespacedKey lifeKey = new NamespacedKey(this, "aspect_life");
ShapedRecipe lifeRecipe = new ShapedRecipe(lifeKey, ItemUtil.createAspectLife());
lifeRecipe.shape("RAR", "A A", "RAR");
lifeRecipe.setIngredient('R', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("RED_DYE").map(XMaterial::parseMaterial).orElse(Material.RED_DYE)));
lifeRecipe.setIngredient('A', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("ANCIENT_DEBRIS").map(XMaterial::parseMaterial).orElse(Material.ANCIENT_DEBRIS)));
Bukkit.addRecipe(lifeRecipe);
NamespacedKey beaconKey = new NamespacedKey(this, "revival_beacon");
ShapedRecipe beaconRecipe = new ShapedRecipe(beaconKey, ItemUtil.createRevivalBeacon());
beaconRecipe.shape("LDL", "DHD", "LDL");
beaconRecipe.setIngredient('L', new RecipeChoice.ExactChoice(ItemUtil.createAspectLife()));
beaconRecipe.setIngredient('D', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("DIAMOND").map(XMaterial::parseMaterial).orElse(Material.DIAMOND)));
beaconRecipe.setIngredient('H', new RecipeChoice.MaterialChoice(
XMaterial.matchXMaterial("HEART_OF_THE_SEA").map(XMaterial::parseMaterial).orElse(Material.HEART_OF_THE_SEA)));
Bukkit.addRecipe(beaconRecipe);
}
public DataManager getDataManager() { return dataManager; }
public AspectManager getAspectManager() { return aspectManager; }
public PhaseManager getPhaseManager() { return phaseManager; }
public GUIManager getGuiManager() { return guiManager; }
public AspectInfoGUI getAspectInfoGUI() { return aspectInfoGUI; }
public ReviveGUI getReviveGUI() { return reviveGUI; }
}