multMap = new HashMap<>();
@@ -334,6 +339,7 @@ public void loadEffect(String key, ConfigurationSection cs) {
OriginLocation.valueOf(cs.getString("origin", "HEAD")));
((ChaserEffect) effect).setLoadedChaser(data);
((ChaserEffect) effect).setCanLocationOverride(cs.getBoolean("location-override", false));
+ ((ChaserEffect) effect).setChaseCaster(cs.getBoolean("chase-caster", false));
break;
case CONSOLE_COMMAND:
effect = new ConsoleCommand();
diff --git a/src/main/java/land/face/strife/menus/abilities/ReturnButton.java b/src/main/java/land/face/strife/menus/abilities/ReturnButton.java
index ecfdc04c..bbc86c87 100644
--- a/src/main/java/land/face/strife/menus/abilities/ReturnButton.java
+++ b/src/main/java/land/face/strife/menus/abilities/ReturnButton.java
@@ -1,27 +1,28 @@
/**
* The MIT License Copyright (c) 2015 Teal Cube Games
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package land.face.strife.menus.abilities;
import io.pixeloutlaw.minecraft.spigot.garbage.StringExtensionsKt;
import io.pixeloutlaw.minecraft.spigot.hilt.ItemStackExtensionsKt;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.WeakHashMap;
import land.face.strife.StrifePlugin;
+import land.face.strife.menus.BlankIcon;
import ninja.amp.ampmenus.events.ItemClickEvent;
import ninja.amp.ampmenus.items.MenuItem;
import org.bukkit.Bukkit;
@@ -33,6 +34,7 @@
public class ReturnButton extends MenuItem {
private final StrifePlugin plugin;
+ private static final Map noUseMap = new WeakHashMap<>();
public ReturnButton(StrifePlugin plugin, Material material, String name) {
super(StringExtensionsKt.chatColorize(name), setNameAndLore(new ItemStack(material),
@@ -42,6 +44,9 @@ public ReturnButton(StrifePlugin plugin, Material material, String name) {
@Override
public ItemStack getFinalIcon(Player player) {
+ if (noUseMap.containsKey(player)) {
+ return BlankIcon.getBlankStack();
+ }
ItemStack stack = getIcon().clone();
ItemStackExtensionsKt.addItemFlags(stack, ItemFlag.HIDE_ATTRIBUTES);
ItemStackExtensionsKt.setDisplayName(stack, getDisplayName());
@@ -51,6 +56,11 @@ public ItemStack getFinalIcon(Player player) {
@Override
public void onItemClick(ItemClickEvent event) {
super.onItemClick(event);
+ if (noUseMap.containsKey(event.getPlayer())) {
+ event.setWillUpdate(false);
+ event.setWillClose(false);
+ return;
+ }
event.setWillClose(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (event.getPlayer() != null && event.getPlayer().isValid()) {
@@ -59,4 +69,12 @@ public void onItemClick(ItemClickEvent event) {
}, 2L);
}
+ public static void setBackButtonEnabled(Player player, boolean value) {
+ if (value) {
+ noUseMap.remove(player);
+ } else {
+ noUseMap.put(player, true);
+ }
+ }
+
}
diff --git a/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java b/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java
index d8ea87f1..1d20d9bb 100644
--- a/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java
+++ b/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java
@@ -20,10 +20,9 @@
import com.tealcube.minecraft.bukkit.TextUtils;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
+import java.util.WeakHashMap;
import land.face.strife.StrifePlugin;
import land.face.strife.data.champion.Champion;
import land.face.strife.data.champion.ChampionSaveData;
@@ -40,7 +39,7 @@
public class StatsChangeHealthDisplay extends MenuItem {
private final StrifePlugin plugin;
- private Map selfInspectMap = new HashMap<>();
+ private final Map selfInspectMap = new WeakHashMap<>();
StatsChangeHealthDisplay(StrifePlugin plugin) {
super(TextUtils.color("&c&lHealth Display Options"), new ItemStack(Material.APPLE));
@@ -51,10 +50,10 @@ public class StatsChangeHealthDisplay extends MenuItem {
public ItemStack getFinalIcon(Player commandSender) {
Player player = StrifePlugin.getInstance().getStatsMenu().getTargetPlayer();
if (!player.isValid() || commandSender != player) {
- selfInspectMap.put(commandSender.getUniqueId(), false);
+ selfInspectMap.put(commandSender, false);
return BlankIcon.getBlankStack();
}
- selfInspectMap.put(commandSender.getUniqueId(), true);
+ selfInspectMap.put(commandSender, true);
ItemStack itemStack = new ItemStack(Material.APPLE);
ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(itemStack.getType());
itemMeta.setDisplayName(getDisplayName());
@@ -75,7 +74,7 @@ public ItemStack getFinalIcon(Player commandSender) {
@Override
public void onItemClick(ItemClickEvent event) {
super.onItemClick(event);
- if (!selfInspectMap.getOrDefault(event.getPlayer().getUniqueId(), false)) {
+ if (!selfInspectMap.getOrDefault(event.getPlayer(), false)) {
return;
}
Champion champion = plugin.getChampionManager().getChampion(event.getPlayer());
diff --git a/src/main/java/land/face/strife/tasks/EnergyTask.java b/src/main/java/land/face/strife/tasks/EnergyTask.java
index 25029a9a..4c7d3e8a 100644
--- a/src/main/java/land/face/strife/tasks/EnergyTask.java
+++ b/src/main/java/land/face/strife/tasks/EnergyTask.java
@@ -37,7 +37,7 @@ public void run() {
return;
}
- if (mob.getEnergy() >= StatUtil.getMaximumEnergy(mob)) {
+ if (mob.getStat(StrifeStat.ENERGY) == 0 || mob.getEnergy() >= StatUtil.getMaximumEnergy(mob)) {
return;
}
diff --git a/src/main/java/land/face/strife/util/StatUtil.java b/src/main/java/land/face/strife/util/StatUtil.java
index cd5ec88f..080c1e4c 100644
--- a/src/main/java/land/face/strife/util/StatUtil.java
+++ b/src/main/java/land/face/strife/util/StatUtil.java
@@ -10,8 +10,10 @@
import java.util.Map;
import land.face.strife.StrifePlugin;
import land.face.strife.data.StrifeMob;
+import land.face.strife.events.PropertyUpdateEvent;
import land.face.strife.stats.StrifeStat;
import land.face.strife.stats.StrifeTrait;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.LivingEntity;
@@ -32,11 +34,17 @@ public static float getBarrierRegen(StrifeMob ae) {
}
public static float getHealth(StrifeMob ae) {
- return ae.getStat(StrifeStat.HEALTH) * (1 + ae.getStat(StrifeStat.HEALTH_MULT) / 100);
+ float amount = ae.getStat(StrifeStat.HEALTH) * (1 + ae.getStat(StrifeStat.HEALTH_MULT) / 100);
+ PropertyUpdateEvent event = new PropertyUpdateEvent("life", amount);
+ Bukkit.getPluginManager().callEvent(event);
+ return event.getAppliedValue();
}
public static float getMaximumEnergy(StrifeMob ae) {
- return ae.getStat(StrifeStat.ENERGY) * (1 + ae.getStat(StrifeStat.ENERGY_MULT) / 100);
+ float amount = ae.getStat(StrifeStat.ENERGY) * (1 + ae.getStat(StrifeStat.ENERGY_MULT) / 100);
+ PropertyUpdateEvent event = new PropertyUpdateEvent("energy", amount);
+ Bukkit.getPluginManager().callEvent(event);
+ return event.getAppliedValue();
}
public static void changeEnergy(StrifeMob mob, float amount) {