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 + "'");
}
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";
}
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 "";
}
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 "";
}
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;
}
}
Aggregations