Allow updating holograms in bulk

This improves performance when using *HolographicDisplays* drastically on many holograms.

Plugins like *EpicAnchors* might need to manage and update a lot of holograms frequently, causing SongodaCore to fetch all the holograms from the external API (My test setup reduced the time needed to update from ~30ms to ~1ms)
This commit is contained in:
Brianna 2021-05-27 09:53:45 -05:00
parent 9497be1a4b
commit 108ec6a2ed

View File

@ -57,7 +57,6 @@ public class HolographicDisplaysHolograms extends Holograms {
public void bulkUpdateHolograms(Map<Location, List<String>> hologramData) {
Collection<Hologram> holograms = HologramsAPI.getHolograms(plugin);
outerFor:
for (Map.Entry<Location, List<String>> entry : hologramData.entrySet()) {
Location location = fixLocation(entry.getKey());
List<String> lines = entry.getValue();
@ -73,8 +72,7 @@ public class HolographicDisplaysHolograms extends Holograms {
if (!isChanged) {
// double-check the lines
for (int i = 0; !isChanged && i < lines.size(); ++i) {
isChanged = !(hologram.getLine(i) instanceof TextLine) ||
!((TextLine) hologram.getLine(i)).getText().equals(lines.get(i));
isChanged = !hologram.getLine(i).toString().equals("CraftTextLine [text=" + lines.get(i) + "]");
}
}
@ -86,7 +84,7 @@ public class HolographicDisplaysHolograms extends Holograms {
}
}
continue outerFor;
return;
}
createAt(location, lines);