CommandUtils - Command alias, delay, and other handy stuff

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.

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)
  }
}

This is awesome!

Thanks you so much!

1 Like

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

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.

A new version has been released for CommandUtils, it is available for download here.


Changes:

  • Added HasChanceCommand.
  • Deprecated the CommandUtilsService for adding commands to the ‘whenOnline’ module, use the ‘/cu execute whenOnline’ command instead.

A new version has been released for CommandUtils, it is available for download here.


Changes:

  • Added “has in inventory” condition
  • Added “has given from inventory” condition

Hi, I’m a sponge user in Chinese and I love your plugin soooo much! Can I share your plugin(CommandUtils) in MCBBS which is the biggest Chinese minecraft forum? I will surely state clearly the orginal author and repspect your copyright!

Furthermore, I will translate your wiki into Chinese and make a simple tutorial.

You can do that. Please post the link to MCBBS in here aswell.