mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-09-29 23:17:34 +02:00
Compare commits
No commits in common. "develop" and "1.0.0" have entirely different histories.
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@ -11,22 +11,21 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 16
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
java-version: 16
|
||||||
java-version: 21
|
|
||||||
- name: Cache SonarCloud packages
|
- name: Cache SonarCloud packages
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/.sonar/cache
|
path: ~/.sonar/cache
|
||||||
key: ${{ runner.os }}-sonar
|
key: ${{ runner.os }}-sonar
|
||||||
restore-keys: ${{ runner.os }}-sonar
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
6
CONTRIBUTING.md
Normal file
6
CONTRIBUTING.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Contributions are welcome but acceptance is completely up to tastybento. Do not be offended if your contribution is rejected.
|
||||||
|
I will not accept any contributions that are formatting only, or mostly formatting.
|
||||||
|
Automated code cleanup is also not a valid contribution as a first Pull Request. If a tool is doing your job,
|
||||||
|
the submit an issue that recommends we use a specific tool.
|
||||||
|
Contributions are accepted under the license terms and conditions. Note that this means we may use them elsewhere.
|
||||||
|
Thank you!
|
5
PULL_REQUEST_TEMPLATE.md
Normal file
5
PULL_REQUEST_TEMPLATE.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Thanks for submitting a pull request. Do not use this form for bug reports!
|
||||||
|
Your submission must meet the minimum requirements of a contribution, i.e., add code, refactor code or fix code.
|
||||||
|
It takes time and effort to review submissions, so please do not waste our time.
|
||||||
|
Note: formatting/spacing-only submissions will be rejected!
|
||||||
|
For submissions, we want you to use spaces, not tabs (4 spaces) - thank you.
|
44
README.md
44
README.md
@ -2,9 +2,24 @@
|
|||||||
[![Discord](https://img.shields.io/discord/272499714048524288.svg?logo=discord)](https://discord.bentobox.world)
|
[![Discord](https://img.shields.io/discord/272499714048524288.svg?logo=discord)](https://discord.bentobox.world)
|
||||||
[![Build Status](https://ci.codemc.org/buildStatus/icon?job=BentoBoxWorld/Challenges)](https://ci.codemc.org/job/BentoBoxWorld/job/Challenges/)
|
[![Build Status](https://ci.codemc.org/buildStatus/icon?job=BentoBoxWorld/Challenges)](https://ci.codemc.org/job/BentoBoxWorld/job/Challenges/)
|
||||||
|
|
||||||
Add-on for BentoBox to provide challenges for any BentoBox GameMode. Challenges can be to collect items, to have items or blocks nearby, to amass an amount of money or island levels, or to have accomplished some player statistic. Each challenge can reward the player with money, experience points, blocks, items, or other things, like permissions, Pre-built challenges are available and there is also a Web Library of pre-built ones. Customize them to fit your needs!
|
Add-on for BentoBox to provide challenges for any BentoBox GameMode.
|
||||||
|
|
||||||
![Challenges](https://github.com/BentoBoxWorld/Challenges/assets/4407265/9b3c5278-3a9d-45f2-9ee1-2c1fc1199a8d)
|
## Where to find
|
||||||
|
|
||||||
|
Currently Challenges Addon is in **Beta stage**, so it may or may not contain bugs... a lot of bugs. Also it means, that some features are not working or implemented.
|
||||||
|
Latest official **Beta Release is 0.8.3**, and you can download it from [Release tab](https://github.com/BentoBoxWorld/Challenges/releases)
|
||||||
|
But it will work with BentoBox 1.14.
|
||||||
|
|
||||||
|
Latest development builds will be based on **Minecraft 1.16.1** and **BentoBox 1.14.0**.
|
||||||
|
**Nightly builds** are available in [Jenkins Server](https://ci.codemc.org/job/BentoBoxWorld/job/Challenges/lastStableBuild/).
|
||||||
|
|
||||||
|
If you like this addon but something is missing or is not working as you want, you can always submit an [Issue request](https://github.com/BentoBoxWorld/Challenges/issues) or get a support in Discord [BentoBox ![icon](https://avatars2.githubusercontent.com/u/41555324?s=15&v=4)](https://discord.bentobox.world)
|
||||||
|
|
||||||
|
## Translations
|
||||||
|
|
||||||
|
As most of BentoBox projects, Challenges Addon is translatable in any language. Everyone can contribute, and translate some parts of the addon in their language via [GitLocalize](https://gitlocalize.com/repo/2896).
|
||||||
|
If your language is not in the list, please contact to developers via Discord and it will be added there.
|
||||||
|
Unfortunately, default challenges come only in English translation. But with version 0.8.0 there will be access to different challenges libraries, where everyone could share their challenges with their translations. More information will come soon.
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
@ -12,32 +27,21 @@ Add-on for BentoBox to provide challenges for any BentoBox GameMode. Challenges
|
|||||||
2. Restart the server
|
2. Restart the server
|
||||||
3. Edit the config.yml how you want.
|
3. Edit the config.yml how you want.
|
||||||
4. Restart the server
|
4. Restart the server
|
||||||
5. Run the Admin challenges command to set up challenges for your game mode.
|
|
||||||
|
|
||||||
#### Installation
|
#### Challenges
|
||||||
|
|
||||||
By default, challenges addon comes without any challenge or level. On first run time only Admin GUI will be accessible.
|
By default, challenges addon comes without any challenge or level. On first runtime only Admin GUI will be accessible.
|
||||||
Admins can create their own challenges or import some default challenges. Default challenges contains 5 levels and 57 challenges.
|
Admins can create their own challenges or import some default challenges, which importing also are available via Admin GUI. Default challenges contains 5 levels and 57 challenges.
|
||||||
There also exists a Web Library, where admins can download public challenges. It is accessible from the Admin GUI by clicking on the Web icon.
|
There exist also Web Library, where users can download public challenges. It is accessible with Admin GUI by clicking on Web icon.
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
- [x] BentoBok
|
- [x] BentoBox - 1.14 versions
|
||||||
- [x] BSkyBlock
|
- [x] BSkyBlock
|
||||||
- [x] AcidIsland
|
- [x] AcidIsland
|
||||||
- [x] SkyGrid
|
- [x] SkyGrid
|
||||||
- [x] CaveBlock
|
- [x] CaveBlock
|
||||||
|
|
||||||
## Translations
|
## Information
|
||||||
|
|
||||||
As with most of BentoBox projects, Challenges Addon is translatable into any language. Everyone can contribute, and translate some parts of the addon in their language via [GitLocalize](https://gitlocalize.com/repo/2896).
|
|
||||||
If your language is not in the list, please contact the developers via Discord and it will be added there.
|
|
||||||
Unfortunately, default challenges come only be in English, but there are different challenges libraries where everyone can share their challenges with their translations.
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
More information can be found in the docs: https://docs.bentobox.world/en/latest/addons/Challenges/
|
|
||||||
|
|
||||||
## Bugs or feature requests
|
|
||||||
If you like this addon but something is missing or is not working as you want, you can always submit an [Issue request](https://github.com/BentoBoxWorld/Challenges/issues) or get a support in Discord [BentoBox ![icon](https://avatars2.githubusercontent.com/u/41555324?s=15&v=4)](https://discord.bentobox.world)
|
|
||||||
|
|
||||||
|
More information can be found in [Wiki Pages](https://docs.bentobox.world/en/latest/addons/Challenges/).
|
||||||
|
106
pom.xml
106
pom.xml
@ -32,19 +32,19 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>21</java.version>
|
<java.version>16</java.version>
|
||||||
<powermock.version>2.0.9</powermock.version>
|
<powermock.version>2.0.9</powermock.version>
|
||||||
<!-- More visible way how to change dependency versions -->
|
<!-- More visible way how to change dependency versions -->
|
||||||
<spigot.version>1.21-R0.1-SNAPSHOT</spigot.version>
|
<spigot.version>1.17.1-R0.1-SNAPSHOT</spigot.version>
|
||||||
<spigot-annotations.version>1.2.3-SNAPSHOT</spigot-annotations.version>
|
<spigot-annotations.version>1.2.3-SNAPSHOT</spigot-annotations.version>
|
||||||
<bentobox.version>2.4.2</bentobox.version>
|
<bentobox.version>1.20.0</bentobox.version>
|
||||||
<level.version>2.6.3</level.version>
|
<level.version>2.6.3</level.version>
|
||||||
<vault.version>1.7</vault.version>
|
<vault.version>1.7</vault.version>
|
||||||
<panelutils.version>1.2.0</panelutils.version>
|
<panelutils.version>1.0.0</panelutils.version>
|
||||||
<!-- Revision variable removes warning about dynamic version -->
|
<!-- Revision variable removes warning about dynamic version -->
|
||||||
<revision>${build.version}-SNAPSHOT</revision>
|
<revision>${build.version}-SNAPSHOT</revision>
|
||||||
<!-- This allows to change between versions and snapshots. -->
|
<!-- This allows to change between versions and snapshots. -->
|
||||||
<build.version>1.3.2</build.version>
|
<build.version>1.0.0</build.version>
|
||||||
<build.number>-LOCAL</build.number>
|
<build.number>-LOCAL</build.number>
|
||||||
<!-- Sonar Cloud -->
|
<!-- Sonar Cloud -->
|
||||||
<sonar.projectKey>BentoBoxWorld_Challenges</sonar.projectKey>
|
<sonar.projectKey>BentoBoxWorld_Challenges</sonar.projectKey>
|
||||||
@ -120,12 +120,6 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- This is required for PowerMockito to work and must be placed before it -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.javassist</groupId>
|
|
||||||
<artifactId>javassist</artifactId>
|
|
||||||
<version>3.30.2-GA</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Spigot API -->
|
<!-- Spigot API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
@ -133,6 +127,12 @@
|
|||||||
<version>${spigot.version}</version>
|
<version>${spigot.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>plugin-annotations</artifactId>
|
||||||
|
<version>1.2.3-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<!-- Vault API -->
|
<!-- Vault API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
@ -193,11 +193,6 @@
|
|||||||
<version>1.5.21</version>
|
<version>1.5.21</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-math3</artifactId>
|
|
||||||
<version>3.6.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -228,38 +223,6 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.6.0</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>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
@ -286,7 +249,6 @@
|
|||||||
<version>3.0.0-M5</version>
|
<version>3.0.0-M5</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
${argLine}
|
|
||||||
--add-opens java.base/java.lang=ALL-UNNAMED
|
--add-opens java.base/java.lang=ALL-UNNAMED
|
||||||
--add-opens java.base/java.math=ALL-UNNAMED
|
--add-opens java.base/java.math=ALL-UNNAMED
|
||||||
--add-opens java.base/java.io=ALL-UNNAMED
|
--add-opens java.base/java.io=ALL-UNNAMED
|
||||||
@ -368,35 +330,59 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.10</version>
|
<version>0.8.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<append>true</append>
|
<append>true</append>
|
||||||
<excludes>
|
<excludes>
|
||||||
<!-- This is required to prevent Jacoco from adding
|
<!-- This is required to prevent Jacoco from adding
|
||||||
synthetic fields to a JavaBean class (causes errors in testing) -->
|
synthetic fields to a JavaBean class (causes errors in testing) -->
|
||||||
<exclude>**/*Names*</exclude>
|
<exclude>**/*Names*</exclude>
|
||||||
<!-- Prevents the Material is too large to mock error -->
|
|
||||||
<exclude>org/bukkit/Material*</exclude>
|
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>prepare-agent</id>
|
<id>pre-unit-test</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>prepare-agent</goal>
|
<goal>prepare-agent</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>report</id>
|
<id>post-unit-test</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>report</goal>
|
<goal>report</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
</execution>
|
||||||
<formats>
|
</executions>
|
||||||
<format>XML</format>
|
</plugin>
|
||||||
</formats>
|
<plugin>
|
||||||
</configuration>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.3.1-SNAPSHOT</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>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -408,18 +408,8 @@ public class ChallengesAddon extends Addon {
|
|||||||
addonName + "_latest_level_uncompleted_count",
|
addonName + "_latest_level_uncompleted_count",
|
||||||
user -> {
|
user -> {
|
||||||
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
||||||
|
return String.valueOf(level != null ?
|
||||||
if (level == null)
|
level.getChallenges().size() - this.challengesManager.getLevelCompletedChallengeCount(user, world, level) : 0);
|
||||||
{
|
|
||||||
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));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,21 +7,24 @@
|
|||||||
package world.bentobox.challenges;
|
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.Addon;
|
||||||
import world.bentobox.bentobox.api.addons.Pladdon;
|
import world.bentobox.bentobox.api.addons.Pladdon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*/
|
*/
|
||||||
|
@Plugin(name="Pladdon", version="1.0")
|
||||||
|
@ApiVersion(ApiVersion.Target.v1_17)
|
||||||
|
@Dependency(value = "BentoBox")
|
||||||
public class ChallengesPladdon extends Pladdon
|
public class ChallengesPladdon extends Pladdon
|
||||||
{
|
{
|
||||||
private Addon addon;
|
|
||||||
@Override
|
@Override
|
||||||
public Addon getAddon()
|
public Addon getAddon()
|
||||||
{
|
{
|
||||||
if (addon == null) {
|
return new ChallengesAddon();
|
||||||
addon = new ChallengesAddon();
|
|
||||||
}
|
|
||||||
return addon;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,7 +55,7 @@ public class ChallengesGlobalPlayerCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (this.gameModeAddons.isEmpty())
|
if (this.gameModeAddons.isEmpty())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, user.getWorld(), Constants.ERRORS + "not-hooked");
|
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-hooked"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (this.gameModeAddons.size() == 1)
|
else if (this.gameModeAddons.size() == 1)
|
||||||
@ -80,7 +80,7 @@ public class ChallengesGlobalPlayerCommand extends CompositeCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.sendMessage(user, user.getWorld(), "general.errors.wrong-world");
|
Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
|
||||||
}
|
}
|
||||||
else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
|
else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,6 @@ import world.bentobox.bentobox.api.user.User;
|
|||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
import world.bentobox.challenges.panel.user.ChallengesPanel;
|
import world.bentobox.challenges.panel.user.ChallengesPanel;
|
||||||
import world.bentobox.challenges.utils.Constants;
|
|
||||||
import world.bentobox.challenges.utils.Utils;
|
import world.bentobox.challenges.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
|||||||
if (!this.getIWM().inWorld(user.getWorld()) ||
|
if (!this.getIWM().inWorld(user.getWorld()) ||
|
||||||
!Util.sameWorld(this.getWorld(), user.getWorld())) {
|
!Util.sameWorld(this.getWorld(), user.getWorld())) {
|
||||||
// Not a GameMode world.
|
// Not a GameMode world.
|
||||||
Utils.sendMessage(user, user.getWorld(), "general.errors.wrong-world");
|
Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,13 +47,13 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
|||||||
map(GameModeAddon::getAdminCommand).
|
map(GameModeAddon::getAdminCommand).
|
||||||
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
|
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
|
||||||
orElse(this.getTopLabel());
|
orElse(this.getTopLabel());
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-challenges-admin",
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges-admin",
|
||||||
"[command]",
|
"[command]",
|
||||||
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]);
|
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-challenges");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -63,14 +62,14 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
|||||||
if (this.getIslands().getIsland(this.getWorld(), user) == null)
|
if (this.getIslands().getIsland(this.getWorld(), user) == null)
|
||||||
{
|
{
|
||||||
// Do not open gui if there is no island for this player.
|
// Do not open gui if there is no island for this player.
|
||||||
Utils.sendMessage(user, this.getWorld(), "general.errors.no-island");
|
Utils.sendMessage(user, user.getTranslation("general.errors.no-island"));
|
||||||
return false;
|
return false;
|
||||||
} else if (ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.getWorld()) &&
|
} else if (ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.getWorld()) &&
|
||||||
!this.getIslands().locationIsOnIsland(user.getPlayer(), user.getLocation()))
|
!this.getIslands().locationIsOnIsland(user.getPlayer(), user.getLocation()))
|
||||||
{
|
{
|
||||||
// Do not open gui if player is not on the island, but challenges requires island for
|
// Do not open gui if player is not on the island, but challenges requires island for
|
||||||
// completion.
|
// completion.
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-on-island");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.not-on-island"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import world.bentobox.bentobox.util.Util;
|
|||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
import world.bentobox.challenges.database.object.Challenge;
|
import world.bentobox.challenges.database.object.Challenge;
|
||||||
import world.bentobox.challenges.tasks.TryToComplete;
|
import world.bentobox.challenges.tasks.TryToComplete;
|
||||||
import world.bentobox.challenges.utils.Constants;
|
|
||||||
import world.bentobox.challenges.utils.Utils;
|
import world.bentobox.challenges.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (args.isEmpty())
|
if (args.isEmpty())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||||
this.showHelp(this, user);
|
this.showHelp(this, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -74,7 +73,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (!canMultipleTimes && count > 1)
|
if (!canMultipleTimes && count > 1)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-multiple-permission");
|
Utils.sendMessage(user, user.getTranslation("challenges.error.no-multiple-permission"));
|
||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "unknown-challenge");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||||
this.showHelp(this, user);
|
this.showHelp(this, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class ChallengesGlobalAdminCommand extends CompositeCommand
|
|||||||
@Override
|
@Override
|
||||||
public void setup()
|
public void setup()
|
||||||
{
|
{
|
||||||
this.setPermission("admin.challenges");
|
this.setPermission("addon.admin.challenges");
|
||||||
this.setParametersHelp("challenges.commands.admin.main.parameters");
|
this.setParametersHelp("challenges.commands.admin.main.parameters");
|
||||||
this.setDescription("challenges.commands.admin.main.description");
|
this.setDescription("challenges.commands.admin.main.description");
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ public class ChallengesGlobalAdminCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (this.gameModeAddons.isEmpty())
|
if (this.gameModeAddons.isEmpty())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-hooked");
|
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-hooked"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (this.gameModeAddons.size() == 1)
|
else if (this.gameModeAddons.size() == 1)
|
||||||
|
@ -56,7 +56,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -67,7 +67,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "missing-arguments");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -82,11 +82,9 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
|
||||||
this.getWorld(),
|
|
||||||
"general.errors.unknown-player",
|
|
||||||
TextVariables.NAME,
|
TextVariables.NAME,
|
||||||
args.get(0));
|
args.get(0)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -111,11 +109,9 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.completed",
|
||||||
this.getWorld(),
|
|
||||||
Constants.MESSAGES + "completed",
|
|
||||||
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
|
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
|
||||||
Constants.PARAMETER_PLAYER, target.getName());
|
Constants.PARAMETER_PLAYER, target.getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -127,9 +123,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.already-completed"));
|
||||||
this.getWorld(),
|
|
||||||
Constants.MESSAGES + "already-completed");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -143,9 +137,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||||
this.getWorld(),
|
|
||||||
Constants.ERRORS + "unknown-challenge");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -49,13 +49,13 @@ public class ReloadChallenges extends CompositeCommand
|
|||||||
if (args.isEmpty())
|
if (args.isEmpty())
|
||||||
{
|
{
|
||||||
this.manager.load();
|
this.manager.load();
|
||||||
Utils.sendMessage(user, this.getWorld(), "general.success");
|
Utils.sendMessage(user, user.getTranslation("general.success"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args.get(0).equalsIgnoreCase("hard"))
|
else if (args.get(0).equalsIgnoreCase("hard"))
|
||||||
{
|
{
|
||||||
this.manager.reload();
|
this.manager.reload();
|
||||||
Utils.sendMessage(user, this.getWorld(), "general.success");
|
Utils.sendMessage(user, user.getTranslation("general.success"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -56,7 +56,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -67,7 +67,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "missing-arguments");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -82,11 +82,8 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
|
||||||
this.getWorld(),
|
TextVariables.NAME, args.get(0)));
|
||||||
Constants.ERRORS + "unknown-player",
|
|
||||||
TextVariables.NAME,
|
|
||||||
args.get(0));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -105,11 +102,8 @@ public class ResetCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.reset-all",
|
||||||
this.getWorld(),
|
Constants.PARAMETER_PLAYER, target.getName()));
|
||||||
Constants.MESSAGES + "reset-all",
|
|
||||||
Constants.PARAMETER_PLAYER,
|
|
||||||
target.getName());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -131,11 +125,9 @@ public class ResetCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.reset",
|
||||||
this.getWorld(),
|
|
||||||
Constants.MESSAGES + "reset",
|
|
||||||
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
|
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
|
||||||
Constants.PARAMETER_PLAYER, target.getName());
|
Constants.PARAMETER_PLAYER, target.getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -147,9 +139,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.not-completed"));
|
||||||
this.getWorld(),
|
|
||||||
Constants.MESSAGES + "not-completed");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -163,9 +153,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||||
this.getWorld(),
|
|
||||||
Constants.ERRORS + "unknown-challenge");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -106,10 +106,11 @@ public class Settings implements ConfigObject
|
|||||||
@ConfigComment("Valid values are:")
|
@ConfigComment("Valid values are:")
|
||||||
@ConfigComment(" 'VISIBLE' - there will be no hidden challenges. All challenges will be viewable in GUI.")
|
@ConfigComment(" 'VISIBLE' - there will be no hidden challenges. All challenges will be viewable in GUI.")
|
||||||
@ConfigComment(" 'HIDDEN' - shows only deployed challenges.")
|
@ConfigComment(" 'HIDDEN' - shows only deployed challenges.")
|
||||||
|
@ConfigComment(" 'TOGGLEABLE' - there will be button in GUI that allows users to switch from ALL modes.")
|
||||||
|
@ConfigComment("TOGGLEABLE - Currently not implemented.")
|
||||||
@ConfigEntry(path = "gui-settings.undeployed-view-mode")
|
@ConfigEntry(path = "gui-settings.undeployed-view-mode")
|
||||||
private VisibilityMode visibilityMode = VisibilityMode.VISIBLE;
|
private VisibilityMode visibilityMode = VisibilityMode.VISIBLE;
|
||||||
|
|
||||||
|
|
||||||
@ConfigComment("")
|
@ConfigComment("")
|
||||||
@ConfigComment("This allows to change default locked level icon. This option may be")
|
@ConfigComment("This allows to change default locked level icon. This option may be")
|
||||||
@ConfigComment("overwritten by each challenge level. If challenge level has specified")
|
@ConfigComment("overwritten by each challenge level. If challenge level has specified")
|
||||||
@ -129,13 +130,6 @@ public class Settings implements ConfigObject
|
|||||||
@ConfigEntry(path = "reset-challenges")
|
@ConfigEntry(path = "reset-challenges")
|
||||||
private boolean resetChallenges = true;
|
private boolean resetChallenges = true;
|
||||||
|
|
||||||
@ConfigComment("")
|
|
||||||
@ConfigComment("This option indicates if undepolyed challenges should be counted to level completion.")
|
|
||||||
@ConfigComment("Disabling this option will make it so that only deployed challenges will be counted.")
|
|
||||||
@ConfigComment("Default: true")
|
|
||||||
@ConfigEntry(path = "include-undeployed")
|
|
||||||
private boolean includeUndeployed = true;
|
|
||||||
|
|
||||||
@ConfigComment("")
|
@ConfigComment("")
|
||||||
@ConfigComment("Broadcast 1st time challenge completion messages to all players.")
|
@ConfigComment("Broadcast 1st time challenge completion messages to all players.")
|
||||||
@ConfigComment("Change to false if the spam becomes too much.")
|
@ConfigComment("Change to false if the spam becomes too much.")
|
||||||
@ -171,7 +165,7 @@ public class Settings implements ConfigObject
|
|||||||
* Configuration version
|
* Configuration version
|
||||||
*/
|
*/
|
||||||
@ConfigComment("")
|
@ConfigComment("")
|
||||||
private String configVersion = "v4";
|
private String configVersion = "v3";
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
@ -603,26 +597,4 @@ public class Settings implements ConfigObject
|
|||||||
{
|
{
|
||||||
this.visibilityMode = visibilityMode;
|
this.visibilityMode = visibilityMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is count undeployed to completion boolean.
|
|
||||||
*
|
|
||||||
* @return the boolean
|
|
||||||
*/
|
|
||||||
public boolean isIncludeUndeployed()
|
|
||||||
{
|
|
||||||
return includeUndeployed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets count undeployed to completion.
|
|
||||||
*
|
|
||||||
* @param includeUndeployed the count undeployed to completion
|
|
||||||
*/
|
|
||||||
public void setIncludeUndeployed(boolean includeUndeployed)
|
|
||||||
{
|
|
||||||
this.includeUndeployed = includeUndeployed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,7 @@ public class ChallengesImportManager
|
|||||||
{
|
{
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-file", Constants.PARAMETER_FILE, file));
|
||||||
world,
|
|
||||||
Constants.ERRORS + "no-file",
|
|
||||||
Constants.PARAMETER_FILE,
|
|
||||||
file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -102,14 +98,13 @@ public class ChallengesImportManager
|
|||||||
{
|
{
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-load",
|
||||||
world,
|
Constants.PARAMETER_FILE, file, TextVariables.DESCRIPTION, e.getMessage()));
|
||||||
Constants.ERRORS + "no-load",
|
}
|
||||||
Constants.PARAMETER_FILE, file,
|
else
|
||||||
TextVariables.DESCRIPTION, e.getMessage());
|
{
|
||||||
|
this.addon.logError("Exception when loading file. " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logError("Exception when loading file. " + e.getMessage());
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,12 +116,13 @@ public class ChallengesImportManager
|
|||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user,
|
||||||
world,
|
user.getTranslation(Constants.ERRORS + "not-a-gamemode-world",
|
||||||
Constants.ERRORS + "not-a-gamemode-world",
|
Constants.PARAMETER_WORLD, world.getName()));
|
||||||
Constants.PARAMETER_WORLD, world.getName());
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.addon.logWarning("Given world is not a gamemode world.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logWarning("Given world is not a gamemode world.");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -159,7 +155,6 @@ public class ChallengesImportManager
|
|||||||
challengeCount = reader.getKeys(false).stream().
|
challengeCount = reader.getKeys(false).stream().
|
||||||
mapToInt(challengeId -> this.createChallenge(challengeId,
|
mapToInt(challengeId -> this.createChallenge(challengeId,
|
||||||
prefix,
|
prefix,
|
||||||
world,
|
|
||||||
reader.getConfigurationSection(challengeId))).
|
reader.getConfigurationSection(challengeId))).
|
||||||
sum();
|
sum();
|
||||||
}
|
}
|
||||||
@ -183,10 +178,9 @@ public class ChallengesImportManager
|
|||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user,
|
||||||
world,
|
user.getTranslation(Constants.MESSAGES + "import-count",
|
||||||
Constants.MESSAGES + "import-count",
|
"[levels]", String.valueOf(levelCount),
|
||||||
"[levels]", String.valueOf(levelCount),
|
"[challenges]", String.valueOf(challengeCount)));
|
||||||
"[challenges]", String.valueOf(challengeCount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.log("Imported " + challengeCount + " challenges and " +
|
this.addon.log("Imported " + challengeCount + " challenges and " +
|
||||||
@ -198,13 +192,11 @@ public class ChallengesImportManager
|
|||||||
* This method creates challenge from given config section.
|
* This method creates challenge from given config section.
|
||||||
* @param challengeId Challenge ID.
|
* @param challengeId Challenge ID.
|
||||||
* @param prefix GameMode prefix.
|
* @param prefix GameMode prefix.
|
||||||
* @param world world where challenge is created.
|
|
||||||
* @param section Configuration Section that contains information.
|
* @param section Configuration Section that contains information.
|
||||||
* @return 1 if challenge is created, otherwise 0.
|
* @return 1 if challenge is created, otherwise 0.
|
||||||
*/
|
*/
|
||||||
private int createChallenge(String challengeId,
|
private int createChallenge(String challengeId,
|
||||||
String prefix,
|
String prefix,
|
||||||
World world,
|
|
||||||
@Nullable ConfigurationSection section)
|
@Nullable ConfigurationSection section)
|
||||||
{
|
{
|
||||||
if (section == null)
|
if (section == null)
|
||||||
@ -278,7 +270,7 @@ public class ChallengesImportManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.addon.getChallengesManager().saveChallenge(challenge);
|
this.addon.getChallengesManager().saveChallenge(challenge);
|
||||||
this.addon.getChallengesManager().loadChallenge(challenge, world, true, null, true);
|
this.addon.getChallengesManager().loadChallenge(challenge, true, null, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -644,7 +636,7 @@ public class ChallengesImportManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.addon.getChallengesManager().saveLevel(level);
|
this.addon.getChallengesManager().saveLevel(level);
|
||||||
this.addon.getChallengesManager().loadLevel(level, world,true, null, true);
|
this.addon.getChallengesManager().loadLevel(level, true, null, true);
|
||||||
}
|
}
|
||||||
catch (Exception ignored)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
@ -708,7 +700,7 @@ public class ChallengesImportManager
|
|||||||
challenge.setLevel(uniqueIDPrefix + challenge.getLevel());
|
challenge.setLevel(uniqueIDPrefix + challenge.getLevel());
|
||||||
}
|
}
|
||||||
// Load challenge in memory
|
// Load challenge in memory
|
||||||
manager.loadChallenge(challenge, world, false, user, user == null);
|
manager.loadChallenge(challenge, false, user, user == null);
|
||||||
});
|
});
|
||||||
|
|
||||||
downloadedChallenges.getLevelList().forEach(challengeLevel -> {
|
downloadedChallenges.getLevelList().forEach(challengeLevel -> {
|
||||||
@ -721,7 +713,7 @@ public class ChallengesImportManager
|
|||||||
map(challenge -> uniqueIDPrefix + challenge).
|
map(challenge -> uniqueIDPrefix + challenge).
|
||||||
collect(Collectors.toSet()));
|
collect(Collectors.toSet()));
|
||||||
// Load level in memory
|
// Load level in memory
|
||||||
manager.loadLevel(challengeLevel, world, false, user, user == null);
|
manager.loadLevel(challengeLevel, false, user, user == null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -758,7 +750,7 @@ public class ChallengesImportManager
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user, world, Constants.ERRORS + "exist-challenges-or-levels");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.exist-challenges-or-levels"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -785,7 +777,7 @@ public class ChallengesImportManager
|
|||||||
challenge.setLevel(uniqueIDPrefix + challenge.getLevel());
|
challenge.setLevel(uniqueIDPrefix + challenge.getLevel());
|
||||||
}
|
}
|
||||||
// Load challenge in memory
|
// Load challenge in memory
|
||||||
manager.loadChallenge(challenge, world, false, user, user == null);
|
manager.loadChallenge(challenge, false, user, user == null);
|
||||||
});
|
});
|
||||||
|
|
||||||
downloadedChallenges.getLevelList().forEach(challengeLevel -> {
|
downloadedChallenges.getLevelList().forEach(challengeLevel -> {
|
||||||
@ -798,7 +790,7 @@ public class ChallengesImportManager
|
|||||||
map(challenge -> uniqueIDPrefix + challenge).
|
map(challenge -> uniqueIDPrefix + challenge).
|
||||||
collect(Collectors.toSet()));
|
collect(Collectors.toSet()));
|
||||||
// Load level in memory
|
// Load level in memory
|
||||||
manager.loadLevel(challengeLevel, world, false, user, user == null);
|
manager.loadLevel(challengeLevel, false, user, user == null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -827,9 +819,8 @@ public class ChallengesImportManager
|
|||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user,
|
||||||
world,
|
user.getTranslation(Constants.ERRORS + "file-exist",
|
||||||
Constants.ERRORS + "file-exist",
|
Constants.PARAMETER_FILE, fileName));
|
||||||
Constants.PARAMETER_FILE, fileName);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -895,10 +886,9 @@ public class ChallengesImportManager
|
|||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user,
|
||||||
world,
|
user.getTranslation(Constants.ERRORS + "no-load",
|
||||||
Constants.ERRORS + "no-load",
|
Constants.PARAMETER_FILE, fileName,
|
||||||
Constants.PARAMETER_FILE, fileName,
|
TextVariables.DESCRIPTION, e.getMessage()));
|
||||||
TextVariables.DESCRIPTION, e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logError("Could not save json file: " + e.getMessage());
|
this.addon.logError("Could not save json file: " + e.getMessage());
|
||||||
@ -908,10 +898,9 @@ public class ChallengesImportManager
|
|||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user,
|
||||||
world,
|
user.getTranslation(Constants.CONVERSATIONS + "database-export-completed",
|
||||||
Constants.CONVERSATIONS + "database-export-completed",
|
Constants.PARAMETER_WORLD, world.getName(),
|
||||||
Constants.PARAMETER_WORLD, world.getName(),
|
Constants.PARAMETER_FILE, fileName));
|
||||||
Constants.PARAMETER_FILE, fileName);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,6 @@ import world.bentobox.challenges.events.ChallengeCompletedEvent;
|
|||||||
import world.bentobox.challenges.events.ChallengeResetAllEvent;
|
import world.bentobox.challenges.events.ChallengeResetAllEvent;
|
||||||
import world.bentobox.challenges.events.ChallengeResetEvent;
|
import world.bentobox.challenges.events.ChallengeResetEvent;
|
||||||
import world.bentobox.challenges.events.LevelCompletedEvent;
|
import world.bentobox.challenges.events.LevelCompletedEvent;
|
||||||
import world.bentobox.challenges.utils.Constants;
|
|
||||||
import world.bentobox.challenges.utils.LevelStatus;
|
import world.bentobox.challenges.utils.LevelStatus;
|
||||||
import world.bentobox.challenges.utils.Utils;
|
import world.bentobox.challenges.utils.Utils;
|
||||||
|
|
||||||
@ -98,6 +97,7 @@ public class ChallengesManager
|
|||||||
* String for free Challenge Level.
|
* String for free Challenge Level.
|
||||||
*/
|
*/
|
||||||
public static final String FREE = "";
|
public static final String FREE = "";
|
||||||
|
public static final String VALUE = "[value]";
|
||||||
public static final String USER_ID = "user-id";
|
public static final String USER_ID = "user-id";
|
||||||
public static final String CHALLENGE_ID = "challenge-id";
|
public static final String CHALLENGE_ID = "challenge-id";
|
||||||
public static final String ADMIN_ID = "admin-id";
|
public static final String ADMIN_ID = "admin-id";
|
||||||
@ -113,28 +113,41 @@ public class ChallengesManager
|
|||||||
* This comparator orders challenges by their level, order and name.
|
* This comparator orders challenges by their level, order and name.
|
||||||
*/
|
*/
|
||||||
private final Comparator<Challenge> challengeComparator = (o1, o2) -> {
|
private final Comparator<Challenge> challengeComparator = (o1, o2) -> {
|
||||||
ChallengeLevel o1Level = this.getLevel(o1.getLevel());
|
if (o1.getLevel().equals(o2.getLevel()))
|
||||||
ChallengeLevel o2Level = this.getLevel(o2.getLevel());
|
|
||||||
|
|
||||||
if (o1Level == null && o2Level == null)
|
|
||||||
{
|
{
|
||||||
return Integer.compare(o1.getOrder(), o2.getOrder());
|
if (o1.getOrder() == o2.getOrder())
|
||||||
}
|
{
|
||||||
else if (o1Level == null)
|
// If orders are equal, sort by unique id
|
||||||
{
|
return o1.getUniqueId().compareToIgnoreCase(o2.getUniqueId());
|
||||||
return -1;
|
}
|
||||||
}
|
else
|
||||||
else if (o2Level == null)
|
{
|
||||||
{
|
// If levels are equal, sort them by order numbers.
|
||||||
return 1;
|
return Integer.compare(o1.getOrder(), o2.getOrder());
|
||||||
}
|
}
|
||||||
else if (o1Level.equals(o2Level))
|
|
||||||
{
|
|
||||||
return Integer.compare(o1.getOrder(), o2.getOrder());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Integer.compare(o1Level.getOrder(), o2Level.getOrder());
|
if (o1.getLevel().isEmpty() || o2.getLevel().isEmpty())
|
||||||
|
{
|
||||||
|
// If exist free level challenge, then it should be at the start.
|
||||||
|
return Boolean.compare(o2.getLevel().isEmpty(), o1.getLevel().isEmpty());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChallengeLevel o1Level = this.getLevel(o1.getLevel());
|
||||||
|
ChallengeLevel o2Level = this.getLevel(o2.getLevel());
|
||||||
|
|
||||||
|
if (o1Level == null || o2Level == null)
|
||||||
|
{
|
||||||
|
return Boolean.compare(o1Level == null, o2Level == null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Sort by challenges level order numbers
|
||||||
|
return Integer.compare(o1Level.getOrder(), o2Level.getOrder());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -230,7 +243,7 @@ public class ChallengesManager
|
|||||||
*/
|
*/
|
||||||
private void loadChallenge(@NonNull Challenge challenge)
|
private void loadChallenge(@NonNull Challenge challenge)
|
||||||
{
|
{
|
||||||
this.loadChallenge(challenge, null, true, null, true);
|
this.loadChallenge(challenge, true, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -244,10 +257,9 @@ public class ChallengesManager
|
|||||||
* @return - true if imported
|
* @return - true if imported
|
||||||
*/
|
*/
|
||||||
public boolean loadChallenge(@Nullable Challenge challenge,
|
public boolean loadChallenge(@Nullable Challenge challenge,
|
||||||
World world,
|
boolean overwrite,
|
||||||
boolean overwrite,
|
User user,
|
||||||
User user,
|
boolean silent)
|
||||||
boolean silent)
|
|
||||||
{
|
{
|
||||||
// This may happen if database somehow failed to load challenge and return
|
// This may happen if database somehow failed to load challenge and return
|
||||||
// null as input.
|
// null as input.
|
||||||
@ -255,10 +267,7 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("load-error", "[value]", "NULL"));
|
||||||
world,
|
|
||||||
Constants.ERRORS + "load-error",
|
|
||||||
Constants.PARAMETER_VALUE, "NULL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -268,10 +277,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.invalid-challenge",
|
||||||
world,
|
"[challenge]", challenge.getUniqueId()));
|
||||||
Constants.ERRORS + "invalid-challenge",
|
|
||||||
Constants.PARAMETER_CHALLENGE, challenge.getUniqueId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logWarning("Data for challenge `" + challenge.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
this.addon.logWarning("Data for challenge `" + challenge.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
||||||
@ -286,10 +293,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-skipping",
|
||||||
world,
|
VALUE, challenge.getFriendlyName()));
|
||||||
Constants.MESSAGES + "load-skipping",
|
|
||||||
Constants.PARAMETER_VALUE, challenge.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -298,10 +303,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-overwriting",
|
||||||
world,
|
VALUE, challenge.getFriendlyName()));
|
||||||
Constants.MESSAGES + "load-overwriting",
|
|
||||||
Constants.PARAMETER_VALUE, challenge.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,10 +312,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-add",
|
||||||
world,
|
VALUE, challenge.getFriendlyName()));
|
||||||
Constants.MESSAGES + "load-add",
|
|
||||||
Constants.PARAMETER_VALUE, challenge.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +329,7 @@ public class ChallengesManager
|
|||||||
*/
|
*/
|
||||||
private void loadLevel(@NonNull ChallengeLevel level)
|
private void loadLevel(@NonNull ChallengeLevel level)
|
||||||
{
|
{
|
||||||
this.loadLevel(level, null, true, null, true);
|
this.loadLevel(level, true, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -343,7 +344,6 @@ public class ChallengesManager
|
|||||||
* @return boolean that indicate about load status.
|
* @return boolean that indicate about load status.
|
||||||
*/
|
*/
|
||||||
public boolean loadLevel(@Nullable ChallengeLevel level,
|
public boolean loadLevel(@Nullable ChallengeLevel level,
|
||||||
World world,
|
|
||||||
boolean overwrite,
|
boolean overwrite,
|
||||||
User user,
|
User user,
|
||||||
boolean silent)
|
boolean silent)
|
||||||
@ -354,10 +354,7 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("load-error", "[value]", "NULL"));
|
||||||
world,
|
|
||||||
Constants.ERRORS + "load-error",
|
|
||||||
Constants.PARAMETER_VALUE, "NULL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -367,10 +364,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.invalid-level",
|
||||||
world,
|
"[level]", level.getUniqueId()));
|
||||||
Constants.ERRORS + "invalid-level",
|
|
||||||
"[level]", level.getUniqueId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logWarning("Data for level `" + level.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
this.addon.logWarning("Data for level `" + level.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
||||||
@ -381,10 +376,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.load-error",
|
||||||
world,
|
VALUE, level.getFriendlyName()));
|
||||||
Constants.ERRORS + "load-error",
|
|
||||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -400,10 +393,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-skipping",
|
||||||
world,
|
VALUE, level.getFriendlyName()));
|
||||||
Constants.MESSAGES + "load-skipping",
|
|
||||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -412,10 +403,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-overwriting",
|
||||||
world,
|
VALUE, level.getFriendlyName()));
|
||||||
Constants.MESSAGES + "load-overwriting",
|
|
||||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,10 +412,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-add",
|
||||||
world,
|
VALUE, level.getFriendlyName()));
|
||||||
Constants.MESSAGES + "load-add",
|
|
||||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +499,7 @@ public class ChallengesManager
|
|||||||
if (!this.challengeCacheData.containsKey(uniqueID))
|
if (!this.challengeCacheData.containsKey(uniqueID))
|
||||||
{
|
{
|
||||||
if (!this.challengeDatabase.objectExists(uniqueID) ||
|
if (!this.challengeDatabase.objectExists(uniqueID) ||
|
||||||
!this.loadChallenge(this.challengeDatabase.loadObject(uniqueID), Bukkit.getWorld(level.getWorld()), false, null, true))
|
!this.loadChallenge(this.challengeDatabase.loadObject(uniqueID), false, null, true))
|
||||||
{
|
{
|
||||||
this.addon.logError("Cannot find " + uniqueID + " challenge for " + level.getUniqueId());
|
this.addon.logError("Cannot find " + uniqueID + " challenge for " + level.getUniqueId());
|
||||||
return false;
|
return false;
|
||||||
@ -666,9 +653,7 @@ public class ChallengesManager
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.migrate-start"));
|
||||||
world,
|
|
||||||
Constants.MESSAGES + "migrate-start");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -684,9 +669,7 @@ public class ChallengesManager
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.migrate-end"));
|
||||||
world,
|
|
||||||
Constants.MESSAGES + "migrate-end");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -697,9 +680,7 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(user,
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.migrate-not"));
|
||||||
world,
|
|
||||||
Constants.MESSAGES + "migrate-not");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1126,20 +1107,11 @@ public class ChallengesManager
|
|||||||
// know how many challenges there were and how many has been done. Then
|
// know how many challenges there were and how many has been done. Then
|
||||||
// remove waiver amount to get count of challenges that still necessary to do.
|
// remove waiver amount to get count of challenges that still necessary to do.
|
||||||
|
|
||||||
List<Challenge> previousChallengeList = previousLevel == null ?
|
|
||||||
Collections.emptyList() :
|
|
||||||
this.getLevelChallenges(previousLevel);
|
|
||||||
|
|
||||||
int challengesToDo = previousLevel == null ? 0 :
|
int challengesToDo = previousLevel == null ? 0 :
|
||||||
(previousChallengeList.size() - doneChallengeCount - previousLevel.getWaiverAmount());
|
(previousLevel.getChallenges().size() - doneChallengeCount - previousLevel.getWaiverAmount());
|
||||||
|
|
||||||
List<Challenge> challengeList = this.getLevelChallenges(level);
|
|
||||||
|
|
||||||
// As level already contains unique ids of challenges, just iterate through them.
|
// As level already contains unique ids of challenges, just iterate through them.
|
||||||
doneChallengeCount = (int) challengeList.stream().
|
doneChallengeCount = (int) level.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
||||||
map(Challenge::getUniqueId).
|
|
||||||
filter(playerData::isChallengeDone).
|
|
||||||
count();
|
|
||||||
|
|
||||||
// Mark if level is unlocked
|
// Mark if level is unlocked
|
||||||
boolean unlocked = previousUnlocked && challengesToDo <= 0;
|
boolean unlocked = previousUnlocked && challengesToDo <= 0;
|
||||||
@ -1148,7 +1120,7 @@ public class ChallengesManager
|
|||||||
level,
|
level,
|
||||||
previousLevel,
|
previousLevel,
|
||||||
challengesToDo,
|
challengesToDo,
|
||||||
challengeList.size() == doneChallengeCount,
|
level.getChallenges().size() == doneChallengeCount,
|
||||||
unlocked));
|
unlocked));
|
||||||
|
|
||||||
previousLevel = level;
|
previousLevel = level;
|
||||||
@ -1184,27 +1156,18 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
ChallengeLevel previousLevel = levelIndex < 1 ? null : challengeLevelList.get(levelIndex - 1);
|
ChallengeLevel previousLevel = levelIndex < 1 ? null : challengeLevelList.get(levelIndex - 1);
|
||||||
|
|
||||||
List<Challenge> previousChallengeList = previousLevel == null ? Collections.emptyList() :
|
|
||||||
this.getLevelChallenges(previousLevel);
|
|
||||||
|
|
||||||
int challengesToDo = previousLevel == null ? 0 :
|
int challengesToDo = previousLevel == null ? 0 :
|
||||||
(previousChallengeList.size() - previousLevel.getWaiverAmount()) -
|
(previousLevel.getChallenges().size() - previousLevel.getWaiverAmount()) -
|
||||||
(int) previousChallengeList.stream().map(Challenge::getUniqueId).
|
(int) previousLevel.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
||||||
filter(playerData::isChallengeDone).count();
|
|
||||||
|
|
||||||
List<Challenge> challengeList = this.getLevelChallenges(level);
|
|
||||||
|
|
||||||
// As level already contains unique ids of challenges, just iterate through them.
|
// As level already contains unique ids of challenges, just iterate through them.
|
||||||
int doneChallengeCount = (int) challengeList.stream().
|
int doneChallengeCount = (int) level.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
||||||
map(Challenge::getUniqueId).
|
|
||||||
filter(playerData::isChallengeDone).
|
|
||||||
count();
|
|
||||||
|
|
||||||
return new LevelStatus(
|
return new LevelStatus(
|
||||||
level,
|
level,
|
||||||
previousLevel,
|
previousLevel,
|
||||||
challengesToDo,
|
challengesToDo,
|
||||||
challengeList.size() == doneChallengeCount,
|
level.getChallenges().size() == doneChallengeCount,
|
||||||
challengesToDo <= 0);
|
challengesToDo <= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1232,15 +1195,9 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
this.addPlayerData(storageDataID);
|
this.addPlayerData(storageDataID);
|
||||||
ChallengesPlayerData playerData = this.playerCacheData.get(storageDataID);
|
ChallengesPlayerData playerData = this.playerCacheData.get(storageDataID);
|
||||||
|
long doneChallengeCount = level.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
||||||
|
|
||||||
List<Challenge> challengeList = this.getLevelChallenges(level);
|
return level.getChallenges().size() == doneChallengeCount;
|
||||||
|
|
||||||
long doneChallengeCount = challengeList.stream().
|
|
||||||
map(Challenge::getUniqueId).
|
|
||||||
filter(playerData::isChallengeDone).
|
|
||||||
count();
|
|
||||||
|
|
||||||
return challengeList.size() == doneChallengeCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1799,11 +1756,11 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
// Free Challenges hides under FREE level.
|
// Free Challenges hides under FREE level.
|
||||||
return this.islandWorldManager.getAddon(world).map(gameMode ->
|
return this.islandWorldManager.getAddon(world).map(gameMode ->
|
||||||
this.challengeCacheData.values().stream().
|
this.challengeCacheData.values().stream().
|
||||||
filter(challenge -> challenge.getLevel().equals(FREE) &&
|
filter(challenge -> challenge.getLevel().equals(FREE) &&
|
||||||
challenge.matchGameMode(gameMode.getDescription().getName())).
|
challenge.matchGameMode(gameMode.getDescription().getName())).
|
||||||
sorted(Comparator.comparing(Challenge::getOrder)).
|
sorted(Comparator.comparing(Challenge::getOrder)).
|
||||||
collect(Collectors.toList())).
|
collect(Collectors.toList())).
|
||||||
orElse(Collections.emptyList());
|
orElse(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1814,24 +1771,10 @@ public class ChallengesManager
|
|||||||
* @return List with challenges in given level.
|
* @return List with challenges in given level.
|
||||||
*/
|
*/
|
||||||
public List<Challenge> getLevelChallenges(ChallengeLevel level)
|
public List<Challenge> getLevelChallenges(ChallengeLevel level)
|
||||||
{
|
|
||||||
return this.getLevelChallenges(level,
|
|
||||||
this.addon.getChallengesSettings().isIncludeUndeployed());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Level which challenges must be received
|
|
||||||
* @param level Challenge level.
|
|
||||||
* @param includeUndeployed if true, then include challenges that are not deployed.
|
|
||||||
* @return List with challenges in given level.
|
|
||||||
*/
|
|
||||||
public List<Challenge> getLevelChallenges(ChallengeLevel level, boolean includeUndeployed)
|
|
||||||
{
|
{
|
||||||
return level.getChallenges().stream().
|
return level.getChallenges().stream().
|
||||||
map(this::getChallenge).
|
map(this::getChallenge).
|
||||||
filter(Objects::nonNull).
|
filter(Objects::nonNull).
|
||||||
filter(challenge -> includeUndeployed || challenge.isDeployed()).
|
|
||||||
sorted(Comparator.comparing(Challenge::getOrder)).
|
sorted(Comparator.comparing(Challenge::getOrder)).
|
||||||
collect(Collectors.toList());
|
collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -1950,9 +1893,7 @@ public class ChallengesManager
|
|||||||
*/
|
*/
|
||||||
public int getChallengeCount(World world)
|
public int getChallengeCount(World world)
|
||||||
{
|
{
|
||||||
return (int) this.getAllChallenges(world).stream().
|
return this.getAllChallenges(world).size();
|
||||||
filter(challenge -> this.settings.isIncludeUndeployed() || challenge.isDeployed()).
|
|
||||||
count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,12 +7,12 @@
|
|||||||
package world.bentobox.challenges.panel;
|
package world.bentobox.challenges.panel;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.conversations.*;
|
import org.bukkit.conversations.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -65,7 +65,7 @@ public class ConversationUtils
|
|||||||
|
|
||||||
// Split and check if they exist in valid entries.
|
// Split and check if they exist in valid entries.
|
||||||
String[] accepted = validEntry.toLowerCase().replaceAll("\\s", "").split(",");
|
String[] accepted = validEntry.toLowerCase().replaceAll("\\s", "").split(",");
|
||||||
return Arrays.asList(accepted).contains(input.toLowerCase());
|
return ArrayUtils.contains(accepted, input.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class ConversationUtils
|
|||||||
{
|
{
|
||||||
String validEntry = user.getTranslation(Constants.CONVERSATIONS + "confirm-string").toLowerCase();
|
String validEntry = user.getTranslation(Constants.CONVERSATIONS + "confirm-string").toLowerCase();
|
||||||
|
|
||||||
if (Arrays.asList(validEntry.replaceAll("\\s", "").split(",")).contains(input.toLowerCase()))
|
if (ArrayUtils.contains(validEntry.replaceAll("\\s", "").split(","), input.toLowerCase()))
|
||||||
{
|
{
|
||||||
// Add answer to consumer.
|
// Add answer to consumer.
|
||||||
consumer.accept(true);
|
consumer.accept(true);
|
||||||
@ -432,7 +432,7 @@ public class ConversationUtils
|
|||||||
toLowerCase().replaceAll("\\s", "").
|
toLowerCase().replaceAll("\\s", "").
|
||||||
split(",");
|
split(",");
|
||||||
|
|
||||||
if (input != null && Arrays.asList(exit).contains(input.toLowerCase()))
|
if (input != null && ArrayUtils.contains(exit, input.toLowerCase()))
|
||||||
{
|
{
|
||||||
return messagePrompt;
|
return messagePrompt;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -212,7 +212,7 @@ public class EditLevelPanel extends CommonPagedPanel<Challenge>
|
|||||||
private void buildChallengesPanel(PanelBuilder panelBuilder)
|
private void buildChallengesPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
List<Challenge> challengeList = this.addon.getChallengesManager().
|
List<Challenge> challengeList = this.addon.getChallengesManager().
|
||||||
getLevelChallenges(this.challengeLevel, true).stream().
|
getLevelChallenges(this.challengeLevel).stream().
|
||||||
filter(challenge -> this.searchString.isBlank() ||
|
filter(challenge -> this.searchString.isBlank() ||
|
||||||
challenge.getFriendlyName().toLowerCase().contains(this.searchString.toLowerCase()) ||
|
challenge.getFriendlyName().toLowerCase().contains(this.searchString.toLowerCase()) ||
|
||||||
challenge.getUniqueId().toLowerCase().contains(this.searchString.toLowerCase()) ||
|
challenge.getUniqueId().toLowerCase().contains(this.searchString.toLowerCase()) ||
|
||||||
@ -784,7 +784,7 @@ public class EditLevelPanel extends CommonPagedPanel<Challenge>
|
|||||||
|
|
||||||
// Get all challenge that is not in current level.
|
// Get all challenge that is not in current level.
|
||||||
List<Challenge> challengeList = manager.getAllChallenges(this.world);
|
List<Challenge> challengeList = manager.getAllChallenges(this.world);
|
||||||
challengeList.removeAll(manager.getLevelChallenges(this.challengeLevel, true));
|
challengeList.removeAll(manager.getLevelChallenges(this.challengeLevel));
|
||||||
|
|
||||||
// Generate descriptions for these challenges
|
// Generate descriptions for these challenges
|
||||||
Map<Challenge, List<String>> challengeDescriptionMap = challengeList.stream().
|
Map<Challenge, List<String>> challengeDescriptionMap = challengeList.stream().
|
||||||
@ -820,7 +820,7 @@ public class EditLevelPanel extends CommonPagedPanel<Challenge>
|
|||||||
ChallengesManager manager = this.addon.getChallengesManager();
|
ChallengesManager manager = this.addon.getChallengesManager();
|
||||||
|
|
||||||
// Get all challenge that is in current level.
|
// Get all challenge that is in current level.
|
||||||
List<Challenge> challengeList = manager.getLevelChallenges(this.challengeLevel, true);
|
List<Challenge> challengeList = manager.getLevelChallenges(this.challengeLevel);
|
||||||
|
|
||||||
// Generate descriptions for these challenges
|
// Generate descriptions for these challenges
|
||||||
Map<Challenge, List<String>> challengeDescriptionMap = challengeList.stream().
|
Map<Challenge, List<String>> challengeDescriptionMap = challengeList.stream().
|
||||||
|
@ -119,7 +119,6 @@ public class EditSettingsPanel extends CommonPanel
|
|||||||
panelBuilder.item(11, this.getSettingsButton(Button.GLOW_COMPLETED));
|
panelBuilder.item(11, this.getSettingsButton(Button.GLOW_COMPLETED));
|
||||||
panelBuilder.item(20, this.getSettingsButton(Button.REMOVE_COMPLETED));
|
panelBuilder.item(20, this.getSettingsButton(Button.REMOVE_COMPLETED));
|
||||||
panelBuilder.item(29, this.getSettingsButton(Button.VISIBILITY_MODE));
|
panelBuilder.item(29, this.getSettingsButton(Button.VISIBILITY_MODE));
|
||||||
panelBuilder.item(30, this.getSettingsButton(Button.INCLUDE_UNDEPLOYED));
|
|
||||||
|
|
||||||
panelBuilder.item(21, this.getSettingsButton(Button.LOCKED_LEVEL_ICON));
|
panelBuilder.item(21, this.getSettingsButton(Button.LOCKED_LEVEL_ICON));
|
||||||
|
|
||||||
@ -415,6 +414,9 @@ public class EditSettingsPanel extends CommonPanel
|
|||||||
description.add(this.user.getTranslation(reference +
|
description.add(this.user.getTranslation(reference +
|
||||||
(this.settings.getVisibilityMode().equals(VisibilityMode.HIDDEN) ? "enabled" : "disabled")) +
|
(this.settings.getVisibilityMode().equals(VisibilityMode.HIDDEN) ? "enabled" : "disabled")) +
|
||||||
this.user.getTranslation(reference + "hidden"));
|
this.user.getTranslation(reference + "hidden"));
|
||||||
|
description.add(this.user.getTranslation(reference +
|
||||||
|
(this.settings.getVisibilityMode().equals(VisibilityMode.TOGGLEABLE) ? "enabled" : "disabled")) +
|
||||||
|
this.user.getTranslation(reference + "toggleable"));
|
||||||
|
|
||||||
if (this.settings.getVisibilityMode().equals(VisibilityMode.VISIBLE))
|
if (this.settings.getVisibilityMode().equals(VisibilityMode.VISIBLE))
|
||||||
{
|
{
|
||||||
@ -452,22 +454,6 @@ public class EditSettingsPanel extends CommonPanel
|
|||||||
description.add(this.user.getTranslation(Constants.TIPS + "left-click-to-cycle"));
|
description.add(this.user.getTranslation(Constants.TIPS + "left-click-to-cycle"));
|
||||||
description.add(this.user.getTranslation(Constants.TIPS + "right-click-to-cycle"));
|
description.add(this.user.getTranslation(Constants.TIPS + "right-click-to-cycle"));
|
||||||
}
|
}
|
||||||
case INCLUDE_UNDEPLOYED -> {
|
|
||||||
description.add(this.user.getTranslation(reference +
|
|
||||||
(this.settings.isIncludeUndeployed() ? "enabled" : "disabled")));
|
|
||||||
|
|
||||||
icon = new ItemStack(Material.BARREL);
|
|
||||||
clickHandler = (panel, user1, clickType, i) -> {
|
|
||||||
this.settings.setIncludeUndeployed(!this.settings.isIncludeUndeployed());
|
|
||||||
panel.getInventory().setItem(i, this.getSettingsButton(button).getItem());
|
|
||||||
this.addon.saveSettings();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
glow = this.settings.isIncludeUndeployed();
|
|
||||||
|
|
||||||
description.add("");
|
|
||||||
description.add(this.user.getTranslation(Constants.TIPS + "click-to-toggle"));
|
|
||||||
}
|
|
||||||
default -> {
|
default -> {
|
||||||
icon = new ItemStack(Material.PAPER);
|
icon = new ItemStack(Material.PAPER);
|
||||||
clickHandler = null;
|
clickHandler = null;
|
||||||
@ -571,10 +557,6 @@ public class EditSettingsPanel extends CommonPanel
|
|||||||
LOCKED_LEVEL_ICON,
|
LOCKED_LEVEL_ICON,
|
||||||
SHOW_TITLE,
|
SHOW_TITLE,
|
||||||
TITLE_SHOWTIME,
|
TITLE_SHOWTIME,
|
||||||
/**
|
|
||||||
* This allows to switch between counting/not couting undeployed challenges.
|
|
||||||
*/
|
|
||||||
INCLUDE_UNDEPLOYED,
|
|
||||||
/**
|
/**
|
||||||
* This allows to switch between different challenges visibility modes.
|
* This allows to switch between different challenges visibility modes.
|
||||||
*/
|
*/
|
||||||
|
@ -166,9 +166,8 @@ public class LibraryPanel extends CommonPagedPanel<LibraryEntry>
|
|||||||
{
|
{
|
||||||
if (this.libraryEntries.isEmpty())
|
if (this.libraryEntries.isEmpty())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation(
|
||||||
this.world,
|
Constants.ERRORS + "no-library-entries"));
|
||||||
Constants.ERRORS + "no-library-entries");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,9 +311,8 @@ public class LibraryPanel extends CommonPagedPanel<LibraryEntry>
|
|||||||
{
|
{
|
||||||
this.blockedForDownland = true;
|
this.blockedForDownland = true;
|
||||||
|
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation(
|
||||||
this.world,
|
Constants.MESSAGES + "start-downloading"));
|
||||||
Constants.MESSAGES + "start-downloading");
|
|
||||||
|
|
||||||
// Run download task after 5 ticks.
|
// Run download task after 5 ticks.
|
||||||
this.updateTask = this.addon.getPlugin().getServer().getScheduler().
|
this.updateTask = this.addon.getPlugin().getServer().getScheduler().
|
||||||
|
@ -8,7 +8,6 @@ package world.bentobox.challenges.panel.user;
|
|||||||
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -77,7 +76,7 @@ public class ChallengesPanel extends CommonPanel
|
|||||||
if (!this.containsChallenges)
|
if (!this.containsChallenges)
|
||||||
{
|
{
|
||||||
this.addon.logError("There are no challenges set up!");
|
this.addon.logError("There are no challenges set up!");
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "no-challenges");
|
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-challenges"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +129,7 @@ public class ChallengesPanel extends CommonPanel
|
|||||||
{
|
{
|
||||||
if (this.lastSelectedLevel != null)
|
if (this.lastSelectedLevel != null)
|
||||||
{
|
{
|
||||||
this.challengeList = this.manager.getLevelChallenges(this.lastSelectedLevel.getLevel(), true);
|
this.challengeList = this.manager.getLevelChallenges(this.lastSelectedLevel.getLevel());
|
||||||
|
|
||||||
if (this.addon.getChallengesSettings().isRemoveCompleteOneTimeChallenges())
|
if (this.addon.getChallengesSettings().isRemoveCompleteOneTimeChallenges())
|
||||||
{
|
{
|
||||||
@ -275,43 +274,11 @@ public class ChallengesPanel extends CommonPanel
|
|||||||
builder.description(this.generateChallengeDescription(challenge, this.user));
|
builder.description(this.generateChallengeDescription(challenge, this.user));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If challenge is not repeatable, remove all other actions beside "COMPLETE".
|
|
||||||
// If challenge is completed all possible times, remove action.
|
|
||||||
|
|
||||||
List<ItemTemplateRecord.ActionRecords> actions = template.actions().stream().
|
|
||||||
filter(action -> challenge.isRepeatable() || "COMPLETE".equalsIgnoreCase(action.actionType())).
|
|
||||||
filter(action ->
|
|
||||||
{
|
|
||||||
boolean isCompletedOnce =
|
|
||||||
this.manager.isChallengeComplete(this.user.getUniqueId(), this.world, challenge);
|
|
||||||
|
|
||||||
if (!isCompletedOnce)
|
|
||||||
{
|
|
||||||
// Is not completed once, then it must appear.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (challenge.isRepeatable() && challenge.getMaxTimes() <= 0)
|
|
||||||
{
|
|
||||||
// Challenge is unlimited. Must appear in the list.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Challenge still have some opened slots.
|
|
||||||
|
|
||||||
long doneTimes = challenge.isRepeatable() ?
|
|
||||||
this.manager.getChallengeTimes(this.user, this.world, challenge) : 1;
|
|
||||||
|
|
||||||
return challenge.isRepeatable() && doneTimes < challenge.getMaxTimes();
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
toList();
|
|
||||||
|
|
||||||
// Add Click handler
|
// Add Click handler
|
||||||
builder.clickHandler((panel, user, clickType, i) -> {
|
builder.clickHandler((panel, user, clickType, i) -> {
|
||||||
for (ItemTemplateRecord.ActionRecords action : actions)
|
for (ItemTemplateRecord.ActionRecords action : template.actions())
|
||||||
{
|
{
|
||||||
if (clickType == action.clickType() || clickType.equals(ClickType.UNKNOWN))
|
if (clickType == action.clickType())
|
||||||
{
|
{
|
||||||
switch (action.actionType().toUpperCase())
|
switch (action.actionType().toUpperCase())
|
||||||
{
|
{
|
||||||
@ -401,8 +368,9 @@ public class ChallengesPanel extends CommonPanel
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Collect tooltips.
|
// Collect tooltips.
|
||||||
List<String> tooltips = actions.stream().
|
List<String> tooltips = template.actions().stream().
|
||||||
filter(action -> action.tooltip() != null).
|
filter(action -> action.tooltip() != null).
|
||||||
|
filter(action -> challenge.isRepeatable() || "COMPLETE".equalsIgnoreCase(action.actionType())).
|
||||||
map(action -> this.user.getTranslation(this.world, action.tooltip())).
|
map(action -> this.user.getTranslation(this.world, action.tooltip())).
|
||||||
filter(text -> !text.isBlank()).
|
filter(text -> !text.isBlank()).
|
||||||
collect(Collectors.toCollection(() -> new ArrayList<>(template.actions().size())));
|
collect(Collectors.toCollection(() -> new ArrayList<>(template.actions().size())));
|
||||||
|
@ -265,21 +265,18 @@ public class TryToComplete
|
|||||||
// Send message about first completion only if it is completed only once.
|
// Send message about first completion only if it is completed only once.
|
||||||
if (result.getFactor() == 1)
|
if (result.getFactor() == 1)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-completed-challenge",
|
||||||
this.world,
|
"[value]", this.challenge.getFriendlyName()));
|
||||||
Constants.MESSAGES + "you-completed-challenge",
|
|
||||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
||||||
{
|
{
|
||||||
Bukkit.getOnlinePlayers().stream().
|
Bukkit.getOnlinePlayers().stream().
|
||||||
map(User::getInstance).
|
map(User::getInstance).
|
||||||
forEach(user -> Utils.sendMessage(user,
|
forEach(user -> Utils.sendMessage(user, user.getTranslation(
|
||||||
this.world,
|
"challenges.messages.name-has-completed-challenge",
|
||||||
Constants.MESSAGES + "name-has-completed-challenge",
|
|
||||||
Constants.PARAMETER_NAME, this.user.getName(),
|
Constants.PARAMETER_NAME, this.user.getName(),
|
||||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName()));
|
"[value]", this.challenge.getFriendlyName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends title to player on challenge completion
|
// sends title to player on challenge completion
|
||||||
@ -330,18 +327,14 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (result.getFactor() > 1)
|
if (result.getFactor() > 1)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-repeated-challenge-multiple",
|
||||||
this.world,
|
"[value]", this.challenge.getFriendlyName(),
|
||||||
Constants.MESSAGES + "you-repeated-challenge-multiple",
|
"[count]", Integer.toString(result.getFactor())));
|
||||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName(),
|
|
||||||
"[count]", Integer.toString(result.getFactor()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-repeated-challenge",
|
||||||
this.world,
|
"[value]", this.challenge.getFriendlyName()));
|
||||||
Constants.MESSAGES + "you-repeated-challenge",
|
|
||||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,20 +372,17 @@ public class TryToComplete
|
|||||||
// Run commands
|
// Run commands
|
||||||
this.runCommands(level.getRewardCommands());
|
this.runCommands(level.getRewardCommands());
|
||||||
|
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-completed-level",
|
||||||
this.world,
|
"[value]", level.getFriendlyName()));
|
||||||
Constants.MESSAGES + "you-completed-level",
|
|
||||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
|
||||||
|
|
||||||
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
||||||
{
|
{
|
||||||
Bukkit.getOnlinePlayers().stream().
|
Bukkit.getOnlinePlayers().stream().
|
||||||
map(User::getInstance).
|
map(User::getInstance).
|
||||||
forEach(user -> Utils.sendMessage(user,
|
forEach(user -> Utils.sendMessage(user, user.getTranslation(
|
||||||
this.world,
|
"challenges.messages.name-has-completed-level",
|
||||||
Constants.MESSAGES + "name-has-completed-level",
|
|
||||||
Constants.PARAMETER_NAME, this.user.getName(),
|
Constants.PARAMETER_NAME, this.user.getName(),
|
||||||
Constants.PARAMETER_VALUE, level.getFriendlyName()));
|
"[value]", level.getFriendlyName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.manager.setLevelComplete(this.user, this.world, level);
|
this.manager.setLevelComplete(this.user, this.world, level);
|
||||||
@ -457,8 +447,7 @@ public class TryToComplete
|
|||||||
if (sumEverything != removedAmount)
|
if (sumEverything != removedAmount)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user,
|
||||||
this.world,
|
this.user.getTranslation("challenges.errors.cannot-remove-items"));
|
||||||
Constants.ERRORS + "cannot-remove-items");
|
|
||||||
|
|
||||||
result.removedItems = removedItems;
|
result.removedItems = removedItems;
|
||||||
result.meetsRequirements = false;
|
result.meetsRequirements = false;
|
||||||
@ -506,54 +495,45 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ITEM, BLOCK -> {
|
case ITEM, BLOCK -> {
|
||||||
|
int statistic = this.user.getPlayer().getStatistic(requirements.getStatistic());
|
||||||
|
|
||||||
if (requirements.getMaterial() == null)
|
if (requirements.getMaterial() == null)
|
||||||
{
|
{
|
||||||
// Just a sanity check. Material cannot be null at this point of code.
|
// Just a sanity check. Material cannot be null at this point of code.
|
||||||
removeAmount = 0;
|
removeAmount = 0;
|
||||||
}
|
}
|
||||||
|
else if (removeAmount >= statistic)
|
||||||
|
{
|
||||||
|
this.user.getPlayer().setStatistic(requirements.getStatistic(), requirements.getMaterial(), 0);
|
||||||
|
removeAmount -= statistic;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int statistic = this.user.getPlayer().getStatistic(requirements.getStatistic(),
|
this.user.getPlayer().setStatistic(requirements.getStatistic(),
|
||||||
requirements.getMaterial());
|
requirements.getMaterial(),
|
||||||
|
statistic - removeAmount);
|
||||||
if (removeAmount >= statistic)
|
removeAmount = 0;
|
||||||
{
|
|
||||||
this.user.getPlayer()
|
|
||||||
.setStatistic(requirements.getStatistic(), requirements.getMaterial(), 0);
|
|
||||||
removeAmount -= statistic;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.user.getPlayer().setStatistic(requirements.getStatistic(),
|
|
||||||
requirements.getMaterial(),
|
|
||||||
statistic - removeAmount);
|
|
||||||
removeAmount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ENTITY -> {
|
case ENTITY -> {
|
||||||
|
int statistic = this.user.getPlayer().getStatistic(requirements.getStatistic());
|
||||||
|
|
||||||
if (requirements.getEntity() == null)
|
if (requirements.getEntity() == null)
|
||||||
{
|
{
|
||||||
// Just a sanity check. Entity cannot be null at this point of code.
|
// Just a sanity check. Entity cannot be null at this point of code.
|
||||||
removeAmount = 0;
|
removeAmount = 0;
|
||||||
}
|
}
|
||||||
|
else if (removeAmount >= statistic)
|
||||||
|
{
|
||||||
|
this.user.getPlayer().setStatistic(requirements.getStatistic(), requirements.getEntity(), 0);
|
||||||
|
removeAmount -= statistic;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int statistic = this.user.getPlayer().getStatistic(requirements.getStatistic(),
|
this.user.getPlayer().setStatistic(requirements.getStatistic(),
|
||||||
requirements.getEntity());
|
requirements.getEntity(),
|
||||||
|
statistic - removeAmount);
|
||||||
if (removeAmount >= statistic)
|
removeAmount = 0;
|
||||||
{
|
|
||||||
this.user.getPlayer().setStatistic(requirements.getStatistic(), requirements.getEntity(), 0);
|
|
||||||
removeAmount -= statistic;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.user.getPlayer().setStatistic(requirements.getStatistic(),
|
|
||||||
requirements.getEntity(),
|
|
||||||
statistic - removeAmount);
|
|
||||||
removeAmount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -597,57 +577,45 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ITEM, BLOCK -> {
|
case ITEM, BLOCK -> {
|
||||||
|
int statistic = player.getStatistic(requirements.getStatistic());
|
||||||
|
|
||||||
if (requirements.getMaterial() == null)
|
if (requirements.getMaterial() == null)
|
||||||
{
|
{
|
||||||
// Just a sanity check. Entity cannot be null at this point of code.
|
// Just a sanity check. Entity cannot be null at this point of code.
|
||||||
removeAmount = 0;
|
removeAmount = 0;
|
||||||
}
|
}
|
||||||
|
else if (removeAmount >= statistic)
|
||||||
|
{
|
||||||
|
removeAmount -= statistic;
|
||||||
|
player.setStatistic(requirements.getStatistic(), requirements.getMaterial(), 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int statistic = player.getStatistic(requirements.getStatistic(),
|
player.setStatistic(requirements.getStatistic(),
|
||||||
requirements.getMaterial());
|
requirements.getMaterial(),
|
||||||
|
statistic - removeAmount);
|
||||||
if (removeAmount >= statistic)
|
removeAmount = 0;
|
||||||
{
|
|
||||||
removeAmount -= statistic;
|
|
||||||
player.setStatistic(requirements.getStatistic(),
|
|
||||||
requirements.getMaterial(),
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.setStatistic(requirements.getStatistic(),
|
|
||||||
requirements.getMaterial(),
|
|
||||||
statistic - removeAmount);
|
|
||||||
removeAmount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ENTITY -> {
|
case ENTITY -> {
|
||||||
|
int statistic = player.getStatistic(requirements.getStatistic());
|
||||||
|
|
||||||
if (requirements.getEntity() == null)
|
if (requirements.getEntity() == null)
|
||||||
{
|
{
|
||||||
// Just a sanity check. Entity cannot be null at this point of code.
|
// Just a sanity check. Entity cannot be null at this point of code.
|
||||||
removeAmount = 0;
|
removeAmount = 0;
|
||||||
}
|
}
|
||||||
|
else if (removeAmount >= statistic)
|
||||||
|
{
|
||||||
|
removeAmount -= statistic;
|
||||||
|
player.setStatistic(requirements.getStatistic(), requirements.getEntity(), 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int statistic = player.getStatistic(requirements.getStatistic(),
|
player.setStatistic(requirements.getStatistic(),
|
||||||
requirements.getEntity());
|
requirements.getEntity(),
|
||||||
|
statistic - removeAmount);
|
||||||
if (removeAmount >= statistic)
|
removeAmount = 0;
|
||||||
{
|
|
||||||
removeAmount -= statistic;
|
|
||||||
player.setStatistic(requirements.getStatistic(),
|
|
||||||
requirements.getEntity(),
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.setStatistic(requirements.getStatistic(),
|
|
||||||
requirements.getEntity(),
|
|
||||||
statistic - removeAmount);
|
|
||||||
removeAmount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -672,18 +640,18 @@ public class TryToComplete
|
|||||||
// Check the world
|
// Check the world
|
||||||
if (!this.challenge.isDeployed())
|
if (!this.challenge.isDeployed())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-deployed");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-deployed"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
else if (maxTimes < 1)
|
else if (maxTimes < 1)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-valid-integer");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-valid-integer"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
else if (Util.getWorld(this.world) != Util.getWorld(this.user.getWorld()) ||
|
else if (Util.getWorld(this.world) != Util.getWorld(this.user.getWorld()) ||
|
||||||
!this.challenge.matchGameMode(Utils.getGameMode(this.world)))
|
!this.challenge.matchGameMode(Utils.getGameMode(this.world)))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, "general.errors.wrong-world");
|
Utils.sendMessage(this.user, this.user.getTranslation("general.errors.wrong-world"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Player is not on island
|
// Player is not on island
|
||||||
@ -691,7 +659,7 @@ public class TryToComplete
|
|||||||
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.world) &&
|
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.world) &&
|
||||||
!this.addon.getIslands().locationIsOnIsland(this.user.getPlayer(), this.user.getLocation()))
|
!this.addon.getIslands().locationIsOnIsland(this.user.getPlayer(), this.user.getLocation()))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.MESSAGES + "not-on-island");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-on-island"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check player permission
|
// Check player permission
|
||||||
@ -699,27 +667,27 @@ public class TryToComplete
|
|||||||
map(i -> i.isAllowed(this.user, ChallengesAddon.CHALLENGES_ISLAND_PROTECTION)).
|
map(i -> i.isAllowed(this.user, ChallengesAddon.CHALLENGES_ISLAND_PROTECTION)).
|
||||||
orElse(false))
|
orElse(false))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.MESSAGES + "no-rank");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.no-rank"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check if user has unlocked challenges level.
|
// Check if user has unlocked challenges level.
|
||||||
else if (!this.challenge.getLevel().equals(ChallengesManager.FREE) &&
|
else if (!this.challenge.getLevel().equals(ChallengesManager.FREE) &&
|
||||||
!this.manager.isLevelUnlocked(this.user, this.world, this.manager.getLevel(this.challenge.getLevel())))
|
!this.manager.isLevelUnlocked(this.user, this.world, this.manager.getLevel(this.challenge.getLevel())))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "challenge-level-not-available");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.challenge-level-not-available"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check max times
|
// Check max times
|
||||||
else if (this.challenge.isRepeatable() && this.challenge.getMaxTimes() > 0 &&
|
else if (this.challenge.isRepeatable() && this.challenge.getMaxTimes() > 0 &&
|
||||||
this.manager.getChallengeTimes(this.user, this.world, this.challenge) >= this.challenge.getMaxTimes())
|
this.manager.getChallengeTimes(this.user, this.world, this.challenge) >= this.challenge.getMaxTimes())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-repeatable");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-repeatable"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check repeatability
|
// Check repeatability
|
||||||
else if (!this.challenge.isRepeatable() && this.manager.isChallengeComplete(this.user, this.world, this.challenge))
|
else if (!this.challenge.isRepeatable() && this.manager.isChallengeComplete(this.user, this.world, this.challenge))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-repeatable");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-repeatable"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check if timeout is not broken
|
// Check if timeout is not broken
|
||||||
@ -728,22 +696,22 @@ public class TryToComplete
|
|||||||
long missing = this.manager.getLastCompletionDate(this.user, this.world, challenge) +
|
long missing = this.manager.getLastCompletionDate(this.user, this.world, challenge) +
|
||||||
this.challenge.getTimeout() - System.currentTimeMillis();
|
this.challenge.getTimeout() - System.currentTimeMillis();
|
||||||
|
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "timeout",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.timeout",
|
||||||
"[timeout]", Utils.parseDuration(Duration.ofMillis(this.challenge.getTimeout()), this.user),
|
"[timeout]", Utils.parseDuration(Duration.ofMillis(this.challenge.getTimeout()), this.user),
|
||||||
"[wait-time]", Utils.parseDuration(Duration.ofMillis(missing), this.user));
|
"[wait-time]", Utils.parseDuration(Duration.ofMillis(missing), this.user)));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check environment
|
// Check environment
|
||||||
else if (!this.challenge.getEnvironment().isEmpty() &&
|
else if (!this.challenge.getEnvironment().isEmpty() &&
|
||||||
!this.challenge.getEnvironment().contains(this.user.getWorld().getEnvironment()))
|
!this.challenge.getEnvironment().contains(this.user.getWorld().getEnvironment()))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "wrong-environment");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.wrong-environment"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check permission
|
// Check permission
|
||||||
else if (!this.checkPermissions())
|
else if (!this.checkPermissions())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "no-permission");
|
Utils.sendMessage(this.user, this.user.getTranslation("general.errors.no-permission"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
else if (type.equals(ChallengeType.INVENTORY_TYPE))
|
else if (type.equals(ChallengeType.INVENTORY_TYPE))
|
||||||
@ -823,25 +791,17 @@ public class TryToComplete
|
|||||||
private void runCommands(List<String> commands)
|
private void runCommands(List<String> commands)
|
||||||
{
|
{
|
||||||
// Ignore commands with this perm
|
// Ignore commands with this perm
|
||||||
if (this.user.hasPermission(this.permissionPrefix + "command.challengeexempt") && !this.user.isOp())
|
if (user.hasPermission(this.permissionPrefix + "command.challengeexempt") && !user.isOp())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Island island = this.addon.getIslandsManager().getIsland(this.world, this.user);
|
|
||||||
final String owner = island == null ? "" : this.addon.getPlayers().getName(island.getOwner());
|
|
||||||
|
|
||||||
for (String cmd : commands)
|
for (String cmd : commands)
|
||||||
{
|
{
|
||||||
if (cmd.startsWith("[SELF]"))
|
if (cmd.startsWith("[SELF]"))
|
||||||
{
|
{
|
||||||
String alert = "Running command '" + cmd + "' as " + this.user.getName();
|
String alert = "Running command '" + cmd + "' as " + this.user.getName();
|
||||||
this.addon.getLogger().info(alert);
|
this.addon.getLogger().info(alert);
|
||||||
cmd = cmd.substring(6).
|
cmd = cmd.substring(6).replace(Constants.PARAMETER_PLAYER, this.user.getName()).trim();
|
||||||
replaceAll(Constants.ESC + Constants.PARAMETER_PLAYER, this.user.getName()).
|
|
||||||
replaceAll(Constants.ESC + Constants.PARAMETER_OWNER, owner).
|
|
||||||
replaceAll(Constants.ESC + Constants.PARAMETER_NAME, island == null || island.getName() == null ? "" : island.getName()).
|
|
||||||
trim();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!user.performCommand(cmd))
|
if (!user.performCommand(cmd))
|
||||||
@ -856,17 +816,11 @@ public class TryToComplete
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substitute in any references to player
|
// Substitute in any references to player
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cmd = cmd.replaceAll(Constants.ESC + Constants.PARAMETER_PLAYER, this.user.getName()).
|
if (!this.addon.getServer().dispatchCommand(this.addon.getServer().getConsoleSender(),
|
||||||
replaceAll(Constants.ESC + Constants.PARAMETER_OWNER, owner).
|
cmd.replace(Constants.PARAMETER_PLAYER, this.user.getName())))
|
||||||
replaceAll(Constants.ESC + Constants.PARAMETER_NAME, island == null || island.getName() == null ? "" : island.getName()).
|
|
||||||
trim();
|
|
||||||
|
|
||||||
if (!this.addon.getServer().dispatchCommand(this.addon.getServer().getConsoleSender(), cmd))
|
|
||||||
{
|
{
|
||||||
this.showError(cmd);
|
this.showError(cmd);
|
||||||
}
|
}
|
||||||
@ -940,9 +894,9 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (numInInventory < required.getAmount())
|
if (numInInventory < required.getAmount())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-enough-items",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-items",
|
||||||
"[items]",
|
"[items]",
|
||||||
Utils.prettifyObject(required, this.user));
|
Utils.prettifyObject(required, this.user)));
|
||||||
return EMPTY_RESULT;
|
return EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,8 +906,6 @@ public class TryToComplete
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
requiredItems = Collections.emptyList();
|
requiredItems = Collections.emptyList();
|
||||||
// Set maxTime to 2, to not crash client when completing 2147483647 times.
|
|
||||||
maxTimes = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the result
|
// Return the result
|
||||||
@ -1207,16 +1159,13 @@ public class TryToComplete
|
|||||||
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setBlockQueue(blockFromWorld);
|
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setBlockQueue(blockFromWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-close-enough",
|
||||||
this.world,
|
"[number]", String.valueOf(this.getIslandRequirements().getSearchRadius())));
|
||||||
Constants.ERRORS + "not-close-enough",
|
|
||||||
Constants.PARAMETER_NUMBER, String.valueOf(this.getIslandRequirements().getSearchRadius()));
|
|
||||||
|
|
||||||
blocks.forEach((k, v) -> Utils.sendMessage(this.user,
|
blocks.forEach((k, v) -> Utils.sendMessage(this.user,
|
||||||
this.world,
|
this.user.getTranslation("challenges.errors.you-still-need",
|
||||||
Constants.ERRORS + "you-still-need",
|
"[amount]", String.valueOf(v),
|
||||||
"[amount]", String.valueOf(v),
|
"[item]", Utils.prettifyObject(k, this.user))));
|
||||||
"[item]", Utils.prettifyObject(k, this.user)));
|
|
||||||
|
|
||||||
|
|
||||||
// kick garbage collector
|
// kick garbage collector
|
||||||
@ -1296,11 +1245,9 @@ public class TryToComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
minimalRequirements.forEach((reqEnt, amount) ->
|
minimalRequirements.forEach((reqEnt, amount) ->
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.you-still-need",
|
||||||
this.world,
|
|
||||||
Constants.ERRORS + "you-still-need",
|
|
||||||
"[amount]", String.valueOf(amount),
|
"[amount]", String.valueOf(amount),
|
||||||
"[item]", Utils.prettifyObject(reqEnt, this.user)));
|
"[item]", Utils.prettifyObject(reqEnt, this.user))));
|
||||||
|
|
||||||
// Kick garbage collector
|
// Kick garbage collector
|
||||||
entitiesFound.clear();
|
entitiesFound.clear();
|
||||||
@ -1381,47 +1328,42 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (!this.addon.isLevelProvided() && requirements.getRequiredIslandLevel() != 0)
|
if (!this.addon.isLevelProvided() && requirements.getRequiredIslandLevel() != 0)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "missing-addon");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.missing-addon"));
|
||||||
}
|
}
|
||||||
else if (!this.addon.isEconomyProvided() &&
|
else if (!this.addon.isEconomyProvided() &&
|
||||||
requirements.getRequiredMoney() != 0)
|
requirements.getRequiredMoney() != 0)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "missing-addon");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.missing-addon"));
|
||||||
}
|
}
|
||||||
else if (this.addon.isEconomyProvided() && requirements.getRequiredMoney() < 0)
|
else if (this.addon.isEconomyProvided() && requirements.getRequiredMoney() < 0)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "incorrect");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.incorrect"));
|
||||||
}
|
}
|
||||||
else if (this.addon.isEconomyProvided() &&
|
else if (this.addon.isEconomyProvided() &&
|
||||||
!this.addon.getEconomyProvider().has(this.user, requirements.getRequiredMoney()))
|
!this.addon.getEconomyProvider().has(this.user, requirements.getRequiredMoney()))
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-money",
|
||||||
this.world,
|
"[value]",
|
||||||
Constants.ERRORS + "not-enough-money",
|
Double.toString(requirements.getRequiredMoney())));
|
||||||
Constants.PARAMETER_VALUE, Double.toString(requirements.getRequiredMoney()));
|
|
||||||
}
|
}
|
||||||
else if (requirements.getRequiredExperience() < 0)
|
else if (requirements.getRequiredExperience() < 0)
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "incorrect");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.incorrect"));
|
||||||
}
|
}
|
||||||
else if (this.user.getPlayer().getTotalExperience() < requirements.getRequiredExperience() &&
|
else if (this.user.getPlayer().getTotalExperience() < requirements.getRequiredExperience() &&
|
||||||
this.user.getPlayer().getGameMode() != GameMode.CREATIVE)
|
this.user.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
// Players in creative gamemode has infinite amount of EXP.
|
// Players in creative gamemode has infinite amount of EXP.
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-experience",
|
||||||
this.world,
|
"[value]",
|
||||||
Constants.ERRORS + "not-enough-experience",
|
Integer.toString(requirements.getRequiredExperience())));
|
||||||
Constants.PARAMETER_VALUE,
|
|
||||||
Integer.toString(requirements.getRequiredExperience()));
|
|
||||||
}
|
}
|
||||||
else if (this.addon.isLevelProvided() &&
|
else if (this.addon.isLevelProvided() &&
|
||||||
this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < requirements.getRequiredIslandLevel())
|
this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < requirements.getRequiredIslandLevel())
|
||||||
{
|
{
|
||||||
Utils.sendMessage(this.user,
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.island-level",
|
||||||
this.world,
|
|
||||||
Constants.ERRORS + "island-level",
|
|
||||||
TextVariables.NUMBER,
|
TextVariables.NUMBER,
|
||||||
String.valueOf(requirements.getRequiredIslandLevel()));
|
String.valueOf(requirements.getRequiredIslandLevel())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1484,35 +1426,9 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (currentValue < requirements.getAmount())
|
if (currentValue < requirements.getAmount())
|
||||||
{
|
{
|
||||||
switch (Objects.requireNonNull(requirements.getStatistic()).getType())
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met",
|
||||||
{
|
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
||||||
case ITEM, BLOCK -> {
|
"[value]", String.valueOf(currentValue)));
|
||||||
Utils.sendMessage(this.user,
|
|
||||||
this.world,
|
|
||||||
Constants.ERRORS + "requirement-not-met-material",
|
|
||||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
|
||||||
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
|
|
||||||
"[material]", Utils.prettifyObject(requirements.getMaterial(), this.user),
|
|
||||||
Constants.PARAMETER_VALUE, String.valueOf(currentValue));
|
|
||||||
}
|
|
||||||
case ENTITY -> {
|
|
||||||
Utils.sendMessage(this.user,
|
|
||||||
this.world,
|
|
||||||
Constants.ERRORS + "requirement-not-met-entity",
|
|
||||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
|
||||||
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
|
|
||||||
"[entity]", Utils.prettifyObject(requirements.getEntity(), this.user),
|
|
||||||
Constants.PARAMETER_VALUE, String.valueOf(currentValue));
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
Utils.sendMessage(this.user,
|
|
||||||
this.world,
|
|
||||||
Constants.ERRORS + "requirement-not-met",
|
|
||||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
|
||||||
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
|
|
||||||
Constants.PARAMETER_VALUE, String.valueOf(currentValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -223,9 +223,4 @@ public class Constants
|
|||||||
* Reference string to challenge parameter in translations.
|
* Reference string to challenge parameter in translations.
|
||||||
*/
|
*/
|
||||||
public static final String PARAMETER_CHALLENGE = "[challenge]";
|
public static final String PARAMETER_CHALLENGE = "[challenge]";
|
||||||
|
|
||||||
/**
|
|
||||||
* Regex escape chars.
|
|
||||||
*/
|
|
||||||
public static final String ESC = "\\";
|
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,11 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Statistic;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
import org.bukkit.inventory.meta.*;
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionData;
|
import org.bukkit.potion.PotionData;
|
||||||
import org.bukkit.potion.PotionType;
|
import org.bukkit.potion.PotionType;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@ -194,14 +186,11 @@ public class Utils
|
|||||||
* Send given message to user and add prefix to the start of the message.
|
* Send given message to user and add prefix to the start of the message.
|
||||||
*
|
*
|
||||||
* @param user User who need to receive message.
|
* @param user User who need to receive message.
|
||||||
* @param world Reference to world where message must be send.
|
* @param message String of message that must be send.
|
||||||
* @param translation String of message that must be send.
|
|
||||||
* @param parameters Parameters that must be added to translation.
|
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(User user, World world, String translation, String... parameters)
|
public static void sendMessage(User user, String message)
|
||||||
{
|
{
|
||||||
user.sendMessage(user.getTranslation(world, Constants.CONVERSATIONS + "prefix") +
|
user.sendMessage(user.getTranslation(Constants.CONVERSATIONS + "prefix") + message);
|
||||||
user.getTranslation(world, translation, parameters));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -566,13 +555,6 @@ public class Utils
|
|||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
// Return the display name if it already has one
|
|
||||||
if (object.hasItemMeta()) {
|
|
||||||
ItemMeta im = object.getItemMeta();
|
|
||||||
if (im.hasDisplayName()) {
|
|
||||||
return im.getDisplayName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find addon structure with:
|
// Find addon structure with:
|
||||||
// [addon]:
|
// [addon]:
|
||||||
@ -838,7 +820,7 @@ public class Utils
|
|||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
enchantmentMeta.getStoredEnchants().forEach((enchantment, level) -> {
|
enchantmentMeta.getEnchants().forEach((enchantment, level) -> {
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
builder.append(user.getTranslationOrNothing(Constants.ITEM_STACKS + "meta.enchant-meta",
|
builder.append(user.getTranslationOrNothing(Constants.ITEM_STACKS + "meta.enchant-meta",
|
||||||
"[type]", prettifyObject(enchantment, user),
|
"[type]", prettifyObject(enchantment, user),
|
||||||
@ -883,8 +865,8 @@ public class Utils
|
|||||||
final String metaReference = Constants.ITEM_STACKS + "meta.";
|
final String metaReference = Constants.ITEM_STACKS + "meta.";
|
||||||
|
|
||||||
String meta = user.getTranslationOrNothing(metaReference + "book-meta",
|
String meta = user.getTranslationOrNothing(metaReference + "book-meta",
|
||||||
"[title]", bookMeta.hasTitle() ? bookMeta.getTitle() : "",
|
"[title]", bookMeta.getTitle(),
|
||||||
"[author]", bookMeta.hasAuthor() ? bookMeta.getAuthor() : "");
|
"[author]", bookMeta.getAuthor());
|
||||||
|
|
||||||
return user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
|
return user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
|
||||||
"[type]", prettifyObject(itemType, user),
|
"[type]", prettifyObject(itemType, user),
|
||||||
|
@ -151,11 +151,6 @@ public class WebManager
|
|||||||
if (this.plugin.getSettings().isLogGithubDownloadData())
|
if (this.plugin.getSettings().isLogGithubDownloadData())
|
||||||
{
|
{
|
||||||
this.plugin.log("Could not connect to GitHub.");
|
this.plugin.log("Could not connect to GitHub.");
|
||||||
this.plugin.log(
|
|
||||||
"JSON files can be found at https://github.com/BentoBoxWorld/weblink/tree/master/challenges/library");
|
|
||||||
user.sendRawMessage("Could not connect to GitHub.");
|
|
||||||
user.sendRawMessage(
|
|
||||||
"JSON files can be found at https://github.com/BentoBoxWorld/weblink/tree/master/challenges/library");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -649,12 +649,6 @@ challenges:
|
|||||||
visible: Zeigen Sie sichtbare Herausforderungen
|
visible: Zeigen Sie sichtbare Herausforderungen
|
||||||
hidden: Alle Herausforderungen anzeigen
|
hidden: Alle Herausforderungen anzeigen
|
||||||
toggleable: Umschalten zulassen
|
toggleable: Umschalten zulassen
|
||||||
include_undeployed:
|
|
||||||
name: "&f&l Nicht bereitgestellte Herausforderungen einschließen"
|
|
||||||
description: "&7 Gibt an, ob nicht bereitgestellte \n&7 Herausforderungen
|
|
||||||
\n&7 für den Abschluss von Level \n&7 angerechnet werden sollen."
|
|
||||||
enabled: "&2 Aktiviert"
|
|
||||||
disabled: "&c Deaktiviert"
|
|
||||||
download:
|
download:
|
||||||
name: "&f&l Bibliotheken herunterladen"
|
name: "&f&l Bibliotheken herunterladen"
|
||||||
description: |-
|
description: |-
|
||||||
@ -857,7 +851,7 @@ challenges:
|
|||||||
environment-single: "&7 Limitiert auf [environment]"
|
environment-single: "&7 Limitiert auf [environment]"
|
||||||
environment-title: "&7 Limitiert auf:"
|
environment-title: "&7 Limitiert auf:"
|
||||||
environment-list: " &7 - &e [environment]"
|
environment-list: " &7 - &e [environment]"
|
||||||
permission-single: "&c Erfordert die Berechtigung [permission]"
|
permission-single: "&c Requires [permissions] permission"
|
||||||
permissions-title: "&c Erfordert Berechtigungen:"
|
permissions-title: "&c Erfordert Berechtigungen:"
|
||||||
permissions-list: " &c - [permission]"
|
permissions-list: " &c - [permission]"
|
||||||
island:
|
island:
|
||||||
@ -1004,9 +998,9 @@ challenges:
|
|||||||
write-reward-commands: "&e Bitte geben Sie pro Zeile im Chat einen neuen Belohnungsbefehl
|
write-reward-commands: "&e Bitte geben Sie pro Zeile im Chat einen neuen Belohnungsbefehl
|
||||||
ein und beenden Sie den Chat in einer eigenen Zeile."
|
ein und beenden Sie den Chat in einer eigenen Zeile."
|
||||||
reward-commands-changed: "&a Erfolg, die Belohnungsbefehle wurden aktualisiert."
|
reward-commands-changed: "&a Erfolg, die Belohnungsbefehle wurden aktualisiert."
|
||||||
write-repeat-reward-commands: "&e Geben Sie bitte pro Zeile im Chat einen neuen
|
write-repeat-reward-commands: "&e Bitte geben Sie pro Zeile im Chat einen neuen
|
||||||
Befehl zur Wiederholung der Belohnung ein und klicken Sie zum Beenden auf „Beenden“
|
Belohnungswiederholungsbefehl ein und beenden Sie den Chat in einer eigenen
|
||||||
in einer eigenen Zeile."
|
Zeile."
|
||||||
repeat-reward-commands-changed: "&a Erfolg, die Wiederholungsbelohnungsbefehle
|
repeat-reward-commands-changed: "&a Erfolg, die Wiederholungsbelohnungsbefehle
|
||||||
wurden aktualisiert."
|
wurden aktualisiert."
|
||||||
challenge-removed: "&a Herausforderungen [challende] für [gamemode] wird aus der
|
challenge-removed: "&a Herausforderungen [challende] für [gamemode] wird aus der
|
||||||
@ -1104,12 +1098,6 @@ challenges:
|
|||||||
not-hooked: "&c Challenges Addon konnte keinen GameMode finden."
|
not-hooked: "&c Challenges Addon konnte keinen GameMode finden."
|
||||||
timeout: "&c Diese Abfrage erfordert eine Wartezeit von [timeout] zwischen den
|
timeout: "&c Diese Abfrage erfordert eine Wartezeit von [timeout] zwischen den
|
||||||
Vervollständigungen. Sie müssen [wait-time] warten, bis Sie es erneut abschließen."
|
Vervollständigungen. Sie müssen [wait-time] warten, bis Sie es erneut abschließen."
|
||||||
requirement-not-met: "&c Für diese Herausforderung muss [statistic] [number] haben.
|
|
||||||
Sie haben nur [value]."
|
|
||||||
requirement-not-met-entity: "&c Für diese Herausforderung muss [statistic] [entity]
|
|
||||||
über [number] verfügen. Sie haben nur [value]."
|
|
||||||
requirement-not-met-material: "&c Diese Herausforderung erfordert, dass [statistic]
|
|
||||||
[material] [number] hat. Sie haben nur [value]."
|
|
||||||
protection:
|
protection:
|
||||||
flags:
|
flags:
|
||||||
CHALLENGES_ISLAND_PROTECTION:
|
CHALLENGES_ISLAND_PROTECTION:
|
||||||
|
@ -683,15 +683,6 @@ challenges:
|
|||||||
visible: "Show visible challenges"
|
visible: "Show visible challenges"
|
||||||
hidden: "Show all challenges"
|
hidden: "Show all challenges"
|
||||||
toggleable: "Allow toggling"
|
toggleable: "Allow toggling"
|
||||||
include_undeployed:
|
|
||||||
name: "&f&l Include Undeployed Challenges"
|
|
||||||
description: |-
|
|
||||||
&7 Indicates if undeployed
|
|
||||||
&7 challenges should be
|
|
||||||
&7 counted towards level
|
|
||||||
&7 completion.
|
|
||||||
enabled: "&2 Enabled"
|
|
||||||
disabled: "&c Disabled"
|
|
||||||
download:
|
download:
|
||||||
name: "&f&l Download Libraries"
|
name: "&f&l Download Libraries"
|
||||||
description: |-
|
description: |-
|
||||||
@ -907,7 +898,7 @@ challenges:
|
|||||||
# Message that will be added after environment-title-multiple.
|
# Message that will be added after environment-title-multiple.
|
||||||
environment-list: " &7 - &e [environment]"
|
environment-list: " &7 - &e [environment]"
|
||||||
# Message that will replace [permissions] placeholder if there is just a single permission.
|
# Message that will replace [permissions] placeholder if there is just a single permission.
|
||||||
permission-single: "&c Requires [permission] permission"
|
permission-single: "&c Requires [permissions] permission"
|
||||||
# Message that will replace [permissions] placeholder if there are multiple permissions.
|
# Message that will replace [permissions] placeholder if there are multiple permissions.
|
||||||
permissions-title: "&c Requires permissions: "
|
permissions-title: "&c Requires permissions: "
|
||||||
# Message that will be added after permissions-title-multiple.
|
# Message that will be added after permissions-title-multiple.
|
||||||
@ -1198,7 +1189,7 @@ challenges:
|
|||||||
not-enough-money: '&c It is necessary to have [value] on your account to complete the challenge.'
|
not-enough-money: '&c It is necessary to have [value] on your account to complete the challenge.'
|
||||||
not-enough-experience: '&c It is necessary to have [value] EXP to complete this challenge.'
|
not-enough-experience: '&c It is necessary to have [value] EXP to complete this challenge.'
|
||||||
island-level: '&c Your island must be level [number] or greater to complete this challenge!'
|
island-level: '&c Your island must be level [number] or greater to complete this challenge!'
|
||||||
no-load: '&c Error: Could not load [file]. Error [message]'
|
no-load: '&c Error: Could not load file. [message]'
|
||||||
load-error: '&c Error: Cannot load [value].'
|
load-error: '&c Error: Cannot load [value].'
|
||||||
no-rank: "&c You do not have rank that is high enough to do that."
|
no-rank: "&c You do not have rank that is high enough to do that."
|
||||||
cannot-remove-items: '&c Some items cannot be removed from your inventory!'
|
cannot-remove-items: '&c Some items cannot be removed from your inventory!'
|
||||||
@ -1212,9 +1203,6 @@ challenges:
|
|||||||
no-library-entries: "&c Cannot find any library entries. Nothing to show."
|
no-library-entries: "&c Cannot find any library entries. Nothing to show."
|
||||||
not-hooked: "&c Challenges Addon could not find any GameMode."
|
not-hooked: "&c Challenges Addon could not find any GameMode."
|
||||||
timeout: "&c This challenge requires to wait [timeout] between completions. You must wait [wait-time] till complete it again."
|
timeout: "&c This challenge requires to wait [timeout] between completions. You must wait [wait-time] till complete it again."
|
||||||
requirement-not-met: "&c This challenge requires [statistic] to have [number]. You have only [value]. "
|
|
||||||
requirement-not-met-entity: "&c This challenge requires [statistic] [entity] to have [number]. You have only [value]. "
|
|
||||||
requirement-not-met-material: "&c This challenge requires [statistic] [material] to have [number]. You have only [value]. "
|
|
||||||
# # Showcase for manual material translation
|
# # Showcase for manual material translation
|
||||||
# materials:
|
# materials:
|
||||||
# # Names should be lowercase.
|
# # Names should be lowercase.
|
||||||
@ -1250,27 +1238,7 @@ challenges:
|
|||||||
# # This will overwrite generic translation.
|
# # This will overwrite generic translation.
|
||||||
# name: "[type] [upgraded] [extended]"
|
# name: "[type] [upgraded] [extended]"
|
||||||
# # Type is either specific translation or potion effect.
|
# # Type is either specific translation or potion effect.
|
||||||
# uncraftable: "Uncraftable"
|
|
||||||
# water: "Water"
|
|
||||||
# mundane: "Mundane"
|
|
||||||
# thick: "Thick"
|
|
||||||
# awkward: "Awkward"
|
|
||||||
# night_vision: "Potion of Night Vision"
|
|
||||||
# invisibility: "Potion of Invisibility"
|
|
||||||
# jump: "Potion of Leaping"
|
|
||||||
# fire_resistance: "Potion of Fire Resistance"
|
|
||||||
# speed: "Potion of Swiftness"
|
|
||||||
# slowness: "Potion of Slowness"
|
|
||||||
# water_breathing: "Potion of Water Breathing"
|
# water_breathing: "Potion of Water Breathing"
|
||||||
# instant_heal: "Potion of Healing"
|
|
||||||
# instant_damage: "Potion of Harming"
|
|
||||||
# poison: "Potion of Poison"
|
|
||||||
# regen: "Potion of Regeneration"
|
|
||||||
# strength: "Potion of Strength"
|
|
||||||
# weakness: "Potion of Weakness"
|
|
||||||
# luck: "Potion of Luck"
|
|
||||||
# turtle_master: "Potion of Turtle Master"
|
|
||||||
# slow_falling: "Potion of Slow Falling"
|
|
||||||
# stone_shovel:
|
# stone_shovel:
|
||||||
# # This will mean that only stone shovels will not show
|
# # This will mean that only stone shovels will not show
|
||||||
# # meta information.
|
# # meta information.
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ gamemode_panel:
|
|||||||
content:
|
content:
|
||||||
2:
|
2:
|
||||||
1:
|
1:
|
||||||
icon: tipped_arrow{CustomPotionColor:11546150}
|
icon: TIPPED_ARROW:INSTANT_HEAL::::1
|
||||||
title: challenges.gui.buttons.previous.name
|
title: challenges.gui.buttons.previous.name
|
||||||
description: challenges.gui.buttons.previous.description
|
description: challenges.gui.buttons.previous.description
|
||||||
data:
|
data:
|
||||||
@ -33,7 +33,7 @@ gamemode_panel:
|
|||||||
7: gamemode
|
7: gamemode
|
||||||
8: gamemode
|
8: gamemode
|
||||||
9:
|
9:
|
||||||
icon: tipped_arrow{CustomPotionColor:8439583}
|
icon: TIPPED_ARROW:JUMP::::1
|
||||||
title: challenges.gui.buttons.next.name
|
title: challenges.gui.buttons.next.name
|
||||||
description: challenges.gui.buttons.next.description
|
description: challenges.gui.buttons.next.description
|
||||||
data:
|
data:
|
||||||
|
@ -23,7 +23,7 @@ main_panel:
|
|||||||
8: challenge_button
|
8: challenge_button
|
||||||
3:
|
3:
|
||||||
1:
|
1:
|
||||||
icon: tipped_arrow{CustomPotionColor:11546150}
|
icon: TIPPED_ARROW:INSTANT_HEAL::::1
|
||||||
title: challenges.gui.buttons.previous.name
|
title: challenges.gui.buttons.previous.name
|
||||||
description: challenges.gui.buttons.previous.description
|
description: challenges.gui.buttons.previous.description
|
||||||
data:
|
data:
|
||||||
@ -41,7 +41,7 @@ main_panel:
|
|||||||
7: challenge_button
|
7: challenge_button
|
||||||
8: challenge_button
|
8: challenge_button
|
||||||
9:
|
9:
|
||||||
icon: tipped_arrow{CustomPotionColor:8439583}
|
icon: TIPPED_ARROW:JUMP::::1
|
||||||
title: challenges.gui.buttons.next.name
|
title: challenges.gui.buttons.next.name
|
||||||
description: challenges.gui.buttons.next.description
|
description: challenges.gui.buttons.next.description
|
||||||
data:
|
data:
|
||||||
@ -53,7 +53,7 @@ main_panel:
|
|||||||
tooltip: challenges.gui.tips.click-to-next
|
tooltip: challenges.gui.tips.click-to-next
|
||||||
5:
|
5:
|
||||||
1:
|
1:
|
||||||
icon: tipped_arrow{CustomPotionColor:11546150}
|
icon: TIPPED_ARROW:INSTANT_HEAL::::1
|
||||||
title: challenges.gui.buttons.previous.name
|
title: challenges.gui.buttons.previous.name
|
||||||
description: challenges.gui.buttons.previous.description
|
description: challenges.gui.buttons.previous.description
|
||||||
data:
|
data:
|
||||||
@ -71,7 +71,7 @@ main_panel:
|
|||||||
7: level_button
|
7: level_button
|
||||||
8: level_button
|
8: level_button
|
||||||
9:
|
9:
|
||||||
icon: tipped_arrow{CustomPotionColor:8439583}
|
icon: TIPPED_ARROW:JUMP::::1
|
||||||
title: challenges.gui.buttons.next.name
|
title: challenges.gui.buttons.next.name
|
||||||
description: challenges.gui.buttons.next.description
|
description: challenges.gui.buttons.next.description
|
||||||
data:
|
data:
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
name: BentoBox-Challenges
|
|
||||||
main: world.bentobox.challenges.ChallengesPladdon
|
|
||||||
version: ${project.version}${build.number}
|
|
||||||
api-version: "1.17"
|
|
||||||
|
|
||||||
authors: [tastybento, BONNe]
|
|
||||||
contributors: ["The BentoBoxWorld Community"]
|
|
||||||
website: https://bentobox.world
|
|
||||||
description: ${project.description}
|
|
@ -88,10 +88,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -126,10 +122,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -228,10 +220,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -266,10 +254,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -355,10 +339,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -393,10 +373,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -488,10 +464,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -526,10 +498,6 @@ challenges:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
@ -583,10 +551,6 @@ levels:
|
|||||||
# It is not necessary to writhe `/`.
|
# It is not necessary to writhe `/`.
|
||||||
# This examples first command will force player to execute `/island` command,
|
# This examples first command will force player to execute `/island` command,
|
||||||
# While second command will run `/kill [player]` from the server console.
|
# While second command will run `/kill [player]` from the server console.
|
||||||
# There are 3 available parameters for commands:
|
|
||||||
# - [player] - player who completed the challenge
|
|
||||||
# - [owner] - the island owner
|
|
||||||
# - [name] - the name of the island.
|
|
||||||
commands:
|
commands:
|
||||||
- island
|
- island
|
||||||
- kill [player]
|
- kill [player]
|
||||||
|
@ -82,7 +82,7 @@ public class ChallengesManagerTest {
|
|||||||
// Mocks
|
// Mocks
|
||||||
@Mock
|
@Mock
|
||||||
private ChallengesAddon addon;
|
private ChallengesAddon addon;
|
||||||
|
@Mock
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private IslandWorldManager iwm;
|
private IslandWorldManager iwm;
|
||||||
@ -134,11 +134,9 @@ public class ChallengesManagerTest {
|
|||||||
when(s.getDatabaseType()).thenReturn(DatabaseType.JSON);
|
when(s.getDatabaseType()).thenReturn(DatabaseType.JSON);
|
||||||
|
|
||||||
// Addon Settings
|
// Addon Settings
|
||||||
settings = new Settings();
|
|
||||||
when(addon.getChallengesSettings()).thenReturn(settings);
|
when(addon.getChallengesSettings()).thenReturn(settings);
|
||||||
settings.setStoreAsIslandData(false);
|
when(settings.isStoreHistory()).thenReturn(true);
|
||||||
settings.setStoreHistory(true);
|
when(settings.getLifeSpan()).thenReturn(10);
|
||||||
settings.setLifeSpan(10);
|
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
database = new File("database");
|
database = new File("database");
|
||||||
@ -247,97 +245,97 @@ public class ChallengesManagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadChallengeNoOverwriteSilent() {
|
public void testLoadChallengeNoOverwriteSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, false, user, true));
|
||||||
// load twice - no overwrite
|
// load twice - no overwrite
|
||||||
assertFalse(cm.loadChallenge(challenge, world, false, user, true));
|
assertFalse(cm.loadChallenge(challenge, false, user, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadChallengeNoOverwriteNotSilent() {
|
public void testLoadChallengeNoOverwriteNotSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, false, user, true));
|
||||||
// load twice - no overwrite, not silent
|
// load twice - no overwrite, not silent
|
||||||
assertFalse(cm.loadChallenge(challenge, world, false, user, false));
|
assertFalse(cm.loadChallenge(challenge, false, user, false));
|
||||||
verify(user).getTranslation(world, "challenges.messages.load-skipping", "[value]", "name");
|
verify(user).getTranslation("challenges.messages.load-skipping", "[value]", "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadChallengeOverwriteSilent() {
|
public void testLoadChallengeOverwriteSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, false, user, true));
|
||||||
// overwrite
|
// overwrite
|
||||||
assertTrue(cm.loadChallenge(challenge, world, true, user, true));
|
assertTrue(cm.loadChallenge(challenge, true, user, true));
|
||||||
verify(user, never()).getTranslation(any(World.class), anyString(), anyString(), anyString());
|
verify(user, never()).getTranslation(anyString(), anyString(), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadChallenge(world.bentobox.challenges.database.object.Challenge, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadChallengeOverwriteNotSilent() {
|
public void testLoadChallengeOverwriteNotSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, false, user, true));
|
||||||
// overwrite not silent
|
// overwrite not silent
|
||||||
assertTrue(cm.loadChallenge(challenge, world, true, user, false));
|
assertTrue(cm.loadChallenge(challenge, true, user, false));
|
||||||
verify(user).getTranslation(world, "challenges.messages.load-overwriting", "[value]", "name");
|
verify(user).getTranslation("challenges.messages.load-overwriting", "[value]", "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadLevelNoOverwriteSilent() {
|
public void testLoadLevelNoOverwriteSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, false, user, true));
|
||||||
// load twice - no overwrite
|
// load twice - no overwrite
|
||||||
assertFalse(cm.loadLevel(level, world, false, user, true));
|
assertFalse(cm.loadLevel(level, false, user, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadLevelNoOverwriteNotSilent() {
|
public void testLoadLevelNoOverwriteNotSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, false, user, true));
|
||||||
// load twice - no overwrite, not silent
|
// load twice - no overwrite, not silent
|
||||||
assertFalse(cm.loadLevel(level, world, false, user, false));
|
assertFalse(cm.loadLevel(level, false, user, false));
|
||||||
verify(user).getTranslation(world, "challenges.messages.load-skipping", "[value]", "Novice");
|
verify(user).getTranslation("challenges.messages.load-skipping", "[value]", "Novice");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadLevelOverwriteSilent() {
|
public void testLoadLevelOverwriteSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, false, user, true));
|
||||||
// overwrite
|
// overwrite
|
||||||
assertTrue(cm.loadLevel(level, world, true, user, true));
|
assertTrue(cm.loadLevel(level, true, user, true));
|
||||||
verify(user, never()).getTranslation(any(World.class), anyString(), anyString(), anyString());
|
verify(user, never()).getTranslation(anyString(), anyString(), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, World, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
* Test method for {@link ChallengesManager#loadLevel(world.bentobox.challenges.database.object.ChallengeLevel, boolean, world.bentobox.bentobox.api.user.User, boolean)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadLevelOverwriteNotSilent() {
|
public void testLoadLevelOverwriteNotSilent() {
|
||||||
// load once
|
// load once
|
||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, false, user, true));
|
||||||
// overwrite not silent
|
// overwrite not silent
|
||||||
assertTrue(cm.loadLevel(level, world, true, user, false));
|
assertTrue(cm.loadLevel(level, true, user, false));
|
||||||
verify(user).getTranslation(world, "challenges.messages.load-overwriting", "[value]", "Novice");
|
verify(user).getTranslation("challenges.messages.load-overwriting", "[value]", "Novice");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -662,7 +660,7 @@ public class ChallengesManagerTest {
|
|||||||
public void testGetAllChallengesNames() {
|
public void testGetAllChallengesNames() {
|
||||||
assertTrue(cm.getAllChallengesNames(world).isEmpty());
|
assertTrue(cm.getAllChallengesNames(world).isEmpty());
|
||||||
cm.saveChallenge(challenge);
|
cm.saveChallenge(challenge);
|
||||||
cm.loadChallenge(challenge, world, false, user, true);
|
cm.loadChallenge(challenge, false, user, true);
|
||||||
List<String> list = cm.getAllChallengesNames(world);
|
List<String> list = cm.getAllChallengesNames(world);
|
||||||
assertFalse(list.isEmpty());
|
assertFalse(list.isEmpty());
|
||||||
assertEquals(cName, list.get(0));
|
assertEquals(cName, list.get(0));
|
||||||
@ -675,7 +673,7 @@ public class ChallengesManagerTest {
|
|||||||
public void testGetAllChallenges() {
|
public void testGetAllChallenges() {
|
||||||
assertTrue(cm.getAllChallenges(world).isEmpty());
|
assertTrue(cm.getAllChallenges(world).isEmpty());
|
||||||
cm.saveChallenge(challenge);
|
cm.saveChallenge(challenge);
|
||||||
cm.loadChallenge(challenge, world, false, user, true);
|
cm.loadChallenge(challenge, false, user, true);
|
||||||
List<Challenge> list = cm.getAllChallenges(world);
|
List<Challenge> list = cm.getAllChallenges(world);
|
||||||
assertFalse(list.isEmpty());
|
assertFalse(list.isEmpty());
|
||||||
assertEquals(challenge, list.get(0));
|
assertEquals(challenge, list.get(0));
|
||||||
@ -690,12 +688,12 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.getFreeChallenges(world).isEmpty());
|
assertTrue(cm.getFreeChallenges(world).isEmpty());
|
||||||
// One normal
|
// One normal
|
||||||
cm.saveChallenge(challenge);
|
cm.saveChallenge(challenge);
|
||||||
cm.loadChallenge(challenge, world, false, user, true);
|
cm.loadChallenge(challenge, false, user, true);
|
||||||
assertTrue(cm.getFreeChallenges(world).isEmpty());
|
assertTrue(cm.getFreeChallenges(world).isEmpty());
|
||||||
// One free
|
// One free
|
||||||
challenge.setLevel("");
|
challenge.setLevel("");
|
||||||
cm.saveChallenge(challenge);
|
cm.saveChallenge(challenge);
|
||||||
cm.loadChallenge(challenge, world, false, user, true);
|
cm.loadChallenge(challenge, false, user, true);
|
||||||
List<Challenge> list = cm.getFreeChallenges(world);
|
List<Challenge> list = cm.getFreeChallenges(world);
|
||||||
assertFalse(list.isEmpty());
|
assertFalse(list.isEmpty());
|
||||||
assertEquals(challenge, list.get(0));
|
assertEquals(challenge, list.get(0));
|
||||||
@ -794,7 +792,7 @@ public class ChallengesManagerTest {
|
|||||||
public void testGetLevelString() {
|
public void testGetLevelString() {
|
||||||
assertNull(cm.getLevel("dss"));
|
assertNull(cm.getLevel("dss"));
|
||||||
cm.saveLevel(level);
|
cm.saveLevel(level);
|
||||||
cm.loadLevel(level, world, false, user, true);
|
cm.loadLevel(level, false, user, true);
|
||||||
assertEquals(level, cm.getLevel(levelName));
|
assertEquals(level, cm.getLevel(levelName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@ -16,6 +17,7 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemFactory;
|
import org.bukkit.inventory.ItemFactory;
|
||||||
@ -36,6 +38,7 @@ import world.bentobox.bentobox.BentoBox;
|
|||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.managers.CommandsManager;
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
@ -43,16 +46,16 @@ import world.bentobox.bentobox.managers.IslandWorldManager;
|
|||||||
import world.bentobox.bentobox.managers.IslandsManager;
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
|
import world.bentobox.challenges.managers.ChallengesManager;
|
||||||
import world.bentobox.challenges.config.Settings;
|
import world.bentobox.challenges.config.Settings;
|
||||||
import world.bentobox.challenges.config.SettingsUtils.VisibilityMode;
|
import world.bentobox.challenges.config.SettingsUtils.VisibilityMode;
|
||||||
import world.bentobox.challenges.managers.ChallengesManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class })
|
@PrepareForTest({Bukkit.class, BentoBox.class, ChatColor.class, Util.class})
|
||||||
public class ChallengesCommandTest {
|
public class ChallengesCommandTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -140,6 +143,10 @@ public class ChallengesCommandTest {
|
|||||||
// Challenges exist
|
// Challenges exist
|
||||||
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(true);
|
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(true);
|
||||||
|
|
||||||
|
// ChatColor
|
||||||
|
PowerMockito.mockStatic(ChatColor.class);
|
||||||
|
when(ChatColor.translateAlternateColorCodes(any(char.class), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
Settings settings = new Settings();
|
Settings settings = new Settings();
|
||||||
when(addon.getChallengesSettings()).thenReturn(settings);
|
when(addon.getChallengesSettings()).thenReturn(settings);
|
||||||
@ -154,9 +161,6 @@ public class ChallengesCommandTest {
|
|||||||
// Util
|
// Util
|
||||||
PowerMockito.mockStatic(Util.class, Mockito.RETURNS_MOCKS);
|
PowerMockito.mockStatic(Util.class, Mockito.RETURNS_MOCKS);
|
||||||
when(Util.sameWorld(any(), any())).thenReturn(true);
|
when(Util.sameWorld(any(), any())).thenReturn(true);
|
||||||
when(Util.translateColorCodes(anyString()))
|
|
||||||
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
|
||||||
|
|
||||||
// Command under test
|
// Command under test
|
||||||
cc = new ChallengesPlayerCommand(addon, ic);
|
cc = new ChallengesPlayerCommand(addon, ic);
|
||||||
}
|
}
|
||||||
@ -168,7 +172,7 @@ public class ChallengesCommandTest {
|
|||||||
public void testCanExecuteWrongWorld() {
|
public void testCanExecuteWrongWorld() {
|
||||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||||
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
||||||
verify(user).getTranslation(world, "general.errors.wrong-world");
|
verify(user).getTranslation("general.errors.wrong-world");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,7 +184,7 @@ public class ChallengesCommandTest {
|
|||||||
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
||||||
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
||||||
verify(addon).logError("There are no challenges set up in world!");
|
verify(addon).logError("There are no challenges set up in world!");
|
||||||
verify(user).getTranslation(world, "challenges.errors.no-challenges");
|
verify(user).getTranslation("challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,8 +196,8 @@ public class ChallengesCommandTest {
|
|||||||
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
||||||
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
||||||
verify(addon).logError("There are no challenges set up in world!");
|
verify(addon).logError("There are no challenges set up in world!");
|
||||||
verify(user).getTranslation(world, "challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
verify(user).getTranslation("challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
||||||
verify(user, never()).getTranslation(world, "challenges.errors.no-challenges");
|
verify(user, never()).getTranslation("challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,8 +209,8 @@ public class ChallengesCommandTest {
|
|||||||
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
||||||
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
||||||
verify(addon).logError("There are no challenges set up in world!");
|
verify(addon).logError("There are no challenges set up in world!");
|
||||||
verify(user).getTranslation(world, "challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
verify(user).getTranslation("challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
||||||
verify(user, never()).getTranslation(world, "challenges.errors.no-challenges");
|
verify(user, never()).getTranslation("challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,8 +223,8 @@ public class ChallengesCommandTest {
|
|||||||
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
when(chm.hasAnyChallengeData(any(World.class))).thenReturn(false);
|
||||||
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
||||||
verify(addon).logError("There are no challenges set up in world!");
|
verify(addon).logError("There are no challenges set up in world!");
|
||||||
verify(user).getTranslation(world, "challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
verify(user).getTranslation("challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
||||||
verify(user, never()).getTranslation(world, "challenges.errors.no-challenges");
|
verify(user, never()).getTranslation("challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,7 +234,7 @@ public class ChallengesCommandTest {
|
|||||||
public void testCanExecuteNoIsland() {
|
public void testCanExecuteNoIsland() {
|
||||||
when(im.getIsland(any(), any(User.class))).thenReturn(null);
|
when(im.getIsland(any(), any(User.class))).thenReturn(null);
|
||||||
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
assertFalse(cc.canExecute(user, "challenges", Collections.emptyList()));
|
||||||
verify(user).getTranslation(world, "general.errors.no-island");
|
verify(user).getTranslation("general.errors.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,6 +246,16 @@ public class ChallengesCommandTest {
|
|||||||
verify(user, never()).sendMessage(anyString());
|
verify(user, never()).sendMessage(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link ChallengesPlayerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testExecuteUserStringListOfStringConsole() {
|
||||||
|
User console = mock(User.class);
|
||||||
|
assertFalse(cc.execute(console, "challenges", Collections.emptyList()));
|
||||||
|
verify(console).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ChallengesPlayerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
* Test method for {@link ChallengesPlayerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||||
*/
|
*/
|
||||||
|
@ -19,6 +19,7 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemFactory;
|
import org.bukkit.inventory.ItemFactory;
|
||||||
@ -45,12 +46,11 @@ import world.bentobox.bentobox.managers.IslandWorldManager;
|
|||||||
import world.bentobox.bentobox.managers.IslandsManager;
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
|
import world.bentobox.challenges.managers.ChallengesManager;
|
||||||
import world.bentobox.challenges.config.Settings;
|
import world.bentobox.challenges.config.Settings;
|
||||||
import world.bentobox.challenges.config.SettingsUtils.VisibilityMode;
|
import world.bentobox.challenges.config.SettingsUtils.VisibilityMode;
|
||||||
import world.bentobox.challenges.database.object.Challenge;
|
import world.bentobox.challenges.database.object.Challenge;
|
||||||
import world.bentobox.challenges.managers.ChallengesManager;
|
|
||||||
import world.bentobox.challenges.tasks.TryToComplete;
|
import world.bentobox.challenges.tasks.TryToComplete;
|
||||||
import world.bentobox.challenges.utils.Constants;
|
|
||||||
import world.bentobox.challenges.utils.Utils;
|
import world.bentobox.challenges.utils.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +58,7 @@ import world.bentobox.challenges.utils.Utils;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class, Utils.class, TryToComplete.class, Util.class })
|
@PrepareForTest({Bukkit.class, BentoBox.class, ChatColor.class, Utils.class, TryToComplete.class, Util.class})
|
||||||
public class CompleteChallengeCommandTest {
|
public class CompleteChallengeCommandTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -149,6 +149,11 @@ public class CompleteChallengeCommandTest {
|
|||||||
List<String> nameList = Arrays.asList("world_maker", "world_placer", "bad_challenge_name", "world_breaker");
|
List<String> nameList = Arrays.asList("world_maker", "world_placer", "bad_challenge_name", "world_breaker");
|
||||||
when(chm.getAllChallengesNames(any())).thenReturn(nameList);
|
when(chm.getAllChallengesNames(any())).thenReturn(nameList);
|
||||||
|
|
||||||
|
|
||||||
|
// ChatColor
|
||||||
|
PowerMockito.mockStatic(ChatColor.class);
|
||||||
|
when(ChatColor.translateAlternateColorCodes(any(char.class), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
Settings settings = new Settings();
|
Settings settings = new Settings();
|
||||||
when(addon.getChallengesSettings()).thenReturn(settings);
|
when(addon.getChallengesSettings()).thenReturn(settings);
|
||||||
@ -170,8 +175,6 @@ public class CompleteChallengeCommandTest {
|
|||||||
// Util
|
// Util
|
||||||
PowerMockito.mockStatic(Util.class);
|
PowerMockito.mockStatic(Util.class);
|
||||||
when(Util.tabLimit(any(), any())).thenAnswer((Answer<List<String>>) invocation -> (List<String>)invocation.getArgument(0, List.class));
|
when(Util.tabLimit(any(), any())).thenAnswer((Answer<List<String>>) invocation -> (List<String>)invocation.getArgument(0, List.class));
|
||||||
when(Util.translateColorCodes(anyString()))
|
|
||||||
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
|
||||||
|
|
||||||
// Command under test
|
// Command under test
|
||||||
cc = new CompleteChallengeCommand(addon, ic);
|
cc = new CompleteChallengeCommand(addon, ic);
|
||||||
@ -204,8 +207,7 @@ public class CompleteChallengeCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteUserStringListOfStringNoArgs() {
|
public void testExecuteUserStringListOfStringNoArgs() {
|
||||||
assertFalse(cc.execute(user, "complete", Collections.emptyList()));
|
assertFalse(cc.execute(user, "complete", Collections.emptyList()));
|
||||||
PowerMockito.verifyStatic(Utils.class);
|
verify(user).getTranslation(eq("challenges.errors.no-name"));
|
||||||
Utils.sendMessage(user, world, Constants.ERRORS + "no-name");
|
|
||||||
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
|
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +218,7 @@ public class CompleteChallengeCommandTest {
|
|||||||
public void testExecuteUserStringListOfStringUnknownChallenge() {
|
public void testExecuteUserStringListOfStringUnknownChallenge() {
|
||||||
when(chm.getChallenge(anyString())).thenReturn(null);
|
when(chm.getChallenge(anyString())).thenReturn(null);
|
||||||
assertFalse(cc.execute(user, "complete", Collections.singletonList("mychal")));
|
assertFalse(cc.execute(user, "complete", Collections.singletonList("mychal")));
|
||||||
PowerMockito.verifyStatic(Utils.class);
|
verify(user).getTranslation(eq("challenges.errors.unknown-challenge"));
|
||||||
Utils.sendMessage(user, world, Constants.ERRORS + "unknown-challenge");
|
|
||||||
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
|
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,8 +247,7 @@ public class CompleteChallengeCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteUserStringListOfStringKnownChallengeSuccessMultipleTimesNoPerm() {
|
public void testExecuteUserStringListOfStringKnownChallengeSuccessMultipleTimesNoPerm() {
|
||||||
assertTrue(cc.execute(user, "complete", Arrays.asList("mychal", "5")));
|
assertTrue(cc.execute(user, "complete", Arrays.asList("mychal", "5")));
|
||||||
PowerMockito.verifyStatic(Utils.class);
|
verify(user).getTranslation(eq("challenges.error.no-multiple-permission"));
|
||||||
Utils.sendMessage(user, world, Constants.ERRORS + "no-multiple-permission");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user