use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class CoreCommands method editSkin.
/**
* Opens the NUI editor for a ui skin
*
* @param uri String containing name of ui skin
* @return String containing final message
*/
@Command(shortDescription = "Opens the NUI editor for a ui skin", requiredPermission = PermissionManager.NO_PERMISSION)
public String editSkin(@CommandParam(value = "uri", suggester = SkinSuggester.class) String uri) {
if (!nuiSkinEditorSystem.isEditorActive()) {
nuiSkinEditorSystem.toggleEditor();
}
Set<ResourceUrn> urns = assetManager.resolve(uri, UISkinAsset.class);
switch(urns.size()) {
case 0:
return String.format("No asset found for screen '%s'", uri);
case 1:
ResourceUrn urn = urns.iterator().next();
((NUISkinEditorScreen) nuiManager.getScreen(NUISkinEditorScreen.ASSET_URI)).selectAsset(urn);
return "Success";
default:
return String.format("Multiple matches for screen '%s': {%s}", uri, Arrays.toString(urns.toArray()));
}
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class WorldCommands method simulate.
@Command(shortDescription = "Random", runOnServer = true)
public String simulate(@Sender EntityRef sender) {
EntityRef simulatedEntity = entityManager.create("engine:multiWorldSim");
DisplayNameComponent displayNameComponent = simulatedEntity.getComponent(DisplayNameComponent.class);
displayNameComponent.name = "I-Travel-Worlds-" + simulatedEntity.getId();
simulatedEntity.saveComponent(displayNameComponent);
ColorComponent colorComponent = simulatedEntity.getComponent(ColorComponent.class);
colorComponent.color = Color.RED;
simulatedEntity.saveComponent(colorComponent);
sender.send(new ChatMessageEvent("yay", simulatedEntity));
return "done";
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class FirstPersonClientSystem method setFirstPersonheldItemMountPointTranslation.
@Command(shortDescription = "Sets the held item mount point translation for the first person view")
public void setFirstPersonheldItemMountPointTranslation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
if (newComponent != null) {
newComponent.translate = new Vector3f(x, y, z);
ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
}
}
use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class FirstPersonClientSystem method setFirstPersonheldItemMountPointRotation.
@Command(shortDescription = "Sets the held item mount point rotation for the first person view")
public void setFirstPersonheldItemMountPointRotation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
if (newComponent != null) {
newComponent.rotateDegrees = new Vector3f(x, y, z);
ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
}
}
use of org.terasology.engine.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