diff --git a/core/src/main/java/tc/oc/pgm/variables/types/PlayerLocationVariable.java b/core/src/main/java/tc/oc/pgm/variables/types/PlayerLocationVariable.java index 4804b93590..565e46577b 100644 --- a/core/src/main/java/tc/oc/pgm/variables/types/PlayerLocationVariable.java +++ b/core/src/main/java/tc/oc/pgm/variables/types/PlayerLocationVariable.java @@ -81,7 +81,7 @@ public enum Component { private static RayBlockIntersection intersection(MatchPlayer player) { RayCastCache cache = lastRaytrace; - if (player.getLocation().equals(cache.location)) { + if (cache != null && player.getLocation().equals(cache.location)) { return cache.rayCast; } lastRaytrace = cache = new RayCastCache( diff --git a/core/src/main/java/tc/oc/pgm/variables/types/ScoreVariable.java b/core/src/main/java/tc/oc/pgm/variables/types/ScoreVariable.java index 666b09ed21..69f0ad5123 100644 --- a/core/src/main/java/tc/oc/pgm/variables/types/ScoreVariable.java +++ b/core/src/main/java/tc/oc/pgm/variables/types/ScoreVariable.java @@ -13,14 +13,17 @@ public ScoreVariable() { @Override protected double getValueImpl(Party party) { - if (party instanceof Competitor) - return party.moduleRequire(ScoreMatchModule.class).getScore((Competitor) party); - return 0; + if (party instanceof Competitor c) + return party + .moduleOptional(ScoreMatchModule.class) + .map(smm -> smm.getScore(c)) + .orElse(-1d); + return -1; } @Override protected void setValueImpl(Party party, double value) { - if (party instanceof Competitor) - party.moduleRequire(ScoreMatchModule.class).setScore((Competitor) party, value); + if (party instanceof Competitor c) + party.moduleOptional(ScoreMatchModule.class).ifPresent(smm -> smm.setScore(c, value)); } }