Skip to content

Commit

Permalink
Release 1.2.0 (#317)
Browse files Browse the repository at this point in the history
* Init 1.2.0 version

* Fixes #311 localization errors in zn-CN.

Original translation author translated `[]` placeholders which broke locale

* Init 1.2.0 version

* Edit some unfit translation (#312)

Edit some unfit translation

* Fixes a regex bug that replaced every [player] char instead of whole word.

* Fixes a crash that prevented STATISTICS entity and material/item challenges to be completed.

* Add requirement-not-met-material and requirement-not-met-entity to display statistic required item on error.

* Add locale of Chinese-Hong Kong (zh-HK) (#313)

Addition of locale updated to latest version

* Add ${argLine} to get jacoco coverage

* Updated Jacoco POM section

* Update build.yml

Java 17 for Surefire

* Updated pladdon annotations

* Add support for gamemode-specific translations.

This was a request from Floris

* Update ChallengesManagerTest methods with world parameter.

* Implement option that excludes undeployed challenges

The new option allows to toggle if undeployed challenges should be included in level completion count. Disabling option will not include these challenges for level completion.

Fixes #315

* Create plugin.yml (#316)

* Create plugin.yml

* Update pom.xml

* Update ChallengesPladdon.java

* Remove dependency to org.apache.commons

Replace org.apache.commons.lang.ArrayUtils to a default Java implementation.

---------

Co-authored-by: EpicMo <1982742309@qq.com>
Co-authored-by: JamesMCL44 <epicquarters@gmail.com>
Co-authored-by: tastybento <tastybento@users.noreply.github.com>
Co-authored-by: tastybento <tastybento@wasteofplastic.com>
  • Loading branch information
5 people committed Apr 15, 2023
1 parent 7f58af7 commit b1fa9a9
Show file tree
Hide file tree
Showing 29 changed files with 1,869 additions and 504 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 16
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 16
java-version: 17
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand All @@ -34,4 +34,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
55 changes: 25 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>16</java.version>
<java.version>17</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17.1-R0.1-SNAPSHOT</spigot.version>
Expand All @@ -44,7 +44,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.1.0</build.version>
<build.version>1.2.0</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Challenges</sonar.projectKey>
Expand Down Expand Up @@ -127,12 +127,6 @@
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>plugin-annotations</artifactId>
<version>1.2.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Vault API -->
<dependency>
<groupId>net.milkbowl.vault</groupId>
Expand Down Expand Up @@ -249,6 +243,7 @@
<version>3.0.0-M5</version>
<configuration>
<argLine>
${argLine}
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
Expand Down Expand Up @@ -355,34 +350,34 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.1-SNAPSHOT</version>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<configuration>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>lv.id.bonne:panelutils:*</include>
</includes>
</artifactSet>
<transformers>
<!-- Add a transformer to exclude any other manifest files (possibly from dependencies). -->
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>MANIFEST.MF</resource>
</transformer>
<!-- Add a transformer to include your custom manifest file. -->
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>META-INF/MANIFEST.MF</resource>
<file>src/main/resources/META-INF/MANIFEST.MF</file>
</transformer>
</transformers>
<append>true</append>
<excludes>
<!-- This is required to prevent Jacoco from adding
synthetic fields to a JavaBean class (causes errors in testing) -->
<exclude>**/*Names*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>package</phase>
<id>prepare-agent</id>
<goals>
<goal>shade</goal>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/world/bentobox/challenges/ChallengesAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,18 @@ private void registerPlaceholders(GameModeAddon gameModeAddon)
addonName + "_latest_level_uncompleted_count",
user -> {
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
return String.valueOf(level != null ?
level.getChallenges().size() - this.challengesManager.getLevelCompletedChallengeCount(user, world, level) : 0);

if (level == null)
{
return "0";
}

int challengeCount = this.getChallengesSettings().isIncludeUndeployed() ?
level.getChallenges().size() :
this.challengesManager.getLevelChallenges(level, false).size();

return String.valueOf(challengeCount -
this.challengesManager.getLevelCompletedChallengeCount(user, world, level));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@
package world.bentobox.challenges;


import org.bukkit.plugin.java.annotation.dependency.Dependency;
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
import org.bukkit.plugin.java.annotation.plugin.Plugin;

import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.Pladdon;

/**
* @author tastybento
*/
@Plugin(name="Pladdon", version="1.0")
@ApiVersion(ApiVersion.Target.v1_17)
@Dependency(value = "BentoBox")
public class ChallengesPladdon extends Pladdon
{
@Override
public Addon getAddon()
{
return new ChallengesAddon();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean execute(User user, String label, List<String> args)

if (this.gameModeAddons.isEmpty())
{
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-hooked"));
Utils.sendMessage(user, user.getWorld(), Constants.ERRORS + "not-hooked");
return false;
}
else if (this.gameModeAddons.size() == 1)
Expand All @@ -80,7 +80,7 @@ else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode
}
}

Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
Utils.sendMessage(user, user.getWorld(), "general.errors.wrong-world");
}
else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import world.bentobox.bentobox.util.Util;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.panel.user.ChallengesPanel;
import world.bentobox.challenges.utils.Constants;
import world.bentobox.challenges.utils.Utils;


Expand All @@ -31,7 +32,7 @@ public boolean canExecute(User user, String label, List<String> args)
if (!this.getIWM().inWorld(user.getWorld()) ||
!Util.sameWorld(this.getWorld(), user.getWorld())) {
// Not a GameMode world.
Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
Utils.sendMessage(user, user.getWorld(), "general.errors.wrong-world");
return false;
}

Expand All @@ -47,13 +48,13 @@ public boolean canExecute(User user, String label, List<String> args)
map(GameModeAddon::getAdminCommand).
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
orElse(this.getTopLabel());
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges-admin",
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-challenges-admin",
"[command]",
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]));
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]);
}
else
{
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-challenges");
}

