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