The various kinds of commands
#4
I don't like Bukkit's way of putting all the commands together. If one plugin registers a "test" console command, another plugin cannot register a "test" in-game command (which is perfectly possible now in Cuberite).

Minecarts with command blocks could use commandblock registrations and call the callbacks with a_CommandBlockEntity set to the minecart-with-CB. Not much pain.

@NiLSPACE That's more or less what I had in mind - the CommandOutput object is there so that a handler may add any output up until it calls Terminate:
--- Lists all entities in a given chunk
function HandleConsoleEnumChunkEntities(a_Split, a_Player, a_EntireCmd, a_CommandOutput)
  local worldName = a_Split[2]
  local chunkX = tonumber(a_Split[3])
  local chunkZ = tonumber(a_Split[4])
  
  local world = cRoot:Get():GetWorld(worldName)
  world:ChunkStay({{chunkX, chunkZ}},
    nil,  -- ChunkAvailable
    function ()  -- AllChunksReady
      -- The chunk has been loaded, enum the entities:
      world:ForEachEntityInChunk(chunkX, chunkZ,
        function (a_Entity)
          a_CommandOutput.Add(string.format("Entity %s at {%d, %d, %d}", 
            a_Entity:GetClass(), a_Entity:GetPosX(), a_Entity:GetPosY(), a_Entity:GetPosZ())
          )
        end
      )
      -- All entities have been listed, terminate the output:
      a_CommandOutput.Terminate()
    end
  )

  return true  -- Must not return a message - that would terminate the CommandOutput immediately
end
Reply
Thanks given by:


Messages In This Thread
The various kinds of commands - by xoft - 11-01-2015, 12:05 AM
RE: The various kinds of commands - by NiLSPACE - 11-01-2015, 12:24 AM
RE: The various kinds of commands - by bibo38 - 11-01-2015, 04:10 AM
RE: The various kinds of commands - by xoft - 11-01-2015, 08:03 AM
RE: The various kinds of commands - by bibo38 - 11-01-2015, 07:45 PM



Users browsing this thread: 1 Guest(s)