From dfb36a9e4352be9253c641da2e92433265688dac Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 28 Jan 2012 17:02:18 +0100 Subject: [PATCH 1/4] Noted a possible npe --- .../massivecraft/factions/listeners/FactionsPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 16760a7c..96ee75d8 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -264,7 +264,7 @@ public class FactionsPlayerListener extends PlayerListener public void onPlayerRespawn(PlayerRespawnEvent event) { FPlayer me = FPlayers.i.get(event.getPlayer()); - Location home = me.getFaction().getHome(); + Location home = me.getFaction().getHome(); // TODO: WARNING FOR NPE HERE THE ORIO FOR RESPAWN SHOULD BE ASSIGNABLE FROM CONFIG. if ( Conf.homesEnabled From c248d419bb942dac9260e555b8d5267d19914f30 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 28 Jan 2012 17:15:20 +0100 Subject: [PATCH 2/4] Panic fix to remove infinite loop --- src/com/massivecraft/factions/FPlayer.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 746ebd56..b13ff483 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -133,9 +133,14 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator public final void resetFactionData(boolean doSpotUpdate) { - Faction currentFaction = this.getFaction(); - if (currentFaction != null) - currentFaction.removeFPlayer(this); + if (this.factionId != null && Factions.i.exists(this.factionId)) // Avoid infinite loop! TODO: I think that this is needed is a sign we need to refactor. + { + Faction currentFaction = this.getFaction(); + if (currentFaction != null) + { + currentFaction.removeFPlayer(this); + } + } this.factionId = "0"; // The default neutral faction this.chatMode = ChatMode.PUBLIC; From ba760b69ae2ad94cd4f6c8e9c1c659bc4bf5a216 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 28 Jan 2012 18:10:19 +0100 Subject: [PATCH 3/4] Reverting... wtf --- src/com/massivecraft/factions/Board.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index 37bb6011..d523493d 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -187,7 +187,7 @@ public class Board int halfWidth = Conf.mapWidth / 2; int halfHeight = Conf.mapHeight / 2; - FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight); + FLocation topLeft = flocation.getRelative(-halfHeight, halfWidth); int width = halfWidth * 2 + 1; int height = halfHeight * 2 + 1; @@ -199,13 +199,13 @@ public class Board int chrIdx = 0; // For each row - for (int dz = 0; dz < height; dz++) + for (int dx = 0; dx < height; dx++) { // Draw and add that row String row = ""; - for (int dx = 0; dx < width; dx++) + for (int dz = 0; dz > -width; dz--) { - if(dx == halfWidth && dz == halfHeight) + if(dz == -(halfWidth) && dx == halfHeight) { row += ChatColor.AQUA+"+"; continue; From 8a13cd8cdc6869e0f1c1873825a2926763bd65b2 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 28 Jan 2012 19:00:13 +0100 Subject: [PATCH 4/4] reverting the revert (sorry) --- src/com/massivecraft/factions/Board.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index d523493d..37bb6011 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -187,7 +187,7 @@ public class Board int halfWidth = Conf.mapWidth / 2; int halfHeight = Conf.mapHeight / 2; - FLocation topLeft = flocation.getRelative(-halfHeight, halfWidth); + FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight); int width = halfWidth * 2 + 1; int height = halfHeight * 2 + 1; @@ -199,13 +199,13 @@ public class Board int chrIdx = 0; // For each row - for (int dx = 0; dx < height; dx++) + for (int dz = 0; dz < height; dz++) { // Draw and add that row String row = ""; - for (int dz = 0; dz > -width; dz--) + for (int dx = 0; dx < width; dx++) { - if(dz == -(halfWidth) && dx == halfHeight) + if(dx == halfWidth && dz == halfHeight) { row += ChatColor.AQUA+"+"; continue;