CommandUtils - Command alias, delay, and other handy stuff


#21

Hey,

I’m wondering if it’s possible to run a command for every player on join.
That would make it possible to provide items or other things.


#22

This is possible with KtSkript, use the following script:

onPlayerJoin {
  Server.console.executeCommand("give ${player.name} minecraft:cookie 3")
}

Or use this more sophisticated approach from here:

onPlayerJoin {
  val commands = listOf(
    "nucleus:warp ${player.name} main-spawn",
    "give ${player.name} minecraft:cookie 3"
  )

  commands.forEach { command ->
    Server.console.executeCommand(command)
  }
}

#23

This is awesome!

Thanks you so much!


#24

Is there a way to check if the player has a certain number of multiple items and execute a command that takes them away in exchange for an item?

An example would be to cost 1 iron ore and 2 coal for an iron ingot


#25

No, CommandUtils can’t count and/or save anything itself for later use, nor can it check for items in the whole inventory.

But you could do some stuff with scoreboards to increment some virtual “account/scoreboard value” which holds the amount of your coal/iron ore. I am not a scoreboard expert really. There might be other ways by using other mechanisms somehow.

Or you could try something with KtSkript. There are no easy helpers to access the inventory in a simpler way in KtSkript yet. You would have to use the bare SpongeAPI (which isn’t bad at all). It only requires some knowledge of programming.

Let me know what you will attempt and I can help you further.