mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-03 13:57:36 +01:00
A bit jank but this fixes the reload problem for now.
This commit is contained in:
parent
706fbd8792
commit
bbebd41ed3
@ -111,12 +111,12 @@ public class ActiveBossHolder implements IActiveHolder {
|
||||
.filter(e -> e.getValue() != null && e.getValue().getWorld().isChunkLoaded(
|
||||
e.getValue().getLocation().getBlockX() >> 4,
|
||||
e.getValue().getLocation().getBlockZ() >> 4))
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
// remove everything we can
|
||||
toRemove.entrySet().stream().forEach(e -> {
|
||||
e.getValue().remove();
|
||||
livingEntityMap.remove(e.getKey());
|
||||
toRemove.forEach((key, value) -> {
|
||||
value.remove();
|
||||
livingEntityMap.remove(key);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -45,22 +45,25 @@ public class BossDamageListener implements Listener {
|
||||
double damage = event.getDamage();
|
||||
Player player = null;
|
||||
|
||||
if (activeBossHolder == null) {
|
||||
if (activeBossHolder == null && livingEntity.getCustomName() != null) {
|
||||
// Check to see if this was a boss and respawn it if so.
|
||||
String convert = TextUtils.convertFromInvisibleString(livingEntity.getCustomName());
|
||||
if (convert.startsWith("BOSS:")) {
|
||||
String convert = livingEntity.getCustomName();
|
||||
|
||||
if (convert.toUpperCase().startsWith(TextUtils.convertToInvisibleString("BOSS:"))) {
|
||||
String name = convert.split(":")[1];
|
||||
|
||||
BossEntity bossEntity = bossesFileManager.getBossEntity(name);
|
||||
bossEntityManager.createActiveBossHolder(bossEntity, livingEntity.getLocation(), name, null);
|
||||
if (bossEntity != null) {
|
||||
bossEntityManager.createActiveBossHolder(bossEntity, livingEntity.getLocation(), name, null);
|
||||
|
||||
if (livingEntity.isInsideVehicle() && livingEntity.getVehicle() != null)
|
||||
livingEntity.getVehicle().remove();
|
||||
if (livingEntity.isInsideVehicle() && livingEntity.getVehicle() != null)
|
||||
livingEntity.getVehicle().remove();
|
||||
|
||||
if (livingEntity.getPassenger() != null)
|
||||
livingEntity.getPassenger().remove();
|
||||
if (livingEntity.getPassenger() != null)
|
||||
livingEntity.getPassenger().remove();
|
||||
|
||||
livingEntity.remove();
|
||||
livingEntity.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -3,10 +3,13 @@ package com.songoda.epicbosses.managers.files;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.container.BossEntityContainer;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
|
||||
import com.songoda.epicbosses.entity.elements.MainStatsElement;
|
||||
import com.songoda.epicbosses.file.BossesFileHandler;
|
||||
import com.songoda.epicbosses.utils.ILoadable;
|
||||
import com.songoda.epicbosses.utils.IReloadable;
|
||||
import com.songoda.epicbosses.utils.ISavable;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -54,6 +57,15 @@ public class BossesFileManager implements ILoadable, ISavable, IReloadable {
|
||||
}
|
||||
|
||||
public BossEntity getBossEntity(String name) {
|
||||
for (Map.Entry<String, BossEntity> entry : this.bossEntityContainer.getData().entrySet()) {
|
||||
for (EntityStatsElement entityStatsElement : entry.getValue().getEntityStats()) {
|
||||
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
|
||||
String customName = mainStatsElement.getDisplayName();
|
||||
System.out.println(name + " : " + StringUtils.get().translateColor(customName));
|
||||
if (StringUtils.get().translateColor(customName).equals(name))
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return this.bossEntityContainer.getData().getOrDefault(name, null);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ import com.songoda.epicbosses.mechanics.IBossMechanic;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
@ -29,7 +31,7 @@ public class NameMechanic implements IBossMechanic {
|
||||
if (livingEntity == null || customName == null) continue;
|
||||
String formattedName = StringUtils.get().translateColor(customName);
|
||||
|
||||
livingEntity.setCustomName(TextUtils.convertToInvisibleString("BOSS:" + activeBossHolder.getName() + ":") + formattedName);
|
||||
livingEntity.setCustomName(TextUtils.convertToInvisibleString("BOSS:") + formattedName);
|
||||
livingEntity.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,16 @@ public class StringUtils {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public String toNum(String s) {
|
||||
StringBuilder t = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); ++i) {
|
||||
char ch = s.charAt(i);
|
||||
int n = (int)ch - (int)'a' + 1;
|
||||
t.append(n);
|
||||
}
|
||||
return t.toString();
|
||||
}
|
||||
|
||||
public String stripColor(String string) {
|
||||
return ChatColor.stripColor(string);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user