本文整理汇总了Java中org.bukkit.util.ChatPaginator.wordWrap方法的典型用法代码示例。如果您正苦于以下问题:Java ChatPaginator.wordWrap方法的具体用法?Java ChatPaginator.wordWrap怎么用?Java ChatPaginator.wordWrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.ChatPaginator
的用法示例。
在下文中一共展示了ChatPaginator.wordWrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWordWrap1
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap1() {
String rawString = ChatColor.RED + "123456789 123456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.RED + "123456789 123456789"));
assertThat(lines[1], is(ChatColor.RED.toString() + "123456789"));
}
示例2: testWordWrap2
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap2() {
String rawString = "123456789 123456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 22);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789 123456789"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
示例3: testWordWrap3
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap3() {
String rawString = ChatColor.RED + "123456789 " + ChatColor.RED + ChatColor.RED + "123456789 " + ChatColor.RED + "123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 16);
assertThat(lines.length, is(3));
assertThat(lines[0], is(ChatColor.RED + "123456789"));
assertThat(lines[1], is(ChatColor.RED.toString() + ChatColor.RED + "123456789"));
assertThat(lines[2], is(ChatColor.RED + "123456789"));
}
示例4: testWordWrap4
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap4() {
String rawString = "123456789 123456789 123456789 12345";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789 123456789"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789 12345"));
}
示例5: testWordWrap5
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap5() {
String rawString = "123456789\n123456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789 123456789"));
}
示例6: testWordWrap6
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap6() {
String rawString = "12345678 23456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "12345678 23456789"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
示例7: testWordWrap7
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap7() {
String rawString = "12345678 23456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "12345678 23456789"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
示例8: testWordWrap8
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap8() {
String rawString = "123456789 123456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 6);
assertThat(lines.length, is(6));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "789"));
assertThat(lines[2], is(ChatColor.WHITE.toString() + "123456"));
assertThat(lines[3], is(ChatColor.WHITE.toString() + "789"));
assertThat(lines[4], is(ChatColor.WHITE.toString() + "123456"));
assertThat(lines[5], is(ChatColor.WHITE.toString() + "789"));
}
示例9: testWordWrap9
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap9() {
String rawString = "1234 123456789 123456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 6);
assertThat(lines.length, is(7));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "1234"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456"));
assertThat(lines[2], is(ChatColor.WHITE.toString() + "789"));
assertThat(lines[3], is(ChatColor.WHITE.toString() + "123456"));
assertThat(lines[4], is(ChatColor.WHITE.toString() + "789"));
assertThat(lines[5], is(ChatColor.WHITE.toString() + "123456"));
assertThat(lines[6], is(ChatColor.WHITE.toString() + "789"));
}
示例10: testWordWrap10
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap10() {
String rawString = "123456789\n123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789"));
assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
示例11: testWordWrap11
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Test
public void testWordWrap11() {
String rawString = ChatColor.RED + "a a a " + ChatColor.BLUE + "a a";
String[] lines = ChatPaginator.wordWrap(rawString, 9);
assertThat(lines.length, is(1));
assertThat(lines[0], is(ChatColor.RED + "a a a " + ChatColor.BLUE + "a a"));
}
示例12: addMessage
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
public void addMessage(String message) {
//-1 because of the added space after a line break
String[] linesToAdd = ChatPaginator.wordWrap(message, ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - 2 - 1);
int oversize = chatHistory.size() + linesToAdd.length - QUEUE_SIZE;
for (int i = 1; i <= oversize; i++) {
//remove the oldest element
chatHistory.remove(0);
}
chatHistory.add(linesToAdd[0]);
for (int i = 1; i < linesToAdd.length; i++) {
String messagePart = ' ' + linesToAdd[i];
chatHistory.add(messagePart);
}
}
示例13: getSignLabel
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
/**
* Get the label text for the block's label sign. The default behaviour
* is simply to put the block's item name on the first line of the sign;
* override this in subclasses if you want a customised sign label.
*
* @param face the face to which the sign is attached
* @return a 4-line string array of sign label text
*/
protected String[] getSignLabel(BlockFace face) {
String[] lines = ChatPaginator.wordWrap(makeItemLabel(face), 13);
String[] res = new String[4];
for (int i = 0; i < 4; i++) {
res[i] = i < lines.length ? lines[i] : "";
}
return res;
}
示例14: cmdWarp
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
private boolean cmdWarp(final CommandSender sender, String[] args) {
if (args.length == 0) {
// Lists available warps
this.plugin.sendMessage(sender, MessageId.world_availableWarps);
final StringBuilder builder = new StringBuilder();
for (final Warp warp : this.plugin.getWarps()) {
if (warp.isEnabled()) {
final boolean hasPermission = Perms.has(sender, warp.getRequiredPermission()) || Perms.hasWarpAll(sender);
if (hasPermission) {
if (warp.isHidden()) {
builder.append(ChatColor.GRAY + ", " + ChatColor.DARK_GREEN + warp.getName());
} else {
builder.append(ChatColor.GRAY + ", " + ChatColor.GREEN + warp.getName());
}
} else if (!warp.isHidden()) {
builder.append(ChatColor.GRAY + ", " + ChatColor.RED + warp.getName());
}
}
}
if (builder.length() == 0) {
sender.sendMessage(ChatColor.RED + "No warps");
} else {
final String warps = builder.toString().substring((ChatColor.GRAY + ", ").length());
final String[] messages = ChatPaginator.wordWrap(warps, ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH);
for (final String message : messages) {
sender.sendMessage(message);
}
}
return true;
} else if (args.length == 1) {
// Warp to warp location
return this.subCmdWarp(sender, args[0]);
} else { // Handle subcommands
final String subCmd = args[0].toLowerCase();
args = Arrays.copyOfRange(args, 1, args.length);
switch (subCmd) {
case "hidden":
case "sethidden":
return this.subCmdWarpSetHidden(sender, args);
case "perm":
case "setperm":
return this.subCmdWarpSetPerm(sender, args);
default:
return false;
}
}
}
示例15: sendMsg
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
/**
* Plugin method to easily send messages to players (and console too). This
* is the core of all the sender methods included here.
*
* @param sender The CommandSender to send the message to.
* @param msg The message to be sent.
* @param pagination Whether to paginate the message or not.
*
* @since 1.5
*/
public static void sendMsg(CommandSender sender, String msg, boolean pagination) {
String message = translateAlternateColorCodes('&', msg);
if (message.length() > ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH && pagination) {
String[] multiline = ChatPaginator.wordWrap(message, ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH);
sender.sendMessage(multiline);
} else {
sender.sendMessage(message);
}
}