Search in sources :

Example 76 with Command

use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.

the class ItemCommands method listItems.

@Command(shortDescription = "Lists all available items (prefabs)\nYou can filter by adding the beginning of words " + "after the commands, e.g.: \"listItems engine: core:\" will list all items from the engine and core module", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String listItems(@CommandParam(value = "startsWith", required = false) String[] startsWith) {
    List<String> stringItems = Lists.newArrayList();
    for (Prefab prefab : prefabManager.listPrefabs()) {
        if (!BlockCommands.uriStartsWithAnyString(prefab.getName(), startsWith)) {
            continue;
        }
        stringItems.add(prefab.getName());
    }
    Collections.sort(stringItems);
    StringBuilder items = new StringBuilder();
    for (String item : stringItems) {
        if (!items.toString().isEmpty()) {
            items.append(Console.NEW_LINE);
        }
        items.append(item);
    }
    return items.toString();
}
Also used : Prefab(org.terasology.entitySystem.prefab.Prefab) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Aggregations

Command (org.terasology.logic.console.commandSystem.annotations.Command)76 ClientComponent (org.terasology.network.ClientComponent)48 EntityRef (org.terasology.entitySystem.entity.EntityRef)28 ConsoleCommand (org.terasology.logic.console.commandSystem.ConsoleCommand)16 Vector3f (org.terasology.math.geom.Vector3f)14 CharacterMovementComponent (org.terasology.logic.characters.CharacterMovementComponent)11 LocationComponent (org.terasology.logic.location.LocationComponent)10 DisplayNameComponent (org.terasology.logic.common.DisplayNameComponent)9 ResourceUrn (org.terasology.assets.ResourceUrn)8 Prefab (org.terasology.entitySystem.prefab.Prefab)6 CharacterTeleportEvent (org.terasology.logic.characters.CharacterTeleportEvent)6 SimpleUri (org.terasology.engine.SimpleUri)5 BlockFamily (org.terasology.world.block.family.BlockFamily)4 Map (java.util.Map)3 AnatomyComponent (org.terasology.anatomy.component.AnatomyComponent)3 SetMovementModeEvent (org.terasology.logic.characters.events.SetMovementModeEvent)3 DropItemEvent (org.terasology.logic.inventory.events.DropItemEvent)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2