本文整理汇总了Java中org.bukkit.util.ChatPaginator类的典型用法代码示例。如果您正苦于以下问题:Java ChatPaginator类的具体用法?Java ChatPaginator怎么用?Java ChatPaginator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChatPaginator类属于org.bukkit.util包,在下文中一共展示了ChatPaginator类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFullText
import org.bukkit.util.ChatPaginator; //导入依赖的package包/类
public String getFullText(CommandSender sender) {
StringBuilder sb = new StringBuilder();
if (preamble != null) {
sb.append(buildPreamble(sender));
sb.append("\n");
}
for (HelpTopic topic : allTopics) {
if (topic.canSee(sender)) {
String lineStr = buildIndexLine(sender, topic).replace("\n", ". ");
if (sender instanceof Player && lineStr.length() > ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH) {
sb.append(lineStr.substring(0, ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - 3));
sb.append("...");
} else {
sb.append(lineStr);
}
sb.append("\n");
}
}
return sb.toString();
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:23,代码来源:IndexHelpTopic.java
示例2: appendCenteredText
import org.bukkit.util.ChatPaginator; //导入依赖的package包/类
public ImageMessage appendCenteredText(String... text) {
for (int y = 0; y < lines.length; y++) {
if (text.length > y) {
int len = ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH - lines[y].length();
lines[y] = lines[y] + center(text[y], len);
} else {
return this;
}
}
return this;
}
开发者ID:crazyhorse961,项目名称:NationZ,代码行数:12,代码来源:ImageMessage.java
示例3: onCommand
import org.bukkit.util.ChatPaginator; //导入依赖的package包/类
@Override
public final boolean onCommand(final CommandSender sender, final Command command, final String label, String[] args) {
if(!sender.hasPermission("owngarden.command")) {
OwnGarden.log(ChatColor.RED, "You do not have the permission to execute this command.", sender);
return true;
}
final PluginDescriptionFile description = Bukkit.getPluginManager().getPlugin("OwnGarden").getDescription();
sender.sendMessage(ChatColor.GREEN + description.getName() + " v" + description.getVersion() + ChatColor.GOLD + " by " + Joiner.on(' ').join(description.getAuthors()));
final StringBuilder builder = new StringBuilder();
for(int i = 0; i != ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - 2; i++) {
builder.append("=");
}
final String line = builder.toString();
sender.sendMessage(ChatColor.RESET + line);
sender.sendMessage(ChatColor.GOLD + "SCHEMATICS : ");
sender.sendMessage(ChatColor.RESET + "" + ChatColor.BOLD + "- Oak : " + ChatColor.RESET + Joiner.on(' ').join(OwnGarden.config.saplingOakSchematics));
sender.sendMessage(ChatColor.BOLD + "- Spruce : " + ChatColor.RESET + Joiner.on(' ').join(OwnGarden.config.saplingSpruceSchematics));
sender.sendMessage(ChatColor.BOLD + "- Jungle : " + ChatColor.RESET + Joiner.on(' ').join(OwnGarden.config.saplingJungleSchematics));
sender.sendMessage(ChatColor.BOLD + "- Acacia : " + ChatColor.RESET + Joiner.on(' ').join(OwnGarden.config.saplingAcaciaSchematics));
sender.sendMessage(ChatColor.BOLD + "- Dark Oak : " + ChatColor.RESET + Joiner.on(' ').join(OwnGarden.config.saplingDarkOakSchematics));
sender.sendMessage(line);
sender.sendMessage(ChatColor.GOLD + "PERMISSIONS : ");
for(final Permission permission : description.getPermissions()) {
sender.sendMessage(sender.hasPermission(permission) ?
(ChatColor.GREEN + "- You have the permission " + ChatColor.BOLD + permission.getName() + ChatColor.RESET + ChatColor.GREEN + ".") :
(ChatColor.RED + "- You do not have the permission " + ChatColor.BOLD + permission.getName() + ChatColor.RESET + ChatColor.RED + ".")
);
}
sender.sendMessage(ChatColor.RESET + line);
sender.sendMessage(ChatColor.AQUA + "" + ChatColor.ITALIC + "The above list is scrollable.");
return true;
}
开发者ID:Skyost,项目名称:OwnGarden,代码行数:40,代码来源:OwnGardenCommand.java
示例4: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例5: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例6: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:11,代码来源:ChatPaginatorTest.java
示例7: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例8: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例9: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例10: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例11: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:14,代码来源:ChatPaginatorTest.java
示例12: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:15,代码来源:ChatPaginatorTest.java
示例13: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:10,代码来源:ChatPaginatorTest.java
示例14: 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"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:9,代码来源:ChatPaginatorTest.java
示例15: testPaginate1
import org.bukkit.util.ChatPaginator; //导入依赖的package包/类
@Test
public void testPaginate1() {
String rawString = "1234 123456789 123456789 123456789";
ChatPaginator.ChatPage page = ChatPaginator.paginate(rawString, 1, 6, 2);
assertThat(page.getPageNumber(), is(1));
assertThat(page.getTotalPages(), is(4));
assertThat(page.getLines().length, is(2));
assertThat(page.getLines()[0], is(ChatColor.WHITE.toString() + "1234"));
assertThat(page.getLines()[1], is(ChatColor.WHITE.toString() + "123456"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:12,代码来源:ChatPaginatorTest.java
示例16: testPaginate2
import org.bukkit.util.ChatPaginator; //导入依赖的package包/类
@Test
public void testPaginate2() {
String rawString = "1234 123456789 123456789 123456789";
ChatPaginator.ChatPage page = ChatPaginator.paginate(rawString, 2, 6, 2);
assertThat(page.getPageNumber(), is(2));
assertThat(page.getTotalPages(), is(4));
assertThat(page.getLines().length, is(2));
assertThat(page.getLines()[0], is(ChatColor.WHITE.toString() + "789"));
assertThat(page.getLines()[1], is(ChatColor.WHITE.toString() + "123456"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:12,代码来源:ChatPaginatorTest.java
示例17: testPaginate3
import org.bukkit.util.ChatPaginator; //导入依赖的package包/类
@Test
public void testPaginate3() {
String rawString = "1234 123456789 123456789 123456789";
ChatPaginator.ChatPage page = ChatPaginator.paginate(rawString, 4, 6, 2);
assertThat(page.getPageNumber(), is(4));
assertThat(page.getTotalPages(), is(4));
assertThat(page.getLines().length, is(1));
assertThat(page.getLines()[0], is(ChatColor.WHITE.toString() + "789"));
}
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:11,代码来源:ChatPaginatorTest.java
示例18: 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);
}
}
开发者ID:games647,项目名称:TabChannels,代码行数:16,代码来源:Channel.java
注:本文中的org.bukkit.util.ChatPaginator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论