Search in sources :

Example 1 with Plugin

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

the class DebugZones method register.

public static void register(Plugin plugin) {
    new CommandAPICommand("debugzones").withPermission(CommandPermission.fromString("scriptedquests.debugzones")).withArguments(new EntitySelectorArgument("player", EntitySelectorArgument.EntitySelector.ONE_PLAYER)).executes((sender, args) -> {
        plugin.mZoneManager.sendDebug(sender, (Player) args[0]);
    }).register();
    new CommandAPICommand("debugzones").withPermission(CommandPermission.fromString("scriptedquests.debugzones")).withArguments(new LocationArgument("position")).executes((sender, args) -> {
        plugin.mZoneManager.sendDebug(sender, ((Location) args[0]).toVector());
    }).register();
}
Also used : CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) LocationArgument(dev.jorel.commandapi.arguments.LocationArgument) Location(org.bukkit.Location) CommandPermission(dev.jorel.commandapi.CommandPermission) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) Player(org.bukkit.entity.Player) CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) Plugin(com.playmonumenta.scriptedquests.Plugin) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) Player(org.bukkit.entity.Player) LocationArgument(dev.jorel.commandapi.arguments.LocationArgument) Location(org.bukkit.Location)

Example 2 with Plugin

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

the class GuiCommand method register.

@SuppressWarnings("unchecked")
public static void register(Plugin plugin) {
    Argument guiNameArgument = new StringArgument("name").replaceSuggestions(i -> plugin.mGuiManager.getGuiNames());
    Argument guiPageArgument = new StringArgument("page").replaceSuggestions(i -> {
        Optional<Gui> gui = Arrays.stream(i.previousArgs()).filter(a -> a instanceof String).findFirst().map(label -> plugin.mGuiManager.getGui((String) label));
        return gui.isPresent() ? gui.get().getPages() : new String[0];
    });
    new CommandAPICommand("sqgui").withPermission("scriptedquests.gui").withSubcommand(new CommandAPICommand("show").withPermission("scriptedquests.gui.show").withArguments(guiNameArgument, new EntitySelectorArgument("player", EntitySelectorArgument.EntitySelector.MANY_PLAYERS)).executes((sender, args) -> {
        for (Player player : (Collection<Player>) args[1]) {
            plugin.mGuiManager.showGui((String) args[0], player, GuiManager.MAIN_PAGE);
        }
    })).withSubcommand(new CommandAPICommand("show").withPermission("scriptedquests.gui.show").withArguments(guiNameArgument, new EntitySelectorArgument("player", EntitySelectorArgument.EntitySelector.MANY_PLAYERS), guiPageArgument).executes((sender, args) -> {
        for (Player player : (Collection<Player>) args[1]) {
            plugin.mGuiManager.showGui((String) args[0], player, (String) args[2]);
        }
    })).withSubcommand(new CommandAPICommand("edit").withPermission("scriptedquests.gui.edit").withArguments(guiNameArgument).executesPlayer((sender, args) -> {
        plugin.mGuiManager.editGui((String) args[0], sender, GuiManager.MAIN_PAGE);
    })).withSubcommand(new CommandAPICommand("edit").withPermission("scriptedquests.gui.edit").withArguments(guiNameArgument, guiPageArgument).executesPlayer((sender, args) -> {
        plugin.mGuiManager.editGui((String) args[0], sender, (String) args[1]);
    })).register();
}
Also used : CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) Arrays(java.util.Arrays) Gui(com.playmonumenta.scriptedquests.quests.Gui) GuiManager(com.playmonumenta.scriptedquests.managers.GuiManager) Collection(java.util.Collection) Optional(java.util.Optional) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) Argument(dev.jorel.commandapi.arguments.Argument) Player(org.bukkit.entity.Player) CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) Plugin(com.playmonumenta.scriptedquests.Plugin) StringArgument(dev.jorel.commandapi.arguments.StringArgument) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) Player(org.bukkit.entity.Player) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) Argument(dev.jorel.commandapi.arguments.Argument) StringArgument(dev.jorel.commandapi.arguments.StringArgument) Collection(java.util.Collection) Gui(com.playmonumenta.scriptedquests.quests.Gui) StringArgument(dev.jorel.commandapi.arguments.StringArgument)

Example 3 with Plugin

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

the class InteractNpc method register.

@SuppressWarnings("unchecked")
public static void register(Plugin plugin) {
    /* First one of these has both required arguments */
    new CommandAPICommand("interactnpc").withPermission(CommandPermission.fromString("scriptedquests.interactnpc")).withArguments(new EntitySelectorArgument("players", EntitySelectorArgument.EntitySelector.MANY_PLAYERS)).withArguments(new StringArgument("npcName")).withArguments(new EntityTypeArgument("npcType")).executes((sender, args) -> {
        interact(plugin, sender, (Collection<Player>) args[0], (String) args[1], (EntityType) args[2]);
    }).register();
    /* Second one accepts a single NPC entity, and goes earlier to take priority over entity names */
    new CommandAPICommand("interactnpc").withPermission(CommandPermission.fromString("scriptedquests.interactnpc")).withArguments(new EntitySelectorArgument("players", EntitySelectorArgument.EntitySelector.MANY_PLAYERS)).withArguments(new EntitySelectorArgument("npc", EntitySelectorArgument.EntitySelector.ONE_ENTITY)).executes((sender, args) -> {
        interact(plugin, sender, (Collection<Player>) args[0], (Entity) args[1]);
    }).register();
    /* Third one just has the npc name with VILLAGER as default */
    new CommandAPICommand("interactnpc").withPermission(CommandPermission.fromString("scriptedquests.interactnpc")).withArguments(new EntitySelectorArgument("players", EntitySelectorArgument.EntitySelector.MANY_PLAYERS)).withArguments(new StringArgument("npcName")).executes((sender, args) -> {
        interact(plugin, sender, (Collection<Player>) args[0], (String) args[1], EntityType.VILLAGER);
    }).register();
}
Also used : CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) CommandSender(org.bukkit.command.CommandSender) Entity(org.bukkit.entity.Entity) Collection(java.util.Collection) UUID(java.util.UUID) Player(org.bukkit.entity.Player) CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) EntityType(org.bukkit.entity.EntityType) Plugin(com.playmonumenta.scriptedquests.Plugin) EntityTypeArgument(dev.jorel.commandapi.arguments.EntityTypeArgument) StringArgument(dev.jorel.commandapi.arguments.StringArgument) CommandPermission(dev.jorel.commandapi.CommandPermission) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) ChatColor(org.bukkit.ChatColor) Pattern(java.util.regex.Pattern) Bukkit(org.bukkit.Bukkit) EntityType(org.bukkit.entity.EntityType) EntitySelectorArgument(dev.jorel.commandapi.arguments.EntitySelectorArgument) Entity(org.bukkit.entity.Entity) Collection(java.util.Collection) EntityTypeArgument(dev.jorel.commandapi.arguments.EntityTypeArgument) StringArgument(dev.jorel.commandapi.arguments.StringArgument)

