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

Add experience point support to ExprTotalExperience #7144

Open
wants to merge 2 commits into
base: dev/feature
Choose a base branch
from

Conversation

erenkarakal
Copy link
Contributor

Description

This PR adds 'experience point' support to the total experience expression and some tests.
The reason I made this PR is for the "on level progress change:" event. It did not let you get how much experience was changed as a number.

on level progress change:
  set {_xp} to event-experience     <--- what can you even do with this besides giving it to a player

Target Minecraft Versions: any
Requirements: none
Related Issues: none

@erenkarakal erenkarakal added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Oct 13, 2024
Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

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

and test could include reset or delete

}

@Override
@Nullable
public Integer convert(Entity entity) {
public Integer convert(Object object) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public Integer convert(Object object) {
public @Nullable Integer convert(Object object) {


// invalid entity type
// invalid type
return null;
}

@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
Copy link
Member

@Efnilite Efnilite Oct 13, 2024

Choose a reason for hiding this comment

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

Suggested change
public Class<?>[] acceptChange(ChangeMode mode) {
public Class<?> @Nullable [] acceptChange(ChangeMode mode) {

Copy link
Member

Choose a reason for hiding this comment

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

wrong spot

Copy link
Member

Choose a reason for hiding this comment

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

reviewing on mobile moment

return null;
}
return switch (mode) {
case ADD, REMOVE, SET, DELETE, RESET -> new Class[]{Number.class};
Copy link
Member

Choose a reason for hiding this comment

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

Can't this be Integer?

Comment on lines +66 to +72
if (object instanceof Player player)
return PlayerUtils.getTotalXP(player.getLevel(), player.getExp());

// experience points
if (object instanceof Experience experience) {
return experience.getXP();
}
Copy link
Member

Choose a reason for hiding this comment

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

choose braces or no braces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants