Added getter for players online as well as registered dimensions to debug card. Closes #1122.

This commit is contained in:
Florian Nücke 2015-05-04 11:33:20 +02:00
parent 48b4bed67a
commit 5b0e896f6f

View File

@ -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()