diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 5ef8df4c..db80f49c 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -239,14 +239,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc } public void giveSkillReallocationPoints(int value) { - skillReallocationPoints+=value; + skillReallocationPoints += value; } public int countSkillPointsWhenReallocate() { int sum = 0; - for(ClassSkill skill:getProfess().getSkills()) { + for (ClassSkill skill : getProfess().getSkills()) { //0 if the skill is level 1(just unlocked) or 0 locked. - sum+=Math.max(0,getSkillLevel(skill.getSkill())-1); + sum += Math.max(0, getSkillLevel(skill.getSkill()) - 1); } return sum; } @@ -415,6 +415,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc waypoints.add(waypoint.getId()); } + public void lockWaypoint(Waypoint waypoint) { + waypoints.remove(waypoint); + } + + /** * @deprecated Provide a heal reason with {@link #heal(double, PlayerResourceUpdateEvent.UpdateReason)} */ @@ -770,6 +775,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); } + @Deprecated public void setAttribute(PlayerAttribute attribute, int value) { setAttribute(attribute.getId(), value); diff --git a/src/main/java/net/Indyuce/mmocore/command/CommandVerbose.java b/src/main/java/net/Indyuce/mmocore/command/CommandVerbose.java index fa6c47e5..24a16d45 100644 --- a/src/main/java/net/Indyuce/mmocore/command/CommandVerbose.java +++ b/src/main/java/net/Indyuce/mmocore/command/CommandVerbose.java @@ -56,7 +56,8 @@ public class CommandVerbose { NOCD, POINTS, RESET, - RESOURCE + RESOURCE, + WAYPOINT; } private enum VerboseValue { diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/WaypointCommandTreeNode.java b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/WaypointCommandTreeNode.java new file mode 100644 index 00000000..01daddbf --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/WaypointCommandTreeNode.java @@ -0,0 +1,75 @@ +package net.Indyuce.mmocore.command.rpg.admin; + +import io.lumine.mythic.lib.command.api.CommandTreeNode; +import io.lumine.mythic.lib.command.api.Parameter; +import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.command.CommandVerbose; +import net.Indyuce.mmocore.waypoint.Waypoint; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.function.BiConsumer; +import java.util.function.BiFunction; + +public class WaypointCommandTreeNode extends CommandTreeNode { + public WaypointCommandTreeNode(CommandTreeNode parent) { + super(parent, "waypoint"); + addChild(new ActionCommandTreeNode(this, "unlock", + (playerData, waypoint) -> !playerData.getWaypoints().contains(waypoint) + , (playerData, waypoint) -> playerData.unlockWaypoint(waypoint))); + addChild(new ActionCommandTreeNode(this, "lock", + (playerData, waypoint) -> playerData.getWaypoints().contains(waypoint) + , (playerData, waypoint) -> playerData.lockWaypoint(waypoint))); + } + + @Override + public CommandResult execute(CommandSender commandSender, String[] strings) { + return null; + } + + private class ActionCommandTreeNode extends CommandTreeNode { + private final BiFunction check; + private final BiConsumer change; + + + public ActionCommandTreeNode(CommandTreeNode parent, String id, + BiFunction check, + BiConsumer change) { + super(parent, id); + this.change = change; + this.check = check; + addParameter(Parameter.PLAYER); + addParameter(new Parameter("waypoint", ((commandTreeExplorer, list) -> + MMOCore.plugin.waypointManager.getAll().forEach(waypoint -> list.add(waypoint.getId())) + ))); + } + + @Override + public CommandResult execute(CommandSender sender, String[] args) { + Player player = Bukkit.getPlayer(args[0]); + if (player == null) { + sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[0] + "."); + return CommandResult.FAILURE; + } + + Waypoint waypoint = MMOCore.plugin.waypointManager.get(args[1]); + if (waypoint == null) { + sender.sendMessage(ChatColor.RED + "Could not find the waypoint called " + args[1] + "."); + return CommandResult.FAILURE; + } + + PlayerData playerData = PlayerData.get(player); + if (!check.apply(playerData, waypoint)) { + sender.sendMessage(ChatColor.RED + "The waypoint " + args[1] + "is already in this state."); + return CommandResult.FAILURE; + } + change.accept(playerData, waypoint); + return CommandResult.SUCCESS; + + } + } + +} diff --git a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 2c4fb192..a64368e4 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -376,7 +376,7 @@ public class SkillList extends EditableInventory { if (item.getFunction().equals("slot")) { int index = slotSlots.indexOf(context.getSlot()); -KEy // unbind if there is a current spell. + // unbind if there is a current spell. if (context.getClickType() == ClickType.RIGHT) { if (!playerData.hasSkillBound(index)) { MMOCore.plugin.configManager.getSimpleMessage("no-skill-bound").send(player); diff --git a/src/main/java/net/Indyuce/mmocore/skill/cast/listener/KeyCombos.java b/src/main/java/net/Indyuce/mmocore/skill/cast/listener/KeyCombos.java index 5c6ef186..04600530 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/cast/listener/KeyCombos.java +++ b/src/main/java/net/Indyuce/mmocore/skill/cast/listener/KeyCombos.java @@ -104,7 +104,6 @@ public class KeyCombos implements Listener { } - // Adding pressed key CustomSkillCastingHandler casting = (CustomSkillCastingHandler) playerData.getSkillCasting(); casting.current.registerKey(event.getPressed()); @@ -173,18 +172,21 @@ public class KeyCombos implements Listener { CustomSkillCastingHandler(PlayerData caster) { super(caster, 10); if (!caster.getProfess().getCombos().isEmpty()) { - classCombos=caster.getProfess().getCombos(); - classLongestCombo=caster.getProfess().getLongestCombo(); + classCombos = caster.getProfess().getCombos(); + classLongestCombo = caster.getProfess().getLongestCombo(); } else { classCombos = combos; - classLongestCombo=longestCombo; + classLongestCombo = longestCombo; } } @Override public void onTick() { if (actionBarOptions != null) - getCaster().displayActionBar(actionBarOptions.format(this)); + if (actionBarOptions.isSubtitle) + getCaster().getPlayer().sendTitle(" ", actionBarOptions.format(this), 0, 20, 0); + else + getCaster().displayActionBar(actionBarOptions.format(this)); } } @@ -198,11 +200,13 @@ public class KeyCombos implements Listener { * the current player's key combo on the action bar */ private final Map keyNames = new HashMap<>(); + private final boolean isSubtitle; ActionBarOptions(ConfigurationSection config) { + this.separator = Objects.requireNonNull(config.getString("separator"), "Could not find action bar option 'separator'"); this.noKey = Objects.requireNonNull(config.getString("no-key"), "Could not find action bar option 'no-key'"); - + this.isSubtitle = config.getBoolean("is-subtitle", false); for (PlayerKey key : PlayerKey.values()) keyNames.put(key, Objects.requireNonNull(config.getString("key-name." + key.name()), "Could not find translation for key " + key.name())); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 54f170b7..ddba977d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -256,4 +256,5 @@ command-verbose: nocd: true points: true reset: true - resource: true \ No newline at end of file + resource: true + waypoint: true \ No newline at end of file