From 5b0e896f6fceaeeebfaf94846032076693b036a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 4 May 2015 11:33:20 +0200 Subject: [PATCH] Added getter for players online as well as registered dimensions to debug card. Closes #1122. --- .../cil/oc/server/component/DebugCard.scala | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/scala/li/cil/oc/server/component/DebugCard.scala b/src/main/scala/li/cil/oc/server/component/DebugCard.scala index efa2c27ad..36cb97818 100644 --- a/src/main/scala/li/cil/oc/server/component/DebugCard.scala +++ b/src/main/scala/li/cil/oc/server/component/DebugCard.scala @@ -98,10 +98,17 @@ class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment { result(host.zPosition) } - @Callback(doc = """function():userdata -- Get the container's world object.""") + @Callback(doc = """function([id:number]):userdata -- Get the world object for the specified dimension ID, or the container's.""") def getWorld(context: Context, args: Arguments): Array[AnyRef] = { checkEnabled() - result(new DebugCard.WorldValue(host.world)) + if (args.count() > 0) result(new DebugCard.WorldValue(DimensionManager.getWorld(args.checkInteger(0)))) + else result(new DebugCard.WorldValue(host.world)) + } + + @Callback(doc = """function():table -- Get a list of all world IDs, loaded and unloaded.""") + def getWorlds(context: Context, args: Arguments): Array[AnyRef] = { + checkEnabled() + result(DimensionManager.getStaticDimensionIDs) } @Callback(doc = """function(name:string):userdata -- Get the entity of a player.""") @@ -110,6 +117,12 @@ class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment { result(new DebugCard.PlayerValue(args.checkString(0))) } + @Callback(doc = """function():table -- Get a list of currently logged-in players.""") + def getPlayers(context: Context, args: Arguments): Array[AnyRef] = { + checkEnabled() + result(MinecraftServer.getServer.getAllUsernames) + } + @Callback(doc = """function(name:string):boolean -- Get whether a mod or API is loaded.""") def isModLoaded(context: Context, args: Arguments): Array[AnyRef] = { checkEnabled() @@ -122,7 +135,7 @@ class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment { checkEnabled() val commands = if (args.isTable(0)) collectionAsScalaIterable(args.checkTable(0).values()) - else Iterable (args.checkString(0)) + else Iterable(args.checkString(0)) CommandSender.synchronized { CommandSender.prepare()