Fixed merge compile errors

This commit is contained in:
Jules 2022-08-07 21:38:42 +02:00
parent 90cf189577
commit 312522d77c
17 changed files with 101 additions and 154 deletions

View File

@ -3,14 +3,11 @@ package net.Indyuce.mmocore;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.version.SpigotPlugin;
import io.lumine.mythic.utils.plugin.LuminePlugin;
import net.Indyuce.mmocore.api.ConfigFile;
import net.Indyuce.mmocore.api.PlayerActionBar;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.api.util.debug.DebugMode;
import net.Indyuce.mmocore.command.*;
import net.Indyuce.mmocore.comp.citizens.CitizenInteractEventListener;
import net.Indyuce.mmocore.comp.citizens.CitizensMMOLoader;
@ -34,7 +31,6 @@ import net.Indyuce.mmocore.listener.event.PlayerPressKeyListener;
import net.Indyuce.mmocore.listener.option.*;
import net.Indyuce.mmocore.listener.profession.FishingListener;
import net.Indyuce.mmocore.listener.profession.PlayerCollectStats;
import net.Indyuce.mmocore.loot.chest.LootChest;
import net.Indyuce.mmocore.manager.*;
import net.Indyuce.mmocore.manager.data.DataProvider;
import net.Indyuce.mmocore.manager.data.mysql.MySQLDataProvider;
@ -48,10 +44,10 @@ import net.Indyuce.mmocore.party.PartyModule;
import net.Indyuce.mmocore.party.PartyModuleType;
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
import net.Indyuce.mmocore.skill.custom.mechanic.ExperienceMechanic;
import net.Indyuce.mmocore.skill.custom.mechanic.ManaMechanic;
import net.Indyuce.mmocore.skill.custom.mechanic.StaminaMechanic;
import net.Indyuce.mmocore.skill.custom.mechanic.StelliumMechanic;
import net.Indyuce.mmocore.script.mechanic.ExperienceMechanic;
import net.Indyuce.mmocore.script.mechanic.StaminaMechanic;
import net.Indyuce.mmocore.script.mechanic.ManaMechanic;
import net.Indyuce.mmocore.script.mechanic.StelliumMechanic;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -64,7 +60,6 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.logging.Level;
public class MMOCore extends JavaPlugin {
@ -110,8 +105,6 @@ public class MMOCore extends JavaPlugin {
public GuildModule guildModule;
public boolean shouldDebugSQL = false;
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
public MMOCore() {
plugin = this;
}
@ -119,7 +112,6 @@ public class MMOCore extends JavaPlugin {
@Override
public void onLoad() {
// Register MMOCore-specific objects
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
@ -201,7 +193,6 @@ public class MMOCore extends JavaPlugin {
}
}.runTaskTimer(MMOCore.plugin, 100, 20);
/*
* For the sake of the lord, make sure they aren't using MMOItems Mana and
* Stamina Addon...This should prevent a couple error reports produced by people
@ -220,24 +211,6 @@ public class MMOCore extends JavaPlugin {
if (getConfig().getBoolean("vanilla-exp-redirection.enabled"))
Bukkit.getPluginManager().registerEvents(new RedirectVanillaExp(getConfig().getDouble("vanilla-exp-redirection.ratio")), this);
// Enable debug mode for extra debug tools
if (getConfig().contains("debug")) {
DebugMode.setLevel(getConfig().getInt("debug", 0));
DebugMode.enableActionBar();
}
// Load quest module
try {
String questPluginName = UtilityMethods.enumName(getConfig().getString("quest-plugin"));
PartyModuleType moduleType = PartyModuleType.valueOf(questPluginName);
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
partyModule = moduleType.provideModule();
} catch (RuntimeException exception) {
getLogger().log(Level.WARNING, "Could not initialize quest module: " + exception.getMessage());
partyModule = new MMOCorePartyModule();
}
// Load party module
try {
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
@ -438,7 +411,6 @@ public class MMOCore extends JavaPlugin {
if (getConfig().isConfigurationSection("action-bar"))
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
if (clearBefore)
PlayerData.getAll().forEach(PlayerData::update);
}
@ -447,18 +419,10 @@ public class MMOCore extends JavaPlugin {
log(Level.INFO, message);
}
public static void debug(int value, String message) {
debug(value, Level.INFO, message);
}
public static void log(Level level, String message) {
plugin.getLogger().log(level, message);
}
public static void debug(int value, Level level, String message) {
if (DebugMode.level > (value - 1)) plugin.getLogger().log(level, message);
}
public File getJarFile() {
return getFile();
}

View File

@ -1,10 +1,9 @@
package net.Indyuce.mmocore.api.player;
import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.player.TemporaryPlayerData;
import io.lumine.mythic.lib.player.cooldown.CooldownMap;
import io.lumine.mythic.lib.player.modifier.PlayerModifier;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.SoundEvent;
@ -20,6 +19,7 @@ import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import net.Indyuce.mmocore.api.player.social.FriendRequest;
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.experience.EXPSource;
@ -30,13 +30,19 @@ import net.Indyuce.mmocore.experience.droptable.ExperienceItem;
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
import net.Indyuce.mmocore.guild.provided.Guild;
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
import net.Indyuce.mmocore.manager.data.mysql.MySQLTableEditor;
import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.party.provided.Party;
import net.Indyuce.mmocore.player.Unlockable;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill;
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
import net.Indyuce.mmocore.tree.IntegerCoordinates;
import net.Indyuce.mmocore.tree.NodeState;
import net.Indyuce.mmocore.tree.SkillTreeNode;
import net.Indyuce.mmocore.tree.skilltree.LinkedSkillTree;
import net.Indyuce.mmocore.tree.skilltree.SkillTree;
import net.Indyuce.mmocore.tree.skilltree.display.DisplayInfo;
import net.Indyuce.mmocore.tree.skilltree.display.Icon;
import net.Indyuce.mmocore.waypoint.Waypoint;
import net.Indyuce.mmocore.waypoint.WaypointOption;
import net.md_5.bungee.api.ChatMessageType;
@ -76,6 +82,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
private double mana, stamina, stellium;
private Guild guild;
private SkillCastingHandler skillCasting;
private SkillTree cachedSkillTree;
private final PlayerQuests questData;
private final PlayerStats playerStats;
@ -88,6 +95,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
private final Map<String, SavedClassInformation> classSlots = new HashMap<>();
private final Map<PlayerActivity, Long> lastActivity = new HashMap<>();
private final Map<SkillTreeNode, Integer> nodeLevels = new HashMap<>();
private final Map<SkillTreeNode, NodeState> nodeStates = new HashMap<>();
private final Map<String, Integer> skillTreePoints = new HashMap<>();
/**
* Saves all the items that have been unlocked so far by
* the player. This is used for:
@ -185,8 +196,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return nodeLevels.keySet().stream().filter(node -> node.getTree().equals(skillTree)).mapToInt(nodeLevels::get).sum();
}
public HashMap<String, Integer> getSkillTreePoints() {
public Map<String, Integer> getSkillTreePoints() {
return skillTreePoints;
}
@ -194,12 +204,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return skillTreePoints.containsKey(treeId);
}
public Set<Map.Entry<String,Integer>> getNodeLevelsEntrySet() {
HashMap<String,Integer> nodeLevelsString=new HashMap<>();
for(SkillTreeNode node:nodeLevels.keySet()) {
nodeLevelsString.put(node.getFullId(),nodeLevels.get(node));
public Set<Map.Entry<String, Integer>> getNodeLevelsEntrySet() {
HashMap<String, Integer> nodeLevelsString = new HashMap<>();
for (SkillTreeNode node : nodeLevels.keySet()) {
nodeLevelsString.put(node.getFullId(), nodeLevels.get(node));
}
return nodeLevelsString.entrySet();
}
@ -242,15 +250,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
//Applies player modifiers
List<PlayerModifier> modifiers = node.getModifiers(getNodeLevel(node));
if (modifiers != null) {
Bukkit.broadcastMessage("Modifier: "+modifiers.size());
if (modifiers != null)
for (PlayerModifier modifier : modifiers) {
modifier.register(getMMOPlayerData());
}
}
Bukkit.broadcastMessage(playerStats.getStat("HEALTH_REGENERATION")+"");
if (nodeStates.get(node) == NodeState.UNLOCKABLE)
setNodeState(node, NodeState.UNLOCKED);
@ -263,7 +266,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
nodeStates.remove(node1);
}
node.getTree().setupNodeState(this);
}
/**
@ -277,7 +279,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return skillTree.getIcon(displayInfo);
}
public Icon getIcon(SkillTree skillTree, IntegerCoordinates coordinates) {
if (skillTree.isNode(coordinates)) {
@ -293,7 +294,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return null;
}
public int getSkillTreePoint(String treeId) {
return skillTreePoints.get(treeId);
}
@ -315,14 +315,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
}
public int getNodeLevel(SkillTreeNode node) {
return nodeLevels.get(node);
}
public void setNodeLevel(SkillTreeNode node, int nodeLevel) {
nodeLevels.put(node, nodeLevel);
}
@ -392,10 +388,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
this.cachedSkillTree = cachedSkillTree;
}
public SkillTree getCachedSkillTree() {
@NotNull
public SkillTree getOpenedSkillTree() {
if (cachedSkillTree == null)
return MMOCore.plugin.skillTreeManager.getAll().stream().collect(Collectors.toList()).get(0);
return MMOCore.plugin.skillTreeManager.getAll().stream().findFirst().get();
return cachedSkillTree;
}
@ -420,6 +416,18 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return skillPoints;
}
public int getAttributePoints() {
return attributePoints;
}
public int getAttributeReallocationPoints() {
return attributeReallocationPoints;
}
public int getSkillTreeReallocationPoints() {
return skillTreeReallocationPoints;
}
@Override
public int getClaims(ExperienceObject object, ExperienceTable table, ExperienceItem item) {
String key = object.getKey() + "." + table.getId() + "." + item.getId();
@ -447,14 +455,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
// return skillReallocationPoints;
// }
public int getAttributePoints() {
return attributePoints;
}
public int getAttributeReallocationPoints() {
return attributeReallocationPoints;
}
public boolean isOnline() {
return mmoData.isOnline();
}
@ -539,6 +539,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
classPoints = Math.max(0, value);
}
public void setSkillTreeReallocationPoints(int value) {
skillTreeReallocationPoints = Math.max(0, value);
}
public boolean hasSavedClass(PlayerClass profess) {
return classSlots.containsKey(profess.getId());
}
@ -964,6 +968,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
skills.remove(skill);
}
@Deprecated
public boolean hasSkillUnlocked(RegisteredSkill skill) {
return getProfess().hasSkill(skill.getHandler().getId()) && hasSkillUnlocked(getProfess().getSkill(skill.getHandler().getId()));
}
@ -1006,6 +1011,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
setAttributeReallocationPoints(attributeReallocationPoints + value);
}
public void giveSkillTreeReallocationPoints(int value) {
setSkillTreeReallocationPoints(skillTreeReallocationPoints + value);
}
public CooldownMap getCooldownMap() {
return mmoData.getCooldownMap();
}
@ -1056,8 +1065,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
* checks if they could potentially upgrade to one of these
*
* @return If the player can change its current class to
* a subclass
* a subclass
*/
@Deprecated
public boolean canChooseSubclass() {
for (Subclass subclass : getProfess().getSubclasses())
if (getLevel() >= subclass.getLevel())

View File

@ -53,10 +53,6 @@ public class MMOCoreUtils {
return builder.toString();
}
public static String toEnumName(String str) {
return str.replace("-", "_").toUpperCase();
}
/**
*
* @param value an integer you want to convert
@ -127,11 +123,6 @@ public class MMOCoreUtils {
return t;
}
public static String toEnumName(String str) {
return str.replace("-","_").replace(" ","_").toUpperCase();
}
public static String toBase64(ItemStack[] items) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.command;
import io.lumine.mythic.lib.UtilityMethods;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.ConfigurationSection;
@ -19,7 +19,7 @@ public class CommandVerbose {
for (CommandType type : CommandType.values())
try {
values.put(type, VerboseValue.valueOf(config.getString(MMOCoreUtils.toEnumName(type.name()), "TRUE").toUpperCase()));
values.put(type, VerboseValue.valueOf(config.getString(UtilityMethods.enumName(type.name()), "TRUE").toUpperCase()));
} catch (IllegalArgumentException exception) {
values.put(type, VerboseValue.TRUE);
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load command verbose action for " + type.name());

View File

@ -6,6 +6,7 @@ import net.Indyuce.mmocore.api.SoundEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.gui.api.EditableInventory;
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
@ -14,11 +15,10 @@ import net.Indyuce.mmocore.tree.NodeState;
import net.Indyuce.mmocore.tree.skilltree.SkillTree;
import net.Indyuce.mmocore.tree.SkillTreeNode;
import net.Indyuce.mmocore.tree.skilltree.display.Icon;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
@ -28,7 +28,6 @@ import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class SkillTreeViewer extends EditableInventory {
@ -214,10 +213,10 @@ public class SkillTreeViewer extends EditableInventory {
private final int maxTreeListPage;
private final SkillTree skillTree;
public SkillTreeInventory(PlayerData playerData, EditableInventory editable) {
super(playerData, editable);
skillTree = playerData.getCachedSkillTree();
skillTree = playerData.getOpenedSkillTree();
maxTreeListPage = (MMOCore.plugin.skillTreeManager.getAll().size() - 1) / editable.getByFunction("skill-tree").getSlots().size();
//We get the width and height of the GUI(corresponding to the slots given)
List<Integer> slots = editable.getByFunction("skill-tree-node").getSlots();
@ -266,9 +265,7 @@ public class SkillTreeViewer extends EditableInventory {
}
@Override
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
public void whenClicked(InventoryClickContext event, InventoryItem item) {
if (item.getFunction().equals("next-tree-list-page")) {
treeListPage++;
open();
@ -313,9 +310,8 @@ public class SkillTreeViewer extends EditableInventory {
}
}
if (item.getFunction().equals("skill-tree")) {
String id = event.getCurrentItem().getItemMeta().getPersistentDataContainer().get(
String id = event.getItemStack().getItemMeta().getPersistentDataContainer().get(
new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING);
playerData.setCachedSkillTree(MMOCore.plugin.skillTreeManager.get(id));
MMOCore.plugin.soundManager.getSound(SoundEvent.CHANGE_SKILL_TREE).playTo(player);
@ -327,7 +323,7 @@ public class SkillTreeViewer extends EditableInventory {
if (item.getFunction().equals("skill-tree-node")) {
if (event.getAction().equals(InventoryAction.PICKUP_HALF)) {
if (event.getClickType() == ClickType.RIGHT) {
int offset = event.getSlot();
int xOffset=offset%9-middleSlot%9;
int yOffset=offset/9-middleSlot/9;
@ -338,8 +334,8 @@ public class SkillTreeViewer extends EditableInventory {
return;
}
else if (event.getAction() == InventoryAction.PICKUP_ALL) {
PersistentDataContainer container = event.getCurrentItem().getItemMeta().getPersistentDataContainer();
else if (event.getClickType() == ClickType.LEFT) {
PersistentDataContainer container = event.getItemStack().getItemMeta().getPersistentDataContainer();
int x = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.x"), PersistentDataType.INTEGER);
int y = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.y"), PersistentDataType.INTEGER);
SkillTreeNode node = skillTree.getNode(new IntegerCoordinates(x, y));

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmocore.gui.api;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.gui.api.adaptor.AdaptorType;
@ -39,7 +40,7 @@ public abstract class EditableInventory {
public void reload(FileConfiguration config) {
this.adaptorType = AdaptorType.valueOf(MMOCoreUtils.toEnumName(config.getString("adaptor-type", "classic-adaptor")));
this.adaptorType = AdaptorType.valueOf(UtilityMethods.enumName(config.getString("adaptor-type", "classic-adaptor")));
Validate.notNull(adaptorType, config.getString("adaptor-type") + " does not correspond to an adaptor-type.");//TODO
this.radius = config.getDouble("radius", 2);

View File

@ -8,7 +8,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public abstract class MMOCoreRegister<T extends RegisterObject> implements MMOCoreManager {
public abstract class MMOCoreRegister<T extends RegisteredObject> implements MMOCoreManager {
protected final Map<String, T> registered = new HashMap<>();
public void register(T t) {

View File

@ -1,6 +1,6 @@
package net.Indyuce.mmocore.manager.registry;
public interface RegisterObject {
public interface RegisteredObject {
/**
* Identifier used to register an object

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.skill.custom.mechanic;
package net.Indyuce.mmocore.script.mechanic;
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
import io.lumine.mythic.lib.skill.SkillMetadata;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.skill.custom.mechanic;
package net.Indyuce.mmocore.script.mechanic;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.skill.SkillMetadata;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.skill.custom.mechanic;
package net.Indyuce.mmocore.script.mechanic;
public enum Operation {
GIVE,

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.skill.custom.mechanic;
package net.Indyuce.mmocore.script.mechanic;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.skill.SkillMetadata;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.skill.custom.mechanic;
package net.Indyuce.mmocore.script.mechanic;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmocore.tree;
import com.gmail.nossr50.mcmmo.acf.annotation.HelpSearchTags;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.player.modifier.PlayerModifier;
import io.lumine.mythic.lib.util.configobject.ConfigObject;
@ -27,6 +28,7 @@ public class SkillTreeNode implements Unlockable {
private final String name, id;
private IntegerCoordinates coordinates;
private boolean isRoot;
/**
* The lore corresponding to each level
*/
@ -35,64 +37,58 @@ public class SkillTreeNode implements Unlockable {
//TODO modifiers depending on level with drop tables
private final HashMap<Integer, List<PlayerModifier>> modifiers = new HashMap<>();
private final HashMap<Integer, List<Trigger>> triggers = new HashMap<>();
//The max level the skill tree node can have and the max amount of children it can have.
private final int maxLevel, maxChildren, size;
private final ArrayList<SkillTreeNode> children = new ArrayList<>();
/**
* Associates the required level to each parent
* You only need to have the requirement for one of your softParents but you need to fulfill the requirements
* of all of your strong parents.
* Associates the required level to each parent.
* <p>
* You only need to have the requirement for one of your softParents
* but you need to fulfill the requirements of all of your strong parents.
**/
private final HashMap<SkillTreeNode, Integer> softParents = new HashMap<>();
private final HashMap<SkillTreeNode, Integer> strongParents = new HashMap<>();
public SkillTreeNode(SkillTree tree, ConfigurationSection config) {
Validate.notNull(config, "Config cannot be null");
this.id = config.getName();
this.tree = tree;
name = Objects.requireNonNull(config.getString("name"), "Could not find node name");
size = Objects.requireNonNull(config.getInt("size"));
isRoot = config.contains("is-root") ? config.getBoolean("is-root") ? true : false : false;
isRoot = config.getBoolean("is-root", false);
//We initialize the value of the lore for each skill tree node.
for (String state : Objects.requireNonNull(config.getConfigurationSection("lores")).getKeys(false)) {
NodeState nodeState = NodeState.valueOf(MMOCoreUtils.toEnumName(state));
NodeState nodeState = NodeState.valueOf(UtilityMethods.enumName(state));
if (nodeState == NodeState.UNLOCKED) {
//TODO: Message could'nt load ... instead of exce/*99+*-*99**9+-ption
ConfigurationSection section = config.getConfigurationSection("lores." + state);
for (String level : section.getKeys(false)) {
for (String level : section.getKeys(false))
lores.put(new NodeContext(nodeState, Integer.parseInt(level)), section.getStringList(level));
}
} else {
lores.put(new NodeContext(nodeState, 0), config.getStringList("lores." + state));
}
}
//We load the triggers
if (config.contains("triggers")) {
try {
ConfigurationSection section = config.getConfigurationSection("triggers");
for (String level : section.getKeys(false)) {
int value = Integer.parseInt(level);
for (String str : section.getStringList(level)) {
List<Trigger> triggerList = MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(str));
for (Trigger trigger : triggerList) {
if (!triggers.containsKey(value)) {
triggers.put(value, new ArrayList<>());
}
triggers.get(value).add(trigger);
}
}
for (String levelFormat : section.getKeys(false)) {
final int level = Integer.parseInt(levelFormat);
final List<Trigger> triggers = new ArrayList<>();
for (String str : section.getStringList(levelFormat))
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(str)));
this.triggers.put(level, triggers);
}
} catch (NumberFormatException e) {
MMOCore.plugin.getLogger().log(Level.WARNING, "Couldn't load triggers for the skill node " + tree.getId() + "." + id + " :Problem with the Number Format.");
MMOCore.plugin.getLogger().log(Level.WARNING, "Couldn't load triggers for skill node " + tree.getId() + "." + id + " : Problem with the Number Format.");
}
}
//We load the player Modifiers
if (config.contains("modifiers")) {
try {
@ -216,18 +212,15 @@ public class SkillTreeNode implements Unlockable {
return modifiers.get(level);
}
public List<Trigger> getTriggers(int level) {
return triggers.get(level);
}
@Override
public String getUnlockNamespacedKey() {
return "skill_tree:" + tree.getId() + "_" + coordinates.getX() + "_" + coordinates.getY();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -308,7 +301,6 @@ public class SkillTreeNode implements Unlockable {
}
/**
* @param namespacedKey Something like "skill_tree:tree_name_1_5"
* @return The corresponding skill tree node
@ -369,6 +361,4 @@ public class SkillTreeNode implements Unlockable {
return Objects.hash(nodeState, nodeLevel);
}
}
}

View File

@ -1,11 +1,12 @@
package net.Indyuce.mmocore.tree.skilltree;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.util.PostLoadObject;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.manager.registry.RegisterObject;
import net.Indyuce.mmocore.manager.registry.RegisteredObject;
import net.Indyuce.mmocore.tree.NodeState;
import net.Indyuce.mmocore.tree.skilltree.display.DisplayInfo;
import net.Indyuce.mmocore.tree.skilltree.display.Icon;
@ -13,7 +14,6 @@ import net.Indyuce.mmocore.tree.IntegerCoordinates;
import net.Indyuce.mmocore.tree.SkillTreeNode;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;
@ -38,7 +38,7 @@ import java.util.logging.Level;
* @author Ka0rX
* @see {@link SkillTreeNode}
*/
public abstract class SkillTree extends PostLoadObject implements RegisterObject {
public abstract class SkillTree extends PostLoadObject implements RegisteredObject {
private final String id, name;
private final List<String> lore = new ArrayList<>();
private final Material item;
@ -55,15 +55,14 @@ public abstract class SkillTree extends PostLoadObject implements RegisterObject
protected final List<SkillTreeNode> roots = new ArrayList<>();
public SkillTree(ConfigurationSection config) {
super(config);
this.id = Objects.requireNonNull(config.getString("id"), "Could not find skill tree id");
this.name = MythicLib.plugin.parseColors(Objects.requireNonNull(config.getString("name"), "Could not find skill tree name"));
Objects.requireNonNull(config.getStringList("lore"), "Could not find skill tree lore").forEach(str -> lore.add(MythicLib.plugin.parseColors(str)));
this.item = Material.valueOf(MMOCoreUtils.toEnumName(Objects.requireNonNull(config.getString("item"))));
this.item = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("item"))));
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
try {
@ -71,7 +70,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisterObject
nodes.put(node.getId(), node);
} catch (Exception e) {
MMOCore.plugin.getLogger().log(Level.SEVERE,"Couldn't load skill tree node "+id+"."+key+": "+e.getMessage());
MMOCore.plugin.getLogger().log(Level.SEVERE, "Couldn't load skill tree node " + id + "." + key + ": " + e.getMessage());
}
}
try {
@ -97,7 +96,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisterObject
continue;
}
for (String size : config.getConfigurationSection("icons." + key).getKeys(false)) {
DisplayInfo displayInfo = new DisplayInfo(NodeState.valueOf(MMOCoreUtils.toEnumName(key)), Integer.parseInt(size));
DisplayInfo displayInfo = new DisplayInfo(NodeState.valueOf(UtilityMethods.enumName(key)), Integer.parseInt(size));
Icon icon = new Icon(config.getConfigurationSection("icons." + key + "." + size));
icons.put(displayInfo, icon);
@ -251,10 +250,10 @@ public abstract class SkillTree extends PostLoadObject implements RegisterObject
}
@Nullable
/**
* Returns null if it is not a node and returns the node type if it a node
*/
@Nullable
public boolean isNode(IntegerCoordinates coordinates) {
for (SkillTreeNode node : nodes.values()) {
if (node.getCoordinates().equals(coordinates))

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.tree.skilltree.display;
import io.lumine.mythic.lib.UtilityMethods;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -21,7 +22,7 @@ public class Icon {
return customModelData;
}
public Icon(ConfigurationSection config) {
this(Material.valueOf(Objects.requireNonNull(MMOCoreUtils.toEnumName(
this(Material.valueOf(Objects.requireNonNull(UtilityMethods.enumName(
config.getString("item")))),config.contains("model-data")?config.getInt("model-data"):0);
}

View File

@ -231,11 +231,6 @@ resource-bar-colors:
stamina-half: 'DARK_GREEN'
stamina-empty: 'WHITE'
# When set to true, attributes are saved and
# reset when a player changes their class.
# Not implemented yet.
# attributes-as-class-info: true
# Whether or not the admin commands should display
# the result of the command when ran.
# For Example: "Players Level is now 10."