mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-03 06:57:58 +01:00
Catch null ItemStack for #548. Bump version number
This commit is contained in:
parent
2139465cfc
commit
c464916e9d
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests</artifactId>
|
||||
<version>3.4.5</version>
|
||||
<version>3.4.6</version>
|
||||
<name>quests</name>
|
||||
<url>https://github.com/FlyingPikachu/Quests/</url>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import me.blackvein.quests.util.QuestMob;
|
||||
@ -208,7 +209,14 @@ public class Event {
|
||||
}
|
||||
if (items.isEmpty() == false) {
|
||||
for (ItemStack is : items) {
|
||||
Quests.addItem(player, is);
|
||||
try {
|
||||
Quests.addItem(player, is);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Unable to add null item to inventory of "
|
||||
+ player.getName() + " during quest " + quest.name + " event " + name);
|
||||
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
|
||||
+ "Please contact an administrator.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stormWorld != null) {
|
||||
|
@ -318,7 +318,14 @@ public class Quest {
|
||||
}
|
||||
}
|
||||
for (ItemStack i : itemRewards) {
|
||||
Quests.addItem(player, i);
|
||||
try {
|
||||
Quests.addItem(player, i);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Unable to add null reward item to inventory of "
|
||||
+ player.getName() + " upon completion of quest " + name);
|
||||
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
|
||||
+ "Please contact an administrator.");
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
for (String s : commands) {
|
||||
@ -368,7 +375,14 @@ public class Quest {
|
||||
if (lb.getItemList().isEmpty() == false) {
|
||||
phatLootItems.addAll(lb.getItemList());
|
||||
for (ItemStack is : lb.getItemList()) {
|
||||
Quests.addItem(player, is);
|
||||
try {
|
||||
Quests.addItem(player, is);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of "
|
||||
+ player.getName() + " upon completion of quest " + name);
|
||||
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
|
||||
+ "Please contact an administrator.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lb.getCommandList().isEmpty() == false) {
|
||||
|
@ -3760,13 +3760,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
return SkillType.getSkill(s);
|
||||
}
|
||||
|
||||
public static void addItem(Player p, ItemStack i) {
|
||||
/**
|
||||
* Adds item to player's inventory. If full, item is dropped at player's location.
|
||||
*
|
||||
* @throws NullPointerException when ItemStack is null
|
||||
*/
|
||||
public static void addItem(Player p, ItemStack i) throws Exception {
|
||||
if (i == null) {
|
||||
throw new NullPointerException("Null item while trying to add to inventory of " + p.getName());
|
||||
}
|
||||
PlayerInventory inv = p.getInventory();
|
||||
HashMap<Integer, ItemStack> leftover = inv.addItem(i);
|
||||
if (leftover != null) {
|
||||
if (leftover.isEmpty() == false) {
|
||||
for (ItemStack i2 : leftover.values()) {
|
||||
p.getWorld().dropItem(p.getLocation(), i2);
|
||||
if (i != null) {
|
||||
HashMap<Integer, ItemStack> leftover = inv.addItem(i);
|
||||
if (leftover != null) {
|
||||
if (leftover.isEmpty() == false) {
|
||||
for (ItemStack i2 : leftover.values()) {
|
||||
p.getWorld().dropItem(p.getLocation(), i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user