From 38a8a6f2ff0d2be1b39cbd5487cf2d8ffe4795f4 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 17 Jan 2013 11:26:55 -0500 Subject: [PATCH] Fix possible NPE when using the PartyAPI to add a player to a party that doesn't exist. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/api/PartyAPI.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 65f1ac170..ffa59e1ce 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -20,6 +20,7 @@ Version 1.3.13-dev + Added wooden button to the list of items that shouldn't trigger abilities + Added a new feature to fishing. Players will have +10% chance of finding enchanted items when fishing while it's raining + Added displaying bonus perks on skill commands + = Fix possible NPE when using the PartyAPI to add a player to a party that doesn't exist. = Fix mcremove command for mySQL = Impact now works with mobs wearing armor = Fixed issue with Tree Feller dropping player-placed blocks diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index d2d41988a..491976d82 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -69,7 +69,16 @@ public final class PartyAPI { * @param partyName The party to add the player to */ public static void addToParty(Player player, String partyName) { - PartyManager.getInstance().addToParty(player.getName(), Users.getProfile(player), PartyManager.getInstance().getParty(partyName)); //TODO this will throw a NPE if the party doesn't exist + Party party = PartyManager.getInstance().getParty(partyName); + String playerName = player.getName(); + + if (party == null) { + party = new Party(); + party.setName(partyName); + party.setLeader(playerName); + } + + PartyManager.getInstance().addToParty(playerName, Users.getProfile(player), party); } /**