Skip to content

Conversation

@DarkEyeDragon
Copy link

Adds command selector handling to BukkitCommandContexts#getOnlinePlayer However i'm not sure how to deal with @A or selectors that return more than one entity. So in this draft i just return the first entry. However this isn't an optimal solution, and also currently fails if there are no players

//Check if mc version is higher than 1.13.1 (added in 1.13.2)
if ((manager.mcMinorVersion > 13) || (manager.mcMinorVersion == 13 && manager.mcPatchVersion > 1)) {
try {
Entity entity = Bukkit.selectEntities(issuer.getIssuer(), lookup).get(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than blind look up 0 relying on errors, iterate and return on first player match instead, and lack of finding should fall through to the lines below.

And we can only run this selectEntities if the input starts with @

Player player = ACFBukkitUtil.findPlayerSmart(issuer, lookup);
//noinspection Duplicates
if (player == null) {
if (issuer.getManager() instanceof BukkitCommandManager) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already a bukkit context, this isn't really needed.

this.manager should already exists.

Copy link
Author

@DarkEyeDragon DarkEyeDragon Oct 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.manager returns a CommandManager which does not have the version fields, however, i should probably be able to cast that safely right?

Iterate over the entitylist properly now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants