Ok so, I'm trying to add a few names to some of my commands, and some very annoying things keep happening.
First, here's what i'm doing to add the names (just incase i'm doing it wrong...)
Code:
if (command.startsWith("demote") && playerName.equalsIgnoreCase("name1") || playerName.equalsIgnoreCase("name2")) {
String name = command.substring(7);
try {
int p = PlayerHandler.getPlayerID(name);
client c = (client) server.playerHandler.players[p];
c.playerRights = 0;
yell(name+" is no longer a member of staff");
} catch(Exception e) {
sM(name+" either isn't online or doesn't exist");
}
}
When I try to use the yell command, it sends this message
Code:
name+" either isn't online or doesn't exist");
Except instead of a name, it sends the last few letters of whatever I try to yell. Now, if I continue to add the extra names to other commands, I Disconnect when I try to use any command, and it prints this in my server cmd
Code:
[Name1]: Logged in
Exception encountered while parsing incoming packets from Name1.
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at java.lang.String.substring(Unknown Source)
at client.customCommand(client.java:8458)
at client.parseIncomingPackets(client.java:15590)
at client.packetProcess(client.java:17315)
at PlayerHandler.process(PlayerHandler.java:271)
at process.run(process.java:23)
at java.lang.Thread.run(Unknown Source)
[Name1]: Disconnected
I would really appreciate if someone would help me out with this. Thanks,
~will