summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorfatpigsarefat <fatpigsarefat@outlook.com>2018-04-29 11:11:08 +0100
committerfatpigsarefat <fatpigsarefat@outlook.com>2018-05-05 21:19:32 +0100
commitf4997269badc3197dc8be93f1c3b84a83d9d9c19 (patch)
tree70d2b71c6b2e92b4254fc44a029b240139f0a593 /src
parentaa6a6cc926190528e6b4fb5f8b01182d7a74cea2 (diff)
Can now accept items above their required amount.
Diffstat (limited to 'src')
-rw-r--r--src/me/fatpigsarefat/quests/quests/tasktypes/types/InventoryTaskType.java20
-rw-r--r--src/plugin.yml2
2 files changed, 15 insertions, 7 deletions
diff --git a/src/me/fatpigsarefat/quests/quests/tasktypes/types/InventoryTaskType.java b/src/me/fatpigsarefat/quests/quests/tasktypes/types/InventoryTaskType.java
index 66499681..b0b7a1a6 100644
--- a/src/me/fatpigsarefat/quests/quests/tasktypes/types/InventoryTaskType.java
+++ b/src/me/fatpigsarefat/quests/quests/tasktypes/types/InventoryTaskType.java
@@ -10,6 +10,7 @@ import me.fatpigsarefat.quests.quests.Task;
import me.fatpigsarefat.quests.quests.tasktypes.ConfigValue;
import me.fatpigsarefat.quests.quests.tasktypes.TaskType;
import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -17,11 +18,14 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
+import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
public final class InventoryTaskType extends TaskType {
@@ -95,16 +99,20 @@ public final class InventoryTaskType extends TaskType {
}
ItemStack is;
if (configData != null) {
- is = new ItemStack(material, amount, (Short) configData);
+ is = new ItemStack(material, 1, ((Integer) configData).shortValue());
} else {
- is = new ItemStack(material, amount);
+ is = new ItemStack(material, 1);
}
- if (player.getInventory().contains(is)) {
- taskProgress.setCompleted(true);
+ if (player.getInventory().containsAtLeast(is, amount)) {
+ is.setAmount(amount);
+ Map<Integer, ItemStack> failures = player.getInventory().removeItem(is);
+ if (failures.size() == 0) {
+ taskProgress.setCompleted(true);
- if (remove != null && ((Boolean) remove)) {
- player.getInventory().remove(is);
+ if (remove != null && ((Boolean) remove)) {
+ player.getInventory().remove(is);
+ }
}
}
}
diff --git a/src/plugin.yml b/src/plugin.yml
index 5f1c6826..c6c424ba 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -1,5 +1,5 @@
name: Quests
-version: 2.0.4-beta
+version: 2.0.5-beta
main: me.fatpigsarefat.quests.Quests
author: fatpigsarefat
softdepend: [ASkyBlock, uSkyBlock]