📈 Rank Upper [Universal]

Rank Upper - Promote your players based on requeriments and minecraft statistics.

Promote your players on your server based on requeriments. Actually the requeriments are:

  • Time played;
  • Money Earned;
  • Experience (in Levels);
  • Minecraft Statistics (new);

Read the full description and download form ORE!


Just curious, why do you use the low-level command API instead of CommandSpec? You spend a heck of a lot of lines of code parsing arguments and checking argument amounts, which can be done in like five lines if you use CommandSpec instead. You also don’t implement any of the other methods, which CommandSpec does for you.

I have ported this plugin from bukkit and for now i need this plugin working on my sponge server, but all help with code will be appreciated. :slight_smile:

*Its a private plugin and I don’t releaseto bukkit.

What can i change on my code to use CommandSpec?

It’s a little more than just a quick change. Have a read of the docs.
Copying and pasting huge sections of code and changing everything Bukkit to a Sponge equivalent is a bad way to make a plugin. It completely circumvents the layer of abstraction that Sponge provides, and nullifies the benefits of having it in the first place. I would recommend completely rewriting the plugin to better fit Sponge.

I’ve started having a few problems with this plugin.

First off, the set group commands won’t always register. The console says they do, but users just end up getting deranked to the bottom of the latter. It will eventually get them to the rank they need to be, but they also get the money that comes along with the group. Maybe adding a delay between the commands being entered would work?

Also, if the playtime or required time is between 1 day and 1 day + 1 hour they won’t display the 1 day. Rather than saying 1 day and x minutes, it just says 0 hours and x minutes.

what about a required group option? Basically I have the ranks Guest, Member, Expert

Guest is the default group
Member is the group they get by joining our website
and Expert is the rank I want them to unlock when they reach 12hours + are a Member

I think there needs to be some sort of Group Requirement option so they HAVE to be in a pre-req group before ranking up.

If understod, this image explains this: http://i.imgur.com/rnrPlFw.png

The origiin group comes first, and the next group is inside configurations and requerimento of the origigin group name.

If i understanded wrong, fix me please.

well my 2nd rank (Member) isn’t given by this plugin; its given by the enjin module when they join my website. (its automatic)
So would I make the default rank for this plugin (Member) and it pick up once they’re in the member?

basically i don’t want this plugin to do anything unless the player is already in the 2nd rank for my server which is member, and then from there it starts.

You can configure your desired rank like this:

Member {
        "pex user {player} parent delete group Member",
        "pex user {player} parent add group Expert"
    message-broadcast="&a>> The player &6{player} &ahas played for &6{time} &aand now is a member Expert on server."

This configuration will give the rank Expert only if the player are in the group Member. if the player is in other any group, will do nothing.

Updated to High-Level commands!

Download: Release

Lol, that’s not exactly what I meant. You’re meant to use CommandSpec to describe the structure of the command. Just defining three strings and making the second two optional isn’t really using this to the full extent. I could write the CommandSpec for this if you want, and trust me it’s much easier to use and it’s extensible.

The javadocs are not exact and dont have many examples. I check if the argumment exists because i didnt understand how work exactly.

But as start, i changed to use high level and i makind another plugin for chat. In this plugin i will aprimore my experiencie with CommandSpec.

Uh, the JavaDocs are pretty clear. The actual explanation, however, resides in SpongeDocs.
To properly use it, make multiple CommandSpecs for each subcommand, then add them as children to the main /ru command. So for instance:

CommandSpec check = CommandSpec.builder()
        .executor(new RUCheckCommand())

CommandSpec cs = CommandSpec.builder()
        .child(check, "check")

By the way, note the permission change. A permission automatically inherits things that look like child permissions, so granting rankupper.check automatically grants rankupper.check.others as well. It is explained in SpongeDocs that you should append .self to permissions for commands that require an extra permission to operate on others.
Each subcommand gets its own CommandExecutor. You can use lambdas to simplify this.

RUCommand commands = new RUCommands();

And you would have a method just like execute() but named check(). This way you can fit multiple ones in one class.
In your command executor for /ru check, you’d get the player like so:

Player player = args.getOne("player").get();

If you’re targeting a User instead of a Player, you can use GenericArguments.userOrSource() (which I wrote! :3) instead of GenericArguments.playerOrSource().
A couple of other things:
You know that CommandResult you created? Take a look at the method name. CommandResult.success()
This indicates success. If the command failed, don’t return a success, throw a CommandException. That’s what they’re for. The argument for the constructor is a Text, this will be shown to the player. You can also put a boolean after the Text, and if it’s true, it’ll show the usage to the player.
Also, for things that show numbers to the player, maybe try returning a more descriptive result.

return CommandResult.builder().queryResult(minutes).build();

This can be used in command blocks and such by mapmakers.

Essentially, the high-level API is about having Sponge do everything for you. Instead of doing a switch statement on a string, make subcommands. Instead of checking UserStorageService, say that you want a User. Instead of returning success at every point, do things relevant to what actually happened.

In fact, you seem to have skimmed over a lot of SpongeDocs. Things such as injection.

@Inject Game game;
@Inject @ConfigDir(sharedRoot = false) File file;
@Inject PluginContainer container;


game.getAssetManager().getAsset(this, "default.conf").get().copyToFile(configFile);

Things like that.
I’d recommend a read of basically all the docs before writing more plugins.


Is this plugin better than [Discontinued] AutoRank [v1.1.1] [API 4.0.3]? Because currently, Autorank continuously and randomly resets my player’s playtime. Sometimes by a few minutes, others by hours, causing them to revert back to the previous ranks.

I think yes, and if not, i am active on community, solving problens and getting some suggestions.

i havent had any issues out of rank upper yet and I’m running one of the latest spongeforge versions with pixelmon. Goodluck mate.

Good to see working fine for you ^^

the commands wont work. Keeps telling unknown command.

And yes, the plugin is installed and shows up on /sponge plugins