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();
}
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();
}
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();
}
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();
}
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();
});
}
Aggregations