@Command
@Syntax("@dispose")
@Description("Fixes you if you are stuck.")
@Alias({"fix", "unbug"})
@Tags({"tutorial"})
public void dispose() {
NPCScriptManager.getInstance().dispose(Client);
Client.announce(MaplePacketCreator.enableActions());
Chr.message("Fixed.");
}
@Command(false)
@Description("Not used.")
public void unused() {
}
Variables inherited from super class. Ex: Chr, Client, Wserv, Cserv, Args
An organized help menu can be generated using the information above the method.
Command alias' don't need another method for each one.
Commands can have tags that can be used to filter what commands can be used when. Example above uses the tag "tutorial". This means that this command can be used in the tutorial.
Commands don't need to be commented out to be disabled. Example above sets the value of Command to false. This disables the command making it so it won't execute when called.
Any commands without a syntax reverts to the default label. (Ex. @unused)
Any commands without a description does not get generated into the help.
Somewhat easy to transfer from existing methods.
What do you think?
03-05-12
Liv3
Re: What do you think of commands like this?
Sure... but I don't mind making commands like normal.
03-05-12
sunnyboy
Re: What do you think of commands like this?
Yeah.. I still prefer the old way.
03-05-12
Yaseen
Re: What do you think of commands like this?
...meh. It may be good for people who don't understand a thing of java, but once you learn how to code the commands, that way is kind of...different.
03-05-12
SuPeR SoNiC
Re: What do you think of commands like this?
Actually, I think it's pretty nice. I hate looking at my commands file - it's so messy and looks like a huge wall of code. A format like yours would make it look much cleaner, and code organizing is something which is very important for me. :)
03-05-12
daniel4evar
Re: What do you think of commands like this?
I prefer the old way actually..
03-05-12
mertjuh
Re: What do you think of commands like this?
It will be harder to maintain the commands when you have lots of them.
03-05-12
Liv3
Re: What do you think of commands like this?
Quote:
Originally Posted by SuPeR SoNiC
Actually, I think it's pretty nice. I hate looking at my commands file - it's so messy and looks like a huge wall of code. A format like yours would make it look much cleaner, and code organizing is something which is very important for me. :)
Using AuraSEA's way was pretty nice. A class(within another, which is called a sub-class) for each command.
I still prefer the normal way.
04-05-12
SuPeR SoNiC
Quote:
Originally Posted by mertjuh
It will be harder to maintain the commands when you have lots of them.
That's true. There might be a way to make this more useful with some rework, though.
Sent from my E15i using Tapatalk 2
04-05-12
aaronweiss
Re: What do you think of commands like this?
I've been working on a way that I like quite a bit.
Looks something like this:
PHP Code:
public class AdminCommands extends Commands { public static boolean execute(MapleClient c, String[] sub, char heading) { MapleCharacter chr = c.getPlayer(); Channel cserv = c.getChannelServer(); MapleCharacter victim; // For commands with targets. ResultSet rs; // For commands with MySQL results.
The idea is you use enumerations and switch statements to produce clean, legible commands without having to deal with the massive if-else statement that is most command systems. It doesn't have anything for a help message, so that has to be manually created, but I like how it works for me so far.
04-05-12
F4keName
Re: What do you think of commands like this?
Quote:
Originally Posted by aaronweiss
I've been working on a way that I like quite a bit.
Looks something like this:
PHP Code:
public class AdminCommands extends Commands { public static boolean execute(MapleClient c, String[] sub, char heading) { MapleCharacter chr = c.getPlayer(); Channel cserv = c.getChannelServer(); MapleCharacter victim; // For commands with targets. ResultSet rs; // For commands with MySQL results.
The idea is you use enumerations and switch statements to produce clean, legible commands without having to deal with the massive if-else statement that is most command systems. It doesn't have anything for a help message, so that has to be manually created, but I like how it works for me so far.
Lol, that's exactly what I wanted to do ever since Java 7, I'm still waiting for Moople 117
First I just wanted to change everything to switch statements with strings, and then I thought about a key and value list, and then enums came into mind.
04-05-12
kevintjuh93
Re: What do you think of commands like this?
Quote:
Originally Posted by F4keName
Lol, that's exactly what I wanted to do ever since Java 7, I'm still waiting for Moople 117
First I just wanted to change everything to switch statements with strings, and then I thought about a key and value list, and then enums came into mind.
Yus, Java 7 supports String switch cases.
05-05-12
Handsfree
Re: What do you think of commands like this?
I like this method mainly because of the automatic command info generation.
It's nice how each command has is own method because netbeans shows you all the commands in a list and you can navigate easily through them. Also it works nicely with the editor because If you need you can collapse any method you don't want to see.
It just makes it easier to find your commands.
I do like the switch though. :)
07-05-12
SuperLol
Re: What do you think of commands like this?
I create an instance of each command and add them into a map. Then when people use a command, it retrieves it from the map. This method is faster than using if statements every time. It uses slightly more memory (command object is small though). Handlers should actually be done this way too (how it is in odin)... it's more industry standard.