Fixed MySpawn NPE

This commit is contained in:
nossr50 2011-08-05 20:04:44 -07:00
parent 434e7000f2
commit 492ad76f26
4 changed files with 14 additions and 11 deletions

View File

@ -67,9 +67,9 @@ public class Item {
} }
} }
} }
if(PP.getMySpawn(player, plugin) != null) if(PP.getMySpawn(player) != null)
{ {
Location mySpawn = PP.getMySpawn(player, plugin); Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null){ if(mySpawn != null){
player.teleport(mySpawn); //Do it twice to prevent weird stuff player.teleport(mySpawn); //Do it twice to prevent weird stuff
player.teleport(mySpawn); player.teleport(mySpawn);

View File

@ -10,10 +10,9 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.contrib.SpoutStuff; import com.gmail.nossr50.contrib.SpoutStuff;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
@ -1025,11 +1024,12 @@ public class PlayerProfile
return false; return false;
} }
} }
public String getMySpawnWorld(Plugin plugin){ public String getMySpawnWorld()
{
if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){ if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){
return myspawnworld; return myspawnworld;
} else { } else {
return plugin.getServer().getWorlds().get(0).toString(); return Bukkit.getServer().getWorlds().get(0).toString();
} }
} }
//Save a users spawn location //Save a users spawn location
@ -1068,7 +1068,7 @@ public class PlayerProfile
public boolean isDead(){ public boolean isDead(){
return dead; return dead;
} }
public Location getMySpawn(Player player, Plugin plugin) public Location getMySpawn(Player player)
{ {
Location loc = null; Location loc = null;
if(myspawn != null) if(myspawn != null)
@ -1084,7 +1084,10 @@ public class PlayerProfile
loc.setPitch(0); loc.setPitch(0);
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null) if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null)
{ {
loc.setWorld(plugin.getServer().getWorld(this.getMySpawnWorld(plugin))); if(Bukkit.getServer().getWorld(this.getMySpawnWorld()) != null)
loc.setWorld(Bukkit.getServer().getWorld(this.getMySpawnWorld()));
else
loc.setWorld(Bukkit.getServer().getWorlds().get(0));
return loc; return loc;
} else { } else {
return null; return null;

View File

@ -67,7 +67,7 @@ public class mcPlayerListener extends PlayerListener
{ {
PP.setRespawnATS(System.currentTimeMillis()); PP.setRespawnATS(System.currentTimeMillis());
Location mySpawn = PP.getMySpawn(player, plugin); Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null) if(mySpawn != null)
{ {

View File

@ -1711,9 +1711,9 @@ public class mcMMO extends JavaPlugin
return true; return true;
} }
PP.setMySpawnATS(System.currentTimeMillis()); PP.setMySpawnATS(System.currentTimeMillis());
if(PP.getMySpawn(player, this) != null) if(PP.getMySpawn(player) != null)
{ {
Location mySpawn = PP.getMySpawn(player, this); Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null){ if(mySpawn != null){
//It's done twice because it acts oddly when you are in another world //It's done twice because it acts oddly when you are in another world