mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-22 00:58:55 +01:00
Finished Quest item clicking, starting stage time delays
This commit is contained in:
parent
173d33520f
commit
d37101c8bf
@ -2,6 +2,7 @@ package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
@ -450,7 +451,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
}else{
|
||||
|
||||
if(player != null && evt.getCurrentItem() != null && evt.getResult().equals(org.bukkit.event.Event.Result.ALLOW)){
|
||||
if(player != null && evt.getCurrentItem() != null){
|
||||
|
||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getName());
|
||||
Material mat = evt.getCurrentItem().getType();
|
||||
@ -459,14 +460,23 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if(quester.currentQuest.questItems.containsKey(mat)){
|
||||
|
||||
String s = Quester.checkPlacement(evt.getInventory(), evt.getRawSlot());
|
||||
if(s == null){
|
||||
List<Integer> changedSlots = Quester.getChangedSlots(evt.getInventory(), evt.getCurrentItem());
|
||||
boolean can = true;
|
||||
for(int i : changedSlots){
|
||||
|
||||
String s = Quester.checkPlacement(evt.getInventory(), i);
|
||||
if(s != null){
|
||||
can = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if(!can){
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + "You may not store Quest items.");
|
||||
evt.setCancelled(true);
|
||||
player.updateInventory();
|
||||
|
||||
}else{
|
||||
}else if(can && Quester.checkPlacement(evt.getInventory(), evt.getRawSlot()) != null){
|
||||
|
||||
ItemStack oldStack = evt.getCurrentItem();
|
||||
Inventory inv = plugin.getServer().createInventory(null, evt.getInventory().getType());
|
||||
|
@ -48,6 +48,7 @@ public class Quest {
|
||||
List<String> commands = new LinkedList<String>();
|
||||
List<String> permissions = new LinkedList<String>();
|
||||
LinkedList<ItemStack> itemRewards = new LinkedList<ItemStack>();
|
||||
LinkedList<Integer> itemRewardAmounts = new LinkedList<Integer>();
|
||||
//Heroes
|
||||
int heroesExp = 0;
|
||||
String heroesClass = null;
|
||||
@ -69,6 +70,7 @@ public class Quest {
|
||||
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
|
||||
if(q.currentStage.event != null)
|
||||
q.currentStage.event.happen(player);
|
||||
|
||||
completeQuest(q);
|
||||
|
||||
}else {
|
||||
@ -245,7 +247,7 @@ public class Quest {
|
||||
}
|
||||
|
||||
for(ItemStack i : itemRewards){
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount());
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + itemRewardAmounts.get(itemRewards.indexOf(i)));
|
||||
none = null;
|
||||
}
|
||||
|
||||
@ -284,6 +286,7 @@ public class Quest {
|
||||
q.currentStage = null;
|
||||
|
||||
q.saveData();
|
||||
player.updateInventory();
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ public class Quester {
|
||||
Map<Integer, Integer> potionsBrewed = new HashMap<Integer, Integer>();
|
||||
int fishCaught = 0;
|
||||
int playersKilled = 0;
|
||||
long stageDelay = 0;
|
||||
Map<String, Long> playerKillTimes = new HashMap<String, Long>();
|
||||
Map<Map<Enchantment, Material>, Integer> itemsEnchanted = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
LinkedList<EntityType> mobsKilled = new LinkedList<EntityType>();
|
||||
@ -2672,4 +2673,49 @@ public class Quester {
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static List<Integer> getChangedSlots(Inventory inInv, ItemStack inNew)
|
||||
{
|
||||
List<Integer> changed = new ArrayList<Integer>();
|
||||
if(inInv.contains(inNew.getType()))
|
||||
{
|
||||
int amount = inNew.getAmount();
|
||||
HashMap<Integer, ? extends ItemStack> items = inInv.all(inNew.getType());
|
||||
for(int i = 0; i < inInv.getSize(); i++)
|
||||
{
|
||||
if(!items.containsKey((Integer)i))
|
||||
continue;
|
||||
|
||||
ItemStack item = items.get((Integer)i);
|
||||
int slotamount = item.getMaxStackSize() - item.getAmount();
|
||||
if(slotamount > 1)
|
||||
{
|
||||
if(amount > slotamount)
|
||||
{
|
||||
int toAdd = slotamount - amount;
|
||||
amount = amount - toAdd;
|
||||
changed.add(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
changed.add(i);
|
||||
amount = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(amount > 0)
|
||||
{
|
||||
if(inInv.firstEmpty() != -1)
|
||||
changed.add(inInv.firstEmpty());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(inInv.firstEmpty() != -1)
|
||||
changed.add(inInv.firstEmpty());
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
|
@ -2685,6 +2685,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".delay")) {
|
||||
|
||||
if (config.getLong("quests." + s + ".stages.ordered." + s2 + ".delay", -999) != -999){
|
||||
stage.delay = config.getLong("quests." + s + ".stages.ordered." + s2 + ".delay");
|
||||
}else {
|
||||
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "delay: " + ChatColor.GOLD + "in " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a number!");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(config.contains("quests." + s + ".stages.ordered." + s2 + ".delay-message")){
|
||||
|
||||
stage.delayMessage = config.getString("quests." + s + ".stages.ordered." + s2 + ".delay-message");
|
||||
|
||||
}
|
||||
|
||||
stage.citizensToInteract = npcsToTalkTo;
|
||||
|
||||
@ -2717,8 +2735,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
ItemStack stack = new ItemStack(m, config.getIntegerList("quests." + s + ".rewards.item-amounts").get(config.getIntegerList("quests." + s + ".rewards.item-ids").indexOf(i)));
|
||||
int amnt = config.getIntegerList("quests." + s + ".rewards.item-amounts").get(config.getIntegerList("quests." + s + ".rewards.item-ids").indexOf(i));
|
||||
ItemStack stack = new ItemStack(m, amnt);
|
||||
quest.itemRewards.add(stack);
|
||||
quest.itemRewardAmounts.add(amnt);
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class Stage {
|
||||
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
LinkedList<String> areaNames = new LinkedList<String>();
|
||||
LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(){
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
@ -87,6 +87,8 @@ public class Stage {
|
||||
Map<Material, Integer> itemsToCraft = new EnumMap<Material, Integer>(Material.class);
|
||||
String script;
|
||||
Event event;
|
||||
long delay = -1;
|
||||
String delayMessage = "";
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@ -232,6 +234,12 @@ public class Stage {
|
||||
} else if (other.event == null && event != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(other.delay != delay)
|
||||
return false;
|
||||
|
||||
if(other.delayMessage.equalsIgnoreCase(delayMessage) == false)
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user