Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to get the top ten. #46

Closed
poma123 opened this issue Feb 27, 2019 · 7 comments
Closed

Trying to get the top ten. #46

poma123 opened this issue Feb 27, 2019 · 7 comments

Comments

@poma123
Copy link
Contributor

poma123 commented Feb 27, 2019

Hi.
I'm trying to get the top ten from the Level addon in my plugin. My plan was to list the top 10 islands' owners and levels to the chat, when I run a command. But I can't figure out how should I do that.
I've tried few things:

TopTen topten = ((Level) bentoBox.getAddonsManager().getAddonByName("Level").get()).getTopTen();

java.lang.NoClassDefFoundError: world/bentobox/level/Level

Addon lvl = bentoBox.getAddonsManager().getAddonByName("Level").get();

Method mthd = lvl.getClass().getMethod("getTopTen");

TopTen topten = (TopTen) mthd.invoke(lvl);

java.lang.ClassNotFoundException: world.bentobox.level.TopTen

So the question is; how shall I do this?

Thanks in advance for your reply.

@BONNe
Copy link
Member

BONNe commented Feb 27, 2019

You should use PAPI

Placeholders ;)

@Poslovitch
Copy link
Member

@BONNe Placeholders won't work if he want to get access to the TopTen instance for programmatic use.

For reference, addons classes cannot be accessed by plugins. That's a Java language specification. Either use the AddonRequestHandlers or create an addon.

@poma123
Copy link
Contributor Author

poma123 commented Feb 27, 2019

Thanks for the reply!
So if I would like to do this with AddonRequestHandlers, I have to loop all the island levels and sort the list?
Because as I saw there are only an island-level handler in the Level addon.

@Poslovitch
Copy link
Member

@tastybento will probably help you better than I can.

tastybento pushed a commit that referenced this issue Feb 27, 2019
Add new data Request Handler for Level add-on, which requires world-name in input and returns:
- empty map, if input is invalid
- LinkedHashMap from TopTenData object for given world.
@tastybento
Copy link
Member

Thanks @BONNe I think your PR should enable this.

@BONNe
Copy link
Member

BONNe commented Feb 28, 2019

So, to get Top 10 players you should use Addon Request Handler.
BentoBoxWorld/BentoBox#400

As input you should add world-name and in output you will get Map that contains UUID and Long (player and its island level)

@poma123
Copy link
Contributor Author

poma123 commented Feb 28, 2019

Now working, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants