use of org.terasology.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, UISkin.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.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class CoreCommands method setLanguage.
/**
* Change the UI language
* @param langTag String containing language code to change
* @return String containing language or if not recognized error message
*/
@Command(shortDescription = "Changes the UI language")
public String setLanguage(@CommandParam("language-tag") String langTag) {
Locale locale = Locale.forLanguageTag(langTag);
TranslationProject proj = translationSystem.getProject(new SimpleUri("engine:menu"));
// Try if language exists
if (proj.getAvailableLocales().contains(locale)) {
config.getSystem().setLocale(locale);
nuiManager.invalidate();
String nat = translationSystem.translate("${engine:menu#this-language-native}", locale);
String eng = translationSystem.translate("${engine:menu#this-language-English}", locale);
return String.format("Language set to %s (%s)", nat, eng);
} else {
return "Unrecognized locale! Try one of: " + proj.getAvailableLocales();
}
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class ServerCommands method shutdownServer.
@Command(shortDescription = "Shutdown the server", runOnServer = true, requiredPermission = PermissionManager.SERVER_MANAGEMENT_PERMISSION)
public String shutdownServer(@Sender EntityRef sender) {
// TODO: verify permissions of sender
EntityRef clientInfo = sender.getComponent(ClientComponent.class).clientInfo;
DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
logger.info("Shutdown triggered by {}", name.name);
gameEngine.shutdown();
return "Server shutdown triggered";
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class ServerCommands method listUsers.
@Command(shortDescription = "List users", requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String listUsers() {
StringBuilder stringBuilder = new StringBuilder();
for (EntityRef clientInfo : entityManager.getEntitiesWith(ClientInfoComponent.class)) {
DisplayNameComponent dnc = clientInfo.getComponent(DisplayNameComponent.class);
NetworkComponent nc = clientInfo.getComponent(NetworkComponent.class);
String playerText = PlayerUtil.getColoredPlayerName(clientInfo);
String line = String.format("%s - %s (%d)", playerText, dnc.description, nc.getNetworkId());
stringBuilder.append(line);
stringBuilder.append(Console.NEW_LINE);
}
return stringBuilder.toString();
}
use of org.terasology.logic.console.commandSystem.annotations.Command in project Terasology by MovingBlocks.
the class ServerCommands method kickUser.
@Command(shortDescription = "Kick user by name", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String kickUser(@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)) {
return kick(clientEntity);
}
}
throw new IllegalArgumentException("No such user '" + username + "'");
}
Aggregations