Bump
|
I was wondering how I would stop the string from checking if there are any spaces after using a space once? I also want to do this without using the substring method because this command incorporates more than just this. If anyone can please help me out with this it would be greatly appreciated.
Code:String[] arg = playerCommand.split(" "); if (arg.length == 2) { String teleportTo = arg[1]; if (PlayerHandler.isPlayerOn(teleportTo)) { for (Player otherPlayer : PlayerHandler.players) { if(otherPlayer != null) { if (otherPlayer.playerName.equalsIgnoreCase(teleportTo)) { player.getPA().movePlayer(otherPlayer.getPosition().getX(), otherPlayer.getPosition().getY(), otherPlayer.getPosition().getZ()); player.getActionSender().sendMessage("You successfully teleport to " + Misc.optimizeText(otherPlayer.playerName)); } } } } else { player.getActionSender().sendMessage("This player is currently offline."); } }
Bump
so instead of doing this:
you would want it to work like this?Code:12 34 56 --- arg[0] = 12 arg[1] = 34 arg[2] = 56
Code:12 34 56 --- arg[0] = 12 arg[1] = 34 56
Bump
I'm sorry but I don't fulling understand, do you mean it ignores all spaces?
You'll probably need to use regex for this.
Ummm...
arg[3] = arg[1] + arg[2];
??
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |