I have a question regarding
I want to output following: When the Player types Hello, the output should be oHell. When the Player types Hello World, the output should be oHello dWorl.
public class ConnectionListener implements Listener {
ArrayList<String> newArrOfStr = new ArrayList<String>();
@EventHandler
public void onMessageSent(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String output = event.getMessage();
event.setCancelled(true);
StringBuffer sb = new StringBuffer(output);
sb.deleteCharAt(sb.length()-1);
String[] arrOfStr = output.split(" ");
int i = 0;
for (String a : arrOfStr)
newArrOfStr.add(a);
player.sendMessage(newArrOfStr(beginning - end));
newArrOfStr.clear();
Hello >> oHell
Hello World >> oHell dWorl
A BC AAR >> A CB RAA
I just dont understand how to output an Array to a nondefined ending, beacause the Player could send multiple arguments and not only 1, 2 or 3.
The "beginning -end" is the space I mean. I have the complete Array under the tag "newArrOfStr" and now would like to output the single words with a Space inbetween. It is supposed to be one sentence and should not be output like this:
A BC RAA