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>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests</artifactId>
|
<artifactId>quests</artifactId>
|
||||||
<version>3.4.5</version>
|
<version>3.4.6</version>
|
||||||
<name>quests</name>
|
<name>quests</name>
|
||||||
<url>https://github.com/FlyingPikachu/Quests/</url>
|
<url>https://github.com/FlyingPikachu/Quests/</url>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.QuestMob;
|
import me.blackvein.quests.util.QuestMob;
|
||||||
@ -208,7 +209,14 @@ public class Event {
|
|||||||
}
|
}
|
||||||
if (items.isEmpty() == false) {
|
if (items.isEmpty() == false) {
|
||||||
for (ItemStack is : items) {
|
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) {
|
if (stormWorld != null) {
|
||||||
|
@ -318,7 +318,14 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ItemStack i : itemRewards) {
|
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;
|
none = null;
|
||||||
}
|
}
|
||||||
for (String s : commands) {
|
for (String s : commands) {
|
||||||
@ -368,7 +375,14 @@ public class Quest {
|
|||||||
if (lb.getItemList().isEmpty() == false) {
|
if (lb.getItemList().isEmpty() == false) {
|
||||||
phatLootItems.addAll(lb.getItemList());
|
phatLootItems.addAll(lb.getItemList());
|
||||||
for (ItemStack is : 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) {
|
if (lb.getCommandList().isEmpty() == false) {
|
||||||
|
@ -3759,14 +3759,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
public static SkillType getMcMMOSkill(String s) {
|
public static SkillType getMcMMOSkill(String s) {
|
||||||
return SkillType.getSkill(s);
|
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();
|
PlayerInventory inv = p.getInventory();
|
||||||
HashMap<Integer, ItemStack> leftover = inv.addItem(i);
|
if (i != null) {
|
||||||
if (leftover != null) {
|
HashMap<Integer, ItemStack> leftover = inv.addItem(i);
|
||||||
if (leftover.isEmpty() == false) {
|
if (leftover != null) {
|
||||||
for (ItemStack i2 : leftover.values()) {
|
if (leftover.isEmpty() == false) {
|
||||||
p.getWorld().dropItem(p.getLocation(), i2);
|
for (ItemStack i2 : leftover.values()) {
|
||||||
|
p.getWorld().dropItem(p.getLocation(), i2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user