1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Proper error handling and updated changelog

This commit is contained in:
TheBusyBiscuit 2021-01-15 03:31:33 +01:00
parent 1997fe04d8
commit 3663a7d43b
2 changed files with 21 additions and 14 deletions

View File

@ -29,6 +29,7 @@
#### Additions
#### Changes
* Massive performance improvements to holograms/armorstands
#### Fixes
* Fixed elevator floor order
@ -37,6 +38,7 @@
* Fixed #2636
* Fixed a threading issue related to BlockStates and persistent data
* Fixed #2721
* Fixed duplication issues related to holograms/armorstands
## Release Candidate 19 (11 Jan 2021)

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Consumer;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -110,11 +111,6 @@ public class HologramsService {
private Hologram getHologram(@Nonnull Location loc, boolean createIfNoneExists) {
Validate.notNull(loc, "Location cannot be null");
// Make sure there's no concurrency issues
if (!Bukkit.isPrimaryThread()) {
throw new UnsupportedOperationException("A hologram cannot be accessed asynchronously.");
}
BlockPosition position = new BlockPosition(loc);
Hologram hologram = cache.get(position);
@ -230,10 +226,14 @@ public class HologramsService {
Validate.notNull(consumer, "Callbacks must not be null");
Runnable runnable = () -> {
Hologram hologram = getHologram(loc, true);
try {
Hologram hologram = getHologram(loc, true);
if (hologram != null) {
consumer.accept(hologram);
if (hologram != null) {
consumer.accept(hologram);
}
} catch (Exception | LinkageError x) {
SlimefunPlugin.logger().log(Level.SEVERE, "Something went wrong while trying to update a hologram", x);
}
};
@ -260,13 +260,18 @@ public class HologramsService {
Validate.notNull(loc, "Location cannot be null");
if (Bukkit.isPrimaryThread()) {
Hologram hologram = getHologram(loc, false);
try {
Hologram hologram = getHologram(loc, false);
if (hologram != null) {
cache.remove(new BlockPosition(loc));
hologram.remove();
return true;
} else {
if (hologram != null) {
cache.remove(new BlockPosition(loc));
hologram.remove();
return true;
} else {
return false;
}
} catch (Exception | LinkageError x) {
SlimefunPlugin.logger().log(Level.SEVERE, "Something went wrong while trying to remove a hologram", x);
return false;
}
} else {