Search in sources :

Example 66 with Command

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

the class MovementDebugCommands method teleportCommand.

@Command(value = "teleport", shortDescription = "Teleports you to a location", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String teleportCommand(@Sender EntityRef sender, @CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
    ClientComponent clientComp = sender.getComponent(ClientComponent.class);
    clientComp.character.send(new CharacterTeleportEvent(new Vector3f(x, y, z)));
    return "Teleporting  to " + x + " " + y + " " + z;
}
Also used : CharacterTeleportEvent(org.terasology.logic.characters.CharacterTeleportEvent) Vector3f(org.terasology.math.geom.Vector3f) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 67 with Command

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

the class PermissionCommands method removePermission.

@Command(shortDescription = "Removes specified permission from player", helpText = "Removes specified permission from player", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String removePermission(@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 remove 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.removePermission(clientComponent.clientInfo, permission);
            permissionGiven = true;
        }
    }
    if (permissionGiven) {
        return "Permission " + permission + " removed from 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)

Example 68 with Command

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

the class PermissionCommands method listPermissions.

@Command(shortDescription = "Lists all permission the specified player has", helpText = "Lists all permission the specified player has", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String listPermissions(@CommandParam(value = "player", suggester = UsernameSuggester.class) String player) {
    for (EntityRef client : entityManager.getEntitiesWith(ClientComponent.class)) {
        ClientComponent clientComponent = client.getComponent(ClientComponent.class);
        if (clientHasName(clientComponent, player)) {
            EntityRef clientInfo = clientComponent.clientInfo;
            PermissionSetComponent permissionSetComp = clientInfo.getComponent(PermissionSetComponent.class);
            return Objects.toString(permissionSetComp.permissions);
        }
    }
    return "Player not found";
}
Also used : EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) ConsoleCommand(org.terasology.logic.console.commandSystem.ConsoleCommand) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 69 with Command

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

the class HealthCommands method restoreCollisionDamage.

@Command(shortDescription = "Restore default collision damage values", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String restoreCollisionDamage(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    Optional<Prefab> prefab = Assets.get(new ResourceUrn("engine:player"), Prefab.class);
    HealthComponent healthDefault = prefab.get().getComponent(HealthComponent.class);
    HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
    if (health != null && healthDefault != null) {
        health.fallingDamageSpeedThreshold = healthDefault.fallingDamageSpeedThreshold;
        health.horizontalDamageSpeedThreshold = healthDefault.horizontalDamageSpeedThreshold;
        health.excessSpeedDamageMultiplier = healthDefault.excessSpeedDamageMultiplier;
        clientComp.character.saveComponent(health);
    }
    return "Normal collision damage values restored";
}
Also used : ResourceUrn(org.terasology.assets.ResourceUrn) ClientComponent(org.terasology.network.ClientComponent) Prefab(org.terasology.entitySystem.prefab.Prefab) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 70 with Command

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

the class HealthCommands method softLanding.

@Command(shortDescription = "Land without breaking a leg", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String softLanding(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
    if (health != null) {
        health.fallingDamageSpeedThreshold = 85f;
        health.excessSpeedDamageMultiplier = 2f;
        clientComp.character.saveComponent(health);
        return "Soft landing mode activated";
    }
    return "";
}
Also used : ClientComponent(org.terasology.network.ClientComponent) 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