Search in sources :

Example 1 with InteractableEntry

use of com.playmonumenta.scriptedquests.quests.InteractableEntry in project scripted-quests by TeamMonumenta.

the class InteractableManager method handleEvent.

private boolean handleEvent(Plugin plugin, Player player, ItemStack item, InteractType type, List<InteractableEntry> entries) {
    boolean cancelEvent = false;
    QuestContext context = new QuestContext(plugin, player, null, false, null, item);
    for (InteractableEntry entry : entries) {
        if (entry.interactEvent(context, type)) {
            cancelEvent = true;
        }
    }
    return cancelEvent;
}
Also used : InteractableEntry(com.playmonumenta.scriptedquests.quests.InteractableEntry) QuestContext(com.playmonumenta.scriptedquests.quests.QuestContext)

Example 2 with InteractableEntry

use of com.playmonumenta.scriptedquests.quests.InteractableEntry in project scripted-quests by TeamMonumenta.

the class InteractableManager method reload.

/*
	 * If sender is non-null, it will be sent debugging information
	 */
public void reload(Plugin plugin, CommandSender sender) {
    mInteractables.clear();
    QuestUtils.loadScriptedQuests(plugin, "interactables", sender, (object) -> {
        InteractableEntry interactable = new InteractableEntry(object);
        for (Material material : interactable.getMaterials()) {
            mInteractables.computeIfAbsent(material, k -> new ArrayList<>()).add(interactable);
        }
        return (interactable.getMaterials().size() == 1 ? interactable.getMaterials().iterator().next() : interactable.getMaterials()) + ":" + interactable.getComponents().size();
    });
}
Also used : MaterialUtils(com.playmonumenta.scriptedquests.utils.MaterialUtils) CommandSender(org.bukkit.command.CommandSender) Entity(org.bukkit.entity.Entity) EnumMap(java.util.EnumMap) InteractType(com.playmonumenta.scriptedquests.quests.InteractableEntry.InteractType) QuestUtils(com.playmonumenta.scriptedquests.utils.QuestUtils) Player(org.bukkit.entity.Player) Action(org.bukkit.event.block.Action) Plugin(com.playmonumenta.scriptedquests.Plugin) ArrayList(java.util.ArrayList) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) Block(org.bukkit.block.Block) Map(java.util.Map) InteractableEntry(com.playmonumenta.scriptedquests.quests.InteractableEntry) QuestContext(com.playmonumenta.scriptedquests.quests.QuestContext) Material(org.bukkit.Material) InteractableEntry(com.playmonumenta.scriptedquests.quests.InteractableEntry) ArrayList(java.util.ArrayList) Material(org.bukkit.Material)

Aggregations

InteractableEntry (com.playmonumenta.scriptedquests.quests.InteractableEntry)2 QuestContext (com.playmonumenta.scriptedquests.quests.QuestContext)2 Plugin (com.playmonumenta.scriptedquests.Plugin)1 InteractType (com.playmonumenta.scriptedquests.quests.InteractableEntry.InteractType)1 MaterialUtils (com.playmonumenta.scriptedquests.utils.MaterialUtils)1 QuestUtils (com.playmonumenta.scriptedquests.utils.QuestUtils)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 List (java.util.List)1 Map (java.util.Map)1 Material (org.bukkit.Material)1 Block (org.bukkit.block.Block)1 CommandSender (org.bukkit.command.CommandSender)1 Entity (org.bukkit.entity.Entity)1 Player (org.bukkit.entity.Player)1 Action (org.bukkit.event.block.Action)1 ItemStack (org.bukkit.inventory.ItemStack)1