From 492ad76f262f75ab31c7d4eaa5e28be917830dad Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 5 Aug 2011 20:04:44 -0700 Subject: [PATCH] Fixed MySpawn NPE --- mcMMO/com/gmail/nossr50/Item.java | 4 ++-- .../gmail/nossr50/datatypes/PlayerProfile.java | 15 +++++++++------ .../gmail/nossr50/listeners/mcPlayerListener.java | 2 +- mcMMO/com/gmail/nossr50/mcMMO.java | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mcMMO/com/gmail/nossr50/Item.java b/mcMMO/com/gmail/nossr50/Item.java index d7d202f10..f19659669 100644 --- a/mcMMO/com/gmail/nossr50/Item.java +++ b/mcMMO/com/gmail/nossr50/Item.java @@ -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){ player.teleport(mySpawn); //Do it twice to prevent weird stuff player.teleport(mySpawn); diff --git a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java index d97359e5c..1dbf43d9a 100644 --- a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -10,10 +10,9 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.contrib.SpoutStuff; import com.gmail.nossr50.m; @@ -1025,11 +1024,12 @@ public class PlayerProfile return false; } } - public String getMySpawnWorld(Plugin plugin){ + public String getMySpawnWorld() + { if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){ return myspawnworld; } else { - return plugin.getServer().getWorlds().get(0).toString(); + return Bukkit.getServer().getWorlds().get(0).toString(); } } //Save a users spawn location @@ -1068,7 +1068,7 @@ public class PlayerProfile public boolean isDead(){ return dead; } - public Location getMySpawn(Player player, Plugin plugin) + public Location getMySpawn(Player player) { Location loc = null; if(myspawn != null) @@ -1084,7 +1084,10 @@ public class PlayerProfile loc.setPitch(0); 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; } else { return null; diff --git a/mcMMO/com/gmail/nossr50/listeners/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/listeners/mcPlayerListener.java index 3d0816798..88130c45f 100644 --- a/mcMMO/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -67,7 +67,7 @@ public class mcPlayerListener extends PlayerListener { PP.setRespawnATS(System.currentTimeMillis()); - Location mySpawn = PP.getMySpawn(player, plugin); + Location mySpawn = PP.getMySpawn(player); if(mySpawn != null) { diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 0fb409149..c6972a063 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -1711,9 +1711,9 @@ public class mcMMO extends JavaPlugin return true; } 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){ //It's done twice because it acts oddly when you are in another world