use of org.terasology.engine.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.engine.network.ClientComponent 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.engine.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method teleportPlayerToPlayer.
@Command(shortDescription = "Teleport User1 to User2", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String teleportPlayerToPlayer(@CommandParam("usernameFrom") String usernameFrom, @CommandParam("usernameTo") String usernameTo) {
if (usernameFrom.equalsIgnoreCase(usernameTo)) {
throw new IllegalArgumentException("Why teleport to yourself...");
}
EntityRef entityFrom = null;
EntityRef entityTo = null;
boolean foundEntityFrom = false;
boolean foundEntityTo = false;
for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
if (!foundEntityFrom && usernameFrom.equalsIgnoreCase(name.name)) {
entityFrom = clientEntity;
foundEntityFrom = true;
} else if (!foundEntityTo && usernameTo.equalsIgnoreCase(name.name)) {
entityTo = clientEntity;
foundEntityTo = true;
}
if (foundEntityFrom && foundEntityTo) {
break;
}
}
if (!foundEntityFrom) {
throw new IllegalArgumentException("No such user '" + usernameFrom + "'");
}
if (!foundEntityTo) {
throw new IllegalArgumentException("No such user '" + usernameTo + "'");
}
LocationComponent locationComponent = entityTo.getComponent(LocationComponent.class);
if (locationComponent != null) {
Vector3f vLocation = locationComponent.getWorldPosition(new Vector3f());
ClientComponent clientComp = entityFrom.getComponent(ClientComponent.class);
if (clientComp != null) {
clientComp.character.send(new CharacterTeleportEvent(vLocation));
return "Teleporting " + usernameFrom + " to " + usernameTo + " at " + vLocation.x + " " + vLocation.y + " " + vLocation.z;
}
}
throw new IllegalArgumentException("User " + usernameTo + " has an invalid location.");
}
use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.
the class OnlinePlayersOverlay method determinePlayerAndPing.
private String determinePlayerAndPing(PingStockComponent pingStockComponent) {
Map<EntityRef, Long> pingMap = pingStockComponent.getValues();
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Map.Entry<EntityRef, Long> entry : pingMap.entrySet()) {
EntityRef clientEntity = entry.getKey();
if (clientEntity == null || clientEntity.getComponent(ClientComponent.class) == null) {
logger.warn("OnlinePlayersOverlay skipping a null client entity or component");
continue;
}
if (!first) {
sb.append("\n");
}
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
AfkComponent afkComponent = clientEntity.getComponent(AfkComponent.class);
if (afkComponent != null) {
if (afkComponent.afk) {
sb.append(FontColor.getColored("[AFK]", Color.red));
sb.append(" ");
}
}
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();
}
Aggregations