From 542547fd5befd96c45c1eb8b4d75e98d50c10a0b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 20 Jan 2020 18:46:52 +0100 Subject: [PATCH] Hotfix NPE Signed-off-by: Lixfel --- .../winconditions/WinconditionPoints.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java index 23d2857..6bbfea8 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java @@ -97,7 +97,7 @@ public class WinconditionPoints extends PlayerWincondition { public static class TeamPoints { private final FightTeam enemy; private final WinconditionRelativePercent.TeamPercent enemyPercent; - private final double factor; + private double factor; private static final int maxPoints = 2000; private int points; @@ -107,18 +107,21 @@ public class WinconditionPoints extends PlayerWincondition { this.enemyPercent = enemyPercent; points = 0; - if(enemyPercent.getBlockCount() < ownPercent.getBlockCount()) - this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte - else{ - double f = 10000.0 * ownPercent.getBlockCount() / enemyPercent.getBlockCount(); + //Prevent NPE + Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () ->{ + if(enemyPercent.getBlockCount() < ownPercent.getBlockCount()) + this.factor = 10000; //Original mit 20 (20% = 0.2 ergeben 2000 Punkte + else{ + double f = 10000.0 * ownPercent.getBlockCount() / enemyPercent.getBlockCount(); - if(f > 10000) - f = 10000; - else if(f < 4000) - f = 4000; + if(f > 10000) + f = 10000; + else if(f < 4000) + f = 4000; - this.factor = f; - } + this.factor = f; + } + }); } public int getPoints(){