Skip to content

Conversation

@tastybento
Copy link
Member

@tastybento tastybento commented Feb 7, 2025

This PR introduces improvements related to challenge tracking and completion logic, adding the ability to set up Island Range challenges that will complete based on block groups, e.g., 20 of any coral, entity groups, e.g., all undead, or challenges that have multiple statistics, e.g., kill 10 skeletons and kill 10 creepers.

Key Updates

Other Updates

  • The English text was reviewed and adjusted and formatted.
  • Icons for entities and statistics were added.

Statistic Challenges

More than one statistic can be required to complete a challenge. If more than one is set, all statistics have to be met in order for the challenge to be completed.

Block Groups and Entity Groups

For Island Challenges, these can be used. This allows challenges to be less specific and more general.

Reduce code duplication by abstracting classes
This enables things like a challenge to kill 10 creepers, 10 zombies,
and 10 skeletons.
Enable challenges to have multiple statistic requirements
public StatisticRequirements()
{
// Empty constructor
public record StatisticRec(@Expose Statistic statistic, @Expose EntityType entity, @Expose Material material,
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a new record that contains all the data for a Statistic challenge.

// Section: Getters and setters
// ---------------------------------------------------------------------

@Expose
Copy link
Member Author

Choose a reason for hiding this comment

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

This entry is not removed to keep backward compatibility, however, it is never read directly by the code and instead is used when requesting the List of statistics.

{
return material;
}
private List<StatisticRec> statisticList;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the new Statistics list.

return tags;
}

private String getEntityTypeTagsDescription(IslandRequirements requirement, String reference) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Entity Tags description

* Stores filtered items.
*/
private List<EntityType> filterElements;
public class MultiEntitySelector extends UnifiedMultiSelector<EntityType> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added more abstraction to reduce code duplication

return true;
}).
build();
icon(ManageStatisticsPanel.getStatisticIcon(statistic)).description(description)
Copy link
Member Author

Choose a reason for hiding this comment

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

Use the new Statistic icons instead of just paper.

case STATISTIC_TYPE -> {
StatisticRequirements requirements = this.challenge.getRequirements();
}
case STATISTIC_TYPE -> {
Copy link
Member Author

Choose a reason for hiding this comment

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

The main change in this class is here where multiple stats are checked instead of just the one.

private Map<Material, Integer> requiredBlocks = new EnumMap<>(Material.class);

@Expose
private Map<Tag<Material>, Integer> requiredMaterialTags = new HashMap<>();
Copy link
Member Author

Choose a reason for hiding this comment

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

New block tags added

@Expose
private Map<Tag<Material>, Integer> requiredMaterialTags = new HashMap<>();
@Expose
private Map<Tag<Fluid>, Integer> requiredFluidTags = new HashMap<>();
Copy link
Member Author

Choose a reason for hiding this comment

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

New fluid tag map added, but this is not used right now. Could be used in the future maybe.

private Map<Tag<Material>, Integer> requiredMaterialTags = new HashMap<>();
@Expose
private Map<Tag<Fluid>, Integer> requiredFluidTags = new HashMap<>();
@Expose
Copy link
Member Author

Choose a reason for hiding this comment

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

Entity group map added

* Stores filtered items.
*/
private List<Material> filterElements;
public class MultiBlockSelector extends UnifiedMultiSelector<Material> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Shrunk down by using Abstract class to reduce code duplication.

* @param et entity type
* @return ItemStack
*/
public static ItemStack getIcon(EntityType et) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Small method for entity icons. A big better than just eggs.

@tastybento tastybento requested a review from BONNe February 11, 2025 07:44
@tastybento
Copy link
Member Author

Hi @BONNe - this is just FYI - I am sure you are busy. Please feel free to try the SNAPSHOT. I am working on a couple of other additions, but I'd like to get this one out soon. I made the changes to support some of the challenges I want for Poseidon. I plan to put the Poseidon challenges on the web so they can be downloaded too.

Enables per-player permission waivers.
Add permission [gamemode].challenges.waiver-add.x to addon
The admin may want to hide the rewards and just use the reward
description. If the number of rewards is very long, it can be a problem
to list them all.
Add switch to hide reward items from the GUI list.
Added a PAPI formula option to Other challenge types.
Enables giving rewards for advancements or combining them into a
challenge.
Adds Advancements as an option to the Other challenges
Add string comparison for PAPI placeholders #366
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
12.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@tastybento tastybento merged commit 7231113 into master Feb 23, 2025
3 of 4 checks passed
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