Action API Concept

An action is something that the server tells the client to do once and never worries about from the server side again. They’re reasonable to perform over groups of players, such as the whole server, a whole world, a radius around a location, a specific Extent, a single player, or some other grouping.

The goal of defining Actions is to avoid creating many copies of methods on each player set (see above) which may want to make available these actions to avoid the need for manual looping in plugin code in many situations.

Action would define void apply(Player). Some sort of factory would have ways to construct an Action for each thing listed below, and player sets would need only a single playAction/showAction/whatever method (or for World, an additional method which takes a radius).

Just a concept - not even sure Action is really the best name. The list following is a useful reference for these kinds of tasks even if this concept isn’t used.

Based on Bukkit methods
playNote
playEffect (clientbound 0x28)
playSound (clientbound 0x29)
showParticle (clientbound 0x2A)

sendMessage (sort of. more complicated)
sendBlockChange
sendChunkChange
sendSignChange
sendMap

setCompassTarget
setResourcePack
sendPluginMessage

New in 1.8
showTitle
showDifficulty (difficulty shown grayed-out in options menu… incredibly minor)

Misc
roll credits
show lightning effect (no server-side presence)

11 Likes

I opened an issue for that before: http://issues.spongepowered.org/youtrack/issue/SPONGE-54

Actually, almost any packet that can be sent to the client can be sent manually as an Action…

  • send a block change (also sign text change)
  • send a game sound
  • send entity (particles, mobs, …)
  • send inventory changes
  • send name tag changes
  • change world time per player
  • anything else?

Maybe we can name it Context?

Things like entity spawning, inventory, nametag, and world time while certainly good fits for the API aren’t good fits for what I’m describing because generally the server wants to know things about them, or they aren’t really good to send to many players.