Added support for many common variations of the jagex coordinate format for admin command ::tele, including:

regionX_regionY
plane_regionX_regionY
regionX_regionY_localX_localY
plane_regionX_regionY_localX_localY
This commit is contained in:
Ceikry
2022-06-23 23:27:36 +00:00
committed by Ryan
parent 01c8072e9b
commit 419533e6c8
2 changed files with 37 additions and 15 deletions
@@ -70,6 +70,7 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
var obj: Scenery? = null
notify(player,"Absolute: " + l + ", regional: [" + l.localX + ", " + l.localY + "], chunk: [" + l.chunkOffsetX + ", " + l.chunkOffsetY + "], flag: [" + RegionManager.isTeleportPermitted(l) + ", " + RegionManager.getClippingFlag(l) + ", " + RegionManager.isLandscape(l) + "].")
notify(player,"Region: [id=" + l.regionId + ", active=" + r.isActive + ", instanced=" + (r is DynamicRegion) + "], obj=" + RegionManager.getObject(l) + ".")
notify(player, "Jagex: ${l.z}_${l.regionId shr 8}_${l.regionId and 0xFF}_${l.localX}_${l.localY}")
notify(player,"Object: " + RegionManager.getObject(l).also{obj = it} + ".")
notify(player,"Object Varp: " + obj?.definition?.configFile?.configId + " offset: " + obj?.definition?.configFile?.bitShift + " size: " + (obj?.definition?.configFile?.bitShift?.minus(obj?.definition?.configFile?.bitShift!!)))
SystemLogger.logInfo("Viewport: " + l.getSceneX(player.playerFlags.lastSceneGraph) + "," + l.getSceneY(player.playerFlags.lastSceneGraph))
@@ -52,7 +52,21 @@ class TeleportCommandSet : CommandSet(Privilege.ADMIN){
if (args.size == 2 && args[1].contains("_"))
{
val tokens = args[1].split("_")
if(tokens.size == 4) {
when (tokens.size) {
2 -> {
val regionX = tokens[0].toInt()
val regionY = tokens[1].toInt()
player.properties.teleportLocation = Location.create((regionX shl 6) or 15, (regionY shl 6) or 15, 0)
}
3 -> {
val plane = tokens[0].toInt()
val regionX = tokens[1].toInt()
val regionY = tokens[2].toInt()
player.properties.teleportLocation = Location.create((regionX shl 6) or 15, (regionY shl 6) or 15, plane)
}
4 -> {
val regionX = tokens[0].toInt()
val regionY = tokens[1].toInt()
val offsetX = tokens[2].toInt()
@@ -63,13 +77,20 @@ class TeleportCommandSet : CommandSet(Privilege.ADMIN){
player.properties.teleportLocation = Location.create(xCoord, yCoord, 0)
}
else if(tokens.size == 2){
val regionX = tokens[0].toInt()
val regionY = tokens[1].toInt()
5 -> {
val plane = tokens[0].toInt()
val regionX = tokens[1].toInt()
val regionY = tokens[2].toInt()
val offsetX = tokens[3].toInt()
val offsetY = tokens[4].toInt()
player.properties.teleportLocation = Location.create((regionX shl 6) or 15, (regionY shl 6) or 15, 0)
val xCoord = (regionX shl 6) or offsetX
val yCoord = (regionY shl 6) or offsetY
player.properties.teleportLocation = Location.create(xCoord, yCoord, plane)
}
else -> reject(player, "Usage: regionX_regionY OR regionX_regionY_offsetX_offsetY")
}
else reject(player, "Usage: regionX_regionY OR regionX_regionY_offsetX_offsetY")
return@define
}
if (args.size < 2) {