[JAVA][BUKKIT] ChatPagniator

Any help topics that don't fit in the current categories can go here.
Post Reply
User avatar
exload
Posts: 9
Joined: Mon Oct 29, 2012 4:32 am
Contact:

[JAVA][BUKKIT] ChatPagniator

Post by exload »

I am trying to make a help menu with pages for my plugin. I found this class in the apidocs. http://jd.bukkit.org/apidocs/org/bukkit/util/ChatPaginator.ChatPage.html
I was curious how it works and if it would save me some time in the future. So, my question, how exactly would this work for creating a paged help menu ? Would it really save time ?
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by jacek »

It looks like it returns a portion of the array for the given page number, so it that should be pretty useful for creating pages :P I've not used it personally but you should be able to using it directly with a CommandSender

[syntax=java]sender.sendMessage(ChatPaginator.ChatPage(helpLines));[/syntax]
you could also look how it's used in the /help command.
Image
User avatar
exload
Posts: 9
Joined: Mon Oct 29, 2012 4:32 am
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by exload »

jacek wrote:It looks like it returns a portion of the array for the given page number, so it that should be pretty useful for creating pages :P I've not used it personally but you should be able to using it directly with a CommandSender

[syntax=java]sender.sendMessage(ChatPaginator.ChatPage(helpLines));[/syntax]
you could also look how it's used in the /help command.

Yes I have looked at that, however, it seems as though it becomes overly complicated for a simple task that I am going for. This is how I set it up currently:
[syntax=java]
String[] lines = new String[msg.size()];
ChatPage page = new ChatPage(msg.toArray(lines), 1, 4);[/syntax]
I am unsure how to send a player a specific page though.

As a side note, I ticked "notify me when reply is posted" and I did not receive any email when you replied to this post, assuming that is the purpose of that checkbox.. :P )
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by jacek »

ChatPage has getLines() which should be all of the lines that are meant to appear on that page. There is also getPageNumber() and getTotalPages() which could be useful for a nice header :)

exload wrote:As a side note, I ticked "notify me when reply is posted" and I did not receive any email when you replied to this post, assuming that is the purpose of that checkbox.. :P )

Urg, spam filters usually.
Image
User avatar
exload
Posts: 9
Joined: Mon Oct 29, 2012 4:32 am
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by exload »

jacek wrote:ChatPage has getLines() which should be all of the lines that are meant to appear on that page. There is also getPageNumber() and getTotalPages() which could be useful for a nice header :)

exload wrote:As a side note, I ticked "notify me when reply is posted" and I did not receive any email when you replied to this post, assuming that is the purpose of that checkbox.. :P )

Urg, spam filters usually.

Oh. I was thinking this class had an entirely different function and ability. My hope was to send it a huge arraylist of messages that I wanted it to display. It would have the amount of lines per page as a parameter. Then once you created an instance of this class you would be able to access methods such as getPage(id), getTotalPages(), and getPageNumber().
Something along those lines.
I have tried creating my own class to do this function but I ran into several issues when sending a page based on permissions a user had.

Also I searched through my spam and could not find any notification from this site.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by jacek »

exload wrote:Oh. I was thinking this class had an entirely different function and ability. My hope was to send it a huge arraylist of messages that I wanted it to display. It would have the amount of lines per page as a parameter. Then once you created an instance of this class you would be able to access methods such as getPage(id), getTotalPages(), and getPageNumber().
Something along those lines.

I think it does that, you get the ChatPage for the page you want then the lines on that page are getLines()

exload wrote:Also I searched through my spam and could not find any notification from this site.

@live.com by any chance ? They are often out right rejected too.
Image
User avatar
exload
Posts: 9
Joined: Mon Oct 29, 2012 4:32 am
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by exload »

jacek wrote:
exload wrote:Oh. I was thinking this class had an entirely different function and ability. My hope was to send it a huge arraylist of messages that I wanted it to display. It would have the amount of lines per page as a parameter. Then once you created an instance of this class you would be able to access methods such as getPage(id), getTotalPages(), and getPageNumber().
Something along those lines.

I think it does that, you get the ChatPage for the page you want then the lines on that page are getLines()

exload wrote:Also I searched through my spam and could not find any notification from this site.

@live.com by any chance ? They are often out right rejected too.

Yes, however, when I send the player the lines in getLines() it sends every line that I have in my ArrayList.

I am still not seeing anything from @live.com.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by jacek »

exload wrote:Yes, however, when I send the player the lines in getLines() it sends every line that I have in my ArrayList.

In that case, it seems pretty useless :s

exload wrote:I am still not seeing anything from @live.com.

I'm not planning on doing anything about it, Microsoft need to be less strict :P
Image
User avatar
exload
Posts: 9
Joined: Mon Oct 29, 2012 4:32 am
Contact:

Re: [JAVA][BUKKIT] ChatPagniator

Post by exload »

jacek wrote:
exload wrote:Yes, however, when I send the player the lines in getLines() it sends every line that I have in my ArrayList.

In that case, it seems pretty useless :s

exload wrote:I am still not seeing anything from @live.com.

I'm not planning on doing anything about it, Microsoft need to be less strict :P

I think I will just continue with making my own class to do this function then :P Thanks for your help! :D
Post Reply