From e5c3670e0d011c303fc38b0fca077b06a1e4be1a Mon Sep 17 00:00:00 2001 From: Indyuce Date: Fri, 15 Jul 2022 10:47:22 +0200 Subject: [PATCH 1/4] framework for guild target restrictions --- .../Indyuce/mmocore/guild/RelationType.java | 19 +++++++++++++++++++ src/main/resources/config.yml | 8 ++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/main/java/net/Indyuce/mmocore/guild/RelationType.java diff --git a/src/main/java/net/Indyuce/mmocore/guild/RelationType.java b/src/main/java/net/Indyuce/mmocore/guild/RelationType.java new file mode 100644 index 00000000..1277296c --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/guild/RelationType.java @@ -0,0 +1,19 @@ +package net.Indyuce.mmocore.guild; + +public enum RelationType { + + /** + * In the same guild + */ + ALLY, + + /** + * One of the two players has no guild + */ + NEUTRAL, + + /** + * + */ + ENEMY; +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d7eb3cdb..1985a826 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -211,6 +211,14 @@ can-creative-cast: false # This replaces anvil inputs by chat inputs. use-chat-input: true +ability-targeting-options: + + # Prevent heals/buffs on players in a different guild + cant-heal-enemies: true + + # Prevent heals/buffs UNLESS the player is in your party/guild + cant-heal-neutrals: false + # Prevents mobs spawned from spawners from giving XP points. prevent-spawner-xp: true From a6594687754ee156c4aef51e5c156463276dbc60 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 24 Jul 2022 21:25:26 +0200 Subject: [PATCH 2/4] Fixed period of 0 for exp items --- .../experience/droptable/ExperienceItem.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java b/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java index e9a6035a..27045351 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java +++ b/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java @@ -55,9 +55,7 @@ public class ExperienceItem { Validate.isTrue(config.contains("triggers")); id = config.getName(); - final int periodOption = config.getInt("period", 1); - // A period of 0 means the item will only trigger once - period = periodOption == 0 ? Integer.MAX_VALUE : periodOption; + period = config.getInt("period", 1); firstTrigger = config.getInt("first-trigger", period); lastTrigger = config.getInt("last-trigger", Integer.MAX_VALUE); claimChance = config.getDouble("chance", 100) / 100; @@ -79,10 +77,17 @@ public class ExperienceItem { * account the randomness factor from the 'chance' parameter */ public boolean roll(int professionLevel, int timesCollected) { + + // Check for the last triggering level if (professionLevel > lastTrigger) return false; - int claimsRequired = (professionLevel + 1 - (firstTrigger + timesCollected * period)); + // A period of 0 means the item only triggers once + if (period == 0 && timesCollected > 0) + return false; + + // Basic formula + final int claimsRequired = (professionLevel + 1 - (firstTrigger + timesCollected * period)); if (claimsRequired < 1) return false; From 55d1a3cf13bddd4bb3804ba4790b7e6f6826d170 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 24 Jul 2022 21:58:57 +0200 Subject: [PATCH 3/4] Fixed an issue with 'Skill Scroller' casting mode --- .../net/Indyuce/mmocore/skill/cast/listener/SkillScroller.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/Indyuce/mmocore/skill/cast/listener/SkillScroller.java b/src/main/java/net/Indyuce/mmocore/skill/cast/listener/SkillScroller.java index 43717196..c7189bcf 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/cast/listener/SkillScroller.java +++ b/src/main/java/net/Indyuce/mmocore/skill/cast/listener/SkillScroller.java @@ -107,6 +107,9 @@ public class SkillScroller implements Listener { CustomSkillCastingHandler casting = (CustomSkillCastingHandler) playerData.getSkillCasting(); casting.index = mod(casting.index + change, playerData.getBoundSkills().size()); casting.onTick(); + + if (changeSound != null) + changeSound.playTo(event.getPlayer()); } private int mod(int x, int n) { From 1ac652e4598025d002be7524c7f39fb27b32862d Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 24 Jul 2022 22:36:38 +0200 Subject: [PATCH 4/4] Fixed attributes points spending overflow --- .../mmocore/api/player/PlayerData.java | 4 +-- .../Indyuce/mmocore/gui/AttributeView.java | 30 +++++++------------ src/main/resources/default/messages.yml | 4 +-- 3 files changed, 13 insertions(+), 25 deletions(-) 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 20db1fb1..c98a805e 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -804,12 +804,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc Validate.isTrue(isCasting(), "Player not in casting mode"); skillCasting.close(); this.skillCasting = null; + setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar } public void displayActionBar(String message) { - if (!isOnline()) - return; - setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE); getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); } diff --git a/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java b/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java index ebd108e7..21dd9065 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java @@ -16,8 +16,6 @@ import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryClickEvent; -import java.util.logging.Level; - public class AttributeView extends EditableInventory { public AttributeView() { super("attribute-view"); @@ -47,20 +45,14 @@ public class AttributeView extends EditableInventory { public static class AttributeItem extends InventoryItem { private final PlayerAttribute attribute; - private int shiftCost=1; + private final int shiftCost; public AttributeItem(String function, ConfigurationSection config) { super(config); attribute = MMOCore.plugin.attributeManager .get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-")); - if(config.contains("shift-cost")) { - shiftCost = config.getInt("shift-cost"); - if (shiftCost < 1) { - MMOCore.log(Level.WARNING, "Level up points cost must not be less than 1. Using default value: 1"); - shiftCost = 1; - } - } + shiftCost = Math.max(config.getInt("shift-cost"), 1); } @Override @@ -124,7 +116,6 @@ public class AttributeView extends EditableInventory { if (item.getFunction().startsWith("attribute_")) { PlayerAttribute attribute = ((AttributeItem) item).attribute; - int shiftCost = ((AttributeItem) item).shiftCost; if (playerData.getAttributePoints() < 1) { MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player); @@ -140,16 +131,15 @@ public class AttributeView extends EditableInventory { } // Amount of points spent - int pointsSpent = 1; + final boolean shiftClick = event.isShiftClick(); + int pointsSpent = shiftClick ? ((AttributeItem) item).shiftCost : 1; + if (attribute.hasMax()) + pointsSpent = Math.min(pointsSpent, attribute.getMax() - ins.getBase()); - if (event.isShiftClick()) { - if (playerData.getAttributePoints() < shiftCost) { - MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", "" + shiftCost).send(player); - MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer()); - return; - } - - pointsSpent = shiftCost; + if (shiftClick && playerData.getAttributePoints() < pointsSpent) { + MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", String.valueOf(pointsSpent)).send(player); + MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer()); + return; } ins.addBase(pointsSpent); diff --git a/src/main/resources/default/messages.yml b/src/main/resources/default/messages.yml index f15c0711..ee0499a6 100644 --- a/src/main/resources/default/messages.yml +++ b/src/main/resources/default/messages.yml @@ -156,8 +156,8 @@ cant-choose-new-class: # Attributes no-attribute-points-spent: '&cYou have not spent any attribute points.' not-attribute-reallocation-point: '&cYou do not have 1 reallocation point.' -not-attribute-point: '&cYou do not have 1 attribute point.' -not-attribute-point-shift: '&cYou do not have &4{shift_points} &cattribute points.' +not-attribute-point: '&cYou have no attribute point.' +not-attribute-point-shift: '&cYou must have &4{shift_points} &cattribute points.' attribute-points-reallocated: '&eYou successfully reset your attributes. You now have &6{points} &eattribute points.' attribute-max-points-hit: '&cYou cannot level up this attribute anymore.' attribute-level-up: '&eYou successfully leveled up your &6{attribute}&e.' # {level}