This commit is contained in:
Blackvein 2012-11-05 11:35:28 -08:00
parent 97a48db886
commit b5481a7663
3 changed files with 59 additions and 33 deletions

View File

@ -26,6 +26,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerFishEvent.State;
import org.bukkit.event.player.*;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -276,7 +277,19 @@ public class PlayerListener implements Listener {
if(evt.isShiftClick()){
evt.
final int amntBefore = Quests.countInv(evt.getInventory(), evt.getCurrentItem().getType());
final Material mat = evt.getCurrentItem().getType();
final Inventory inv = evt.getInventory();
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
@Override
public void run(){
int amntAfter = Quests.countInv(evt.getInventory(), mat);
}
}, 5);
}

View File

@ -25,9 +25,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.*;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
@ -3799,10 +3797,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return null;
}
public int getCraftTimes(Inventory i, Recipe r){
return 0;
public static int countInv(Inventory inv, Material m){
int count = 0;
for(ItemStack i : inv.getContents()){
if(i != null){
if(i.getType().equals(m))
count += i.getAmount();
}
}
return count;
}
}

View File

@ -22,41 +22,45 @@ public class StageTimer implements Runnable{
Player player = plugin.getServer().getPlayerExact(quester.name);
if(quester.currentQuest.stages.indexOf(quester.currentStage) == (quester.currentQuest.stages.size() - 1)){
if(quester.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
if(quester.currentStage.event != null)
quester.currentStage.event.happen(player);
quester.currentQuest.completeQuest(quester);
if(quester.currentQuest != null){
}else {
if(quester.currentQuest.stages.indexOf(quester.currentStage) == (quester.currentQuest.stages.size() - 1)){
quester.reset();
player.sendMessage(plugin.parseString(quester.currentStage.finished, quester.currentQuest));
if(quester.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
if(quester.currentStage.event != null)
quester.currentStage.event.happen(player);
quester.currentStage = quester.currentQuest.stages.get(quester.currentQuest.stages.indexOf(quester.currentStage) + 1);
quester.addEmpties();
quester.delayStartTime = 0;
quester.delayTimeLeft = -1;
if(quester.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
if(quester.currentStage.event != null)
quester.currentStage.event.happen(player);
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
for(String s : quester.getObjectives()){
quester.currentQuest.completeQuest(quester);
player.sendMessage(s);
}else {
quester.reset();
player.sendMessage(plugin.parseString(quester.currentStage.finished, quester.currentQuest));
if(quester.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
if(quester.currentStage.event != null)
quester.currentStage.event.happen(player);
quester.currentStage = quester.currentQuest.stages.get(quester.currentQuest.stages.indexOf(quester.currentStage) + 1);
quester.addEmpties();
quester.delayStartTime = 0;
quester.delayTimeLeft = -1;
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
for(String s : quester.getObjectives()){
player.sendMessage(s);
}
}
}
quester.delayOver = true;
}
quester.delayOver = true;
}
}