every time i go to write a plugin I give up because of the commands.
let's say someone uses mino's mail plugin and just types "/mail" my plugin gives a bunch of red text (yes it is mine that is giving it)
I may be stupid but how do I make it so my plugin won't Trigger when somneone is using anothetr command?
-
- English
- King Nothing
- Thread is marked as Resolved.
-
-
Could you post the red text? or the log file which will contain it and would make reading it a lot easier for me?
In general if you follow the command plugin example from red51 your plugins will not have any problems colliding with other plugins (that is unless both plugins use the exact same command).
Java -
java.lang.ArrayIndexOutOfBoundsException: 1
at ServerApp.onCommand(ServerApp.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at pluginapi.PluginEventHandler.triggerEvent(SourceFile:190)
at aT.c.a(SourceFile:231)
at aT.c.messageReceived(SourceFile:181)
at k.e.a(SourceFile:109)
at k.c.run(SourceFile:65)it only does that when i issue a bad command.
-
well can I see either the error or the code snippet which causes the error or better both? Without more information I can't possibly guess where the issue might be
-
it only does that when i issuse a bad command,
-
Code
-
can you please highlight line number 56 for me to see which array is trying to access an incorrect index?
-
(56, now 54) else if(cmd[1].equals("/adminmessage")){ < i didn't give the WHOLE code, but that is what is giving me errors,
Codedo i need a "blank" command so it won't complain?
-
the second one should be an "else if(cmd[0].equals("/adminmessage")){" with a 0 again not a 1
-
.equalsIgnoreCase()
People should use that more often ☺
-
thanks That [0] helped, I don' know why Red's has [1] and ill use ignorecase that should help, too.
-
when using a command /thiscommand it always starts with 0 you only use 1 or 2 or 3 when the command is split into more than one Lets say words
like /this command = (cmd[0] = this) and (cmd[1] = command)
or /this command is sweet = (cmd[0] = this) and (cmd[1] = command) and (cmd[2] = is) and (cmd[3] = sweet)so you can do things like
if cmd[0] = this and cmd[1] = command and cmd[3] = sweet then do this
-
Thank you. that cleared up the confusion. guess i didn';t know about combining commands. No more red errors, it feels like i kinda know what I'm doing now, LOL.. with your help from last time and I'm looking up how to do some stuff for the most part, the plugin is coming along.
might just make the quotes a separate plugin and upload it after its done, -
Thank you. that cleared up the confusion. guess i didn';t know about combining commands. No more red errors, it feels like i kinda know what I'm doing now, LOL.. with your help from last time and I'm looking up how to do some stuff for the most part, the plugin is coming along.
might just make the quotes a separate plugin and upload it after its done,sweet, yeah sometimes when someone tells you whats wrong with your code it does not help you learn why it did not work in the first place, all its done is fix the error but you learnt nothing and your just left confused because you had seen red51 use cmd[1], so that's why i did my reply, so you can learn and get better at coding, and now when you look back at reds code your see he was in fact right to use cmd[1] lol
Anyway good luck with your plugin, and now with your new knowledge your be able to open up a whole lot of new ideas with lots more problems to solve lol Coding why do we do it oO
-
Coding why do we do it oO
Never a truer word spoken!
-
Coding why do we do it oO
Never a truer word spoken!
-
@yahgiggle as a matter of fact I just checked red's code snippet and he actually has a mistake, that 1 should be a 0 in his code too.
See thread: Create a Plugin
in the last example after "Here is a more complex Plugin-class which listens for the PlayerCommandEvent (when a player enters a command) as well as the PlayerChatEvent (when a player writes a chat message):"
this line (No. 48): else if(cmd[1].equals("/adminmessage")){
should be: else if(cmd[0].equals("/adminmessage")){
I am sure he wrote that in a hurry without really testing it thus the error
-
@yahgiggle as a matter of fact I just checked red's code snippet and he actually has a mistake, that 1 should be a 0 in his code too.
Oh, that's true Sorry for the confusion, I've updated the post, thanks @Minotorious and @Captian_Cornball for pointing that out
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!