Use 'getPlayer()' to prevent NPE (FS-159) (#87)

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
This commit is contained in:
Nathan Curran 2021-06-27 00:06:15 +10:00 committed by GitHub
parent a08fd2afb6
commit d77f59435b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.player;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.caging.CageData;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -16,8 +14,12 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
public class FPlayer
{
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
@ -247,7 +249,7 @@ public class FPlayer
public void startArrowShooter(TotalFreedomMod plugin)
{
this.stopArrowShooter();
this.mp44ScheduleTask = new ArrowShooter(this.player).runTaskTimer(plugin, 1L, 1L);
this.mp44ScheduleTask = new ArrowShooter(getPlayer()).runTaskTimer(plugin, 1L, 1L);
this.mp44Firing = true;
}
@ -709,8 +711,11 @@ public class FPlayer
@Override
public void run()
{
Arrow shot = player.launchProjectile(Arrow.class);
shot.setVelocity(shot.getVelocity().multiply(2.0));
if (player != null)
{
Arrow shot = player.launchProjectile(Arrow.class);
shot.setVelocity(shot.getVelocity().multiply(2.0));
}
}
}
}