use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class BlockCommands method listFreeShapeBlocks.
@Command(shortDescription = "Lists available free shape blocks", helpText = "Lists all the available free shape blocks. These blocks can be created with any shape.\n" + "You can filter by adding the beginning of words after the commands, e.g.: \"listFreeShapeBlocks" + "engine: core\" will list all free shape blocks from the engine and modules starting with 'core'", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String listFreeShapeBlocks(@CommandParam(value = "startsWith", required = false) String[] startsWith) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Free Shape Blocks");
stringBuilder.append(Console.NEW_LINE);
stringBuilder.append("-----------------");
stringBuilder.append(Console.NEW_LINE);
List<BlockUri> sortedUris = sortItems(blockExplorer.getFreeformBlockFamilies());
for (BlockUri uri : sortedUris) {
if (!uriStartsWithAnyString(uri.toString(), startsWith)) {
continue;
}
stringBuilder.append(uri.toString());
stringBuilder.append(Console.NEW_LINE);
}
return stringBuilder.toString();
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class BlockCommands method listBlocks.
@Command(shortDescription = "List all available blocks\nYou can filter by adding the beginning of words after the" + " commands, e.g.: \"listBlocks engine: core\" will list all blocks from the engine and modules starting with 'core'", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String listBlocks(@CommandParam(value = "startsWith", required = false) String[] startsWith) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Used Blocks");
stringBuilder.append(Console.NEW_LINE);
stringBuilder.append("-----------");
stringBuilder.append(Console.NEW_LINE);
List<BlockUri> registeredBlocks = sortItems(blockManager.listRegisteredBlockUris());
for (BlockUri blockUri : registeredBlocks) {
if (!uriStartsWithAnyString(blockUri.toString(), startsWith)) {
continue;
}
stringBuilder.append(blockUri.toString());
stringBuilder.append(Console.NEW_LINE);
}
stringBuilder.append(Console.NEW_LINE);
stringBuilder.append("Available Blocks");
stringBuilder.append(Console.NEW_LINE);
stringBuilder.append("----------------");
stringBuilder.append(Console.NEW_LINE);
List<BlockUri> availableBlocks = sortItems(blockExplorer.getAvailableBlockFamilies());
for (BlockUri blockUri : availableBlocks) {
if (!uriStartsWithAnyString(blockUri.toString(), startsWith)) {
continue;
}
stringBuilder.append(blockUri.toString());
stringBuilder.append(Console.NEW_LINE);
}
return stringBuilder.toString();
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class BlockCommands method replaceBlock.
@Command(shortDescription = "Replaces a block in front of user", helpText = "Replaces a block in front of the user at the specified max distance", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public void replaceBlock(@Sender EntityRef sender, @CommandParam("blockName") String uri, @CommandParam(value = "maxDistance", required = false) Integer maxDistanceParam) {
int maxDistance = maxDistanceParam != null ? maxDistanceParam : 12;
EntityRef playerEntity = sender.getComponent(ClientComponent.class).character;
EntityRef gazeEntity = GazeAuthoritySystem.getGazeEntityForCharacter(playerEntity);
LocationComponent gazeLocation = gazeEntity.getComponent(LocationComponent.class);
Set<ResourceUrn> matchingUris = Assets.resolveAssetUri(uri, BlockFamilyDefinition.class);
targetSystem.updateTarget(gazeLocation.getWorldPosition(new Vector3f()), gazeLocation.getWorldDirection(new Vector3f()), maxDistance);
EntityRef target = targetSystem.getTarget();
BlockComponent targetLocation = target.getComponent(BlockComponent.class);
if (matchingUris.size() == 1) {
Optional<BlockFamilyDefinition> def = Assets.get(matchingUris.iterator().next(), BlockFamilyDefinition.class);
if (def.isPresent()) {
BlockFamily blockFamily = blockManager.getBlockFamily(uri);
Block block = blockManager.getBlock(blockFamily.getURI());
world.setBlock(targetLocation.getPosition(), block);
} else if (matchingUris.size() > 1) {
StringBuilder builder = new StringBuilder();
builder.append("Non-unique shape name, possible matches: ");
Iterator<ResourceUrn> shapeUris = sortItems(matchingUris).iterator();
while (shapeUris.hasNext()) {
builder.append(shapeUris.next().toString());
if (shapeUris.hasNext()) {
builder.append(", ");
}
}
}
}
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class WorldRendererImpl method dagRedirect.
/**
* Redirect output FBO from one node to another's input
* <p>
* Usage: {@code dagRedirect <connectionTypeString> <fromNodeUri> <outputFboId> <toNodeUri> <inputFboId>}
* <p>
* Example: dagRedirect fbo blurredAmbientOcclusion 1 BasicRendering:outputToScreenNode 1 dagRedirect bufferpair
* backdrop 1 AdvancedRendering:intermediateHazeNode 1
*/
@Command(shortDescription = "Debugging command for DAG.", requiredPermission = PermissionManager.NO_PERMISSION)
public void dagRedirect(@CommandParam("fromNodeUri") final String connectionTypeString, @CommandParam("fromNodeUri") final String fromNodeUri, @CommandParam("outputFboId") final int outputFboId, @CommandParam("toNodeUri") final String toNodeUri, @CommandParam(value = "inputFboId") final int inputFboId) {
RenderGraph.ConnectionType connectionType;
if (connectionTypeString.equalsIgnoreCase("fbo")) {
connectionType = RenderGraph.ConnectionType.FBO;
} else if (connectionTypeString.equalsIgnoreCase("bufferpair")) {
connectionType = RenderGraph.ConnectionType.BUFFER_PAIR;
} else {
throw new RuntimeException(("Unsupported connection type: '" + connectionTypeString + "'. Expected 'fbo' " + "or 'bufferpair'.\n"));
}
Node toNode = renderGraph.findNode(toNodeUri);
if (toNode == null) {
toNode = renderGraph.findAka(toNodeUri);
if (toNode == null) {
throw new RuntimeException(("No node is associated with URI '" + toNodeUri + "'"));
}
}
Node fromNode = renderGraph.findNode(fromNodeUri);
if (fromNode == null) {
fromNode = renderGraph.findAka(fromNodeUri);
if (fromNode == null) {
throw new RuntimeException(("No node is associated with URI '" + fromNodeUri + "'"));
}
}
renderGraph.reconnectInputToOutput(fromNode, outputFboId, toNode, inputFboId, connectionType, true);
toNode.clearDesiredStateChanges();
requestTaskListRefresh();
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class CoreCommands method help.
/**
* Prints out short descriptions for all available commands, or a longer help text if a command is provided.
*
* @param commandName String containing command for which will be displayed help
* @return String containing short description of all commands or longer help text if command is provided
*/
@Command(shortDescription = "Prints out short descriptions for all available commands, or a longer help text if a command is provided.", requiredPermission = PermissionManager.NO_PERMISSION)
public String help(@CommandParam(value = "command", required = false, suggester = CommandNameSuggester.class) Name commandName) {
if (commandName == null) {
StringBuilder msg = new StringBuilder();
// Get all commands, with appropriate sorting
List<ConsoleCommand> commands = Ordering.natural().immutableSortedCopy(console.getCommands());
for (ConsoleCommand cmd : commands) {
if (!msg.toString().isEmpty()) {
msg.append(Console.NEW_LINE);
}
msg.append(FontColor.getColored(cmd.getUsage(), ConsoleColors.COMMAND));
msg.append(" - ");
msg.append(cmd.getDescription());
}
return msg.toString();
} else {
ConsoleCommand cmd = console.getCommand(commandName);
if (cmd == null) {
return "No help available for command '" + commandName + "'. Unknown command.";
} else {
StringBuilder msg = new StringBuilder();
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
msg.append(cmd.getUsage());
msg.append(Console.NEW_LINE);
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
if (!cmd.getHelpText().isEmpty()) {
msg.append(cmd.getHelpText());
msg.append(Console.NEW_LINE);
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
} else if (!cmd.getDescription().isEmpty()) {
msg.append(cmd.getDescription());
msg.append(Console.NEW_LINE);
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
}
if (!cmd.getRequiredPermission().isEmpty()) {
msg.append("Required permission level - " + cmd.getRequiredPermission());
msg.append(Console.NEW_LINE);
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
}
return msg.toString();
}
}
}
Aggregations