Search in sources :

Example 51 with Command

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

the class CoreCommands method editSkin.

/**
 * Opens the NUI editor for a ui skin
 *
 * @param uri String containing name of ui skin
 * @return String containing final message
 */
@Command(shortDescription = "Opens the NUI editor for a ui skin", requiredPermission = PermissionManager.NO_PERMISSION)
public String editSkin(@CommandParam(value = "uri", suggester = SkinSuggester.class) String uri) {
    if (!nuiSkinEditorSystem.isEditorActive()) {
        nuiSkinEditorSystem.toggleEditor();
    }
    Set<ResourceUrn> urns = assetManager.resolve(uri, UISkinAsset.class);
    switch(urns.size()) {
        case 0:
            return String.format("No asset found for screen '%s'", uri);
        case 1:
            ResourceUrn urn = urns.iterator().next();
            ((NUISkinEditorScreen) nuiManager.getScreen(NUISkinEditorScreen.ASSET_URI)).selectAsset(urn);
            return "Success";
        default:
            return String.format("Multiple matches for screen '%s': {%s}", uri, Arrays.toString(urns.toArray()));
    }
}
Also used : NUISkinEditorScreen(org.terasology.engine.rendering.nui.editor.layers.NUISkinEditorScreen) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.engine.logic.console.commandSystem.ConsoleCommand)

Example 52 with Command

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

the class WorldCommands method simulate.

@Command(shortDescription = "Random", runOnServer = true)
public String simulate(@Sender EntityRef sender) {
    EntityRef simulatedEntity = entityManager.create("engine:multiWorldSim");
    DisplayNameComponent displayNameComponent = simulatedEntity.getComponent(DisplayNameComponent.class);
    displayNameComponent.name = "I-Travel-Worlds-" + simulatedEntity.getId();
    simulatedEntity.saveComponent(displayNameComponent);
    ColorComponent colorComponent = simulatedEntity.getComponent(ColorComponent.class);
    colorComponent.color = Color.RED;
    simulatedEntity.saveComponent(colorComponent);
    sender.send(new ChatMessageEvent("yay", simulatedEntity));
    return "done";
}
Also used : DisplayNameComponent(org.terasology.engine.logic.common.DisplayNameComponent) ChatMessageEvent(org.terasology.engine.logic.chat.ChatMessageEvent) ColorComponent(org.terasology.engine.network.ColorComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 53 with Command

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

the class FirstPersonClientSystem method setFirstPersonheldItemMountPointTranslation.

@Command(shortDescription = "Sets the held item mount point translation for the first person view")
public void setFirstPersonheldItemMountPointTranslation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
    FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
    if (newComponent != null) {
        newComponent.translate = new Vector3f(x, y, z);
        ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
    }
}
Also used : Vector3f(org.joml.Vector3f) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 54 with Command

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

the class FirstPersonClientSystem method setFirstPersonheldItemMountPointRotation.

@Command(shortDescription = "Sets the held item mount point rotation for the first person view")
public void setFirstPersonheldItemMountPointRotation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
    FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
    if (newComponent != null) {
        newComponent.rotateDegrees = new Vector3f(x, y, z);
        ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
    }
}
Also used : Vector3f(org.joml.Vector3f) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 55 with Command

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

the class PermissionCommands method givePermission.

@Command(shortDescription = "Gives specified permission to player", helpText = "Gives specified permission to player", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String givePermission(@CommandParam(value = "player", suggester = UsernameSuggester.class) String player, @CommandParam("permission") String permission, @Sender EntityRef requester) {
    boolean permissionGiven = false;
    ClientComponent requesterClientComponent = requester.getComponent(ClientComponent.class);
    EntityRef requesterClientInfo = requesterClientComponent.clientInfo;
    if (!permissionManager.hasPermission(requesterClientInfo, permission)) {
        return String.format("You can't give the permission %s because you don't have it yourself", permission);
    }
    for (EntityRef client : entityManager.getEntitiesWith(ClientComponent.class)) {
        ClientComponent clientComponent = client.getComponent(ClientComponent.class);
        if (clientHasName(clientComponent, player)) {
            permissionManager.addPermission(clientComponent.clientInfo, permission);
            permissionGiven = true;
        }
    }
    if (permissionGiven) {
        return "Permission " + permission + " added to player " + player;
    } else {
        return "Unable to find player " + player;
    }
}
Also used : ClientComponent(org.terasology.engine.network.ClientComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ConsoleCommand(org.terasology.engine.logic.console.commandSystem.ConsoleCommand) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)67 ClientComponent (org.terasology.engine.network.ClientComponent)42 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)35 Vector3f (org.joml.Vector3f)16 ConsoleCommand (org.terasology.engine.logic.console.commandSystem.ConsoleCommand)16 CharacterMovementComponent (org.terasology.engine.logic.characters.CharacterMovementComponent)11 DisplayNameComponent (org.terasology.engine.logic.common.DisplayNameComponent)10 LocationComponent (org.terasology.engine.logic.location.LocationComponent)10 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)9 BlockFamily (org.terasology.engine.world.block.family.BlockFamily)6 Map (java.util.Map)5 CharacterTeleportEvent (org.terasology.engine.logic.characters.CharacterTeleportEvent)5 DropItemEvent (org.terasology.engine.logic.inventory.events.DropItemEvent)5 BlockItemFactory (org.terasology.engine.world.block.items.BlockItemFactory)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)3 List (java.util.List)3 Locale (java.util.Locale)3