mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-02 22:48:05 +01:00
Finished Crafting Quest Items
This commit is contained in:
parent
5803acdba9
commit
51e545e26a
@ -274,9 +274,10 @@ public class PlayerListener implements Listener {
|
||||
|
||||
}else if(quester.hasObjective("craftItem")){
|
||||
|
||||
final int amntBefore = Quests.countInv(evt.getInventory(), evt.getCurrentItem().getType());
|
||||
final int amntBefore = Quests.countInv(evt.getInventory(), evt.getCurrentItem().getType(), evt.getCurrentItem().getAmount());
|
||||
System.out.println("Amount before: " + amntBefore);
|
||||
final Material mat = evt.getCurrentItem().getType();
|
||||
final Inventory inv = evt.getInventory();
|
||||
final Inventory inv = evt.getWhoClicked().getInventory();
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
|
||||
@Override
|
||||
@ -284,7 +285,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if(evt.isCancelled() == false){
|
||||
|
||||
int amntAfter = Quests.countInv(inv, mat);
|
||||
int amntAfter = Quests.countInv(inv, mat, 0);
|
||||
System.out.println("Amount after: " + amntAfter);
|
||||
quester.craftItem(new ItemStack(mat, amntAfter - amntBefore));
|
||||
|
||||
}
|
||||
@ -392,7 +394,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent evt) {
|
||||
|
||||
System.out.println("Click fired.");
|
||||
Player player = null;
|
||||
if (evt.getWhoClicked() instanceof Player) {
|
||||
player = (Player) evt.getWhoClicked();
|
||||
@ -516,16 +518,15 @@ public class PlayerListener implements Listener {
|
||||
} else {
|
||||
|
||||
if (evt.getCurrentItem() != null) {
|
||||
|
||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getName());
|
||||
Material mat = evt.getCurrentItem().getType();
|
||||
|
||||
if (quester.currentQuest != null) {
|
||||
|
||||
if (quester.currentQuest.questItems.containsKey(mat)) {
|
||||
|
||||
if(evt.getInventory().getType().equals(InventoryType.CRAFTING) && evt.getRawSlot() == 0)
|
||||
System.out.println(evt.getInventory().getType());
|
||||
if((evt.getInventory().getType().equals(InventoryType.WORKBENCH) && evt.getRawSlot() == 0) || (evt.getInventory().getType().equals(InventoryType.CRAFTING) && evt.getRawSlot() == 0)){
|
||||
return;
|
||||
}
|
||||
|
||||
List<Integer> changedSlots = Quester.getChangedSlots(evt.getInventory(), evt.getCurrentItem());
|
||||
boolean can = true;
|
||||
|
@ -444,18 +444,21 @@ public class Quester {
|
||||
|
||||
for (Entry e : currentStage.itemsToCraft.entrySet()) {
|
||||
|
||||
System.out.println("Entry.");
|
||||
Entry entry = null;
|
||||
for(Object o : ((Map) e.getKey()).entrySet())
|
||||
entry = (Entry) o;
|
||||
|
||||
for (Entry e2 : itemsCrafted.entrySet()) {
|
||||
|
||||
if (e.getKey().equals(e2.getKey())) {
|
||||
if (entry.getKey().equals(e2.getKey())) {
|
||||
|
||||
if ((Integer) e2.getValue() < (Integer) e.getValue()) {
|
||||
if ((Integer) e2.getValue() < (Integer) entry.getValue()) {
|
||||
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Craft " + prettyItemString(((Material) e.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue()));
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Craft " + prettyItemString(((Material) entry.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) entry.getValue()));
|
||||
|
||||
} else {
|
||||
|
||||
finishedObjectives.add(ChatColor.GRAY + "Craft " + prettyItemString(((Material) e.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue()));
|
||||
finishedObjectives.add(ChatColor.GRAY + "Craft " + prettyItemString(((Material) entry.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) entry.getValue()));
|
||||
|
||||
}
|
||||
|
||||
@ -976,7 +979,7 @@ public class Quester {
|
||||
}
|
||||
|
||||
if (itemsCrafted.get(i.getType()).equals((Integer) m.get(i.getType()))) {
|
||||
finishObjective("craftItem", null, i, null, null, null, null, null, null, 0);
|
||||
finishObjective("craftItem", i.getType(), null, null, null, null, null, null, null, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3802,7 +3802,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int countInv(Inventory inv, Material m){
|
||||
public static int countInv(Inventory inv, Material m, int subtract){
|
||||
|
||||
int count = 0;
|
||||
|
||||
@ -3815,7 +3815,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
return count - subtract;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user