diff --git a/src/com/cnaude/chairs/core/Chairs.java b/src/com/cnaude/chairs/core/Chairs.java index 6db9705..0295ff7 100644 --- a/src/com/cnaude/chairs/core/Chairs.java +++ b/src/com/cnaude/chairs/core/Chairs.java @@ -21,6 +21,7 @@ import org.bukkit.util.Vector; import com.cnaude.chairs.commands.ChairsCommand; import com.cnaude.chairs.commands.ChairsIgnoreList; +import com.cnaude.chairs.listeners.NANLoginListener; import com.cnaude.chairs.listeners.TrySitEventListener; import com.cnaude.chairs.listeners.TryUnsitEventListener; import com.cnaude.chairs.sitaddons.ChairEffects; @@ -50,13 +51,11 @@ public class Chairs extends JavaPlugin { private PlayerSitData psitdata; - public PlayerSitData getPlayerSitData() - { + public PlayerSitData getPlayerSitData() { return psitdata; } private Class vehiclearrowclass; - protected Class getVehicleArrowClass() - { + protected Class getVehicleArrowClass() { return vehiclearrowclass; } @@ -96,6 +95,7 @@ public class Chairs extends JavaPlugin { if (sitPickupEnabled) { chairEffects.startPickup(); } + getServer().getPluginManager().registerEvents(new NANLoginListener(), this); getServer().getPluginManager().registerEvents(new TrySitEventListener(this, ignoreList), this); getServer().getPluginManager().registerEvents(new TryUnsitEventListener(this), this); getServer().getPluginManager().registerEvents(new CommandRestrict(this), this); diff --git a/src/com/cnaude/chairs/listeners/NANLoginListener.java b/src/com/cnaude/chairs/listeners/NANLoginListener.java new file mode 100644 index 0000000..24d82f9 --- /dev/null +++ b/src/com/cnaude/chairs/listeners/NANLoginListener.java @@ -0,0 +1,19 @@ +package com.cnaude.chairs.listeners; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class NANLoginListener implements Listener { + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + if (Double.isNaN(player.getLocation().getY())) { + player.teleport(player.getWorld().getSpawnLocation()); + } + } + +}