Fixed NPEs

This commit is contained in:
Frank Baumann 2012-11-06 23:13:44 +01:00
parent 0e940816e0
commit 0b05a63fc1

View File

@ -74,6 +74,7 @@ public class DPlayer {
this.player.getInventory().clear(); this.player.getInventory().clear();
this.player.getInventory().setArmorContents(null); this.player.getInventory().setArmorContents(null);
this.player.setTotalExperience(0); this.player.setTotalExperience(0);
this.player.setLevel(0);
this.player.setHealth(20); this.player.setHealth(20);
this.player.setFoodLevel(20); this.player.setFoodLevel(20);
this.isEditing=isEditing; this.isEditing=isEditing;
@ -159,24 +160,26 @@ public class DPlayer {
} }
//Give Secure Objects other Players //Give Secure Objects other Players
if(!dgroup.isEmpty()){ if(dgroup!=null){
int i=0; if(!dgroup.isEmpty()){
Player groupplayer; int i=0;
do{ Player groupplayer;
groupplayer=dgroup.players.get(i); do{
if(groupplayer!=null){ groupplayer=dgroup.players.get(i);
for(ItemStack istack:this.player.getInventory()){ if(groupplayer!=null){
if(istack!=null){ for(ItemStack istack:this.player.getInventory()){
if(gworld.secureobjects.contains(istack.getType())){ if(istack!=null){
groupplayer.getInventory().addItem(istack); if(gworld.secureobjects.contains(istack.getType())){
groupplayer.getInventory().addItem(istack);
}
} }
} }
DungeonsXL.p.updateInventory(groupplayer);
} }
DungeonsXL.p.updateInventory(groupplayer); i++;
} }while(groupplayer==null);
i++;
}while(groupplayer==null); }
} }
} }
@ -234,10 +237,9 @@ public class DPlayer {
DungeonsXL.p.msg(this.player, ChatColor.YELLOW+"Du hast den Dungeon erfolgreich beendet!"); DungeonsXL.p.msg(this.player, ChatColor.YELLOW+"Du hast den Dungeon erfolgreich beendet!");
this.isFinished=true; this.isFinished=true;
DGroup dgroup=DGroup.get(this.player); DGroup dgroup=DGroup.get(this.player);
if(dgroup.isPlaying){ if(dgroup!=null){
if(dgroup!=null){ if(dgroup.isPlaying){
for(Player player:dgroup.players){ for(Player player:dgroup.players){
DPlayer dplayer=get(player); DPlayer dplayer=get(player);
if(!dplayer.isFinished){ if(!dplayer.isFinished){
@ -246,17 +248,12 @@ public class DPlayer {
} }
} }
for(Player player:dgroup.players){ for(Player player:dgroup.players){
DPlayer dplayer=get(player); DPlayer dplayer=get(player);
dplayer.leave(); dplayer.leave();
} }
} }
} }
} }
public void msg(String msg){ public void msg(String msg){
@ -379,6 +376,7 @@ public class DPlayer {
public void addTreasure(){ public void addTreasure(){
new DLootInventory(this.player,this.treasureInv.getContents()); new DLootInventory(this.player,this.treasureInv.getContents());
} }
//Static //Static
public static void remove(DPlayer player){ public static void remove(DPlayer player){
players.remove(player); players.remove(player);