items() {
+ return items;
+ }
+
+ public Material icon() {
+ return icon;
+ }
+
+ public AbilityTree tree() {
+ return tree;
+ }
+}
diff --git a/src/main/java/me/zenox/evocraft/gameclass/tree/AbilityPath.java b/src/main/java/me/zenox/evocraft/gameclass/tree/AbilityPath.java
new file mode 100644
index 0000000..a93151a
--- /dev/null
+++ b/src/main/java/me/zenox/evocraft/gameclass/tree/AbilityPath.java
@@ -0,0 +1,26 @@
+package me.zenox.evocraft.gameclass.tree;
+
+import me.zenox.evocraft.abilities.ClassAbility;
+import me.zenox.evocraft.data.PlayerData;
+
+/**
+ * Represents an ability path, which is a linear progression of ability upgrades
+ */
+public class AbilityPath extends Path {
+
+ public final ClassAbility ability;
+
+ public AbilityPath(String id, ClassAbility ability) {
+ super(id, ability.getModifiers().size());
+ this.ability = ability;
+ }
+
+ public ClassAbility getAbility() {
+ return ability;
+ }
+
+ @Override
+ public void apply(PlayerData playerData) {
+ // Nothing, this is just a linear progression with no side effects
+ }
+}
diff --git a/src/main/java/me/zenox/evocraft/gameclass/tree/AbilityTree.java b/src/main/java/me/zenox/evocraft/gameclass/tree/AbilityTree.java
new file mode 100644
index 0000000..ca73a29
--- /dev/null
+++ b/src/main/java/me/zenox/evocraft/gameclass/tree/AbilityTree.java
@@ -0,0 +1,48 @@
+package me.zenox.evocraft.gameclass.tree;
+
+import me.zenox.evocraft.abilities.ClassAbility;
+import me.zenox.evocraft.gameclass.ClickCombination;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a global ability tree, including GUI and all
+ *
+ * Player information can be found in the PlayerData class
+ */
+public record AbilityTree (ClassAbility LL_Ability, ClassAbility LR_Ability,
+ ClassAbility RL_Ability, ClassAbility RR_Ability, List paths){
+
+ public AbilityTree(ClassAbility LL_Ability, ClassAbility LR_Ability, ClassAbility RL_Ability, ClassAbility RR_Ability, Path ... paths) {
+ this(LL_Ability, LR_Ability, RL_Ability, RR_Ability, new ArrayList<>(List.of(
+ new AbilityPath(LL_Ability.getId(), LL_Ability),
+ new AbilityPath(LR_Ability.getId(), LR_Ability),
+ new AbilityPath(RL_Ability.getId(), RL_Ability),
+ new AbilityPath(RR_Ability.getId(), RR_Ability))));
+ this.paths.addAll(List.of(paths));
+ }
+
+ public ClassAbility getAbility(ClickCombination cc){
+ return switch(cc){
+ case LEFT_LEFT -> LL_Ability;
+ case LEFT_RIGHT -> LR_Ability;
+ case RIGHT_LEFT -> RL_Ability;
+ case RIGHT_RIGHT -> RR_Ability;
+ };
+ }
+
+ public Path path(ClassAbility ability) {
+ return paths.stream()
+ .filter(path -> (path instanceof AbilityPath) && ((AbilityPath) path).ability.equals(ability))
+ .findFirst()
+ .orElse(null);
+ }
+
+ public Path path(String id) {
+ return paths.stream()
+ .filter(path -> path.getId().equals(id))
+ .findFirst()
+ .orElse(null);
+ }
+}
diff --git a/src/main/java/me/zenox/evocraft/gameclass/tree/Path.java b/src/main/java/me/zenox/evocraft/gameclass/tree/Path.java
new file mode 100644
index 0000000..709fb6b
--- /dev/null
+++ b/src/main/java/me/zenox/evocraft/gameclass/tree/Path.java
@@ -0,0 +1,51 @@
+package me.zenox.evocraft.gameclass.tree;
+
+import me.zenox.evocraft.data.PlayerData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a player's path on the AbilityTree
+ */
+public abstract class Path {
+
+ private String id;
+
+ public static final List registeredPaths = new ArrayList<>();
+ private final int maxLevel;
+
+ // Constructor
+ public Path(String id, int maxLevel) {
+ this.id = id;
+ this.maxLevel = maxLevel;
+ registeredPaths.add(this);
+ }
+
+ public static Path getFromID(String key) {
+ return registeredPaths.stream()
+ .filter(path -> path.getId().equals(key)).findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("No path with ID " + key + " found"));
+ }
+
+ // Getter for ID
+ public String getId() {
+ return id;
+ }
+
+ // Method to progress the ability
+ public void progress(PlayerData playerData) {
+ int currentLevel = playerData.getPathLevel(this);
+ playerData.setPathLevel(this, currentLevel + 1);
+
+ // Apply the effects to the PlayerData
+ apply(playerData);
+ }
+
+ // Abstract method to apply stats, metadata, etc. to player
+ public abstract void apply(PlayerData playerData);
+
+ public int getMaxLevel() {
+ return maxLevel;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/zenox/evocraft/gui/EnchantGUIBuilder.java b/src/main/java/me/zenox/evocraft/gui/EnchantGUIBuilder.java
deleted file mode 100644
index 035224b..0000000
--- a/src/main/java/me/zenox/evocraft/gui/EnchantGUIBuilder.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package me.zenox.evocraft.gui;
-
-import de.studiocode.invui.gui.GUI;
-import de.studiocode.invui.gui.builder.GUIBuilder;
-import de.studiocode.invui.gui.builder.GUIContext;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.reflect.Field;
-
-
-/**
- * hhahahh enchant gui code go brr
- */
-public class EnchantGUIBuilder extends GUIBuilder {
-
- private final EnchantGUIType guiType;
- private final GUIContext context;
- private final Player p;
- private final Block block;
-
- public EnchantGUIBuilder(@NotNull EnchantGUIType guiType, Player p, Block block) {
- super(guiType);
- this.guiType = guiType;
- this.context = new GUIContext();
- try {
- Field f = getClass().getSuperclass().getDeclaredField("context");
- f.setAccessible(true);
- f.set(this, context);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- this.p = p;
- this.block = block;
- }
-
- @Override
- public EnchantingGUI build() {
- if (context.getStructure() == null) throw new IllegalStateException("GUIContext has not been set yet.");
- return guiType.createGUI(context, p, block);
- }
-
-}
-
diff --git a/src/main/java/me/zenox/evocraft/gui/EnchantGUIType.java b/src/main/java/me/zenox/evocraft/gui/EnchantGUIType.java
deleted file mode 100644
index b0a189e..0000000
--- a/src/main/java/me/zenox/evocraft/gui/EnchantGUIType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package me.zenox.evocraft.gui;
-
-import de.studiocode.invui.gui.builder.GUIContext;
-import de.studiocode.invui.gui.builder.guitype.GUIType;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-
-class EnchantGUIType implements GUIType {
-
- public EnchantingGUI createGUI(GUIContext context, Player p, Block block) {
- EnchantingGUI gui = new EnchantingGUI(context.getStructure(), p, block);
- gui.setBackground(context.getBackground());
- return gui;
- }
-
- @Override
- public EnchantingGUI createGUI(GUIContext context) {
- throw new IllegalStateException("You cannot use EnchantGUIType with the normal GUI builder.");
- }
-
- @Override
- public boolean acceptsGUIs() {
- return false;
- }
-
- @Override
- public boolean acceptsItems() {
- return false;
- }
-
- @Override
- public boolean acceptsInventory() {
- return false;
- }
-
-}
-
diff --git a/src/main/java/me/zenox/evocraft/gui/EnchantGuiBuilder.java b/src/main/java/me/zenox/evocraft/gui/EnchantGuiBuilder.java
new file mode 100644
index 0000000..30ef939
--- /dev/null
+++ b/src/main/java/me/zenox/evocraft/gui/EnchantGuiBuilder.java
@@ -0,0 +1,31 @@
+package me.zenox.evocraft.gui;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import xyz.xenondevs.invui.gui.AbstractGui;
+
+
+/**
+ * A builder class for {@link EnchantingGui}.
+ */
+public class EnchantGuiBuilder extends AbstractGui.AbstractBuilder implements EnchantingGui.Enchanting {
+
+ private final Player p;
+ private final Block block;
+
+ public EnchantGuiBuilder(Player p, Block block) {
+ this.p = p;
+ this.block = block;
+ }
+
+ @Override
+ public @NotNull EnchantingGui build() {
+ if (structure == null)
+ throw new IllegalStateException("Structure is not defined.");
+ EnchantingGui gui = new EnchantingGui(structure, p, block);
+ gui.setBackground(background);
+ return gui;
+ }
+}
+
diff --git a/src/main/java/me/zenox/evocraft/gui/EnchantingGUI.java b/src/main/java/me/zenox/evocraft/gui/EnchantingGui.java
similarity index 76%
rename from src/main/java/me/zenox/evocraft/gui/EnchantingGUI.java
rename to src/main/java/me/zenox/evocraft/gui/EnchantingGui.java
index 574d052..968897a 100644
--- a/src/main/java/me/zenox/evocraft/gui/EnchantingGUI.java
+++ b/src/main/java/me/zenox/evocraft/gui/EnchantingGui.java
@@ -1,13 +1,7 @@
package me.zenox.evocraft.gui;
-import com.archyx.aureliumskills.api.AureliumAPI;
-import com.archyx.aureliumskills.skills.Skills;
-import de.studiocode.invui.gui.GUI;
-import de.studiocode.invui.gui.SlotElement;
-import de.studiocode.invui.gui.impl.SimpleGUI;
-import de.studiocode.invui.gui.structure.Structure;
-import de.studiocode.invui.item.builder.ItemBuilder;
-import de.studiocode.invui.virtualinventory.VirtualInventoryManager;
+import dev.aurelium.auraskills.api.skill.Skills;
+import dev.aurelium.auraskills.api.user.SkillsUser;
import me.zenox.evocraft.enchant.ComplexEnchantment;
import me.zenox.evocraft.gui.item.BookshelfItem;
import me.zenox.evocraft.gui.item.BooleanItem;
@@ -18,6 +12,9 @@
import me.zenox.evocraft.item.LoreEntry;
import me.zenox.evocraft.item.VariableType;
import me.zenox.evocraft.util.Util;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Particle;
@@ -26,6 +23,13 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
+import xyz.xenondevs.inventoryaccess.component.AdventureComponentWrapper;
+import xyz.xenondevs.invui.gui.AbstractGui;
+import xyz.xenondevs.invui.gui.Gui;
+import xyz.xenondevs.invui.gui.SlotElement;
+import xyz.xenondevs.invui.gui.structure.Structure;
+import xyz.xenondevs.invui.inventory.VirtualInventoryManager;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
import java.util.*;
@@ -34,7 +38,7 @@
/**
* Enchantment GUI that is shown to players
*/
-public class EnchantingGUI extends SimpleGUI {
+public class EnchantingGui extends AbstractGui {
public static final VariableType ENCHANT_FUEL_VAR = new VariableType<>("enchant_fuel",
new LoreEntry("enchant_fuel",
@@ -52,13 +56,13 @@ public class EnchantingGUI extends SimpleGUI {
private final Block eTable;
private int bookshelfPower = 0;
- public EnchantingGUI(int width, int height, Player p, Block eTable) {
+ public EnchantingGui(int width, int height, Player p, Block eTable) {
super(width, height);
this.p = p;
this.eTable = eTable;
}
- public EnchantingGUI(@NotNull Structure structure, Player p, Block eTable) {
+ public EnchantingGui(@NotNull Structure structure, Player p, Block eTable) {
super(structure.getWidth(), structure.getHeight());
applyStructure(structure);
this.p = p;
@@ -82,11 +86,12 @@ public boolean enchantItem(int level, int xpRequired) {
ComplexItemStack item = ComplexItemStack.of(getEItem());
ComplexItemStack fuelItem = ComplexItemStack.of(getFuelItem());
Random r = new Random();
+ SkillsUser user = Util.getSkillsUser(p);
int fuelStrength = (int) (fuelItem.getComplexMeta().getVariable(ENCHANT_FUEL_VAR).getValue());
double variety = calculateVariety(bookshelfPower);
- double strength = calculateStrength(level, fuelStrength, AureliumAPI.getSkillLevel(p, Skills.ENCHANTING));
+ double strength = calculateStrength(level, fuelStrength, user.getSkillLevel(Skills.ENCHANTING));
// Util.sendMessage(p, "Enchant | Strength: " + strength + " | Variety: " + variety);
@@ -151,9 +156,9 @@ public boolean enchantItem(int level, int xpRequired) {
fuelItem.getItem().setAmount(fuelItem.getItem().getAmount() - 1);
// Set fuel to be empty
- VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_FUEL_KEY + p.getName()), 1).setItemStack(null, 0, fuelItem.getItem());
+ VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_FUEL_KEY + p.getName()), 1).setItem(null, 0, fuelItem.getItem());
// update virtual container with enchanted version
- VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_ITEM_KEY + p.getName()), 1).setItemStack(null, 0, item.getItem());
+ VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_ITEM_KEY + p.getName()), 1).setItem(null, 0, item.getItem());
this.eTable.getWorld().playSound(this.eTable.getLocation(), ENCHANT_SOUND, 1f + level, 1f - level * 0.15f);
@@ -167,7 +172,7 @@ public boolean enchantItem(int level, int xpRequired) {
p.setLevel(p.getLevel() - xpRequired - level + 1);
// Update player's Skill XP
- AureliumAPI.addXp(p, Skills.ENCHANTING, calculateSkillXP(level, strength, calculateVariety(bookshelfPower)));
+ user.addSkillXp(Skills.ENCHANTING, calculateSkillXP(level, strength, calculateVariety(bookshelfPower)));
return true;
}
@@ -177,7 +182,7 @@ public boolean enchantItem(int level, int xpRequired) {
* @return the item being enchanted
*/
private ItemStack getEItem() {
- return VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_ITEM_KEY + p.getName()), 1).getItemStack(0);
+ return VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_ITEM_KEY + p.getName()), 1).getItem(0);
}
/**
@@ -186,7 +191,7 @@ private ItemStack getEItem() {
* @return the fuel item
*/
private ItemStack getFuelItem() {
- return VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_FUEL_KEY + p.getName()), 1).getItemStack(0);
+ return VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_FUEL_KEY + p.getName()), 1).getItem(0);
}
public Block getETable() {
@@ -197,23 +202,24 @@ public void setBookshelfPower(int bookshelfPower) {
this.bookshelfPower = bookshelfPower;
}
- public static boolean enchantValid(EnchantingGUI gui, int power, int XPRequired) {
+ public static boolean enchantValid(EnchantingGui gui, int power, int XPRequired) {
+ SkillsUser user = Util.getSkillsUser(gui.p);
int skillRequirement = 0;
switch (power) {
case 2 -> skillRequirement = 10;
case 3 -> skillRequirement = 25;
}
// Check XP and skill level
- return fuelValid(gui.getFuelItem()) && itemValid(gui.getEItem()) && AureliumAPI.getSkillLevel(gui.p, Skills.ENCHANTING) >= skillRequirement && gui.p.getLevel() >= XPRequired;
+ return fuelValid(gui.getFuelItem()) && itemValid(gui.getEItem()) && user.getSkillLevel(Skills.ENCHANTING) >= skillRequirement && gui.p.getLevel() >= XPRequired;
}
private static boolean itemValid(ItemStack item) {
try {
- ComplexItem.Type type = ComplexItemStack.of(item).getComplexItem().getType();
- return item.getType() != Material.AIR && ComplexEnchantment.getRegisteredEnchants()
+ ComplexItem.Type type = ComplexItem.of(item).getType();
+ return item.getType() != Material.AIR && !ComplexEnchantment.getRegisteredEnchants()
.stream()
.filter(complexEnchantment ->
- complexEnchantment.getTypes().contains(type)).toList().size() > 0;
+ complexEnchantment.getTypes().contains(type)).toList().isEmpty();
} catch (NullPointerException e) {
return false;
}
@@ -275,8 +281,8 @@ private static int combineEnchantLevels(int maxLevel, int enchantLevel1, int enc
return Math.min(maxLevel, result);
}
- public static GUI getGui(Player p, Block block) {
- return new EnchantGUIBuilder(GUITypes.ENCHANT, p, block)
+ public static Gui getGui(Player p, Block block) {
+ return new EnchantGuiBuilder(p, block)
.setStructure(
"# # # # # $ $ 1 #",
"# # # # # $ # # #",
@@ -285,8 +291,28 @@ public static GUI getGui(Player p, Block block) {
"# # # # # ^ ^ 3 #",
"# # # # C B # # #"
)
- .addIngredient('E', new SlotElement.VISlotElement(VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_ITEM_KEY + p.getName()), 1), 0, new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE)))
- .addIngredient('F', new SlotElement.VISlotElement(VirtualInventoryManager.getInstance().getOrCreate(Util.constantUUID(ENCHANT_GUI_FUEL_KEY + p.getName()), 1), 0, new ItemBuilder(Material.BLUE_STAINED_GLASS_PANE)))
+ .addIngredient('E', new SlotElement.InventorySlotElement(VirtualInventoryManager.getInstance()
+ .getOrCreate(Util.constantUUID(ENCHANT_GUI_ITEM_KEY + p.getName()), 1), 0,
+ new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE)
+ .setDisplayName(new AdventureComponentWrapper(
+ Component.text("Enchanting Slot").color(NamedTextColor.LIGHT_PURPLE)))
+ .setLore(List.of(
+ new AdventureComponentWrapper(
+ Component.text("The enchanting table funnels its energy through this slot, adding mystical properties to the item.")
+ .color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC)
+ ),
+ new AdventureComponentWrapper(Component.text("")),
+ new AdventureComponentWrapper(
+ Component.text("→ Place an item here to enchant it.").color(NamedTextColor.YELLOW)
+ )
+ ))))
+ .addIngredient('F', new SlotElement.InventorySlotElement(VirtualInventoryManager.getInstance()
+ .getOrCreate(Util.constantUUID(ENCHANT_GUI_FUEL_KEY + p.getName()), 1), 0,
+ new ItemBuilder(Material.BLUE_STAINED_GLASS_PANE)
+ .setDisplayName(new AdventureComponentWrapper(
+ Component.text("Enchant Fuel").color(NamedTextColor.BLUE)))
+ .setLore(List.of(new AdventureComponentWrapper(
+ Component.text("→ Place an item here to use it as enchant fuel").color(NamedTextColor.YELLOW))))))
.addIngredient('R', new ItemBuilder(Material.RED_STAINED_GLASS_PANE).setDisplayName(""))
.addIngredient('1', new EnchantItem(1, 0))
.addIngredient('2', new EnchantItem(2, 10))
@@ -299,4 +325,6 @@ public static GUI getGui(Player p, Block block) {
.addIngredient('C', new CloseItem())
.build();
}
+
+ interface Enchanting extends Gui.Builder {}
}
diff --git a/src/main/java/me/zenox/evocraft/gui/GUITypes.java b/src/main/java/me/zenox/evocraft/gui/GUITypes.java
deleted file mode 100644
index 2be3ebf..0000000
--- a/src/main/java/me/zenox/evocraft/gui/GUITypes.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package me.zenox.evocraft.gui;
-
-public class GUITypes {
-
- public static EnchantGUIType ENCHANT = new EnchantGUIType();
-}
diff --git a/src/main/java/me/zenox/evocraft/gui/item/BookshelfItem.java b/src/main/java/me/zenox/evocraft/gui/item/BookshelfItem.java
index 5bf74f4..eebbc98 100644
--- a/src/main/java/me/zenox/evocraft/gui/item/BookshelfItem.java
+++ b/src/main/java/me/zenox/evocraft/gui/item/BookshelfItem.java
@@ -1,9 +1,9 @@
package me.zenox.evocraft.gui.item;
-import de.studiocode.invui.item.ItemProvider;
-import de.studiocode.invui.item.builder.ItemBuilder;
-import de.studiocode.invui.item.impl.controlitem.ControlItem;
-import me.zenox.evocraft.gui.EnchantingGUI;
+import xyz.xenondevs.invui.item.ItemProvider;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
+import xyz.xenondevs.invui.item.impl.controlitem.ControlItem;
+import me.zenox.evocraft.gui.EnchantingGui;
import me.zenox.evocraft.util.Util;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -17,12 +17,12 @@
/**
* Bookshelf Counter Item for EnchantingTable
*/
-public class BookshelfItem extends ControlItem {
+public class BookshelfItem extends ControlItem {
- private EnchantingGUI gui;
+ private EnchantingGui gui;
@Override
- public ItemProvider getItemProvider(EnchantingGUI gui) {
+ public ItemProvider getItemProvider(EnchantingGui gui) {
this.gui = gui;
int bookshelfPower = 0;
for (Block block : Util.getNearbyBlocks(gui.getETable().getLocation(), 5, 5))
diff --git a/src/main/java/me/zenox/evocraft/gui/item/BooleanItem.java b/src/main/java/me/zenox/evocraft/gui/item/BooleanItem.java
index e9a4479..e30370c 100644
--- a/src/main/java/me/zenox/evocraft/gui/item/BooleanItem.java
+++ b/src/main/java/me/zenox/evocraft/gui/item/BooleanItem.java
@@ -1,9 +1,9 @@
package me.zenox.evocraft.gui.item;
-import de.studiocode.invui.item.ItemProvider;
-import de.studiocode.invui.item.builder.ItemBuilder;
-import de.studiocode.invui.item.impl.controlitem.ControlItem;
-import me.zenox.evocraft.gui.EnchantingGUI;
+import xyz.xenondevs.invui.item.ItemProvider;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
+import xyz.xenondevs.invui.item.impl.controlitem.ControlItem;
+import me.zenox.evocraft.gui.EnchantingGui;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@@ -15,34 +15,34 @@
/**
* Item that represents a boolean and changes based on boolean
*/
-public class BooleanItem extends ControlItem {
+public class BooleanItem extends ControlItem {
- private Predicate supplier;
+ private final Predicate supplier;
private ItemProvider trueItem = new ItemBuilder(Material.GREEN_STAINED_GLASS_PANE).setDisplayName("§r");
private ItemProvider falseItem = new ItemBuilder(Material.RED_STAINED_GLASS_PANE).setDisplayName("§r");
- public BooleanItem(Predicate supplier, ItemProvider trueItem, ItemProvider falseItem){
+ public BooleanItem(Predicate supplier, ItemProvider trueItem, ItemProvider falseItem){
super();
this.supplier = supplier;
this.trueItem = trueItem;
this.falseItem = falseItem;
}
- public BooleanItem(Predicate supplier, ItemProvider trueItem){
+ public BooleanItem(Predicate supplier, ItemProvider trueItem){
super();
this.supplier = supplier;
this.trueItem = trueItem;
}
- public BooleanItem(Predicate supplier){
+ public BooleanItem(Predicate supplier){
super();
this.supplier = supplier;
}
- private EnchantingGUI gui;
+ private EnchantingGui gui;
@Override
- public ItemProvider getItemProvider(EnchantingGUI gui) {
+ public ItemProvider getItemProvider(EnchantingGui gui) {
this.gui = gui;
return supplier.test(gui) ? trueItem : falseItem;
}
diff --git a/src/main/java/me/zenox/evocraft/gui/item/ClassItem.java b/src/main/java/me/zenox/evocraft/gui/item/ClassItem.java
new file mode 100644
index 0000000..fc014d1
--- /dev/null
+++ b/src/main/java/me/zenox/evocraft/gui/item/ClassItem.java
@@ -0,0 +1,46 @@
+package me.zenox.evocraft.gui.item;
+
+import xyz.xenondevs.invui.item.ItemProvider;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
+import xyz.xenondevs.invui.item.impl.AbstractItem;
+import xyz.xenondevs.invui.window.Window;
+import me.zenox.evocraft.data.TranslatableList;
+import me.zenox.evocraft.data.TranslatableText;
+import me.zenox.evocraft.gameclass.GameClass;
+import me.zenox.evocraft.util.Util;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.ItemFlag;
+import org.jetbrains.annotations.NotNull;
+
+public class ClassItem extends AbstractItem {
+ private final GameClass gameClass;
+ private final TranslatableText NAME;
+ private final TranslatableList LORE;
+
+ public ClassItem(GameClass gameClass){
+ super();
+ this.gameClass = gameClass;
+ this.NAME = new TranslatableText(TranslatableText.Type.GUI + "-class-action-title-" + gameClass.name().toLowerCase());
+ this.LORE = new TranslatableList(TranslatableText.Type.GUI + "-class-action-lore-" + gameClass.name().toLowerCase());
+ }
+
+ @Override
+ public ItemProvider getItemProvider() {
+ return new ItemBuilder(gameClass.icon()).setDisplayName(NAME.toString()).setLegacyLore(LORE.getList()).addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ }
+
+ @Override
+ public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
+ // set the class of a player
+ Util.sendMessage(player, "You have selected the " + gameClass.name() + " class!");
+ GameClass.setClass(player, gameClass);
+ for (Window window : getWindows()) {
+ if(window.getCurrentViewer().equals(player)){
+ window.close();
+ }
+ }
+ }
+}
+
diff --git a/src/main/java/me/zenox/evocraft/gui/item/CloseItem.java b/src/main/java/me/zenox/evocraft/gui/item/CloseItem.java
index 2652a72..b76a1fb 100644
--- a/src/main/java/me/zenox/evocraft/gui/item/CloseItem.java
+++ b/src/main/java/me/zenox/evocraft/gui/item/CloseItem.java
@@ -1,25 +1,25 @@
package me.zenox.evocraft.gui.item;
-import de.studiocode.invui.gui.impl.SimpleGUI;
-import de.studiocode.invui.item.ItemProvider;
-import de.studiocode.invui.item.builder.ItemBuilder;
-import de.studiocode.invui.item.impl.controlitem.ControlItem;
-import de.studiocode.invui.window.Window;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;
+import xyz.xenondevs.invui.gui.AbstractGui;
+import xyz.xenondevs.invui.item.ItemProvider;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
+import xyz.xenondevs.invui.item.impl.controlitem.ControlItem;
+import xyz.xenondevs.invui.window.Window;
/**
* "Empty" item that can be replaced with another item via clicking on it
*/
-public class CloseItem extends ControlItem {
+public class CloseItem extends ControlItem {
- private SimpleGUI gui;
+ private AbstractGui gui;
@Override
- public ItemProvider getItemProvider(SimpleGUI gui) {
+ public ItemProvider getItemProvider(AbstractGui gui) {
this.gui = gui;
return new ItemBuilder(Material.BARRIER).setDisplayName("§cClose Menu");
}
@@ -29,7 +29,7 @@ public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @N
for (Window window :
getWindows()) {
if(window.getCurrentViewer().equals(player)){
- window.closeForViewer();
+ window.close();
}
}
}
diff --git a/src/main/java/me/zenox/evocraft/gui/item/EmptyItem.java b/src/main/java/me/zenox/evocraft/gui/item/EmptyItem.java
index 67fa81a..a782197 100644
--- a/src/main/java/me/zenox/evocraft/gui/item/EmptyItem.java
+++ b/src/main/java/me/zenox/evocraft/gui/item/EmptyItem.java
@@ -1,8 +1,8 @@
package me.zenox.evocraft.gui.item;
-import de.studiocode.invui.item.ItemProvider;
-import de.studiocode.invui.item.builder.ItemBuilder;
-import de.studiocode.invui.item.impl.BaseItem;
+import xyz.xenondevs.invui.item.ItemProvider;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
+import xyz.xenondevs.invui.item.impl.AbstractItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@@ -13,7 +13,7 @@
/**
* "Empty" item that can be replaced with another item via clicking on it
*/
-public class EmptyItem extends BaseItem {
+public class EmptyItem extends AbstractItem {
private ItemStack item = new ItemStack(Material.AIR);
diff --git a/src/main/java/me/zenox/evocraft/gui/item/EnchantItem.java b/src/main/java/me/zenox/evocraft/gui/item/EnchantItem.java
index f4518d9..94a7716 100644
--- a/src/main/java/me/zenox/evocraft/gui/item/EnchantItem.java
+++ b/src/main/java/me/zenox/evocraft/gui/item/EnchantItem.java
@@ -1,18 +1,18 @@
package me.zenox.evocraft.gui.item;
-import de.studiocode.invui.item.ItemProvider;
-import de.studiocode.invui.item.builder.ItemBuilder;
-import de.studiocode.invui.item.impl.controlitem.ControlItem;
+import xyz.xenondevs.invui.item.ItemProvider;
+import xyz.xenondevs.invui.item.builder.ItemBuilder;
+import xyz.xenondevs.invui.item.impl.controlitem.ControlItem;
import me.zenox.evocraft.data.TranslatableList;
import me.zenox.evocraft.data.TranslatableText;
-import me.zenox.evocraft.gui.EnchantingGUI;
+import me.zenox.evocraft.gui.EnchantingGui;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;
-public class EnchantItem extends ControlItem {
+public class EnchantItem extends ControlItem {
private final int level;
private final int skillreq;
@@ -27,17 +27,17 @@ public EnchantItem(int level, int skillreq){
this.LORE = new TranslatableList(TranslatableText.Type.GUI + "-enchant-action-lore-" + level);
}
- private EnchantingGUI gui;
+ private EnchantingGui gui;
@Override
- public ItemProvider getItemProvider(EnchantingGUI gui) {
+ public ItemProvider getItemProvider(EnchantingGui gui) {
this.gui = gui;
return new ItemBuilder(Material.EXPERIENCE_BOTTLE).setDisplayName(NAME.toString()).setLegacyLore(LORE.getList()).setAmount(level);
}
@Override
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
- if(EnchantingGUI.enchantValid(gui, level, getXPRequired())) gui.enchantItem(level, getXPRequired());
+ if(EnchantingGui.enchantValid(gui, level, getXPRequired())) gui.enchantItem(level, getXPRequired());
}
public int getXPRequired(){
diff --git a/src/main/java/me/zenox/evocraft/item/ComplexItem.java b/src/main/java/me/zenox/evocraft/item/ComplexItem.java
index 8fc6a4e..181308d 100644
--- a/src/main/java/me/zenox/evocraft/item/ComplexItem.java
+++ b/src/main/java/me/zenox/evocraft/item/ComplexItem.java
@@ -1,10 +1,10 @@
package me.zenox.evocraft.item;
-import com.archyx.aureliumskills.stats.Stat;
import com.google.common.primitives.Ints;
+import dev.aurelium.auraskills.api.stat.Stats;
import me.zenox.evocraft.EvoCraft;
import me.zenox.evocraft.abilities.Ability;
-import me.zenox.evocraft.abilities.ItemAbility;
+import me.zenox.evocraft.abilities.itemabilities.ItemAbility;
import me.zenox.evocraft.attribute.AttributeModifier;
import me.zenox.evocraft.data.TranslatableList;
import me.zenox.evocraft.data.TranslatableText;
@@ -15,6 +15,8 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.persistence.PersistentDataContainer;
+import org.bukkit.persistence.PersistentDataType;
import java.io.Serializable;
import java.util.ArrayList;
@@ -25,7 +27,7 @@
@SuppressWarnings("UnstableApiUsage")
public class ComplexItem {
- public static final List itemRegistry = new ArrayList<>();
+ public static final HashMap itemRegistry = new HashMap<>();
public static final NamespacedKey GLOBAL_ID = new NamespacedKey(EvoCraft.getPlugin(), "evocraft");
public static final NamespacedKey GLOW_ID = new NamespacedKey(EvoCraft.getPlugin(), "glow");
@@ -41,15 +43,15 @@ public class ComplexItem {
private final Type type;
private final Material material;
private final ItemMeta meta;
- private final Map stats;
- private final List abilities;
+ private final Map stats;
+ private final List> abilities;
private final HashMap variableMap = new HashMap<>();
private final List attributeModifiers;
private String skullURL;
- public ComplexItem(String id, Boolean unique, Boolean glow, Rarity rarity, Type type, Material material, Map stats, List abilities, HashMap variableMap, List attributeModifiers) {
+ public ComplexItem(String id, Boolean unique, Boolean glow, Rarity rarity, Type type, Material material, Map stats, List> abilities, HashMap variableMap, List attributeModifiers) {
this.id = id;
this.name = new TranslatableText(TranslatableText.Type.ITEM_NAME + "-" + id);
this.lore = new TranslatableList(TranslatableText.Type.ITEM_LORE + "-" + id);
@@ -71,15 +73,15 @@ public ComplexItem(String id, Boolean unique, Boolean glow, Rarity rarity, Type
register(false);
}
- public ComplexItem(String id, Boolean unique, Rarity rarity, Type type, Material material, Map stats, List abilities) {
+ public ComplexItem(String id, Boolean unique, Rarity rarity, Type type, Material material, Map stats, List> abilities) {
this(id, unique, false, rarity, type, material, stats, abilities, new HashMap<>(), new ArrayList<>());
}
- public ComplexItem(String id, Rarity rarity, Type type, Material material, Map stats, List abilities) {
+ public ComplexItem(String id, Rarity rarity, Type type, Material material, Map stats, List> abilities) {
this(id, false, rarity, type, material, stats, abilities);
}
- public ComplexItem(String id, Rarity rarity, Type type, Material material, Map stats) {
+ public ComplexItem(String id, Rarity rarity, Type type, Material material, Map stats) {
this(id, false, rarity, type, material, stats, List.of());
}
@@ -87,7 +89,7 @@ public ComplexItem(String id, Rarity rarity, Type type, Material material) {
this(id, false, rarity, type, material, Map.of(), List.of());
}
- public ComplexItem(ItemSettings settings) {
+ public ComplexItem(ItemSettings settings, boolean override) {
this.name = new TranslatableText(TranslatableText.Type.ITEM_NAME + "-" + settings.getId());
this.id = settings.getId();
this.lore = new TranslatableList(TranslatableText.Type.ITEM_LORE + "-" + id);
@@ -106,46 +108,35 @@ public ComplexItem(ItemSettings settings) {
this.variableMap.putAll(settings.getVariableMap());
this.attributeModifiers = settings.getAttributeModifiers();
- register(false);
+ register(override);
}
- protected ComplexItem(ItemSettings settings, boolean override) {
- this.name = new TranslatableText(TranslatableText.Type.ITEM_NAME + "-" + settings.getId());
- this.id = settings.getId();
- this.lore = new TranslatableList(TranslatableText.Type.ITEM_LORE + "-" + id);
- this.key = new NamespacedKey(EvoCraft.getPlugin(), id);
- String str = String.valueOf(Math.abs(id.hashCode()));
- this.customModelData = Ints.tryParse(str.substring(0, Math.min(7, str.length())));
- this.unique = settings.isUnique();
- this.glow = settings.doesGlow();
- this.rarity = settings.getRarity();
- this.type = settings.getType();
- this.material = settings.getMaterial();
- this.meta = settings.getMeta();
- this.stats = settings.getStats();
- this.skullURL = "";
- this.abilities = settings.getAbilities() == null ? new ArrayList<>() : new ArrayList<>(settings.getAbilities());
- this.variableMap.putAll(settings.getVariableMap());
- this.attributeModifiers = settings.getAttributeModifiers();
+ public ComplexItem(ItemSettings settings) {
+ this(settings, false);
+ }
- register(true);
+ /**
+ * Faster, more streamlined method to fetch the ComplexItem attribute without having to read or update ComplexItemMeta
+ *
+ * @param item The item to get the ComplexItem from
+ * @return The ComplexItem object of the item
+ */
+ public static ComplexItem of(ItemStack item) {
+ if (item == null) return null;
+ if (item.getItemMeta() == null) return VanillaItem.of(item.getType());
+ PersistentDataContainer container = item.getItemMeta().getPersistentDataContainer();
+ if (container.has(GLOBAL_ID, PersistentDataType.STRING))
+ return itemRegistry.get(container.get(GLOBAL_ID, PersistentDataType.STRING));
+ else return VanillaItem.of(item.getType());
}
private void register(boolean override){
- for (ComplexItem item:
- new ArrayList<>(itemRegistry)) {
- if (item.getId().equalsIgnoreCase(id)) {
- if (!override) {
- Util.logToConsole("Duplicate ComplexItem ID: " + id + " | Exact Match: " + item.equals(this));
- throw new IllegalArgumentException("ComplexItem ID cannot be duplicate");
- } else {
- itemRegistry.remove(item);
- break;
- }
- }
+ if (itemRegistry.containsKey(id) && !override) {
+ Util.logToConsole("Duplicate ComplexItem ID: " + id + " | Exact Match: " + itemRegistry.get(id).equals(this));
+ throw new IllegalArgumentException("ComplexItem ID cannot be duplicate");
}
- itemRegistry.add(this);
+ itemRegistry.put(id, this);
}
@@ -159,7 +150,7 @@ public ItemStack getItemStack(Integer amount) {
}
protected void writeAbilityLore(List lore) {
- for (Ability ability : this.abilities) {
+ for (Ability> ability : this.abilities) {
lore.add("");
lore.add(ChatColor.GOLD + "Ability: " + ability.getDisplayName() + ChatColor.YELLOW + ChatColor.BOLD + " " + (ability instanceof ItemAbility ? ((ItemAbility) ability).getAction().getName() : ""));
lore.addAll(ability.getLore());
@@ -216,7 +207,7 @@ public Type getType() {
return this.type;
}
- public Map getStats() {
+ public Map getStats() {
return stats;
}
@@ -232,7 +223,7 @@ public void setSkullURL(String URL) {
this.skullURL = URL;
}
- public List getAbilities() {
+ public List> getAbilities() {
return this.abilities;
}
diff --git a/src/main/java/me/zenox/evocraft/item/ComplexItemMeta.java b/src/main/java/me/zenox/evocraft/item/ComplexItemMeta.java
index 4a28d1f..f6f86bd 100644
--- a/src/main/java/me/zenox/evocraft/item/ComplexItemMeta.java
+++ b/src/main/java/me/zenox/evocraft/item/ComplexItemMeta.java
@@ -1,19 +1,20 @@
package me.zenox.evocraft.item;
-import com.archyx.aureliumskills.modifier.ModifierType;
-import com.archyx.aureliumskills.modifier.StatModifier;
-import com.archyx.aureliumskills.stats.Stats;
+import dev.aurelium.auraskills.api.AuraSkillsBukkit;
+import dev.aurelium.auraskills.api.item.ItemManager;
+import dev.aurelium.auraskills.api.item.ModifierType;
+import dev.aurelium.auraskills.api.stat.StatModifier;
+import dev.aurelium.auraskills.api.stat.Stats;
import me.zenox.evocraft.EvoCraft;
import me.zenox.evocraft.abilities.Ability;
-import me.zenox.evocraft.abilities.FullSetArmorAbility;
-import me.zenox.evocraft.abilities.ItemAbility;
+import me.zenox.evocraft.abilities.itemabilities.FullSetArmorAbility;
+import me.zenox.evocraft.abilities.itemabilities.ItemAbility;
import me.zenox.evocraft.attribute.AttributeModifier;
import me.zenox.evocraft.attribute.types.AureliumAttribute;
import me.zenox.evocraft.enchant.ComplexEnchantment;
import me.zenox.evocraft.persistence.ArrayListType;
import me.zenox.evocraft.persistence.SerializedPersistentType;
import me.zenox.evocraft.util.Romans;
-import me.zenox.evocraft.util.Util;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute;
@@ -41,7 +42,6 @@
*/
public class ComplexItemMeta {
- public static final NamespacedKey ABILITY_ID = new NamespacedKey(EvoCraft.getPlugin(), "ability");
public static final String VAR_PREFIX = "var_";
public static final String ATTRIBUTE_BASE_KEY = "base";
public static final VariableType RARITY_VAR = new VariableType<>("rarity", new LoreEntry("rarity", List.of("Rarity Lore")), VariableType.Priority.BELOW, (loreEntry, variable) -> loreEntry.setLore(List.of(((ComplexItem.Rarity) variable.getValue()).color() + ((ComplexItem.Rarity) variable.getValue()).getName())));
@@ -52,22 +52,19 @@ public class ComplexItemMeta {
})), VariableType.Priority.BELOW, (loreEntry, variable) -> loreEntry.setLore(List.of(((ComplexItem.Type) variable.getValue()).getName())));
public static final NamespacedKey ENCHANT_KEY = new NamespacedKey(EvoCraft.getPlugin(), "complexEnchants");
private static final NamespacedKey ATTRIBUTE_KEY = new NamespacedKey(EvoCraft.getPlugin(), "attributes");
- private List abilities;
+
+ private static final ItemManager itemManager = AuraSkillsBukkit.get().getItemManager();
+
private final List variableList = new ArrayList<>();
private HashMap complexEnchantments = new HashMap<>();
private List modifierList = new ArrayList<>();
private final ComplexItemStack complexItemStack;
- public ComplexItemMeta(ComplexItemStack complexItemStack, List abilities) {
- this.abilities = abilities == null ? new ArrayList<>() : new ArrayList<>(abilities);
+ public ComplexItemMeta(ComplexItemStack complexItemStack) {
this.complexItemStack = complexItemStack;
this.read();
}
- public ComplexItemMeta(ComplexItemStack complexItemStack) {
- this(complexItemStack, complexItemStack.getComplexItem().getAbilities());
- }
-
/**
* Updates the ItemStack to match the current ComplexItemMeta
*/
@@ -95,7 +92,7 @@ public void updateItem() {
Arrays.stream(Attribute.values()).forEach(meta::removeAttributeModifier);
item.setItemMeta(meta);
- Arrays.stream(Stats.values()).forEach(stats -> item.setItemMeta(Util.removeAureliumModifier(item, ((ComplexItem.Type) getVariable(TYPE_VAR).getValue()).isWearable() ? ModifierType.ARMOR : ModifierType.ITEM, stats).getItemMeta()));
+ Arrays.stream(Stats.values()).forEach(stats -> item.setItemMeta(itemManager.removeStatModifier(item, ((ComplexItem.Type) getVariable(TYPE_VAR).getValue()).isWearable() ? ModifierType.ARMOR : ModifierType.ITEM, stats).getItemMeta()));
meta = item.getItemMeta();
@@ -133,7 +130,7 @@ public void updateItem() {
}
// Write ComplexEnchants
- dataContainer.set(ENCHANT_KEY, new SerializedPersistentType(), complexEnchMap);
+ dataContainer.set(ENCHANT_KEY, new SerializedPersistentType<>(), complexEnchMap);
// Clear vanilla enchantments
for (Enchantment enchant:
@@ -159,7 +156,6 @@ public void updateItem() {
// Write Abilities
writeAbilityLore(lore);
- dataContainer.set(ABILITY_ID, new ArrayListType(), new ArrayList<>(abilities.stream().map(Ability::getId).toList()));
writeVariables(VariableType.Priority.BELOW_ABILITIES, dataContainer, lore, true);
@@ -257,7 +253,7 @@ private void writeVariables(VariableType.Priority priority, PersistentDataContai
}
private void writeAbilityLore(LoreBuilder loreBuilder) {
- for (Ability ability : this.abilities) {
+ for (Ability> ability : complexItemStack.getComplexItem().getAbilities()) {
List lore = new ArrayList<>();
lore.add(ChatColor.GOLD + (ability.isPassive() ? "Passive " : "") + (ability instanceof FullSetArmorAbility ? "Full Set " : "") + "Ability: " + ability.getDisplayName() + ChatColor.YELLOW + ChatColor.BOLD + " " + (ability instanceof ItemAbility ? ((ItemAbility) ability).getAction().getName() : ""));
lore.addAll(ability.getLore());
@@ -287,7 +283,7 @@ private void writeAbilityLore(LoreBuilder loreBuilder) {
// Read AureliumSkills Modifiers
for(StatModifier modifier :
- Util.getAureliumModifiers(stack.getItem(),
+ itemManager.getStatModifiers(stack.getItem(),
((ComplexItem.Type) meta.getVariable(ComplexItemMeta.TYPE_VAR).getValue()).isWearable() ? ModifierType.ARMOR : ModifierType.ITEM)){
modifiers.add(AttributeModifier.of(modifier));
}
@@ -358,10 +354,6 @@ public List getVariableList() {
return variableList;
}
- public List getAbilities() {
- return abilities;
- }
-
public List getModifierList() {
return modifierList;
}
diff --git a/src/main/java/me/zenox/evocraft/item/ComplexItemStack.java b/src/main/java/me/zenox/evocraft/item/ComplexItemStack.java
index e35bf59..7ab7243 100644
--- a/src/main/java/me/zenox/evocraft/item/ComplexItemStack.java
+++ b/src/main/java/me/zenox/evocraft/item/ComplexItemStack.java
@@ -1,7 +1,9 @@
package me.zenox.evocraft.item;
-import com.archyx.aureliumskills.api.AureliumAPI;
-import com.archyx.aureliumskills.stats.Stat;
+import dev.aurelium.auraskills.api.AuraSkillsBukkit;
+import dev.aurelium.auraskills.api.item.ItemManager;
+import dev.aurelium.auraskills.api.item.ModifierType;
+import dev.aurelium.auraskills.api.stat.Stats;
import me.zenox.evocraft.EvoCraft;
import me.zenox.evocraft.abilities.Ability;
import me.zenox.evocraft.enchant.ComplexEnchantment;
@@ -17,7 +19,10 @@
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
/**
* Class that represents a "custom" ItemStack.
@@ -35,7 +40,9 @@ public class ComplexItemStack {
private ItemStack item;
private ComplexItemMeta complexMeta;
- private String skullURL;
+ private final String skullURL;
+
+ private final static ItemManager itemManager = AuraSkillsBukkit.get().getItemManager();
public ComplexItemStack(ComplexItem complexItem, int amount) {
this(complexItem, new ItemStack(complexItem.getMaterial()));
@@ -76,7 +83,7 @@ public static ComplexItemStack of(@NotNull ItemStack item) {
Map vanillaEnchantments = item.getEnchantments();
- ComplexItem complexItem = Objects.requireNonNullElse(ItemRegistry.byItem(item), VanillaItem.of(item.getType()));
+ ComplexItem complexItem = Objects.requireNonNullElse(ComplexItem.of(item), VanillaItem.of(item.getType()));
ComplexItemStack cItem = new ComplexItemStack(complexItem, item);
// add vanilla variables???
@@ -126,8 +133,9 @@ private ItemStack buildItem(int amount) {
item.setItemMeta(meta);
// Set stats and clone
- for (Map.Entry entry : complexItem.getStats().entrySet()) {
- item = complexItem.getType().isWearable() ? AureliumAPI.addArmorModifier(item, entry.getKey(), entry.getValue(), false) : AureliumAPI.addItemModifier(item, entry.getKey(), entry.getValue(), false);
+ for (Map.Entry entry : complexItem.getStats().entrySet()) {
+ ModifierType type = complexItem.getType().isWearable() ? ModifierType.ARMOR : ModifierType.ITEM;
+ item = itemManager.addStatModifier(item, type, entry.getKey(), entry.getValue(), false);
}
meta = item.getItemMeta();
@@ -173,8 +181,8 @@ public NamespacedKey getKey() {
return this.complexItem.getKey();
}
- public List getAbilities() {
- return this.complexMeta.getAbilities();
+ public List> getAbilities() {
+ return this.complexItem.getAbilities();
}
public ComplexItem getComplexItem() {
diff --git a/src/main/java/me/zenox/evocraft/item/ItemRegistry.java b/src/main/java/me/zenox/evocraft/item/ItemRegistry.java
index d50f50b..e4a767b 100644
--- a/src/main/java/me/zenox/evocraft/item/ItemRegistry.java
+++ b/src/main/java/me/zenox/evocraft/item/ItemRegistry.java
@@ -1,11 +1,15 @@
package me.zenox.evocraft.item;
-import com.archyx.aureliumskills.stats.Stats;
-import me.zenox.evocraft.abilities.*;
+import dev.aurelium.auraskills.api.stat.Stats;
+import me.zenox.evocraft.abilities.AbilityRegistry;
+import me.zenox.evocraft.abilities.ElementalFlux;
+import me.zenox.evocraft.abilities.itemabilities.specific.Crucify;
+import me.zenox.evocraft.abilities.itemabilities.specific.EmberAttune;
+import me.zenox.evocraft.abilities.itemabilities.specific.Psychic;
+import me.zenox.evocraft.abilities.itemabilities.specific.Transcendence;
import me.zenox.evocraft.attribute.AttributeRegistry;
-import me.zenox.evocraft.gui.EnchantingGUI;
+import me.zenox.evocraft.gui.EnchantingGui;
import me.zenox.evocraft.item.basicitems.CorruptPearl;
-import me.zenox.evocraft.item.basicitems.GardenerSapling;
import me.zenox.evocraft.item.basicitems.RavagerSkin;
import me.zenox.evocraft.item.basicitems.TormentedSoul;
import me.zenox.evocraft.util.Util;
@@ -15,20 +19,13 @@
import org.bukkit.Material;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.enchantments.Enchantment;
-import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
-import org.bukkit.persistence.PersistentDataContainer;
-import org.bukkit.persistence.PersistentDataType;
-import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
public class ItemRegistry {
-
- public static final ComplexItem GARDENER_SAPLING = new GardenerSapling();
public static final ComplexItem ENCHANTED_MAGMA_BLOCK = new ComplexItem(new ItemSettings()
.id("enchanted_magma_block")
.material(Material.MAGMA_BLOCK));
@@ -224,7 +221,7 @@ public class ItemRegistry {
.modifier(AttributeRegistry.ATTACK_DAMAGE, 15)
.modifier(AttributeRegistry.ATTACK_SPEED, -3)
.modifier(AttributeRegistry.WISDOM, 50)
- .abilities(AbilityRegistry.VOID_WARP, AbilityRegistry.VOIDULAR_RECALL)
+ .abilities(AbilityRegistry.VOID_WARP)
.rarity(ComplexItem.Rarity.EPIC)
.material(Material.NETHERITE_SHOVEL)
.type(ComplexItem.Type.STAFF)
@@ -342,7 +339,7 @@ public class ItemRegistry {
.rarity(ComplexItem.Rarity.COMMON)
.type(ComplexItem.Type.ENCHANTING_FUEL)
.glow()
- .variable(EnchantingGUI.ENCHANT_FUEL_VAR, 5));
+ .variable(EnchantingGui.ENCHANT_FUEL_VAR, 5));
public static final ComplexItem INFUSED_ORBITEX = new ComplexItem(new ItemSettings()
.id("infused_orbitex")
@@ -350,7 +347,7 @@ public class ItemRegistry {
.rarity(ComplexItem.Rarity.UNCOMMON)
.type(ComplexItem.Type.ENCHANTING_FUEL)
.glow()
- .variable(EnchantingGUI.ENCHANT_FUEL_VAR, 15));
+ .variable(EnchantingGui.ENCHANT_FUEL_VAR, 15));
public static final ComplexItem CREATIVE_MIND = new ComplexItem((new ItemSettings()
.id("creative_mind")
@@ -388,50 +385,6 @@ public class ItemRegistry {
.stat(Stats.STRENGTH, 50d)
.ability(AbilityRegistry.TERRA_STRIKE));
- public static final ComplexItem BURNING_HELMET = new ComplexItem(new ItemSettings()
- .id("burning_helmet")
- .material(Material.LEATHER_HELMET)
- .rarity(ComplexItem.Rarity.RARE)
- .type(ComplexItem.Type.HELMET)
- .modifier(AttributeRegistry.HEALTH, 5)
- .modifier(AttributeRegistry.MOVEMENT_SPEED, 0.05, AttributeModifier.Operation.ADD_SCALAR)
- .modifier(AttributeRegistry.ARMOR, 4)
- .modifier(AttributeRegistry.ARMOR_TOUGHNESS, 1)
- .abilities(AbilityRegistry.ROARING_FLAME));
-
- public static final ComplexItem BURNING_CHESTPLATE = new ComplexItem(new ItemSettings()
- .id("burning_chestplate")
- .material(Material.LEATHER_CHESTPLATE)
- .rarity(ComplexItem.Rarity.RARE)
- .type(ComplexItem.Type.CHESTPLATE)
- .modifier(AttributeRegistry.HEALTH, 12)
- .modifier(AttributeRegistry.MOVEMENT_SPEED, 0.05, AttributeModifier.Operation.ADD_SCALAR)
- .modifier(AttributeRegistry.ARMOR, 10)
- .modifier(AttributeRegistry.ARMOR_TOUGHNESS, 1)
- .abilities(AbilityRegistry.ROARING_FLAME));
-
- public static final ComplexItem BURNING_LEGGINGS = new ComplexItem(new ItemSettings()
- .id("burning_leggings")
- .material(Material.LEATHER_LEGGINGS)
- .rarity(ComplexItem.Rarity.RARE)
- .type(ComplexItem.Type.LEGGINGS)
- .modifier(AttributeRegistry.HEALTH, 10)
- .modifier(AttributeRegistry.MOVEMENT_SPEED, 0.05, AttributeModifier.Operation.ADD_SCALAR)
- .modifier(AttributeRegistry.ARMOR, 8)
- .modifier(AttributeRegistry.ARMOR_TOUGHNESS, 1)
- .abilities(AbilityRegistry.ROARING_FLAME));
-
- public static final ComplexItem BURNING_BOOTS = new ComplexItem(new ItemSettings()
- .id("burning_boots")
- .material(Material.LEATHER_BOOTS)
- .rarity(ComplexItem.Rarity.RARE)
- .type(ComplexItem.Type.BOOTS)
- .modifier(AttributeRegistry.HEALTH, 5)
- .modifier(AttributeRegistry.MOVEMENT_SPEED, 0.05, AttributeModifier.Operation.ADD_SCALAR)
- .modifier(AttributeRegistry.ARMOR, 3)
- .modifier(AttributeRegistry.ARMOR_TOUGHNESS, 1)
- .abilities(AbilityRegistry.ROARING_FLAME, AbilityRegistry.LAVA_GLIDER));
-
public static final ComplexItem DARKCALLER = new ComplexItem(new ItemSettings()
.id("darkcaller")
.material(Material.BEACON)
@@ -451,18 +404,6 @@ public class ItemRegistry {
.ability(AbilityRegistry.GILDED_CONSUME)
.rarity(ComplexItem.Rarity.RARE));
- public static final ComplexItem START_BUTTON = new ComplexItem(new ItemSettings()
- .id("start_button")
- .material(Material.REDSTONE)
- .ability(AbilityRegistry.START_BUTTON)
- .rarity(ComplexItem.Rarity.MYTHIC));
-
- public static final ComplexItem SOUL_STONE = new ComplexItem(new ItemSettings()
- .id("soul_stone")
- .material(Material.NETHER_STAR)
- .ability(AbilityRegistry.PORTALIZER)
- .rarity(ComplexItem.Rarity.MYTHIC));
-
public static final ComplexItem ARCANE_JEWEL = new ComplexItem(new ItemSettings()
.id("arcane_jewel")
.material(Material.AMETHYST_SHARD)
@@ -711,7 +652,7 @@ public class ItemRegistry {
// Vanilla Items
public static final VanillaItem LAPIS_LAZULI = new VanillaItem(new ItemSettings()
.material(Material.LAPIS_LAZULI)
- .variable(EnchantingGUI.ENCHANT_FUEL_VAR, 1));
+ .variable(EnchantingGui.ENCHANT_FUEL_VAR, 1));
public static final ComplexItem VERTEXICAL_BLADE = new ComplexItem(new ItemSettings()
.id("vertex_blade")
@@ -747,7 +688,7 @@ public class ItemRegistry {
@Deprecated
public static List registerRecipes() {
- for (ComplexItem item : ComplexItem.itemRegistry) {
+ for (ComplexItem item : ComplexItem.itemRegistry.values()) {
registeredRecipes.addAll(item.getRecipes());
}
@@ -769,26 +710,4 @@ public static List registerRecipes() {
public static void registerItems() {
Util.logToConsole(ChatColor.WHITE + "Registering " + ChatColor.GOLD + ComplexItem.itemRegistry.size() + ChatColor.WHITE + " items.");
}
-
- @Nullable
- public static ComplexItem byItem(ItemStack item) {
- try {
- PersistentDataContainer container = Objects.requireNonNull(item.getItemMeta()).getPersistentDataContainer();
- String id = container.get(ComplexItem.GLOBAL_ID, PersistentDataType.STRING);
- return byId(id);
- } catch (NullPointerException e) {
- return null;
- }
- }
-
- @Nullable
- public static ComplexItem byId(String id) {
- for (ComplexItem item : ComplexItem.itemRegistry) {
- if (id == null) return null;
- if (id.equals(item.getId())) {
- return item;
- }
- }
- return null;
- }
}
diff --git a/src/main/java/me/zenox/evocraft/item/ItemSettings.java b/src/main/java/me/zenox/evocraft/item/ItemSettings.java
index 3bb25bd..babdffc 100644
--- a/src/main/java/me/zenox/evocraft/item/ItemSettings.java
+++ b/src/main/java/me/zenox/evocraft/item/ItemSettings.java
@@ -1,6 +1,6 @@
package me.zenox.evocraft.item;
-import com.archyx.aureliumskills.stats.Stat;
+import dev.aurelium.auraskills.api.stat.Stats;
import me.zenox.evocraft.Slot;
import me.zenox.evocraft.abilities.Ability;
import me.zenox.evocraft.attribute.Attribute;
@@ -26,9 +26,9 @@ public class ItemSettings {
private ComplexItem.Type type;
private Material material;
private ItemMeta meta;
- private Map stats;
+ private Map stats;
private String skullURL;
- private List abilities;
+ private List> abilities;
private HashMap variableMap;
private List attributeModifiers;
@@ -47,7 +47,7 @@ public ItemSettings() {
this.attributeModifiers = new ArrayList<>();
}
- public ItemSettings(String id, Boolean unique, Boolean glow, ComplexItem.Rarity rarity, ComplexItem.Type type, Material material, ItemMeta meta, Map stats, String skullURL, List abilities, HashMap variableMap, List attributeModifiers) {
+ public ItemSettings(String id, Boolean unique, Boolean glow, ComplexItem.Rarity rarity, ComplexItem.Type type, Material material, ItemMeta meta, Map stats, String skullURL, List> abilities, HashMap variableMap, List attributeModifiers) {
this.id = id;
this.unique = unique;
this.glow = glow;
@@ -62,7 +62,7 @@ public ItemSettings(String id, Boolean unique, Boolean glow, ComplexItem.Rarity
this.attributeModifiers = attributeModifiers;
}
- public ItemSettings(String id, Boolean unique, Boolean glow, ComplexItem.Rarity rarity, ComplexItem.Type type, Material material, ItemMeta meta, Map stats, String skullURL, List abilities){
+ public ItemSettings(String id, Boolean unique, Boolean glow, ComplexItem.Rarity rarity, ComplexItem.Type type, Material material, ItemMeta meta, Map stats, String skullURL, List> abilities){
this(id, unique, glow, rarity, type, material, meta, stats, skullURL, abilities, new HashMap<>(), new ArrayList<>());
}
@@ -105,7 +105,7 @@ public ItemMeta getMeta() {
return meta;
}
- public Map getStats() {
+ public Map getStats() {
return stats;
}
@@ -113,7 +113,7 @@ public String getSkullURL() {
return skullURL;
}
- public List getAbilities() {
+ public List> getAbilities() {
return abilities;
}
@@ -179,12 +179,12 @@ public ItemSettings attribute(org.bukkit.attribute.Attribute attribute, org.bukk
return this;
}
- public ItemSettings stats(Map stats) {
+ public ItemSettings stats(Map stats) {
this.stats = stats;
return this;
}
- public ItemSettings stat(Stat stat, Double num) {
+ public ItemSettings stat(Stats stat, Double num) {
Attribute attr;
try {
attr = ((Attribute) Attribute.attributeRegistry.stream()
@@ -206,22 +206,22 @@ public ItemSettings skullURL(String skullURL) {
return this;
}
- public ItemSettings abilities(List abilities) {
+ public ItemSettings abilities(List> abilities) {
this.abilities = abilities;
return this;
}
- public ItemSettings abilities(Ability... abilities) {
+ public ItemSettings abilities(Ability>... abilities) {
this.abilities = List.of(abilities);
return this;
}
- public ItemSettings addAbilities(Ability... abilities) {
+ public ItemSettings addAbilities(Ability>... abilities) {
this.abilities.addAll(List.of(abilities));
return this;
}
- public ItemSettings ability(Ability ability) {
+ public ItemSettings ability(Ability> ability) {
this.abilities.add(ability);
return this;
}
diff --git a/src/main/java/me/zenox/evocraft/item/VanillaItem.java b/src/main/java/me/zenox/evocraft/item/VanillaItem.java
index 07af797..61ed918 100644
--- a/src/main/java/me/zenox/evocraft/item/VanillaItem.java
+++ b/src/main/java/me/zenox/evocraft/item/VanillaItem.java
@@ -6,6 +6,7 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -83,7 +84,7 @@ public VanillaItem(Material material) {
* Vanilla item constructor to override the default settings of a vanilla item.
* @param settings The settings to override.
*/
- public VanillaItem(ItemSettings settings) {
+ public VanillaItem(@NotNull ItemSettings settings) {
super(settings.id(settings.getMaterial().getKey().getKey()), true);
if (!settings.getMaterial().isItem()) throw new IllegalArgumentException("Material must have an item form");
for (VanillaItem item : new ArrayList<>(vanillaItemList)) {
diff --git a/src/main/java/me/zenox/evocraft/item/basicitems/CorruptPearl.java b/src/main/java/me/zenox/evocraft/item/basicitems/CorruptPearl.java
index 90fb4f4..b34ac06 100644
--- a/src/main/java/me/zenox/evocraft/item/basicitems/CorruptPearl.java
+++ b/src/main/java/me/zenox/evocraft/item/basicitems/CorruptPearl.java
@@ -3,7 +3,6 @@
import me.zenox.evocraft.EvoCraft;
import me.zenox.evocraft.item.ComplexItem;
-import me.zenox.evocraft.persistence.SerializedPersistentType;
import org.bukkit.*;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.EntityType;
@@ -12,6 +11,7 @@
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.persistence.PersistentDataType;
import java.util.List;
import java.util.Map;
@@ -49,11 +49,11 @@ public void dropEvent(EntityDeathEvent event) {
Enderman specialEnderman = (Enderman) w.spawnEntity(loc.clone().add(Math.sin(r.nextDouble(2) * Math.PI) * r.nextDouble(2), 1, Math.sin(r.nextDouble(2) * Math.PI) * r.nextDouble(2)), EntityType.ENDERMAN);
specialEnderman.setCarriedBlock(Material.END_PORTAL_FRAME.createBlockData());
- specialEnderman.getPersistentDataContainer().set(new NamespacedKey(EvoCraft.getPlugin(), "corrupted"), new SerializedPersistentType<>(), true);
+ specialEnderman.getPersistentDataContainer().set(new NamespacedKey(EvoCraft.getPlugin(), "corrupted"), PersistentDataType.BOOLEAN, true);
}
- boolean isCorrupted = entity.getPersistentDataContainer().has(new NamespacedKey(EvoCraft.getPlugin(), "corrupted"), new SerializedPersistentType<>()) ?
- entity.getPersistentDataContainer().get(new NamespacedKey(EvoCraft.getPlugin(), "corrupted"), new SerializedPersistentType<>()) : false;
+ boolean isCorrupted = entity.getPersistentDataContainer().has(new NamespacedKey(EvoCraft.getPlugin(), "corrupted"), PersistentDataType.BOOLEAN) ?
+ entity.getPersistentDataContainer().get(new NamespacedKey(EvoCraft.getPlugin(), "corrupted"), PersistentDataType.BOOLEAN) : false;
if (isCorrupted) {
event.getDrops().removeIf((ItemStack item) -> item.getType().equals(Material.END_PORTAL_FRAME));
w.dropItemNaturally(loc, CORRUPT_PEARL.getItemStack(1));
diff --git a/src/main/java/me/zenox/evocraft/item/basicitems/GardenerSapling.java b/src/main/java/me/zenox/evocraft/item/basicitems/GardenerSapling.java
deleted file mode 100644
index d3608de..0000000
--- a/src/main/java/me/zenox/evocraft/item/basicitems/GardenerSapling.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package me.zenox.evocraft.item.basicitems;
-
-import me.zenox.evocraft.item.ComplexItem;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.enchantments.Enchantment;
-import org.bukkit.inventory.ItemFlag;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class GardenerSapling extends ComplexItem {
- public GardenerSapling() {
- super("gardener_sapling", Rarity.VERY_SPECIAL, Type.MISC, Material.OAK_SAPLING, Map.of());
-
- List lore = new ArrayList<>();
- lore.add(ChatColor.GRAY + "A sapling, that can when cared for");
- lore.add(ChatColor.GRAY + "can grow into something beautiful.");
- lore.add("");
- lore.add(ChatColor.GRAY + "A thanks to the beta testers who helped along the way.");
- lore.add("");
- lore.add(ChatColor.GRAY + "Issued to: " + ChatColor.YELLOW + "%s");
- lore.add(ChatColor.GRAY + "Issued From: " + ChatColor.YELLOW + "%s");
- lore.add(ChatColor.GRAY + "Date Issued: " + ChatColor.YELLOW + "%s");
- this.getMeta().setLore(lore);
- this.getMeta().addEnchant(Enchantment.DAMAGE_ALL, 1, true);
- this.getMeta().addItemFlags(ItemFlag.HIDE_ENCHANTS);
- }
-}
diff --git a/src/main/java/me/zenox/evocraft/recipe/ComplexChoice.java b/src/main/java/me/zenox/evocraft/recipe/ComplexChoice.java
index 8e4bd8d..a63d028 100644
--- a/src/main/java/me/zenox/evocraft/recipe/ComplexChoice.java
+++ b/src/main/java/me/zenox/evocraft/recipe/ComplexChoice.java
@@ -4,7 +4,6 @@
import com.google.common.collect.ImmutableMap;
import me.zenox.evocraft.item.ComplexItem;
import me.zenox.evocraft.item.ComplexItemStack;
-import me.zenox.evocraft.item.ItemRegistry;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.jetbrains.annotations.NotNull;
@@ -39,7 +38,8 @@ public ComplexChoice(@NotNull Map choices) {
@NotNull
@Override
public ItemStack getItemStack() {
- return new ComplexItemStack(ItemRegistry.byId(((Map.Entry) choices.entrySet().toArray()[0]).getKey()), ((Map.Entry) choices.entrySet().toArray()[0]).getValue()).getItem();
+ return new ComplexItemStack(ComplexItem.itemRegistry.get(((Map.Entry) choices.entrySet().toArray()[0]).getKey()),
+ ((Map.Entry) choices.entrySet().toArray()[0]).getValue()).getItem();
}
public Map getChoices() {
@@ -60,7 +60,7 @@ public ComplexChoice clone() {
@Override
public boolean test(@NotNull ItemStack t) {
for (Map.Entry match : choices.entrySet()) {
- if (ComplexItemStack.of(t).getComplexItem().equals(match.getKey()) && (t.getAmount() == match.getValue() || match.getValue() == -1)) {
+ if (ComplexItem.of(t).equals(match.getKey()) && (t.getAmount() == match.getValue() || match.getValue() == -1)) {
return true;
}
}
diff --git a/src/main/java/me/zenox/evocraft/story/Action.java b/src/main/java/me/zenox/evocraft/story/Action.java
deleted file mode 100644
index 69f3e99..0000000
--- a/src/main/java/me/zenox/evocraft/story/Action.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package me.zenox.evocraft.story;
-
-import org.bukkit.event.Event;
-
-public class Action{
-
-}
diff --git a/src/main/java/me/zenox/evocraft/story/Chapter.java b/src/main/java/me/zenox/evocraft/story/Chapter.java
deleted file mode 100644
index 035117c..0000000
--- a/src/main/java/me/zenox/evocraft/story/Chapter.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package me.zenox.evocraft.story;
-
-import me.zenox.evocraft.EvoCraft;
-import me.zenox.evocraft.data.TranslatableText;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event;
-import org.bukkit.event.Listener;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-/**
- * A chapter is a part of the story. It is a collection of actions that are executed when the chapter starts and ends.
- * @param The event that triggers the chapter.
- * @param The event that triggers the end of the chapter (the event that triggers the next chapter).
- */
-public abstract class Chapter implements Listener {
- private final int id;
- private final TranslatableText name;
- /**
- * Whether the chapter is a "solo" chapter. A solo chapter is a chapter that the player has to perform alone, without any other players, hiding them from all other players.
- */
- private final boolean solo;
-
- public Chapter(int id, boolean solo) {
- this.id = id;
- this.name = new TranslatableText("chapter-" + id);
- this.solo = solo;
- }
-
- private Type getType(int index) {
- Class> clazz = getClass();
- while (clazz != null) {
- Type type = clazz.getGenericSuperclass();
- if (type instanceof ParameterizedType) {
- return ((ParameterizedType) type).getActualTypeArguments()[index];
- }
- clazz = clazz.getSuperclass();
- }
- return null;
- }
-
- /**
- * Method that detects when a chapter should start and executes
- */
- public abstract void onChapterStart(T event);
-
- /**
- * Method that executes when a chapter ends
- */
- public abstract void onChapterEnd(U event);
-
- public void progress(Player player, U event) {
- EvoCraft.getChapterManager().setChapter(player, id + 1);
- onChapterEnd(event);
- EvoCraft.getChapterManager().getChapter(id + 1).onChapterStart(event);
- }
-
- public int getId() {
- return id;
- }
-
- public TranslatableText getName() {
- return name;
- }
-
- public boolean isSolo() {
- return solo;
- }
-}
diff --git a/src/main/java/me/zenox/evocraft/story/ChapterManager.java b/src/main/java/me/zenox/evocraft/story/ChapterManager.java
deleted file mode 100644
index 7f8281c..0000000
--- a/src/main/java/me/zenox/evocraft/story/ChapterManager.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package me.zenox.evocraft.story;
-
-import me.zenox.evocraft.EvoCraft;
-import me.zenox.evocraft.story.chapters.ChapterOne;
-import me.zenox.evocraft.story.chapters.ChapterTwo;
-import me.zenox.evocraft.story.chapters.ChapterZero;
-import me.zenox.evocraft.util.Util;
-import org.bukkit.Bukkit;
-import org.bukkit.NamespacedKey;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.persistence.PersistentDataType;
-import org.bukkit.scheduler.BukkitRunnable;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ChapterManager implements Listener {
- public static NamespacedKey CHAPTER_KEY = new NamespacedKey(EvoCraft.getPlugin(), "chapter");
-
- private EvoCraft plugin;
-
- public List chapters = new ArrayList<>();
-
- static {
- // Runnable that hides players for solo chapters
- new BukkitRunnable(){
- @Override
- public void run() {
- ChapterManager manager = EvoCraft.getPlugin().getChapterManager();
- for(Player p : Bukkit.getOnlinePlayers()){
- try {
- if (manager.getChapter(p).isSolo()) {
- for (Player p2 : Bukkit.getOnlinePlayers()) {
- if (p != p2) {
- p.hidePlayer(EvoCraft.getPlugin(), p2);
- if (!p2.getEffectivePermissions().contains("evocraft.admin"))
- p2.hidePlayer(EvoCraft.getPlugin(), p);
- }
- }
- } else {
- for (Player p2 : Bukkit.getOnlinePlayers()) {
- p.showPlayer(EvoCraft.getPlugin(), p2);
- p2.showPlayer(EvoCraft.getPlugin(), p);
- }
- }
- } catch (NullPointerException e){
- Util.logToConsole("Player " + p.getName() + " has no chapter data!");
- manager.setChapter(p, manager.getChapter(2));
- //p.kickPlayer("You have no chapter data! Please rejoin.");
- }
- }
- }
- }.runTaskTimer(EvoCraft.getPlugin(), 1, 10);
- }
-
- public ChapterManager(EvoCraft plugin) {
- this.plugin = plugin;
- registerChapters();
- Bukkit.getPluginManager().registerEvents(this, plugin);
- }
-
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event) {
- Player player = event.getPlayer();
- Chapter chapter = getChapter(player);
- Util.logToConsole("Player " + player.getName() + " joined with chapter " + chapter.getId());
- if(chapter == null) {
- chapter = ChapterZero.getInstance();
- player.getPersistentDataContainer().set(CHAPTER_KEY, PersistentDataType.INTEGER, chapter.getId());
- }
-
- if(chapter.equals(ChapterZero.getInstance())) chapter.onChapterStart(event);
- }
-
- @Nullable
- public Chapter getChapter(@NotNull Player player){
- return player.getPersistentDataContainer().has(CHAPTER_KEY, PersistentDataType.INTEGER) ? chapters.get(player.getPersistentDataContainer().get(CHAPTER_KEY, PersistentDataType.INTEGER)) : null;
- }
-
- @Nullable
- public Chapter getChapter(int id){
- return chapters.get(id);
- }
-
- public void setChapter(Player p, Chapter chapter){
- p.getPersistentDataContainer().set(CHAPTER_KEY, PersistentDataType.INTEGER, chapter.getId());
- }
-
- public void setChapter(Player p, int id){
- Util.sendMessage(p, "Setting chapter of player %s to %s.".formatted(p.getName(), id));
- try{
- setChapter(p, chapters.get(id));
- } catch (IndexOutOfBoundsException e){
- throw(new IndexOutOfBoundsException("Chapter with id " + id + " does not exist!"));
- }
- }
-
- public void registerChapters() {
- // Register all chapters here
- chapters.add(ChapterZero.getInstance());
- chapters.add(ChapterOne.getInstance());
- chapters.add(ChapterTwo.getInstance());
- }
-}
diff --git a/src/main/java/me/zenox/evocraft/story/chapters/ChapterOne.java b/src/main/java/me/zenox/evocraft/story/chapters/ChapterOne.java
deleted file mode 100644
index b88748f..0000000
--- a/src/main/java/me/zenox/evocraft/story/chapters/ChapterOne.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package me.zenox.evocraft.story.chapters;
-
-import me.zenox.evocraft.story.Chapter;
-import me.zenox.evocraft.util.Romans;
-import me.zenox.evocraft.util.Util;
-import org.bukkit.Location;
-import org.bukkit.Sound;
-import org.bukkit.event.player.PlayerInteractEvent;
-
-public class ChapterOne extends Chapter {
-
- private static ChapterOne instance = null;
-
- private ChapterOne() {
- super(1, true);
- }
-
- @Override
- public void onChapterStart(PlayerInteractEvent event) {
- Util.sendTitle(event.getPlayer(), "&b&lChapter " + Romans.encode(this.getId()), "&lThe Guardian's Keep", 10, 40, 10);
- event.getPlayer().teleport(new Location(event.getPlayer().getServer().getWorld("flat"), -346, -54, -510));
- event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 0.5f, 0.8f);
- // Begin Voiceover
- event.getPlayer().playSound(event.getPlayer().getLocation(), "story.chapter.1.backstory_1", 20f, 1f);
- }
-
- @Override
- public void onChapterEnd(PlayerInteractEvent event) {
- }
-
- public static ChapterOne getInstance() {
- if(instance == null) instance = new ChapterOne();
- return instance;
- }
-}
diff --git a/src/main/java/me/zenox/evocraft/story/chapters/ChapterTwo.java b/src/main/java/me/zenox/evocraft/story/chapters/ChapterTwo.java
deleted file mode 100644
index ad3ed6e..0000000
--- a/src/main/java/me/zenox/evocraft/story/chapters/ChapterTwo.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package me.zenox.evocraft.story.chapters;
-
-import me.zenox.evocraft.story.Chapter;
-import me.zenox.evocraft.util.Romans;
-import me.zenox.evocraft.util.Util;
-import org.bukkit.Location;
-import org.bukkit.Sound;
-import org.bukkit.event.player.PlayerInteractEvent;
-
-public class ChapterTwo extends Chapter {
- private static ChapterTwo instance = null;
-
- private ChapterTwo() {
- super(2, false);
- }
-
- @Override
- public void onChapterStart(PlayerInteractEvent event) {
- Util.sendTitle(event.getPlayer(), "&b&lChapter " + Romans.encode(this.getId()), "&lHumble Beginnings", 10, 40, 10);
- event.getPlayer().teleport(new Location(event.getPlayer().getServer().getWorld("flat"), -134, 78, -466));
- event.getPlayer().setBedSpawnLocation(new Location(event.getPlayer().getServer().getWorld("flat"), -134, 78, -466), true);
- event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 1, 1.5f);
- Util.sendMessage(event.getPlayer(), "&b&lQUICK TIP: &fExplore the island! Head to the portal at the center of the island once you would like to begin your adventure.");
-
- }
-
- @Override
- public void onChapterEnd(PlayerInteractEvent event) {
- // Clear the player's inventory
- event.getPlayer().getInventory().clear();
- }
-
- public static ChapterTwo getInstance() {
- if(instance == null) instance = new ChapterTwo();
- return instance;
- }
-}
diff --git a/src/main/java/me/zenox/evocraft/story/chapters/ChapterZero.java b/src/main/java/me/zenox/evocraft/story/chapters/ChapterZero.java
deleted file mode 100644
index 50b2931..0000000
--- a/src/main/java/me/zenox/evocraft/story/chapters/ChapterZero.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package me.zenox.evocraft.story.chapters;
-
-import me.zenox.evocraft.item.ComplexItemStack;
-import me.zenox.evocraft.item.ItemRegistry;
-import me.zenox.evocraft.story.Chapter;
-import me.zenox.evocraft.util.Util;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-
-public class ChapterZero extends Chapter {
-
- private static ChapterZero instance = null;
-
- private ChapterZero() {
- super(0, true);
- }
-
- @Override
- public void onChapterStart(PlayerJoinEvent event) {
- Player player = event.getPlayer();
- player.teleport(new Location(event.getPlayer().getServer().getWorld("flat"), -367, 17, -593));
- Util.sendTitle(player, "&b&lChapter Ω", "&d&lPress Start", 10, 150, 10);
- Util.sendMessage(player, "&eNote: &bEvoCraft &fis best experienced with sounds turned on. If you have sounds turned off, you may miss elemental effects, voiceovers, and other important sounds.");
- player.getInventory().setHeldItemSlot(4);
- player.getInventory().setItem(4, new ComplexItemStack(ItemRegistry.START_BUTTON).getItem());
- }
-
- @Override
- public void onChapterEnd(PlayerInteractEvent event) {
- // Clear the player's inventory
- event.getPlayer().getInventory().clear();
- }
-
- public static ChapterZero getInstance() {
- if(instance == null) instance = new ChapterZero();
- return instance;
- }
-}
-
diff --git a/src/main/java/me/zenox/evocraft/util/Geo.java b/src/main/java/me/zenox/evocraft/util/GeometryUtils.java
similarity index 98%
rename from src/main/java/me/zenox/evocraft/util/Geo.java
rename to src/main/java/me/zenox/evocraft/util/GeometryUtils.java
index 0f134f5..bdd097d 100644
--- a/src/main/java/me/zenox/evocraft/util/Geo.java
+++ b/src/main/java/me/zenox/evocraft/util/GeometryUtils.java
@@ -5,7 +5,7 @@
import java.util.ArrayList;
import java.util.List;
-public class Geo {
+public class GeometryUtils {
/// Generates a list of vertices (in arbitrary order) for a tetrahedron centered on the origin.
public static List makeDodecahedron(Vector vec, double r) {
diff --git a/src/main/java/me/zenox/evocraft/util/Util.java b/src/main/java/me/zenox/evocraft/util/Util.java
index fd7ca4d..4ce3df2 100644
--- a/src/main/java/me/zenox/evocraft/util/Util.java
+++ b/src/main/java/me/zenox/evocraft/util/Util.java
@@ -1,13 +1,11 @@
package me.zenox.evocraft.util;
-import com.archyx.aureliumskills.AureliumSkills;
-import com.archyx.aureliumskills.modifier.ModifierType;
-import com.archyx.aureliumskills.modifier.Modifiers;
-import com.archyx.aureliumskills.modifier.StatModifier;
-import com.archyx.aureliumskills.stats.Stat;
-import com.mojang.authlib.GameProfile;
-import com.mojang.authlib.properties.Property;
-import me.zenox.evocraft.EvoCraft;
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import dev.aurelium.auraskills.api.AuraSkillsApi;
+import dev.aurelium.auraskills.api.user.SkillsUser;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
@@ -17,7 +15,6 @@
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -43,7 +40,11 @@ public static void sendMessage(@NotNull CommandSender p, String message, boolean
}
public static void sendActionBar(@NotNull Player p, String message) {
- EvoCraft.getActionBar().sendAbilityActionBar(p, ChatColor.translateAlternateColorCodes('&', message));
+ AuraSkillsApi.get().getUserManager().getUser(p.getUniqueId()).sendActionBar(ChatColor.translateAlternateColorCodes('&', message));
+ }
+
+ public static void sendActionBar(@NotNull Player p, Component message) {
+ AuraSkillsApi.get().getUserManager().getUser(p.getUniqueId()).sendActionBar( LegacyComponentSerializer.legacySection().serialize(message));
}
public static void sendTitle(@NotNull Player p, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
@@ -74,15 +75,9 @@ public static ItemStack makeSkull(@NotNull ItemStack item, String base64EncodedS
r.nextBytes(array);
UUID id = UUID.nameUUIDFromBytes(array);
- GameProfile profile = new GameProfile(id, null);
- profile.getProperties().put("textures", new Property("textures", base64EncodedString));
- try {
- Field profileField = meta.getClass().getDeclaredField("profile");
- profileField.setAccessible(true);
- profileField.set(meta, profile);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- e.printStackTrace();
- }
+ PlayerProfile profile = Bukkit.createProfile(id, null);
+ profile.getProperties().add(new ProfileProperty("textures", base64EncodedString));
+ meta.setPlayerProfile(profile);
item.setItemMeta(meta);
return item;
}
@@ -104,9 +99,9 @@ public static UUID constantUUID(String str){
/**
* Gets nearby blocks given a radius and location
* @param loc The location
- * @param radius The radius
- * @param yradius The y radius
- * @return
+ * @param radius The radius in the orthogonal horizontal directions
+ * @param yradius The radius in the y direction
+ * @return the list of blocks
*/
public static List getNearbyBlocks(Location loc, int radius, int yradius) {
List nearbyBlocks = new ArrayList();
@@ -129,29 +124,6 @@ public static boolean isInvulnerable(Entity entity){
return (entity.hasMetadata("NPC") || (entity instanceof Player player && player.getGameMode() == GameMode.CREATIVE));
}
- /**
- * Gets all the modifiers an item has
- * @param item the item to check
- * @param type the type of modifier to check
- * @return the list of modifiers
- */
- public static List getAureliumModifiers(ItemStack item, ModifierType type){
- Modifiers modifiers = new Modifiers(AureliumSkills.getPlugin(AureliumSkills.class));
- return modifiers.getModifiers(type, item);
- }
-
- /**
- * Removes all modifiers of a certain type from an item
- * @param item the item to remove the modifiers from
- * @param type the type of modifiers to remove
- * @param stat the stat to remove the modifiers from
- * @return the item with the modifiers removed
- */
- public static ItemStack removeAureliumModifier(ItemStack item, ModifierType type, Stat stat){
- Modifiers modifiers = new Modifiers(AureliumSkills.getPlugin(AureliumSkills.class));
- return modifiers.removeModifier(type, item, stat);
- }
-
/**
* Rounds a given double to the specified number of decimal places.
* @param value the value to round
@@ -162,4 +134,10 @@ public static double round(double value, int digits) {
double factor = Math.pow(10, digits);
return Math.round(value * factor) / factor;
}
+
+ private static final AuraSkillsApi api = AuraSkillsApi.get();
+
+ public static SkillsUser getSkillsUser(Player player) {
+ return api.getUser(player.getUniqueId());
+ }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index e41ef3c..3df492b 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -4,4 +4,6 @@
force_update_default: true
# Locale
-locale: en_US
\ No newline at end of file
+locale: en_US
+
+autosave-minutes: 5
\ No newline at end of file
diff --git a/src/main/resources/languages/en_US.yml b/src/main/resources/languages/en_US.yml
index 21b14e0..6477b2d 100644
--- a/src/main/resources/languages/en_US.yml
+++ b/src/main/resources/languages/en_US.yml
@@ -638,6 +638,18 @@ ability-name-rapid_fire: Rapid Fire
ability-lore-rapid_fire:
- "Fire instantly."
+##########################################################################
+## CLASS ABILITIES ##
+##########################################################################
+ability-name-mage_teleport: Teleport
+ability-name-mage_mana_ball: Mana Ball
+ability-name-mage_rift_beam: Rift Beam
+ability-name-mage_rune_shield: Rune Shield
+
+ability-name-warrior_bloodlust: Bloodlust
+ability-name-warrior_triple_slash: Triple Slash
+ability-name-warrior_bull_rush: Triple Slash
+ability-name-warrior_counterstrike: Triple Slash
##########################################################################
## ENCHANTMENTS ##
##########################################################################
@@ -712,6 +724,85 @@ gui-enchant-action-lore-3:
- ""
- "&c&nRequires enchanting level 25!"
+gui-class-action-title-mage: "&b&lMage &7→ &eClick to Select"
+gui-class-action-lore-mage:
+ - "&fHarness the power of &bmana&f and &bmagic&f."
+ - ""
+ - "&7Weapons: &fStaffs, Wands, Potions"
+ - ""
+ - "&7Subclasses: "
+ - "&eRunecaster, Arcanist, Lightweaver"
+ - ""
+ - "&8(Low health, high damage, medium speed)"
+
+gui-class-action-title-warrior: "&c&lWarrior &7→ &eClick to Select"
+gui-class-action-lore-warrior:
+ - "&fA mobile melee combatant,"
+ - "excelling in close quarters."
+ - ""
+ - "&7Weapons: &fSwords, Axes"
+ - ""
+ - "&7Subclasses: "
+ - "&eGladiator, Rogue, Bladestorm"
+ - ""
+ - "&8(Fast, agile, low health siphon)"
+
+gui-class-action-title-tank: "&a&lTank &7→ &eClick to Select"
+gui-class-action-lore-tank:
+ - "&fBecome the shield of your team,"
+ - "&fand deal massive blows."
+ - ""
+ - "&7Weapons: &fMaces, Greatswords, Hammers"
+ - ""
+ - "&7Subclasses: "
+ - "&eStoneheart, Warden, Centurion"
+ - ""
+ - "&8(High health, slower, high damage)"
+
+gui-class-action-title-archer: "&6&lArcher &7→ &eClick to Select"
+gui-class-action-lore-archer:
+ - "&fMaster the art of ranged combat,"
+ - "&fand deal damage from afar."
+ - ""
+ - "&7Weapons: &fBows, Blasters"
+ - ""
+ - "&7Subclasses: "
+ - "&eDeadeye, Skirmisher, Fusillade"
+ - ""
+ - "&8(Medium health, good speed, medium damage)"
+
+##########################################################################
+## CLASSES ##
+##########################################################################
+class-name-mage: "&b&lMage"
+class-desc-mage:
+ - "&7Harness the mystical arts and control the battlefield with your spells."
+ - "&7Wield powerful &fStaffs, Wands &7and craft potent &fPotions."
+ - "&8Subclasses: &eRunecaster, Arcanist, Lightweaver"
+ - "&8(Low health, high damage, medium speed)"
+
+class-name-warrior: "&c&lWarrior"
+class-desc-warrior:
+ - "&7Engage in close combat with agility and precision."
+ - "&7Brandish deadly &fSwords &7and swift &fAxes."
+ - "&8Subclasses: &eGladiator, Rogue, Bladestorm"
+ - "&8(Fast, agile, low health siphon)"
+
+class-name-tank: "&a&lTank"
+class-desc-tank:
+ - "&7Hold the front line and protect your allies with might."
+ - "&7Swing devastating &fMaces, Greatswords &7and crushing &fHammers."
+ - "&8Subclasses: &eStoneheart, Warden, Centurion"
+ - "&8(High health, slower, high damage)"
+
+class-name-archer: "&6&lArcher"
+class-desc-archer:
+ - "&7Take down foes from a distance, mastering the bow's art."
+ - "&7Equip versatile &fBows &7and modern &fBlasters."
+ - "&8Subclasses: &eDeadeye, Skirmisher, Fusillade"
+ - "&8(Medium health, good speed, medium damage)"
+
+
##########################################################################
## ATTRIBUTES ##
##########################################################################
diff --git a/src/main/resources/playerdata.yml b/src/main/resources/playerdata.yml
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 6368357..3cdd851 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,7 +1,7 @@
name: EvoCraft
version: '${project.version}'
main: me.zenox.evocraft.EvoCraft
-api-version: 1.19
+api-version: 1.20
authors: [ ZenoX ]
description: Transforms your game into an highly specialized MMORPG experience.
softdepend: [ Citizens, WorldGuard, WorldEdit ]