Delete old holograms when moved.

This commit is contained in:
Brianna 2020-04-16 02:29:30 -04:00
parent 7250d74677
commit 1df8a0a3d4
3 changed files with 14 additions and 8 deletions

View File

@ -77,7 +77,7 @@ public class RemoveHologramCommand extends SubCommand {
Hologram hologram = hologramManager.getHologram(hologramType1);
if (hologram != null)
hologram.remove();
hologramManager.removeHologram(hologram);
});
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name()));

View File

@ -49,15 +49,16 @@ public class SetHologramCommand extends SubCommand {
fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
"Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true);
HologramType hologramType1 = HologramType
.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
Hologram hologram = hologramManager.getHologram(hologramType1);
if (hologram != null)
hologram.remove();
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
Hologram hologram = hologramManager.getHologram(hologramType1);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () ->
hologramManager.spawnHologram(hologramType1));
if (hologram != null)
hologramManager.removeHologram(hologram);
hologramManager.spawnHologram(hologramType1);
});
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type",

View File

@ -172,4 +172,9 @@ public class HologramTask extends BukkitRunnable {
hologramList.update(getHologramLines(hologramList.getType()));
}
}
public void removeHologram(Hologram hologram) {
hologramStorage.remove(hologram);
hologram.remove();
}
}