Blockhunt-19 NPE Fix for bad arena coords.
This commit is contained in:
parent
59ef3173d0
commit
c774bcd383
@ -3,8 +3,10 @@ package nl.Steffion.BlockHunt.Listeners;
|
|||||||
import nl.Steffion.BlockHunt.Arena;
|
import nl.Steffion.BlockHunt.Arena;
|
||||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||||
|
import nl.Steffion.BlockHunt.BlockHunt;
|
||||||
import nl.Steffion.BlockHunt.W;
|
import nl.Steffion.BlockHunt.W;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -20,12 +22,24 @@ public class OnPlayerMoveEvent implements Listener {
|
|||||||
public void onPlayerMoveEvent(PlayerMoveEvent event) {
|
public void onPlayerMoveEvent(PlayerMoveEvent event) {
|
||||||
// Early exit if no one is in any arena
|
// Early exit if no one is in any arena
|
||||||
if (ArenaHandler.noPlayersInArenas()) return;
|
if (ArenaHandler.noPlayersInArenas()) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
for (Arena arena : W.arenaList) {
|
for (Arena arena : W.arenaList) {
|
||||||
if (arena.playersInArena.contains(player)) {
|
if (arena.playersInArena.contains(player)) {
|
||||||
if (arena.gameState == ArenaState.INGAME) {
|
if (arena.gameState == ArenaState.INGAME) {
|
||||||
W.moveLoc.put(player, player.getLocation());
|
W.moveLoc.put(player, player.getLocation());
|
||||||
|
if(arena.pos1 == null || arena.pos2 == null){
|
||||||
|
BlockHunt.plugin.getLogger().info("Arena:"+
|
||||||
|
arena.arenaName+" appears to have bad coords : pos1:"+
|
||||||
|
((arena.pos1 != null)?arena.pos1.toString():" NULL")+ " Pos2:" +
|
||||||
|
((arena.pos2 != null)?arena.pos2.toString():" NULL"));
|
||||||
|
BlockHunt.plugin.getLogger().info("Player has been returned to hiderswarp due to bad arena state");
|
||||||
|
event.setCancelled(true);
|
||||||
|
Location loc = player.getLocation();
|
||||||
|
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||||
|
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||||
|
player.teleport(arena.hidersWarp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
double maxX = Math.max(arena.pos1.getX(), arena.pos2.getX());
|
double maxX = Math.max(arena.pos1.getX(), arena.pos2.getX());
|
||||||
double minX = Math.min(arena.pos1.getX(), arena.pos2.getX());
|
double minX = Math.min(arena.pos1.getX(), arena.pos2.getX());
|
||||||
double maxY = Math.max(arena.pos1.getY(), arena.pos2.getY());
|
double maxY = Math.max(arena.pos1.getY(), arena.pos2.getY());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user