From 761550ac89a847d49c89c47568e3c40306110466 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 11 Oct 2021 17:18:37 -0400 Subject: [PATCH] fixed possible exception on player join --- src/main/java/net/tylermurphy/hideAndSeek/Store.java | 7 ++++--- .../net/tylermurphy/hideAndSeek/bukkit/EventListener.java | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Store.java b/src/main/java/net/tylermurphy/hideAndSeek/Store.java index 9aa07e0..ec64323 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Store.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Store.java @@ -1,5 +1,6 @@ package net.tylermurphy.hideAndSeek; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -23,9 +24,9 @@ public class Store { playerLastLocationList = new HashMap(); public static List - Hider, - Seeker, - Spectator; + Hider = new ArrayList(), + Seeker = new ArrayList(), + Spectator = new ArrayList(); public static Scoreboard board; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java index 5cf83a1..40167c4 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java @@ -58,14 +58,18 @@ public class EventListener implements Listener { } else if(status.equals("Setup") || status.equals("Standby")) { if (lobbyManualJoin) { if(event.getPlayer().getWorld().getName().equals("hideandseek_"+spawnWorld)){ - event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); + if(lobbyPosition.getBlockX() != 0 || lobbyPosition.getBlockY() != 0 || lobbyPosition.getBlockZ() != 0) { + event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); + } return; } } Hider.add(event.getPlayer().getName()); HiderTeam.addEntry(event.getPlayer().getName()); event.getPlayer().setGameMode(GameMode.ADVENTURE); - event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); + if(lobbyPosition.getBlockX() != 0 || lobbyPosition.getBlockY() != 0 || lobbyPosition.getBlockZ() != 0) { + event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); + } } playerList.put(event.getPlayer().getName(), event.getPlayer()); }