use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class OnlinePlayersOverlay method determinePlayerAndPing.
private String determinePlayerAndPing(PingStockComponent pingStockComponent) {
Iterable<EntityRef> allClients = entityManager.getEntitiesWith(ClientComponent.class);
Map<EntityRef, Long> pingMap = pingStockComponent.getValues();
StringBuilder sb = new StringBuilder();
boolean first = true;
for (EntityRef clientEntity : allClients) {
if (!first) {
sb.append("\n");
}
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
sb.append(PlayerUtil.getColoredPlayerName(clientComp.clientInfo));
sb.append(" ");
Long pingValue = pingMap.get(clientEntity);
if (pingValue == null) {
sb.append("-");
} else {
sb.append(pingValue.toString());
sb.append("ms");
}
first = false;
}
return sb.toString();
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method teleportMeToPlayer.
@Command(shortDescription = "Teleport to player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String teleportMeToPlayer(@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 = clientEntity.getComponent(LocationComponent.class);
if (locationComponent != null) {
Vector3f vLocation = locationComponent.getWorldPosition();
ClientComponent clientComp = sender.getComponent(ClientComponent.class);
if (clientComp != null) {
clientComp.character.send(new CharacterTeleportEvent(vLocation));
return "Teleporting you to " + username + " at " + vLocation.x + " " + vLocation.y + " " + vLocation.z;
}
}
}
}
throw new IllegalArgumentException("No such user '" + username + "'");
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method stepHeight.
@Command(shortDescription = "Sets the height the player can step up", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String stepHeight(@Sender EntityRef client, @CommandParam("height") float amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float prevStepHeight = move.stepHeight;
move.stepHeight = amount;
clientComp.character.saveComponent(move);
return "Ground friction set to " + amount + " (was " + prevStepHeight + ")";
}
return "";
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method playerHeight.
@Command(shortDescription = "Sets the height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerHeight(@Sender EntityRef client, @CommandParam("height") float amount) {
try {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float prevHeight = move.height;
move.height = amount;
clientComp.character.saveComponent(move);
LocationComponent loc = client.getComponent(LocationComponent.class);
Vector3f currentPosition = loc.getWorldPosition();
clientComp.character.send(new CharacterTeleportEvent(new Vector3f(currentPosition.getX(), currentPosition.getY() + (amount - prevHeight) / 2, currentPosition.getZ())));
physics.removeCharacterCollider(clientComp.character);
physics.getCharacterCollider(clientComp.character);
return "Height of player set to " + amount + " (was " + prevHeight + ")";
}
return "";
} catch (NullPointerException e) {
e.printStackTrace();
return "";
}
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method setJumpSpeed.
@Command(shortDescription = "Set jump speed", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setJumpSpeed(@Sender EntityRef client, @CommandParam("amount") float amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float oldSpeed = move.jumpSpeed;
move.jumpSpeed = amount;
clientComp.character.saveComponent(move);
return "Jump speed set to " + amount + " (was " + oldSpeed + ")";
}
return "";
}
Aggregations