From 41aad7b6a146e2b389fb584153b6115a60052eca Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Wed, 29 Mar 2023 23:35:47 +0100 Subject: [PATCH] Transfered unlockedItems from MythicLib to MMOCore. --- .../java/net/Indyuce/mmocore/MMOCore.java | 2 - .../api/event/unlocking/ItemChangeEvent.java | 36 ++++++++++ .../api/event/unlocking/ItemLockedEvent.java | 24 +++++++ .../event/unlocking/ItemUnlockedEvent.java | 22 ++++++ .../mmocore/api/player/PlayerData.java | 72 ++++++++++++++----- .../mmocore/api/player/Unlockable.java | 24 +++++++ .../player/profess/SavedClassInformation.java | 2 +- .../api/quest/trigger/UnlockSkillTrigger.java | 4 +- .../rpg/admin/SkillCommandTreeNode.java | 8 +-- .../net/Indyuce/mmocore/gui/SkillList.java | 2 +- .../data/mysql/MySQLPlayerDataManager.java | 4 +- .../data/yaml/YAMLPlayerDataManager.java | 2 +- .../mmocore/player/ClassDataContainer.java | 2 +- .../mmocore/player/DefaultPlayerData.java | 2 +- .../mmocore/skill/RegisteredSkill.java | 23 +++++- .../Indyuce/mmocore/waypoint/Waypoint.java | 13 +++- .../net/Indyuce/mmocore/MMOCoreBukkit.java | 1 - .../listener/SkillLockingListener.java | 25 ------- 18 files changed, 206 insertions(+), 62 deletions(-) create mode 100644 MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemChangeEvent.java create mode 100644 MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemLockedEvent.java create mode 100644 MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemUnlockedEvent.java create mode 100644 MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/Unlockable.java delete mode 100644 MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java index e820d667..e059aa65 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -57,8 +57,6 @@ import java.util.logging.Level; public class MMOCore extends JavaPlugin { public static MMOCore plugin; - public final static String MMOCORE_ITEM_ID = "mmocore:"; - public final WaypointManager waypointManager = new WaypointManager(); public final SoundManager soundManager = new SoundManager(); public final RequestManager requestManager = new RequestManager(); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemChangeEvent.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemChangeEvent.java new file mode 100644 index 00000000..b4280658 --- /dev/null +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemChangeEvent.java @@ -0,0 +1,36 @@ +package net.Indyuce.mmocore.api.event.unlocking; + +import net.Indyuce.mmocore.api.event.PlayerDataEvent; +import net.Indyuce.mmocore.api.player.PlayerData; + +public abstract class ItemChangeEvent extends PlayerDataEvent { + private final String itemKey; + + public ItemChangeEvent(PlayerData playerData, String itemKey) { + super(playerData); + this.itemKey = itemKey; + } + + /** + * @return The full item key in the format ::. + */ + public String getItemKey() { + return itemKey; + } + + + /** + * @return The item-type-id which is the first parameter in the key format :. + */ + public String getItemTypeId() { + return itemKey.split(":")[0]; + } + + /** + * @return The item--id which is the last parameter in the key format :. + */ + public String getItemId() { + return itemKey.split(":")[1]; + } +} + diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemLockedEvent.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemLockedEvent.java new file mode 100644 index 00000000..0e9bf37f --- /dev/null +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemLockedEvent.java @@ -0,0 +1,24 @@ +package net.Indyuce.mmocore.api.event.unlocking; + +import net.Indyuce.mmocore.api.player.PlayerData; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +public class ItemLockedEvent extends ItemChangeEvent { + private static final HandlerList handlers = new HandlerList(); + + public ItemLockedEvent(PlayerData playerData, String itemKey) { + super(playerData, itemKey); + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} + diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemUnlockedEvent.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemUnlockedEvent.java new file mode 100644 index 00000000..aa6158e9 --- /dev/null +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/unlocking/ItemUnlockedEvent.java @@ -0,0 +1,22 @@ +package net.Indyuce.mmocore.api.event.unlocking; +import net.Indyuce.mmocore.api.player.PlayerData; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +public class ItemUnlockedEvent extends ItemChangeEvent { + private static final HandlerList handlers = new HandlerList(); + + public ItemUnlockedEvent(PlayerData playerData, String itemKey) { + super(playerData, itemKey); + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 880812f9..68c5a47d 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -12,6 +12,8 @@ import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent; +import net.Indyuce.mmocore.api.event.unlocking.ItemLockedEvent; +import net.Indyuce.mmocore.api.event.unlocking.ItemUnlockedEvent; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes; import net.Indyuce.mmocore.api.player.profess.PlayerClass; @@ -65,9 +67,6 @@ import java.util.*; import java.util.logging.Level; import java.util.stream.Collectors; -import static net.Indyuce.mmocore.MMOCore.MMOCORE_ITEM_ID; - - public class PlayerData extends OfflinePlayerData implements Closable, ExperienceTableClaimer, ClassDataContainer { /** @@ -113,7 +112,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc private final Map nodeLevels = new HashMap<>(); private final Map skillTreePoints = new HashMap<>(); - + /** + * Saves the namespacedkey of the items that have been unlocked in the form item-type:item-key. + * This is used for: + * -Waypoints + * -Skills + * -Skill Books + */ + private final Set unlockedItems= new HashSet<>(); /** * Saves the amount of times the player has claimed some * exp item in exp tables, for both exp tables used @@ -366,27 +372,59 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc return result; } + + /** - * @return All the unlocked items that are handled by MMOCore (the ones that MMOCore saves & load by itself. + * @return If the item is unlocked by the player + * This is used for skills that can be locked & unlocked. + *

+ * Looks at the real value and thus remove the plugin identifier */ - @Override - public Set getMMOUnlockedItems() { - return mmoData.getUnlockedItems().stream().filter(key -> key.startsWith(MMOCORE_ITEM_ID)).collect(Collectors.toSet()); + public boolean hasUnlocked(Unlockable unlockable) { + String unlockableKey = unlockable.getUnlockNamespacedKey().substring(unlockable.getUnlockNamespacedKey().indexOf(":")); + return unlockedItems + .stream() + .filter(key -> key.substring(key.indexOf(":")).equals(unlockableKey)) + .collect(Collectors.toList()).size() != 0; } /** - * Used to change the value of the unlockedItems handled by mmocore. + * Unlocks an item for the player. This is mainly used to unlock skills. * - * @param unlockedItems + * @return If the item was locked when calling this method. */ + public boolean unlock(Unlockable unlockable) { + boolean wasLocked = unlockedItems.add(unlockable.getUnlockNamespacedKey()); + if (wasLocked) + //Calls the event synchronously + Bukkit.getScheduler().runTask(MythicLib.plugin, + () -> Bukkit.getPluginManager().callEvent(new ItemUnlockedEvent(this, unlockable.getUnlockNamespacedKey()))); + + return wasLocked; + } + + /** + * Locks an item for the player by removing it from the unlocked items map if it is present. + * This is mainly used to remove unlocked items when changing class or reallocating a skill tree. + * + * @return If the item was unlocked when calling this method. + */ + public boolean lock(Unlockable unlockable) { + boolean wasUnlocked = unlockedItems.remove(unlockable.getUnlockNamespacedKey()); + if (wasUnlocked) + //Calls the event synchronously + Bukkit.getScheduler().runTask(MythicLib.plugin, () -> Bukkit.getPluginManager().callEvent(new ItemLockedEvent(this, unlockable.getUnlockNamespacedKey()))); + return wasUnlocked; + } + + public Set getUnlockedItems() { + return new HashSet<>(unlockedItems); + } + public void setUnlockedItems(Set unlockedItems) { - Set mythicUnlockedItems = mmoData.getUnlockedItems() - .stream() - .filter((key) -> !key.startsWith(MMOCORE_ITEM_ID)) - .collect(Collectors.toSet()); - mythicUnlockedItems.addAll(unlockedItems); - mmoData.setUnlockedItems(mythicUnlockedItems); + unlockedItems.clear(); + unlockedItems.addAll(unlockedItems); } @@ -1134,7 +1172,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc profess.getSkills() .stream() .filter(ClassSkill::isUnlockedByDefault) - .forEach(skill -> mmoData.unlock(skill.getSkill())); + .forEach(skill ->unlock(skill.getSkill())); } public boolean hasSkillBound(int slot) { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/Unlockable.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/Unlockable.java new file mode 100644 index 00000000..60926d91 --- /dev/null +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/Unlockable.java @@ -0,0 +1,24 @@ +package net.Indyuce.mmocore.api.player; + +/** + * Some item that can be unlocked. All unlockables are saved in the + * same list in the player data. This useful list can be used for: + * - waypoints + * - skill tree nodes + * - skills using skill books? + * - external plugins that implement other unlockable items + * + * @see {@link PlayerData#unlock(Unlockable)} and {@link PlayerData#hasUnlocked(Unlockable)} + */ +public interface Unlockable { + + /** + * Format being used is the minecraft's default namespaced + * key format, e.g "skill_tree:strength_1_5" for readability + */ + String getUnlockNamespacedKey(); + + void whenLocked(PlayerData playerData); + + void whenUnlocked(PlayerData playerData); +} diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java index 2424f8cb..ab0bd9c9 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java @@ -124,7 +124,7 @@ public class SavedClassInformation { data.getNodeLevels().forEach((node, level) -> nodeLevels.put(node.getFullId(), level)); data.getNodeTimesClaimed().forEach((key, val) -> nodeTimesClaimed.put(key, val)); data.mapBoundSkills().forEach((slot, skill) -> boundSkills.put(slot, skill)); - data.getMMOUnlockedItems().forEach(item->unlockedItems.add(item)); + data.getUnlockedItems().forEach(item->unlockedItems.add(item)); } public int getLevel() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java index e827f9b2..4fc77c40 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java @@ -19,11 +19,11 @@ public class UnlockSkillTrigger extends Trigger implements Removable { @Override public void apply(PlayerData player) { - player.getMMOPlayerData().unlock(skill); + player.unlock(skill); } @Override public void remove(PlayerData playerData) { - playerData.getMMOPlayerData().lock(skill); + playerData.lock(skill); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SkillCommandTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SkillCommandTreeNode.java index 67b92505..7aa355fc 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SkillCommandTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SkillCommandTreeNode.java @@ -111,18 +111,18 @@ public class SkillCommandTreeNode extends CommandTreeNode { return CommandResult.FAILURE; } if (lock) { - if (!playerData.getMMOPlayerData().hasUnlocked(skill.getSkill())) { + if (!playerData.hasUnlocked(skill.getSkill())) { CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.RED + "The skill " + skill.getSkill().getName() + " is already locked" + " for " + player.getName()); return CommandResult.SUCCESS; } - playerData.getMMOPlayerData().lock(skill.getSkill()); + playerData.lock(skill.getSkill()); } else { - if (playerData.getMMOPlayerData().hasUnlocked(skill.getSkill())) { + if (playerData.hasUnlocked(skill.getSkill())) { CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.RED + "The skill " + skill.getSkill().getName() + " is already unlocked" + " for " + player.getName()); return CommandResult.SUCCESS; } - playerData.getMMOPlayerData().unlock(skill.getSkill()); + playerData.unlock(skill.getSkill()); } CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.GOLD + "The skill " + skill.getSkill().getName() + " is now " + (lock ? "locked" : "unlocked" + " for " + player.getName())); return CommandResult.SUCCESS; diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index cb387708..0c53849c 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -324,7 +324,7 @@ public class SkillList extends EditableInventory { super(playerData, editable); skills = playerData.getProfess().getSkills() .stream() - .filter((classSkill)->playerData.getMMOPlayerData().hasUnlocked(classSkill.getSkill())) + .filter((classSkill)->playerData.hasUnlocked(classSkill.getSkill())) .collect(Collectors.toList()); skillSlots = getEditable().getByFunction("skill").getSlots(); Validate.notNull(getEditable().getByFunction("slot"), "Your skill GUI config file is out-of-date, please regenerate it."); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java index 666b80ea..6aede10d 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java @@ -63,7 +63,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager { updater.addData("professions", data.getCollectionSkills().toJsonString()); updater.addData("quests", data.getQuestData().toJsonString()); updater.addData("class_info", createClassInfoData(data).toString()); - updater.addJSONArray("unlocked_items", data.getMMOUnlockedItems()); + updater.addJSONArray("unlocked_items", data.getUnlockedItems()); if (logout) updater.addData("is_saved", 1); @@ -90,7 +90,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager { classinfo.addProperty("stamina", info.getStamina()); classinfo.addProperty("stellium", info.getStellium()); JsonArray array = new JsonArray(); - for (String unlockedItem : playerData.getMMOUnlockedItems()) { + for (String unlockedItem : playerData.getUnlockedItems()) { array.add(unlockedItem); } classinfo.add("unlocked-items", array); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java index 2f28b1f7..c5d029b4 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java @@ -159,7 +159,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager { data.getItemClaims().forEach((key, times) -> config.set("times-claimed." + key, times)); data.mapBoundSkills().forEach((slot, skill) -> config.set("bound-skills." + slot, skill)); - config.set("unlocked-items", data.getMMOUnlockedItems().stream().collect(Collectors.toList())); + config.set("unlocked-items", data.getUnlockedItems().stream().collect(Collectors.toList())); config.set("attribute", null); config.createSection("attribute"); data.getAttributes().save(config.getConfigurationSection("attribute")); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java index c30934e5..0aa8a759 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java @@ -47,5 +47,5 @@ public interface ClassDataContainer { Map getNodeTimesClaimed(); - Set getMMOUnlockedItems(); + Set getUnlockedItems(); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java index 06efa836..1a46af5e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java @@ -120,7 +120,7 @@ public class DefaultPlayerData implements ClassDataContainer { } @Override - public Set getMMOUnlockedItems() { + public Set getUnlockedItems() { return new HashSet<>(); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java index a1610d12..91b505c6 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java @@ -1,10 +1,11 @@ package net.Indyuce.mmocore.skill; import io.lumine.mythic.lib.UtilityMethods; -import io.lumine.mythic.lib.player.Unlockable; import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.trigger.TriggerType; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.player.Unlockable; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; @@ -12,6 +13,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.util.*; public class RegisteredSkill implements Unlockable { @@ -33,7 +35,7 @@ public class RegisteredSkill implements Unlockable { categories = config.getStringList("categories"); // Trigger type triggerType = getHandler().isTriggerable() ? (config.contains("passive-type") ? TriggerType.valueOf(UtilityMethods.enumName(config.getString("passive-type"))) : TriggerType.CAST) : TriggerType.API; - if(triggerType.isPassive()) + if (triggerType.isPassive()) categories.add("passive"); else categories.add("active"); @@ -60,7 +62,22 @@ public class RegisteredSkill implements Unlockable { @Override public String getUnlockNamespacedKey() { - return MMOCore.MMOCORE_ITEM_ID+"skill:" + handler.getId().toLowerCase(); + return "skill:" + handler.getId().toLowerCase(); + } + + @Override + public void whenLocked(PlayerData playerData) { + playerData.mapBoundSkills() + .forEach((slot, skill) -> + { + if (skill.equals(getUnlockNamespacedKey().split(":")[1])) + playerData.unbindSkill(slot); + }); + } + + @Override + public void whenUnlocked(PlayerData playerData) { + } public SkillHandler getHandler() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/waypoint/Waypoint.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/waypoint/Waypoint.java index 021261e1..b7997687 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/waypoint/Waypoint.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/waypoint/Waypoint.java @@ -2,8 +2,9 @@ package net.Indyuce.mmocore.waypoint; import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.util.PostLoadObject; -import io.lumine.mythic.lib.player.Unlockable; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.player.Unlockable; import net.Indyuce.mmocore.loot.chest.condition.Condition; import net.Indyuce.mmocore.loot.chest.condition.ConditionInstance; import org.apache.commons.lang.Validate; @@ -212,6 +213,16 @@ public class Waypoint extends PostLoadObject implements Unlockable { return "waypoint:" + getId(); } + @Override + public void whenLocked(PlayerData playerData) { + + } + + @Override + public void whenUnlocked(PlayerData playerData) { + + } + @Override public int hashCode() { return Objects.hash(id); diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java index 4ded3211..160c0922 100644 --- a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java +++ b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java @@ -47,7 +47,6 @@ public class MMOCoreBukkit { Bukkit.getPluginManager().registerEvents(new FishingListener(), plugin); Bukkit.getPluginManager().registerEvents(new PlayerCollectStats(), plugin); Bukkit.getPluginManager().registerEvents(new PlayerPressKeyListener(), plugin); - Bukkit.getPluginManager().registerEvents(new SkillLockingListener(),plugin); // Bukkit.getPluginManager().registerEvents(new ClassTriggers(), plugin); } } diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java deleted file mode 100644 index d65c79d9..00000000 --- a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.Indyuce.mmocore.listener; - -import io.lumine.mythic.lib.api.event.unlocking.ItemLockedEvent; -import net.Indyuce.mmocore.api.player.PlayerData; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public class SkillLockingListener implements Listener { - - /** - * Unbind the skill from boundSkills when it becomes locked. - */ - @EventHandler - public void onSkillLock(ItemLockedEvent event) { - if (event.getItemTypeId().equals("skill")) { - PlayerData playerData = PlayerData.get(event.getData().getUniqueId()); - playerData.mapBoundSkills() - .forEach((slot, skillId) -> { - if (skillId.equalsIgnoreCase(event.getItemId())) - playerData.unbindSkill(slot); - }); - } - } -}