Teleport player to spawn if he logged in with nan location

This commit is contained in:
Shevchik 2014-03-06 16:54:15 +04:00
parent e17944f6cc
commit d5bfae0d2f
2 changed files with 23 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import org.bukkit.util.Vector;
import com.cnaude.chairs.commands.ChairsCommand; import com.cnaude.chairs.commands.ChairsCommand;
import com.cnaude.chairs.commands.ChairsIgnoreList; import com.cnaude.chairs.commands.ChairsIgnoreList;
import com.cnaude.chairs.listeners.NANLoginListener;
import com.cnaude.chairs.listeners.TrySitEventListener; import com.cnaude.chairs.listeners.TrySitEventListener;
import com.cnaude.chairs.listeners.TryUnsitEventListener; import com.cnaude.chairs.listeners.TryUnsitEventListener;
import com.cnaude.chairs.sitaddons.ChairEffects; import com.cnaude.chairs.sitaddons.ChairEffects;
@ -50,13 +51,11 @@ public class Chairs extends JavaPlugin {
private PlayerSitData psitdata; private PlayerSitData psitdata;
public PlayerSitData getPlayerSitData() public PlayerSitData getPlayerSitData() {
{
return psitdata; return psitdata;
} }
private Class<?> vehiclearrowclass; private Class<?> vehiclearrowclass;
protected Class<?> getVehicleArrowClass() protected Class<?> getVehicleArrowClass() {
{
return vehiclearrowclass; return vehiclearrowclass;
} }
@ -96,6 +95,7 @@ public class Chairs extends JavaPlugin {
if (sitPickupEnabled) { if (sitPickupEnabled) {
chairEffects.startPickup(); chairEffects.startPickup();
} }
getServer().getPluginManager().registerEvents(new NANLoginListener(), this);
getServer().getPluginManager().registerEvents(new TrySitEventListener(this, ignoreList), this); getServer().getPluginManager().registerEvents(new TrySitEventListener(this, ignoreList), this);
getServer().getPluginManager().registerEvents(new TryUnsitEventListener(this), this); getServer().getPluginManager().registerEvents(new TryUnsitEventListener(this), this);
getServer().getPluginManager().registerEvents(new CommandRestrict(this), this); getServer().getPluginManager().registerEvents(new CommandRestrict(this), this);

View File

@ -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());
}
}
}