return false;
Expand All @@ -62,14 +63,14 @@ public boolean canExecute(User user, String label, List<String> args)
if (this.getIslands().getIsland(this.getWorld(), user) == null)
{
// Do not open gui if there is no island for this player.
Utils.sendMessage(user, user.getTranslation("general.errors.no-island"));
Utils.sendMessage(user, this.getWorld(), "general.errors.no-island");
return false;
} else if (ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.getWorld()) &&
!this.getIslands().locationIsOnIsland(user.getPlayer(), user.getLocation()))
{
// Do not open gui if player is not on the island, but challenges requires island for
// completion.
Utils.sendMessage(user, user.getTranslation("challenges.errors.not-on-island"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-on-island");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.tasks.TryToComplete;
import world.bentobox.challenges.utils.Constants;
import world.bentobox.challenges.utils.Utils;


Expand Down Expand Up @@ -54,7 +55,7 @@ public boolean execute(User user, String label, List<String> args)
{
if (args.isEmpty())
{
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
this.showHelp(this, user);
return false;
}
Expand All @@ -73,7 +74,7 @@ public boolean execute(User user, String label, List<String> args)

if (!canMultipleTimes && count > 1)
{
Utils.sendMessage(user, user.getTranslation("challenges.error.no-multiple-permission"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-multiple-permission");
count = 1;
}

Expand All @@ -87,7 +88,7 @@ public boolean execute(User user, String label, List<String> args)
}
else
{
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "unknown-challenge");
this.showHelp(this, user);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean execute(User user, String label, List<String> args)

if (this.gameModeAddons.isEmpty())
{
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-hooked"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-hooked");
return false;
}
else if (this.gameModeAddons.size() == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean execute(User user, String label, List<String> args)
{
if (user.isPlayer())
{
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
}
else
{
Expand All @@ -67,7 +67,7 @@ else if (args.size() < 2)
{
if (user.isPlayer())
{
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "missing-arguments");
}
else
{
Expand All @@ -82,9 +82,11 @@ else if (!args.get(1).isEmpty())
{
if (user.isPlayer())
{
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
Utils.sendMessage(user,
this.getWorld(),
"general.errors.unknown-player",
TextVariables.NAME,
args.get(0)));
args.get(0));
}
else
{
Expand All @@ -109,9 +111,11 @@ else if (!args.get(1).isEmpty())

if (user.isPlayer())
{
Utils.sendMessage(user, user.getTranslation("challenges.messages.completed",
Utils.sendMessage(user,
this.getWorld(),
Constants.MESSAGES + "completed",
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
Constants.PARAMETER_PLAYER, target.getName()));
Constants.PARAMETER_PLAYER, target.getName());
}
else
{
Expand All @@ -123,7 +127,9 @@ else if (!args.get(1).isEmpty())
{
if (user.isPlayer())
{
Utils.sendMessage(user, user.getTranslation("challenges.messages.already-completed"));
Utils.sendMessage(user,
this.getWorld(),
Constants.MESSAGES + "already-completed");
}
else
{
Expand All @@ -137,7 +143,9 @@ else if (!args.get(1).isEmpty())
{
if (user.isPlayer())
{
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
Utils.sendMessage(user,
this.getWorld(),
Constants.ERRORS + "unknown-challenge");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public boolean execute(User user, String label, List<String> args)
if (args.isEmpty())
{
this.manager.load();
Utils.sendMessage(user, user.getTranslation("general.success"));
Utils.sendMessage(user, this.getWorld(), "general.success");
return true;
}
else if (args.get(0).equalsIgnoreCase("hard"))
{
this.manager.reload();
Utils.sendMessage(user, user.getTranslation("general.success"));
Utils.sendMessage(user, this.getWorld(), "general.success");
return true;
}
else
Expand Down

0 comments on commit b1fa9a9

Please sign in to comment.