forked from Upstream/mmocore
Fixed merge compile errors
This commit is contained in:
parent
90cf189577
commit
312522d77c
@ -3,14 +3,11 @@ package net.Indyuce.mmocore;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.UtilityMethods;
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.version.SpigotPlugin;
|
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.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.PlayerActionBar;
|
import net.Indyuce.mmocore.api.PlayerActionBar;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
|
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
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.command.*;
|
||||||
import net.Indyuce.mmocore.comp.citizens.CitizenInteractEventListener;
|
import net.Indyuce.mmocore.comp.citizens.CitizenInteractEventListener;
|
||||||
import net.Indyuce.mmocore.comp.citizens.CitizensMMOLoader;
|
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.option.*;
|
||||||
import net.Indyuce.mmocore.listener.profession.FishingListener;
|
import net.Indyuce.mmocore.listener.profession.FishingListener;
|
||||||
import net.Indyuce.mmocore.listener.profession.PlayerCollectStats;
|
import net.Indyuce.mmocore.listener.profession.PlayerCollectStats;
|
||||||
import net.Indyuce.mmocore.loot.chest.LootChest;
|
|
||||||
import net.Indyuce.mmocore.manager.*;
|
import net.Indyuce.mmocore.manager.*;
|
||||||
import net.Indyuce.mmocore.manager.data.DataProvider;
|
import net.Indyuce.mmocore.manager.data.DataProvider;
|
||||||
import net.Indyuce.mmocore.manager.data.mysql.MySQLDataProvider;
|
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.PartyModuleType;
|
||||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
||||||
import net.Indyuce.mmocore.skill.custom.mechanic.ExperienceMechanic;
|
import net.Indyuce.mmocore.script.mechanic.ExperienceMechanic;
|
||||||
import net.Indyuce.mmocore.skill.custom.mechanic.ManaMechanic;
|
import net.Indyuce.mmocore.script.mechanic.StaminaMechanic;
|
||||||
import net.Indyuce.mmocore.skill.custom.mechanic.StaminaMechanic;
|
import net.Indyuce.mmocore.script.mechanic.ManaMechanic;
|
||||||
import net.Indyuce.mmocore.skill.custom.mechanic.StelliumMechanic;
|
import net.Indyuce.mmocore.script.mechanic.StelliumMechanic;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -64,7 +60,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class MMOCore extends JavaPlugin {
|
public class MMOCore extends JavaPlugin {
|
||||||
@ -110,8 +105,6 @@ public class MMOCore extends JavaPlugin {
|
|||||||
public GuildModule guildModule;
|
public GuildModule guildModule;
|
||||||
public boolean shouldDebugSQL = false;
|
public boolean shouldDebugSQL = false;
|
||||||
|
|
||||||
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
|
|
||||||
|
|
||||||
public MMOCore() {
|
public MMOCore() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
@ -119,7 +112,6 @@ public class MMOCore extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
|
||||||
|
|
||||||
// Register MMOCore-specific objects
|
// Register MMOCore-specific objects
|
||||||
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
|
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
|
||||||
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
|
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
|
||||||
@ -201,7 +193,6 @@ public class MMOCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}.runTaskTimer(MMOCore.plugin, 100, 20);
|
}.runTaskTimer(MMOCore.plugin, 100, 20);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For the sake of the lord, make sure they aren't using MMOItems Mana and
|
* 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
|
* 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"))
|
if (getConfig().getBoolean("vanilla-exp-redirection.enabled"))
|
||||||
Bukkit.getPluginManager().registerEvents(new RedirectVanillaExp(getConfig().getDouble("vanilla-exp-redirection.ratio")), this);
|
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
|
// Load party module
|
||||||
try {
|
try {
|
||||||
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
|
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
|
||||||
@ -438,7 +411,6 @@ public class MMOCore extends JavaPlugin {
|
|||||||
if (getConfig().isConfigurationSection("action-bar"))
|
if (getConfig().isConfigurationSection("action-bar"))
|
||||||
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
|
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
|
||||||
|
|
||||||
|
|
||||||
if (clearBefore)
|
if (clearBefore)
|
||||||
PlayerData.getAll().forEach(PlayerData::update);
|
PlayerData.getAll().forEach(PlayerData::update);
|
||||||
}
|
}
|
||||||
@ -447,18 +419,10 @@ public class MMOCore extends JavaPlugin {
|
|||||||
log(Level.INFO, message);
|
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) {
|
public static void log(Level level, String message) {
|
||||||
plugin.getLogger().log(level, 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() {
|
public File getJarFile() {
|
||||||
return getFile();
|
return getFile();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package net.Indyuce.mmocore.api.player;
|
package net.Indyuce.mmocore.api.player;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.api.player.MMOPlayerData;
|
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.cooldown.CooldownMap;
|
||||||
|
import io.lumine.mythic.lib.player.modifier.PlayerModifier;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
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.social.FriendRequest;
|
||||||
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
||||||
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
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.Closable;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.experience.EXPSource;
|
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.experience.droptable.ExperienceTable;
|
||||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||||
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
|
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.AbstractParty;
|
||||||
import net.Indyuce.mmocore.party.provided.Party;
|
import net.Indyuce.mmocore.party.provided.Party;
|
||||||
import net.Indyuce.mmocore.player.Unlockable;
|
import net.Indyuce.mmocore.player.Unlockable;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
|
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.Waypoint;
|
||||||
import net.Indyuce.mmocore.waypoint.WaypointOption;
|
import net.Indyuce.mmocore.waypoint.WaypointOption;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
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 double mana, stamina, stellium;
|
||||||
private Guild guild;
|
private Guild guild;
|
||||||
private SkillCastingHandler skillCasting;
|
private SkillCastingHandler skillCasting;
|
||||||
|
private SkillTree cachedSkillTree;
|
||||||
|
|
||||||
private final PlayerQuests questData;
|
private final PlayerQuests questData;
|
||||||
private final PlayerStats playerStats;
|
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<String, SavedClassInformation> classSlots = new HashMap<>();
|
||||||
private final Map<PlayerActivity, Long> lastActivity = 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
|
* Saves all the items that have been unlocked so far by
|
||||||
* the player. This is used for:
|
* 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();
|
return nodeLevels.keySet().stream().filter(node -> node.getTree().equals(skillTree)).mapToInt(nodeLevels::get).sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Integer> getSkillTreePoints() {
|
||||||
public HashMap<String, Integer> getSkillTreePoints() {
|
|
||||||
return skillTreePoints;
|
return skillTreePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +204,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return skillTreePoints.containsKey(treeId);
|
return skillTreePoints.containsKey(treeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Set<Map.Entry<String, Integer>> getNodeLevelsEntrySet() {
|
public Set<Map.Entry<String, Integer>> getNodeLevelsEntrySet() {
|
||||||
HashMap<String, Integer> nodeLevelsString = new HashMap<>();
|
HashMap<String, Integer> nodeLevelsString = new HashMap<>();
|
||||||
for (SkillTreeNode node : nodeLevels.keySet()) {
|
for (SkillTreeNode node : nodeLevels.keySet()) {
|
||||||
@ -242,15 +250,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
|
|
||||||
//Applies player modifiers
|
//Applies player modifiers
|
||||||
List<PlayerModifier> modifiers = node.getModifiers(getNodeLevel(node));
|
List<PlayerModifier> modifiers = node.getModifiers(getNodeLevel(node));
|
||||||
|
if (modifiers != null)
|
||||||
if (modifiers != null) {
|
|
||||||
Bukkit.broadcastMessage("Modifier: "+modifiers.size());
|
|
||||||
for (PlayerModifier modifier : modifiers) {
|
for (PlayerModifier modifier : modifiers) {
|
||||||
modifier.register(getMMOPlayerData());
|
modifier.register(getMMOPlayerData());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.broadcastMessage(playerStats.getStat("HEALTH_REGENERATION")+"");
|
|
||||||
|
|
||||||
if (nodeStates.get(node) == NodeState.UNLOCKABLE)
|
if (nodeStates.get(node) == NodeState.UNLOCKABLE)
|
||||||
setNodeState(node, NodeState.UNLOCKED);
|
setNodeState(node, NodeState.UNLOCKED);
|
||||||
@ -263,7 +266,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
nodeStates.remove(node1);
|
nodeStates.remove(node1);
|
||||||
}
|
}
|
||||||
node.getTree().setupNodeState(this);
|
node.getTree().setupNodeState(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -277,7 +279,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return skillTree.getIcon(displayInfo);
|
return skillTree.getIcon(displayInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Icon getIcon(SkillTree skillTree, IntegerCoordinates coordinates) {
|
public Icon getIcon(SkillTree skillTree, IntegerCoordinates coordinates) {
|
||||||
|
|
||||||
if (skillTree.isNode(coordinates)) {
|
if (skillTree.isNode(coordinates)) {
|
||||||
@ -293,7 +294,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getSkillTreePoint(String treeId) {
|
public int getSkillTreePoint(String treeId) {
|
||||||
return skillTreePoints.get(treeId);
|
return skillTreePoints.get(treeId);
|
||||||
}
|
}
|
||||||
@ -315,14 +315,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getNodeLevel(SkillTreeNode node) {
|
public int getNodeLevel(SkillTreeNode node) {
|
||||||
|
|
||||||
|
|
||||||
return nodeLevels.get(node);
|
return nodeLevels.get(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setNodeLevel(SkillTreeNode node, int nodeLevel) {
|
public void setNodeLevel(SkillTreeNode node, int nodeLevel) {
|
||||||
|
|
||||||
nodeLevels.put(node, nodeLevel);
|
nodeLevels.put(node, nodeLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,10 +388,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
this.cachedSkillTree = cachedSkillTree;
|
this.cachedSkillTree = cachedSkillTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkillTree getCachedSkillTree() {
|
@NotNull
|
||||||
|
public SkillTree getOpenedSkillTree() {
|
||||||
if (cachedSkillTree == null)
|
if (cachedSkillTree == null)
|
||||||
return MMOCore.plugin.skillTreeManager.getAll().stream().collect(Collectors.toList()).get(0);
|
return MMOCore.plugin.skillTreeManager.getAll().stream().findFirst().get();
|
||||||
return cachedSkillTree;
|
return cachedSkillTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,6 +416,18 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return skillPoints;
|
return skillPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAttributePoints() {
|
||||||
|
return attributePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttributeReallocationPoints() {
|
||||||
|
return attributeReallocationPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSkillTreeReallocationPoints() {
|
||||||
|
return skillTreeReallocationPoints;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getClaims(ExperienceObject object, ExperienceTable table, ExperienceItem item) {
|
public int getClaims(ExperienceObject object, ExperienceTable table, ExperienceItem item) {
|
||||||
String key = object.getKey() + "." + table.getId() + "." + item.getId();
|
String key = object.getKey() + "." + table.getId() + "." + item.getId();
|
||||||
@ -447,14 +455,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
// return skillReallocationPoints;
|
// return skillReallocationPoints;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public int getAttributePoints() {
|
|
||||||
return attributePoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAttributeReallocationPoints() {
|
|
||||||
return attributeReallocationPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
return mmoData.isOnline();
|
return mmoData.isOnline();
|
||||||
}
|
}
|
||||||
@ -539,6 +539,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
classPoints = Math.max(0, value);
|
classPoints = Math.max(0, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSkillTreeReallocationPoints(int value) {
|
||||||
|
skillTreeReallocationPoints = Math.max(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasSavedClass(PlayerClass profess) {
|
public boolean hasSavedClass(PlayerClass profess) {
|
||||||
return classSlots.containsKey(profess.getId());
|
return classSlots.containsKey(profess.getId());
|
||||||
}
|
}
|
||||||
@ -964,6 +968,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
skills.remove(skill);
|
skills.remove(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean hasSkillUnlocked(RegisteredSkill skill) {
|
public boolean hasSkillUnlocked(RegisteredSkill skill) {
|
||||||
return getProfess().hasSkill(skill.getHandler().getId()) && hasSkillUnlocked(getProfess().getSkill(skill.getHandler().getId()));
|
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);
|
setAttributeReallocationPoints(attributeReallocationPoints + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void giveSkillTreeReallocationPoints(int value) {
|
||||||
|
setSkillTreeReallocationPoints(skillTreeReallocationPoints + value);
|
||||||
|
}
|
||||||
|
|
||||||
public CooldownMap getCooldownMap() {
|
public CooldownMap getCooldownMap() {
|
||||||
return mmoData.getCooldownMap();
|
return mmoData.getCooldownMap();
|
||||||
}
|
}
|
||||||
@ -1058,6 +1067,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
* @return If the player can change its current class to
|
* @return If the player can change its current class to
|
||||||
* a subclass
|
* a subclass
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean canChooseSubclass() {
|
public boolean canChooseSubclass() {
|
||||||
for (Subclass subclass : getProfess().getSubclasses())
|
for (Subclass subclass : getProfess().getSubclasses())
|
||||||
if (getLevel() >= subclass.getLevel())
|
if (getLevel() >= subclass.getLevel())
|
||||||
|
@ -53,10 +53,6 @@ public class MMOCoreUtils {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toEnumName(String str) {
|
|
||||||
return str.replace("-", "_").toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param value an integer you want to convert
|
* @param value an integer you want to convert
|
||||||
@ -127,11 +123,6 @@ public class MMOCoreUtils {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toEnumName(String str) {
|
|
||||||
return str.replace("-","_").replace(" ","_").toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String toBase64(ItemStack[] items) {
|
public static String toBase64(ItemStack[] items) {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.command;
|
package net.Indyuce.mmocore.command;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -19,7 +19,7 @@ public class CommandVerbose {
|
|||||||
|
|
||||||
for (CommandType type : CommandType.values())
|
for (CommandType type : CommandType.values())
|
||||||
try {
|
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) {
|
} catch (IllegalArgumentException exception) {
|
||||||
values.put(type, VerboseValue.TRUE);
|
values.put(type, VerboseValue.TRUE);
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load command verbose action for " + type.name());
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load command verbose action for " + type.name());
|
||||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmocore.api.SoundEvent;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
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.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
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.skilltree.SkillTree;
|
||||||
import net.Indyuce.mmocore.tree.SkillTreeNode;
|
import net.Indyuce.mmocore.tree.SkillTreeNode;
|
||||||
import net.Indyuce.mmocore.tree.skilltree.display.Icon;
|
import net.Indyuce.mmocore.tree.skilltree.display.Icon;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
@ -28,7 +28,6 @@ import org.bukkit.persistence.PersistentDataContainer;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SkillTreeViewer extends EditableInventory {
|
public class SkillTreeViewer extends EditableInventory {
|
||||||
@ -214,10 +213,10 @@ public class SkillTreeViewer extends EditableInventory {
|
|||||||
private final int maxTreeListPage;
|
private final int maxTreeListPage;
|
||||||
private final SkillTree skillTree;
|
private final SkillTree skillTree;
|
||||||
|
|
||||||
|
|
||||||
public SkillTreeInventory(PlayerData playerData, EditableInventory editable) {
|
public SkillTreeInventory(PlayerData playerData, EditableInventory editable) {
|
||||||
super(playerData, editable);
|
super(playerData, editable);
|
||||||
skillTree = playerData.getCachedSkillTree();
|
|
||||||
|
skillTree = playerData.getOpenedSkillTree();
|
||||||
maxTreeListPage = (MMOCore.plugin.skillTreeManager.getAll().size() - 1) / editable.getByFunction("skill-tree").getSlots().size();
|
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)
|
//We get the width and height of the GUI(corresponding to the slots given)
|
||||||
List<Integer> slots = editable.getByFunction("skill-tree-node").getSlots();
|
List<Integer> slots = editable.getByFunction("skill-tree-node").getSlots();
|
||||||
@ -266,9 +265,7 @@ public class SkillTreeViewer extends EditableInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
public void whenClicked(InventoryClickContext event, InventoryItem item) {
|
||||||
|
|
||||||
|
|
||||||
if (item.getFunction().equals("next-tree-list-page")) {
|
if (item.getFunction().equals("next-tree-list-page")) {
|
||||||
treeListPage++;
|
treeListPage++;
|
||||||
open();
|
open();
|
||||||
@ -313,9 +310,8 @@ public class SkillTreeViewer extends EditableInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (item.getFunction().equals("skill-tree")) {
|
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);
|
new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING);
|
||||||
playerData.setCachedSkillTree(MMOCore.plugin.skillTreeManager.get(id));
|
playerData.setCachedSkillTree(MMOCore.plugin.skillTreeManager.get(id));
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.CHANGE_SKILL_TREE).playTo(player);
|
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 (item.getFunction().equals("skill-tree-node")) {
|
||||||
|
|
||||||
if (event.getAction().equals(InventoryAction.PICKUP_HALF)) {
|
if (event.getClickType() == ClickType.RIGHT) {
|
||||||
int offset = event.getSlot();
|
int offset = event.getSlot();
|
||||||
int xOffset=offset%9-middleSlot%9;
|
int xOffset=offset%9-middleSlot%9;
|
||||||
int yOffset=offset/9-middleSlot/9;
|
int yOffset=offset/9-middleSlot/9;
|
||||||
@ -338,8 +334,8 @@ public class SkillTreeViewer extends EditableInventory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event.getAction() == InventoryAction.PICKUP_ALL) {
|
else if (event.getClickType() == ClickType.LEFT) {
|
||||||
PersistentDataContainer container = event.getCurrentItem().getItemMeta().getPersistentDataContainer();
|
PersistentDataContainer container = event.getItemStack().getItemMeta().getPersistentDataContainer();
|
||||||
int x = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.x"), PersistentDataType.INTEGER);
|
int x = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.x"), PersistentDataType.INTEGER);
|
||||||
int y = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.y"), PersistentDataType.INTEGER);
|
int y = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.y"), PersistentDataType.INTEGER);
|
||||||
SkillTreeNode node = skillTree.getNode(new IntegerCoordinates(x, y));
|
SkillTreeNode node = skillTree.getNode(new IntegerCoordinates(x, y));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.gui.api;
|
package net.Indyuce.mmocore.gui.api;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.gui.api.adaptor.AdaptorType;
|
import net.Indyuce.mmocore.gui.api.adaptor.AdaptorType;
|
||||||
@ -39,7 +40,7 @@ public abstract class EditableInventory {
|
|||||||
|
|
||||||
public void reload(FileConfiguration config) {
|
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
|
Validate.notNull(adaptorType, config.getString("adaptor-type") + " does not correspond to an adaptor-type.");//TODO
|
||||||
|
|
||||||
this.radius = config.getDouble("radius", 2);
|
this.radius = config.getDouble("radius", 2);
|
||||||
|
@ -8,7 +8,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
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<>();
|
protected final Map<String, T> registered = new HashMap<>();
|
||||||
|
|
||||||
public void register(T t) {
|
public void register(T t) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.manager.registry;
|
package net.Indyuce.mmocore.manager.registry;
|
||||||
|
|
||||||
public interface RegisterObject {
|
public interface RegisteredObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifier used to register an object
|
* Identifier used to register an object
|
@ -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.script.mechanic.type.TargetMechanic;
|
||||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
import io.lumine.mythic.lib.skill.SkillMetadata;
|
@ -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.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
import io.lumine.mythic.lib.skill.SkillMetadata;
|
@ -1,4 +1,4 @@
|
|||||||
package net.Indyuce.mmocore.skill.custom.mechanic;
|
package net.Indyuce.mmocore.script.mechanic;
|
||||||
|
|
||||||
public enum Operation {
|
public enum Operation {
|
||||||
GIVE,
|
GIVE,
|
@ -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.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
import io.lumine.mythic.lib.skill.SkillMetadata;
|
@ -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.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
|
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.tree;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcmmo.acf.annotation.HelpSearchTags;
|
import com.gmail.nossr50.mcmmo.acf.annotation.HelpSearchTags;
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
import io.lumine.mythic.lib.player.modifier.PlayerModifier;
|
import io.lumine.mythic.lib.player.modifier.PlayerModifier;
|
||||||
import io.lumine.mythic.lib.util.configobject.ConfigObject;
|
import io.lumine.mythic.lib.util.configobject.ConfigObject;
|
||||||
@ -27,6 +28,7 @@ public class SkillTreeNode implements Unlockable {
|
|||||||
private final String name, id;
|
private final String name, id;
|
||||||
private IntegerCoordinates coordinates;
|
private IntegerCoordinates coordinates;
|
||||||
private boolean isRoot;
|
private boolean isRoot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The lore corresponding to each level
|
* The lore corresponding to each level
|
||||||
*/
|
*/
|
||||||
@ -35,64 +37,58 @@ public class SkillTreeNode implements Unlockable {
|
|||||||
//TODO modifiers depending on level with drop tables
|
//TODO modifiers depending on level with drop tables
|
||||||
private final HashMap<Integer, List<PlayerModifier>> modifiers = new HashMap<>();
|
private final HashMap<Integer, List<PlayerModifier>> modifiers = new HashMap<>();
|
||||||
private final HashMap<Integer, List<Trigger>> triggers = 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.
|
//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 int maxLevel, maxChildren, size;
|
||||||
private final ArrayList<SkillTreeNode> children = new ArrayList<>();
|
private final ArrayList<SkillTreeNode> children = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates the required level to each parent
|
* 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
|
* <p>
|
||||||
* of all of your strong parents.
|
* 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> softParents = new HashMap<>();
|
||||||
private final HashMap<SkillTreeNode, Integer> strongParents = new HashMap<>();
|
private final HashMap<SkillTreeNode, Integer> strongParents = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public SkillTreeNode(SkillTree tree, ConfigurationSection config) {
|
public SkillTreeNode(SkillTree tree, ConfigurationSection config) {
|
||||||
|
|
||||||
|
|
||||||
Validate.notNull(config, "Config cannot be null");
|
Validate.notNull(config, "Config cannot be null");
|
||||||
this.id = config.getName();
|
this.id = config.getName();
|
||||||
this.tree = tree;
|
this.tree = tree;
|
||||||
name = Objects.requireNonNull(config.getString("name"), "Could not find node name");
|
name = Objects.requireNonNull(config.getString("name"), "Could not find node name");
|
||||||
size = Objects.requireNonNull(config.getInt("size"));
|
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.
|
//We initialize the value of the lore for each skill tree node.
|
||||||
for (String state : Objects.requireNonNull(config.getConfigurationSection("lores")).getKeys(false)) {
|
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) {
|
if (nodeState == NodeState.UNLOCKED) {
|
||||||
//TODO: Message could'nt load ... instead of exce/*99+*-*99**9+-ption
|
//TODO: Message could'nt load ... instead of exce/*99+*-*99**9+-ption
|
||||||
ConfigurationSection section = config.getConfigurationSection("lores." + state);
|
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));
|
lores.put(new NodeContext(nodeState, Integer.parseInt(level)), section.getStringList(level));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
lores.put(new NodeContext(nodeState, 0), config.getStringList("lores." + state));
|
lores.put(new NodeContext(nodeState, 0), config.getStringList("lores." + state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//We load the triggers
|
//We load the triggers
|
||||||
if (config.contains("triggers")) {
|
if (config.contains("triggers")) {
|
||||||
try {
|
try {
|
||||||
ConfigurationSection section = config.getConfigurationSection("triggers");
|
ConfigurationSection section = config.getConfigurationSection("triggers");
|
||||||
for (String level : section.getKeys(false)) {
|
for (String levelFormat : section.getKeys(false)) {
|
||||||
int value = Integer.parseInt(level);
|
final int level = Integer.parseInt(levelFormat);
|
||||||
for (String str : section.getStringList(level)) {
|
final List<Trigger> triggers = new ArrayList<>();
|
||||||
List<Trigger> triggerList = MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(str));
|
for (String str : section.getStringList(levelFormat))
|
||||||
for (Trigger trigger : triggerList) {
|
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(str)));
|
||||||
if (!triggers.containsKey(value)) {
|
this.triggers.put(level, triggers);
|
||||||
triggers.put(value, new ArrayList<>());
|
|
||||||
}
|
|
||||||
triggers.get(value).add(trigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} 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
|
//We load the player Modifiers
|
||||||
if (config.contains("modifiers")) {
|
if (config.contains("modifiers")) {
|
||||||
try {
|
try {
|
||||||
@ -216,18 +212,15 @@ public class SkillTreeNode implements Unlockable {
|
|||||||
return modifiers.get(level);
|
return modifiers.get(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Trigger> getTriggers(int level) {
|
public List<Trigger> getTriggers(int level) {
|
||||||
return triggers.get(level);
|
return triggers.get(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUnlockNamespacedKey() {
|
public String getUnlockNamespacedKey() {
|
||||||
return "skill_tree:" + tree.getId() + "_" + coordinates.getX() + "_" + coordinates.getY();
|
return "skill_tree:" + tree.getId() + "_" + coordinates.getX() + "_" + coordinates.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
@ -308,7 +301,6 @@ public class SkillTreeNode implements Unlockable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param namespacedKey Something like "skill_tree:tree_name_1_5"
|
* @param namespacedKey Something like "skill_tree:tree_name_1_5"
|
||||||
* @return The corresponding skill tree node
|
* @return The corresponding skill tree node
|
||||||
@ -369,6 +361,4 @@ public class SkillTreeNode implements Unlockable {
|
|||||||
return Objects.hash(nodeState, nodeLevel);
|
return Objects.hash(nodeState, nodeLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package net.Indyuce.mmocore.tree.skilltree;
|
package net.Indyuce.mmocore.tree.skilltree;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
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.NodeState;
|
||||||
import net.Indyuce.mmocore.tree.skilltree.display.DisplayInfo;
|
import net.Indyuce.mmocore.tree.skilltree.display.DisplayInfo;
|
||||||
import net.Indyuce.mmocore.tree.skilltree.display.Icon;
|
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 net.Indyuce.mmocore.tree.SkillTreeNode;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -38,7 +38,7 @@ import java.util.logging.Level;
|
|||||||
* @author Ka0rX
|
* @author Ka0rX
|
||||||
* @see {@link SkillTreeNode}
|
* @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 String id, name;
|
||||||
private final List<String> lore = new ArrayList<>();
|
private final List<String> lore = new ArrayList<>();
|
||||||
private final Material item;
|
private final Material item;
|
||||||
@ -55,15 +55,14 @@ public abstract class SkillTree extends PostLoadObject implements RegisterObject
|
|||||||
protected final List<SkillTreeNode> roots = new ArrayList<>();
|
protected final List<SkillTreeNode> roots = new ArrayList<>();
|
||||||
|
|
||||||
public SkillTree(ConfigurationSection config) {
|
public SkillTree(ConfigurationSection config) {
|
||||||
|
|
||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
this.id = Objects.requireNonNull(config.getString("id"), "Could not find skill tree id");
|
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"));
|
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)));
|
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");
|
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
|
||||||
|
|
||||||
|
|
||||||
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
|
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisterObject
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (String size : config.getConfigurationSection("icons." + key).getKeys(false)) {
|
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));
|
Icon icon = new Icon(config.getConfigurationSection("icons." + key + "." + size));
|
||||||
icons.put(displayInfo, icon);
|
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
|
* Returns null if it is not a node and returns the node type if it a node
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public boolean isNode(IntegerCoordinates coordinates) {
|
public boolean isNode(IntegerCoordinates coordinates) {
|
||||||
for (SkillTreeNode node : nodes.values()) {
|
for (SkillTreeNode node : nodes.values()) {
|
||||||
if (node.getCoordinates().equals(coordinates))
|
if (node.getCoordinates().equals(coordinates))
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.tree.skilltree.display;
|
package net.Indyuce.mmocore.tree.skilltree.display;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -21,7 +22,7 @@ public class Icon {
|
|||||||
return customModelData;
|
return customModelData;
|
||||||
}
|
}
|
||||||
public Icon(ConfigurationSection config) {
|
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);
|
config.getString("item")))),config.contains("model-data")?config.getInt("model-data"):0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,11 +231,6 @@ resource-bar-colors:
|
|||||||
stamina-half: 'DARK_GREEN'
|
stamina-half: 'DARK_GREEN'
|
||||||
stamina-empty: 'WHITE'
|
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
|
# Whether or not the admin commands should display
|
||||||
# the result of the command when ran.
|
# the result of the command when ran.
|
||||||
# For Example: "Players Level is now 10."
|
# For Example: "Players Level is now 10."
|
||||||
|
Loading…
Reference in New Issue
Block a user