mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Potentially fixed #2927
This commit is contained in:
parent
5626ad2b2f
commit
9f3f23fb75
@ -50,6 +50,7 @@
|
|||||||
* Fixed #2999
|
* Fixed #2999
|
||||||
* Fixed #2593
|
* Fixed #2593
|
||||||
* Fixed #2937
|
* Fixed #2937
|
||||||
|
* Fixed #2927
|
||||||
|
|
||||||
## Release Candidate 22 (18 Apr 2021)
|
## Release Candidate 22 (18 Apr 2021)
|
||||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#22
|
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#22
|
||||||
|
@ -9,6 +9,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -105,7 +106,9 @@ public class HologramsService {
|
|||||||
Iterator<Hologram> iterator = cache.values().iterator();
|
Iterator<Hologram> iterator = cache.values().iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (iterator.next().hasExpired()) {
|
Hologram hologram = iterator.next();
|
||||||
|
|
||||||
|
if (hologram.hasExpired()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,27 +145,39 @@ public class HologramsService {
|
|||||||
if (n instanceof ArmorStand) {
|
if (n instanceof ArmorStand) {
|
||||||
PersistentDataContainer container = n.getPersistentDataContainer();
|
PersistentDataContainer container = n.getPersistentDataContainer();
|
||||||
|
|
||||||
if (container.has(persistentDataKey, PersistentDataType.LONG)) {
|
/*
|
||||||
// Check if it is ours or a different one.
|
* Any hologram we created will have a persistent data key for identification.
|
||||||
if (container.get(persistentDataKey, PersistentDataType.LONG).equals(position.getPosition())) {
|
* Make sure that the value matches our BlockPosition.
|
||||||
return getAsHologram(position, n, container);
|
*/
|
||||||
|
if (hasHologramData(container, position)) {
|
||||||
|
if (hologram != null) {
|
||||||
|
// Fixes #2927 - Remove any duplicates we find
|
||||||
|
n.remove();
|
||||||
|
} else {
|
||||||
|
hologram = getAsHologram(position, n, container);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Set a persistent tag to re-identify the correct hologram later
|
|
||||||
container.set(persistentDataKey, PersistentDataType.LONG, position.getPosition());
|
|
||||||
return getAsHologram(position, n, container);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createIfNoneExists) {
|
if (hologram == null && createIfNoneExists) {
|
||||||
// Spawn a new ArmorStand
|
// Spawn a new ArmorStand
|
||||||
ArmorStand armorstand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
ArmorStand armorstand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
||||||
PersistentDataContainer container = armorstand.getPersistentDataContainer();
|
PersistentDataContainer container = armorstand.getPersistentDataContainer();
|
||||||
|
|
||||||
return getAsHologram(position, armorstand, container);
|
return getAsHologram(position, armorstand, container);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return hologram;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
private boolean hasHologramData(PersistentDataContainer container, BlockPosition position) {
|
||||||
|
if (container.has(persistentDataKey, PersistentDataType.LONG)) {
|
||||||
|
long value = container.get(persistentDataKey, PersistentDataType.LONG);
|
||||||
|
return value == position.getPosition();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user