use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class ServerCommands method renameUser.
@Command(shortDescription = "Rename a user", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String renameUser(@CommandParam(value = "userName", suggester = UsernameSuggester.class) String userName, @CommandParam(value = "newUserName") String newUserName) {
Iterable<EntityRef> clientInfoEntities = entityManager.getEntitiesWith(ClientInfoComponent.class);
for (EntityRef clientInfo : clientInfoEntities) {
DisplayNameComponent nameComp = clientInfo.getComponent(DisplayNameComponent.class);
if (newUserName.equalsIgnoreCase(nameComp.name)) {
throw new IllegalArgumentException("New user name is already in use");
}
}
for (EntityRef clientInfo : clientInfoEntities) {
DisplayNameComponent nameComp = clientInfo.getComponent(DisplayNameComponent.class);
if (userName.equalsIgnoreCase(nameComp.name)) {
nameComp.name = newUserName;
clientInfo.saveComponent(nameComp);
return "User " + userName + " has been renamed to " + newUserName;
}
}
throw new IllegalArgumentException("No such user '" + userName + "'");
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class ServerCommands method reloadChunk.
@Command(shortDescription = "Invalidates the specified chunk and recreates it (requires storage manager disabled)", runOnServer = true)
public String reloadChunk(@CommandParam("x") int x, @CommandParam("y") int y, @CommandParam("z") int z) {
Vector3i pos = new Vector3i(x, y, z);
if (config.getSystem().isWriteSaveGamesEnabled()) {
return "Writing save games is enabled! Invalidating chunk has no effect";
}
boolean success = chunkProvider.reloadChunk(pos);
return success ? "Cleared chunk " + pos + " from cache and triggered reload" : "Chunk " + pos + " did not exist in the cache";
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class HealthCommands method healthMax.
@Command(shortDescription = "Restores your health to max", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String healthMax(@Sender EntityRef clientEntity) {
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
clientComp.character.send(new DoHealEvent(100000, clientComp.character));
return "Health fully restored";
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class HealthCommands method showHealth.
@Command(shortDescription = "Show your health", requiredPermission = PermissionManager.NO_PERMISSION)
public String showHealth(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
if (health != null) {
return "Your health:" + health.currentHealth + " max:" + health.maxHealth + " regen:" + health.regenRate;
}
return "I guess you're dead?";
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class HealthCommands method damageWithType.
@Command(shortDescription = "Reduce the player's health by an amount by a specific type of damage", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String damageWithType(@Sender EntityRef client, @CommandParam("damageType") String damageType, @CommandParam("amount") int amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
Prefab damageTypePrefab = prefabManager.getPrefab(damageType);
if (damageTypePrefab != null) {
clientComp.character.send(new DoDamageEvent(amount, damageTypePrefab, clientComp.character));
return "Inflicted " + amount + " damage of type " + damageType;
} else {
return "Specified damage type does not exist.";
}
}
Aggregations