mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-03-12 14:39:05 +01:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
1b7be6cfc0
@ -78,7 +78,8 @@ public class WorldGuardLegacyHelper implements IWorldGuardHelper {
|
||||
|
||||
List<String> regions = new ArrayList<>();
|
||||
List<String> parentNames = new ArrayList<>();
|
||||
ApplicableRegionSet set = this.worldGuard.getRegionManager(loc.getWorld()).getApplicableRegions(loc);
|
||||
// this prototype is different from v5 to v6, but they're both Iterable
|
||||
Iterable<ProtectedRegion> set = (Iterable<ProtectedRegion>) this.worldGuard.getRegionManager(loc.getWorld()).getApplicableRegions(loc);
|
||||
|
||||
for (ProtectedRegion region : set) {
|
||||
String id = region.getId();
|
||||
|
@ -26,7 +26,7 @@
|
||||
"&6&l#{pos} &e{name}&f - &e{percent}% &f(&e{dmg} dmg&f)"
|
||||
],
|
||||
"SKTaunt1": [
|
||||
"&6&lSkeleton King &f» &7My pocket knife is sharper then that sword! &o*cackle*"
|
||||
"&6&lSkeleton King &f» &7My pocket knife is sharper than that sword! &o*cackle*"
|
||||
],
|
||||
"SKTaunt2": [
|
||||
"&6&lSkeleton King &f» &7You think you humans can defeat me?! I am the notorious Skeleton King!"
|
||||
|
@ -26,7 +26,7 @@
|
||||
"&6&l#{pos} &e{name}&f - &e{percent}% &f(&e{dmg} dmg&f)"
|
||||
],
|
||||
"SKTaunt1": [
|
||||
"&6&lSkeleton King &f» &7My pocket knife is sharper then that sword! &o*cackle*"
|
||||
"&6&lSkeleton King &f» &7My pocket knife is sharper than that sword! &o*cackle*"
|
||||
],
|
||||
"SKTaunt2": [
|
||||
"&6&lSkeleton King &f» &7You think you humans can defeat me?! I am the notorious Skeleton King!"
|
||||
|
@ -17,6 +17,7 @@ import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -63,7 +64,7 @@ public class BossSpawnListener implements Listener {
|
||||
if(block.getType() == Material.AIR) return;
|
||||
|
||||
Map<BossEntity, ItemStack> entitiesAndSpawnItems = this.bossEntityManager.getMapOfEntitiesAndSpawnItems();
|
||||
ItemStack itemStack = this.versionHandler.getItemInHand(player).clone();
|
||||
ItemStack itemStack = this.versionHandler.getItemInHand(player);
|
||||
BossEntity bossEntity = null;
|
||||
|
||||
for(Map.Entry<BossEntity, ItemStack> entry : entitiesAndSpawnItems.entrySet()) {
|
||||
@ -117,8 +118,8 @@ public class BossSpawnListener implements Listener {
|
||||
BossEntity bossEntity = activeBossHolder.getBossEntity();
|
||||
Location location = activeBossHolder.getLocation();
|
||||
|
||||
List<String> commands = this.bossEntityManager.getOnSpawnCommands(bossEntity);
|
||||
List<String> messages = this.bossEntityManager.getOnSpawnMessage(bossEntity);
|
||||
List<String> commands = new ArrayList(this.bossEntityManager.getOnSpawnCommands(bossEntity));
|
||||
List<String> messages = new ArrayList(this.bossEntityManager.getOnSpawnMessage(bossEntity));
|
||||
int messageRadius = this.bossEntityManager.getOnSpawnMessageRadius(bossEntity);
|
||||
ServerUtils serverUtils = ServerUtils.get();
|
||||
|
||||
@ -133,22 +134,23 @@ public class BossSpawnListener implements Listener {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
if (commands != null)
|
||||
if (!commands.isEmpty())
|
||||
commands.replaceAll(s -> s.replaceAll("%player%", player.getName()));
|
||||
|
||||
if (messages != null && !activeBossHolder.isCustomSpawnMessage())
|
||||
if (!messages.isEmpty() && !activeBossHolder.isCustomSpawnMessage())
|
||||
messages.replaceAll(s -> s.replace("{name}", player.getName()));
|
||||
} else {
|
||||
if (messages != null && !activeBossHolder.isCustomSpawnMessage())
|
||||
if (!messages.isEmpty() && !activeBossHolder.isCustomSpawnMessage())
|
||||
messages.replaceAll(s -> s.replace("{name}", "Console"));
|
||||
}
|
||||
|
||||
if (commands != null)
|
||||
if (!commands.isEmpty())
|
||||
commands.forEach(serverUtils::sendConsoleCommand);
|
||||
|
||||
if(messages != null && !activeBossHolder.isCustomSpawnMessage()) {
|
||||
if(!messages.isEmpty() && !activeBossHolder.isCustomSpawnMessage()) {
|
||||
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
|
||||
messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location)));
|
||||
final String locationString = StringUtils.get().translateLocation(location);
|
||||
messages.replaceAll(s -> s.replace("{location}", locationString));
|
||||
|
||||
MessageUtils.get().sendMessage(location, NumberUtils.get().getSquared(messageRadius), messages);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class BossEntityManager {
|
||||
|
||||
if(messages == null) {
|
||||
Debug.FAILED_TO_LOAD_MESSAGES.debug(id);
|
||||
return null;
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
return messages;
|
||||
@ -203,7 +203,7 @@ public class BossEntityManager {
|
||||
|
||||
if(commands == null) {
|
||||
Debug.FAILED_TO_LOAD_COMMANDS.debug(id);
|
||||
return null;
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
return commands;
|
||||
@ -215,7 +215,7 @@ public class BossEntityManager {
|
||||
|
||||
if(messages == null) {
|
||||
Debug.FAILED_TO_LOAD_MESSAGES.debug(id);
|
||||
return null;
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
return messages;
|
||||
|
@ -7,7 +7,6 @@ import com.songoda.epicbosses.utils.panel.base.ClickAction;
|
||||
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class OnDeathCommandEditor extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
replaceMap.put("{name}", name);
|
||||
|
||||
if(bossEntity.getCommands().getOnDeath().equalsIgnoreCase(name)) {
|
||||
if(bossEntity.getCommands().getOnDeath() != null && bossEntity.getCommands().getOnDeath().equalsIgnoreCase(name)) {
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.selectedName"), replaceMap);
|
||||
} else {
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.name"), replaceMap);
|
||||
|
@ -97,7 +97,7 @@ public class OnSpawnCommandEditor extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
replaceMap.put("{name}", name);
|
||||
|
||||
if(bossEntity.getCommands().getOnSpawn().equalsIgnoreCase(name)) {
|
||||
if(bossEntity.getCommands().getOnSpawn() != null && bossEntity.getCommands().getOnSpawn().equalsIgnoreCase(name)) {
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.selectedName"), replaceMap);
|
||||
} else {
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.name"), replaceMap);
|
||||
|
@ -60,7 +60,7 @@ public class ItemStackUtils {
|
||||
return new ItemStack(Material.AIR);
|
||||
|
||||
if (versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_12_R1)) {
|
||||
return new ItemStack(Material.valueOf("MONSTER_EGG"), spawnableEntityIds.get(entityType));
|
||||
return new ItemStack(Material.valueOf("MONSTER_EGG"), 1, spawnableEntityIds.get(entityType));
|
||||
} else {
|
||||
return new ItemStack(spawnableEntityMaterials.get(entityType));
|
||||
}
|
||||
@ -153,15 +153,15 @@ public class ItemStackUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if(lore != null) {
|
||||
if(lore != null && !lore.isEmpty()) {
|
||||
for(String z : lore) {
|
||||
String y = z;
|
||||
|
||||
if(replacedMap != null) {
|
||||
for(String x : replacedMap.keySet()) {
|
||||
if(!y.contains(x)) continue;
|
||||
if(x == null || !y.contains(x)) continue;
|
||||
|
||||
if (!replacedMap.containsKey(x)) {
|
||||
if (replacedMap.get(x) == null) {
|
||||
ServerUtils.get().logDebug("Failed to apply replaced lore: [y=" + y + "x=" + x + "]");
|
||||
continue;
|
||||
}
|
||||
@ -258,7 +258,14 @@ public class ItemStackUtils {
|
||||
}
|
||||
|
||||
public static void applyDisplayLore(ItemStack itemStack, List<String> lore, Map<String, String> replaceMap) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
ItemMeta itemMeta;
|
||||
if (itemStack == null || (itemMeta = itemStack.getItemMeta()) == null)
|
||||
return;
|
||||
if (lore == null || lore.isEmpty()) {
|
||||
itemMeta.setLore(Collections.EMPTY_LIST);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return;
|
||||
}
|
||||
|
||||
if(replaceMap != null) {
|
||||
for(String s : replaceMap.keySet()) {
|
||||
@ -392,7 +399,8 @@ public class ItemStackUtils {
|
||||
public static boolean isItemStackSame(ItemStack itemStack1, ItemStack itemStack2) {
|
||||
if(itemStack1 == null || itemStack2 == null) return false;
|
||||
if(itemStack1.getType() != itemStack2.getType()) return false;
|
||||
if(itemStack1.getDurability() != itemStack2.getDurability()) return false;
|
||||
// Durability checks are too tempermental to be reliable for all versions
|
||||
//if(itemStack1.getDurability() != itemStack2.getDurability()) return false;
|
||||
|
||||
ItemMeta itemMeta1 = itemStack1.getItemMeta();
|
||||
ItemMeta itemMeta2 = itemStack2.getItemMeta();
|
||||
@ -400,17 +408,15 @@ public class ItemStackUtils {
|
||||
if(itemMeta1 == null || itemMeta2 == null) return false;
|
||||
|
||||
if(itemMeta1.hasDisplayName() == itemMeta2.hasDisplayName()) {
|
||||
if(itemMeta1.hasDisplayName()) {
|
||||
if(!itemMeta1.getDisplayName().equals(itemMeta2.getDisplayName())) return false;
|
||||
}
|
||||
if(itemMeta1.hasDisplayName() && !itemMeta1.getDisplayName().equals(itemMeta2.getDisplayName()))
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(itemMeta1.hasLore() == itemMeta2.hasLore()) {
|
||||
if(itemMeta1.hasLore()) {
|
||||
if(!itemMeta1.getLore().equals(itemMeta2.getLore())) return false;
|
||||
}
|
||||
if(itemMeta1.hasLore() && !itemMeta1.getLore().equals(itemMeta2.getLore()))
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.panel.base;
|
||||
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user