Example 4 with Plugin

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

the class ShowZones method register.

public static void register(Plugin plugin) {
    new CommandAPICommand("showzones").withPermission(CommandPermission.fromString("scriptedquests.showzones")).withArguments(new MultiLiteralArgument("hide")).executes((sender, args) -> {
        return hide(sender);
    }).register();
    new CommandAPICommand("showzones").withPermission(CommandPermission.fromString("scriptedquests.showzones")).withArguments(new MultiLiteralArgument("show")).withArguments(new TextArgument("layer").replaceSuggestions(info -> {
        return plugin.mZoneManager.getLayerNameSuggestions();
    })).executes((sender, args) -> {
        String layerName = (String) args[1];
        return show(plugin, sender, layerName, null);
    }).register();
    new CommandAPICommand("showzones").withPermission(CommandPermission.fromString("scriptedquests.showzones")).withArguments(new MultiLiteralArgument("show")).withArguments(new TextArgument("layer").replaceSuggestions(info -> {
        return plugin.mZoneManager.getLayerNameSuggestions();
    })).withArguments(new TextArgument("property").replaceSuggestions(info -> {
        Object[] args = info.previousArgs();
        if (args.length == 0) {
            return EXECUTE_FALLBACK_SUGGESTION;
        }
        return plugin.mZoneManager.getLoadedPropertySuggestions((String) args[1]);
    })).executes((sender, args) -> {
        String layerName = (String) args[1];
        String propertyName = (String) args[2];
        return show(plugin, sender, layerName, propertyName);
    }).register();
}
Also used : CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) BoundingBox(org.bukkit.util.BoundingBox) XoRoShiRo128PlusRandom(it.unimi.dsi.util.XoRoShiRo128PlusRandom) HashMap(java.util.HashMap) CommandAPICommand(dev.jorel.commandapi.CommandAPICommand) Player(org.bukkit.entity.Player) Component(net.kyori.adventure.text.Component) Map(java.util.Map) CommandAPI(dev.jorel.commandapi.CommandAPI) Color(org.bukkit.Color) Nullable(javax.annotation.Nullable) Bukkit(org.bukkit.Bukkit) ZoneFragment(com.playmonumenta.scriptedquests.zones.ZoneFragment) CommandSender(org.bukkit.command.CommandSender) Iterator(java.util.Iterator) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Set(java.util.Set) UUID(java.util.UUID) NavigableMap(java.util.NavigableMap) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) Plugin(com.playmonumenta.scriptedquests.Plugin) Particle(org.bukkit.Particle) Vector(org.bukkit.util.Vector) Zone(com.playmonumenta.scriptedquests.zones.Zone) TextArgument(dev.jorel.commandapi.arguments.TextArgument) TreeMap(java.util.TreeMap) WrapperCommandSyntaxException(dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException) Entry(java.util.Map.Entry) CommandPermission(dev.jorel.commandapi.CommandPermission) MultiLiteralArgument(dev.jorel.commandapi.arguments.MultiLiteralArgument) ZoneUtils(com.playmonumenta.scriptedquests.utils.ZoneUtils) TextArgument(dev.jorel.commandapi.arguments.TextArgument) MultiLiteralArgument(dev.jorel.commandapi.arguments.MultiLiteralArgument)

Example 5 with Plugin

use of com.playmonumenta.scriptedquests.Plugin 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

Plugin (com.playmonumenta.scriptedquests.Plugin)7 CommandAPICommand (dev.jorel.commandapi.CommandAPICommand)6 Player (org.bukkit.entity.Player)6 CommandPermission (dev.jorel.commandapi.CommandPermission)5 EntitySelectorArgument (dev.jorel.commandapi.arguments.EntitySelectorArgument)4 LocationArgument (dev.jorel.commandapi.arguments.LocationArgument)3 TextArgument (dev.jorel.commandapi.arguments.TextArgument)3 Location (org.bukkit.Location)3 CommandSender (org.bukkit.command.CommandSender)3 CommandAPI (dev.jorel.commandapi.CommandAPI)2 MultiLiteralArgument (dev.jorel.commandapi.arguments.MultiLiteralArgument)2 StringArgument (dev.jorel.commandapi.arguments.StringArgument)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 Component (net.kyori.adventure.text.Component)2 NamedTextColor (net.kyori.adventure.text.format.NamedTextColor)2 Bukkit (org.bukkit.Bukkit)2