Skip to content

Commit

Permalink
protection type can sometimes resolve to null, somehow?
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidendra committed Jun 30, 2012
1 parent fbfcc47 commit 41cce06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/griefcraft/lwc/LWC.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
import com.griefcraft.modules.setup.BaseSetupModule;
import com.griefcraft.modules.setup.DatabaseSetupModule;
import com.griefcraft.modules.setup.LimitsSetup;
import com.griefcraft.modules.pluginsupport.Towny;
import com.griefcraft.modules.unlock.UnlockModule;
import com.griefcraft.scripting.Module;
import com.griefcraft.scripting.ModuleLoader;
Expand Down Expand Up @@ -595,11 +594,16 @@ public boolean enforceAccess(Player player, Protection protection, Block block,
}

String blockName = materialToString(block);
String protectionTypeToString = parser.parseMessage(protection.typeToString().toLowerCase());

if (protectionTypeToString == null) {
protectionTypeToString = "Unknown";
}

if (parser.parseMessage("protection." + blockName.toLowerCase() + ".notice.protected") != null) {
sendLocale(player, "protection." + blockName.toLowerCase() + ".notice.protected", "type", parser.parseMessage(protection.typeToString().toLowerCase()), "block", blockName, "owner", owner);
sendLocale(player, "protection." + blockName.toLowerCase() + ".notice.protected", "type", protectionTypeToString, "block", blockName, "owner", owner);
} else {
sendLocale(player, "protection.general.notice.protected", "type", parser.parseMessage(protection.typeToString().toLowerCase()), "block", blockName, "owner", owner);
sendLocale(player, "protection.general.notice.protected", "type", protectionTypeToString, "block", blockName, "owner", owner);
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/griefcraft/lwc/SimpleMessageParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,8 @@ public String parseMessage(String key, Object... args) {

// add the arguments to the cache key
if (args != null && args.length > 0) {
int index = 0;
for (Object argument : args) {
if (argument == null) {
System.out.println("Argument is null at index " + index);
} else {
cacheKey += argument.toString();
}

index ++;
cacheKey += argument.toString();
}
}

Expand Down

0 comments on commit 41cce06

Please sign in to comment.