Search in sources :

Example 11 with Command

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

the class MovementDebugCommands method teleportPlayerToMe.

@Command(shortDescription = "Teleport player to you", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String teleportPlayerToMe(@Sender EntityRef sender, @CommandParam("username") String username) {
    for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
        EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
        DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
        if (username.equalsIgnoreCase(name.name)) {
            LocationComponent locationComponent = sender.getComponent(LocationComponent.class);
            if (locationComponent != null) {
                Vector3f vLocation = locationComponent.getWorldPosition();
                ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
                if (clientComp != null) {
                    clientComp.character.send(new CharacterTeleportEvent(vLocation));
                    return "Teleporting " + username + " to you at " + vLocation.x + " " + vLocation.y + " " + vLocation.z;
                }
            }
        }
    }
    throw new IllegalArgumentException("No such user '" + username + "'");
}
Also used : DisplayNameComponent(org.terasology.logic.common.DisplayNameComponent) CharacterTeleportEvent(org.terasology.logic.characters.CharacterTeleportEvent) Vector3f(org.terasology.math.geom.Vector3f) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) LocationComponent(org.terasology.logic.location.LocationComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 12 with Command

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

the class MovementDebugCommands method ghost.

@Command(shortDescription = "Grants flight and movement through walls", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String ghost(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    clientComp.character.send(new SetMovementModeEvent(MovementMode.GHOSTING));
    return "Ghost mode toggled";
}
Also used : SetMovementModeEvent(org.terasology.logic.characters.events.SetMovementModeEvent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 13 with Command

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

the class MovementDebugCommands method hspeed.

@Command(shortDescription = "Go really fast", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String hspeed(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        move.speedMultiplier = 10f;
        move.jumpSpeed = 24f;
        clientComp.character.saveComponent(move);
        return "High-speed mode activated";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 14 with Command

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

the class MovementDebugCommands method setSpeedMultiplier.

@Command(shortDescription = "Set speed multiplier", helpText = "Set speedMultiplier", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setSpeedMultiplier(@Sender EntityRef client, @CommandParam("amount") float amount) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        float oldSpeedMultipler = move.speedMultiplier;
        move.speedMultiplier = amount;
        clientComp.character.saveComponent(move);
        return "Speed multiplier set to " + amount + " (was " + oldSpeedMultipler + ")";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 15 with Command

use of org.terasology.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.network.ClientComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) ConsoleCommand(org.terasology.logic.console.commandSystem.ConsoleCommand) 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