mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 20:23:53 -07:00
Add a tab completion API for chat messages. Adds BUKKIT-2607
This implementation provides access to a (mutable) list and the base message. Also provided is a convenience method for getting the last 'token' in the provided string. By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package org.bukkit.event;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
|
||||
import org.bukkit.plugin.messaging.TestPlayer;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PlayerChatTabCompleteEventTest {
|
||||
|
||||
@Test
|
||||
public void testGetLastToken() {
|
||||
assertThat(getToken("Hello everyone!"), is("everyone!"));
|
||||
assertThat(getToken(" welcome to the show..."), is("show..."));
|
||||
assertThat(getToken("The whitespace is here "), is(""));
|
||||
assertThat(getToken("Too much whitespace is here "), is(""));
|
||||
assertThat(getToken("The_whitespace_is_missing"), is("The_whitespace_is_missing"));
|
||||
assertThat(getToken(""), is(""));
|
||||
assertThat(getToken(" "), is(""));
|
||||
}
|
||||
|
||||
private String getToken(String message) {
|
||||
return new PlayerChatTabCompleteEvent(TestPlayer.getInstance(), message, ImmutableList.<String>of()).getLastToken();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user