本文整理汇总了Java中org.bukkit.util.ChatPaginator.paginate方法的典型用法代码示例。如果您正苦于以下问题:Java ChatPaginator.paginate方法的具体用法?Java ChatPaginator.paginate怎么用?Java ChatPaginator.paginate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.ChatPaginator
的用法示例。
在下文中一共展示了ChatPaginator.paginate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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"));
}
示例2: 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"));
}
示例3: 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"));
}
示例4: getPage
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
/**
* Gets the page.
*
* @param pageNumber the page number
* @throws FactoidCommandException the factoid command exception
*/
public void getPage(int pageNumber) throws FactoidCommandException {
// Create page with Bukkit paginator
ChatPaginator.ChatPage page = ChatPaginator.paginate(text, pageNumber, pageWidth, pageHeight);
totalPages = page.getTotalPages();
// If the requested page is more than the last age
if (pageNumber > totalPages) {
throw new FactoidCommandException("Page error", sender, "COMMAND.PAGE.INVALID");
}
// Check if there is a parameter
if (param != null) {
sender.sendMessage(ChatColor.GRAY + Factoid.getThisPlugin().iLanguage().getMessage(header,
ChatColor.GREEN + param + ChatColor.GRAY));
} else {
sender.sendMessage(ChatColor.GRAY + Factoid.getThisPlugin().iLanguage().getMessage(header));
}
// Send lines to sender
sender.sendMessage(page.getLines());
// If there is one or multiple page, put the number of page at the bottom
if (totalPages > 1) {
sender.sendMessage(ChatColor.GRAY + Factoid.getThisPlugin().iLanguage().getMessage("COMMAND.PAGE.MULTIPAGE",
"" + pageNumber, "" + totalPages));
Factoid.getThisPlugin().iPlayerConf().get(sender).setChatPage(this);
} else {
sender.sendMessage(ChatColor.GRAY + Factoid.getThisPlugin().iLanguage().getMessage("COMMAND.PAGE.ONEPAGE"));
Factoid.getThisPlugin().iPlayerConf().get(sender).setChatPage(null);
}
}
示例5: unresolved
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
public boolean unresolved(CommandSender sender, String[] args) {
int myPage = 1;
if (args.length == CMD_ARGS) {
try {
myPage = Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
return false;
}
} else if (args.length > CMD_ARGS) {
return false;
}
String userReports = "unresolved reports:\n";
BasicDBObject query = new BasicDBObject();
query.put("status","unresolved");
DBCursor cursor = table.find(query);
while (cursor.hasNext()) {
DBObject element = cursor.next();
//TODO should probably use a stringbuilder? depends if you believe in them
userReports += "ID: " + element.get("bugID") + " | user: " + element.get("user") + " | issue: " + element.get("issue") + " | date: " + element.get("createdDate") + "\n";
}
ChatPage page = ChatPaginator.paginate(userReports,myPage);
for (String line : page.getLines()) {
sender.sendMessage(line);
}
return true;
}
示例6: thelp
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
public boolean thelp(CommandSender sender, String[] args) {
int myPage;
if (args.length < 2) myPage = 1;
else {
try {
myPage = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
myPage = 1;
}
}
String message;
message = "/kit for a starter kit of gear\n" +
"/spawn to teleport to the spawn point, or to your tribe's 'spawn' teleport\n" +
"/ttp help for help with ttp and teleporting\n" +
"/t create [tribe] can be used to create a tribe\n" +
"/t destroy [yourtribe] can be used to dissolve your tribe\n" +
"/t invite [player] to invite them to your tribe\n" +
"/t uninvite [player] to remove them from your invitese\n" +
"/t join [tribe] to join a tribe you have been invited to\n" +
"/t kick [player] to kick someone from your tribe\n" +
"/t leave to leave your tribe (you cannot be the leader)\n" +
"/t giveLeader [player] to transfer your leadership to another player\n" +
"/t show [tribe] show information about a tribe\n" +
"/t show [player] show what tribe a player belongs to\n" +
"/t help shows this help information";
ChatPage page = ChatPaginator.paginate(message,myPage);
sender.sendMessage("Tribes help (page " + page.getPageNumber() + " of " + page.getTotalPages() + "): ");
for (String line : page.getLines()) {
sender.sendMessage(line);
}
return true;
}
示例7: execute
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
String command;
int pageNumber;
int pageHeight;
int pageWidth;
if (args.length == 0) {
command = "";
pageNumber = 1;
} else if (NumberUtils.isDigits(args[args.length - 1])) {
command = StringUtils.join(ArrayUtils.subarray(args, 0, args.length - 1), " ");
try {
pageNumber = NumberUtils.createInteger(args[args.length - 1]);
} catch (NumberFormatException exception) {
pageNumber = 1;
}
if (pageNumber <= 0) {
pageNumber = 1;
}
} else {
command = StringUtils.join(args, " ");
pageNumber = 1;
}
if (sender instanceof ConsoleCommandSender) {
pageHeight = ChatPaginator.UNBOUNDED_PAGE_HEIGHT;
pageWidth = ChatPaginator.UNBOUNDED_PAGE_WIDTH;
} else {
pageHeight = ChatPaginator.CLOSED_CHAT_PAGE_HEIGHT - 1;
pageWidth = ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH;
}
HelpMap helpMap = Bukkit.getServer().getHelpMap();
HelpTopic topic = helpMap.getHelpTopic(command);
if (topic == null) {
topic = helpMap.getHelpTopic("/" + command);
}
if (topic == null) {
topic = findPossibleMatches(command);
}
if (topic == null || !topic.canSee(sender)) {
sender.sendMessage(ChatColor.RED + "No help for " + command);
return true;
}
ChatPaginator.ChatPage page = ChatPaginator.paginate(topic.getFullText(sender), pageNumber, pageWidth, pageHeight);
StringBuilder header = new StringBuilder();
header.append(ChatColor.YELLOW);
header.append("--------- ");
header.append(ChatColor.WHITE);
header.append("Help: ");
header.append(topic.getName());
header.append(" ");
if (page.getTotalPages() > 1) {
header.append("(");
header.append(page.getPageNumber());
header.append("/");
header.append(page.getTotalPages());
header.append(") ");
}
header.append(ChatColor.YELLOW);
for (int i = header.length(); i < ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH; i++) {
header.append("-");
}
sender.sendMessage(header.toString());
sender.sendMessage(page.getLines());
return true;
}
示例8: execute
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, ArrayList<String> args) {
if (!sender.hasPermission("bw." + this.getPermission())) {
return false;
}
String paginate;
int page = 1;
ArrayList<Game> showedGames = new ArrayList<Game>();
if (args != null) {
if (args.size() == 0 || args.size() > 1) {
paginate = "1";
} else {
paginate = args.get(0);
if (paginate.isEmpty()) {
paginate = "1";
}
if (!Utils.isNumber(paginate)) {
paginate = "1";
}
}
} else {
paginate = "1";
}
page = Integer.parseInt(paginate);
StringBuilder sb = new StringBuilder();
sender.sendMessage(ChatColor.GREEN + "---------- Bedwars Games ----------");
List<Game> games = BedwarsRel.getInstance().getGameManager().getGames();
for (Game game : games) {
GameCheckCode code = game.checkGame();
if (code != GameCheckCode.OK && !sender.hasPermission("bw.setup")) {
continue;
}
showedGames.add(game);
int players = 0;
if (game.getState() == GameState.RUNNING) {
players = game.getCurrentPlayerAmount();
} else {
players = game.getPlayers().size();
}
sb.append(ChatColor.YELLOW
+ ((code != GameCheckCode.OK) ? ChatColor.RED + game.getName() + ChatColor.YELLOW
: game.getName())
+ " - " + game.getRegion().getName() + " - "
+ BedwarsRel._l(sender, "sign.gamestate." + game.getState().toString().toLowerCase())
+ ChatColor.YELLOW
+ " - " + BedwarsRel._l(sender, "sign.players") + ": " + ChatColor.WHITE + "["
+ ChatColor.YELLOW
+ players + ChatColor.WHITE + "/" + ChatColor.YELLOW + game.getMaxPlayers()
+ ChatColor.WHITE + "]\n");
}
if (showedGames.size() == 0) {
sb.append(ChatColor.RED + BedwarsRel._l(sender, "errors.nogames"));
}
ChatPage chatPage = ChatPaginator.paginate(sb.toString(), page);
for (String line : chatPage.getLines()) {
sender.sendMessage(line);
}
sender.sendMessage(ChatColor.GREEN + "---------- "
+ BedwarsRel._l(sender, "default.pages",
ImmutableMap.of("current", String.valueOf(chatPage.getPageNumber()), "max",
String.valueOf(chatPage.getTotalPages())))
+ " ----------");
return true;
}
示例9: list
import org.bukkit.util.ChatPaginator; //导入方法依赖的package包/类
public boolean list(CommandSender sender, String[] args) {
int myPage = 1;
if (args.length == CMD_ARGS) {
try {
myPage = Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
return false;
}
} else if (args.length > CMD_ARGS) {
return false;
}
//query all of our user's bug reports
BasicDBObject query = new BasicDBObject();
query.put("user",sender.getName());
DBCursor cursor = table.find(query);
//if there are none to show..
if (cursor.count() == 0) {
sender.sendMessage("there are no reports to show");
return true;
}
//otherwise, list them all together separated by newlines.
String userReports = "";
while (cursor.hasNext()) {
DBObject element = cursor.next();
userReports += "ID: " + element.get("bugID") + " | " + element.get("status") + " | " + element.get("issue") + " | date: " + element.get("createdDate");
if (element.containsField("reason")) {
userReports += " | reason: " + element.get("reason");
}
userReports += "\n";
}
//divy the report into pages and get the desired page
ChatPage page = ChatPaginator.paginate(userReports,myPage);
//send each line of our page to the user
sender.sendMessage("Page " + page.getPageNumber() + " of " + page.getTotalPages() + " for reports:");
for (String line : page.getLines()) {
sender.sendMessage(line);
}
return true;
}