mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-01 06:53:37 +01:00
Release 1.3.0 (#331)
* Init 1.2.0 version * Fixes #311 localization errors in zn-CN. Original translation author translated `[]` placeholders which broke locale * Init 1.2.0 version * Edit some unfit translation (#312) Edit some unfit translation * Fixes a regex bug that replaced every [player] char instead of whole word. * Fixes a crash that prevented STATISTICS entity and material/item challenges to be completed. * Add requirement-not-met-material and requirement-not-met-entity to display statistic required item on error. * Add locale of Chinese-Hong Kong (zh-HK) (#313) Addition of locale updated to latest version * Add ${argLine} to get jacoco coverage * Updated Jacoco POM section * Update build.yml Java 17 for Surefire * Updated pladdon annotations * Add support for gamemode-specific translations. This was a request from Floris * Update ChallengesManagerTest methods with world parameter. * Implement option that excludes undeployed challenges The new option allows to toggle if undeployed challenges should be included in level completion count. Disabling option will not include these challenges for level completion. Fixes #315 * Create plugin.yml (#316) * Create plugin.yml * Update pom.xml * Update ChallengesPladdon.java * Remove dependency to org.apache.commons Replace org.apache.commons.lang.ArrayUtils to a default Java implementation. * Fixes a crash with written/writable books. The issue was with generating description message for written books without title or author. Fixes #318 * Fixed TryToComplete test class * Fixed CompleteChallengeCommandTest * Fixed ChallengesCommandTest * Fixed ChallengesManagerTest * Update Github Action build script * Add required distribution * Fixes the admin GUI crash. Add shade plugin that was missing for dependencies. * Update Hungarian translation (#301) * Translate hu.yml via GitLocalize * Translate hu.yml via GitLocalize * Translate hu.yml via GitLocalize * Translate hu.yml via GitLocalize * Update hu.yml Fix color codes and placeholders --------- Co-authored-by: driverdakid <tamascsiszar99@icloud.com> Co-authored-by: mt-gitlocalize <mt@gitlocalize.com> Co-authored-by: BONNe <bonne@bonne.id.lv> Co-authored-by: slimcraft <davidelek12@gmail.com> Co-authored-by: tastybento <tastybento@users.noreply.github.com> * Update POM versions to use latest API * Remove duplicate plugin reference in POM * Try adding maven dependency to fix test issue * Remove offending test. Was not that useful anyway. * Update Jacoco * Update pom.xml * Update to BentoBox 2.0.0 Had to ignore some tests because PowerMockito can't mock them for some reason. * Add Ukrainian locale (#326) * Translate uk.yml via GitLocalize * Translate uk.yml via GitLocalize --------- Co-authored-by: mt-gitlocalize <mt@gitlocalize.com> Co-authored-by: GIGABAIT <freebitcoin93@gmail.com> * Translate uk.yml via GitLocalize (#325) Co-authored-by: GIGABAIT <freebitcoin93@gmail.com> Co-authored-by: tastybento <tastybento@users.noreply.github.com> * Show money as formatted. Addresses #324 * Update README.md * Update README.md * Fixes enchanted book meta not displayed (#328) Apparently in Spigot EnchantmentStorage has a map that is not used for enchantment storing. Nice. Fixes #327 * Upgrade PanelUtils to 1.2.0 * Fixes crash when player in CREATIVE shift+clicks on INVENTORY challenge. Limit completion time to 2, if player is in creative instead of Integer.MAX_VALUE Fixes #330 * Fix tests for creative user inventory challenge completion * Update TIPPED_ARROW to latest API in panels * Update en-US.yml * Reference latest BentoBox release version --------- Co-authored-by: BONNe <bonne@bonne.id.lv> Co-authored-by: EpicMo <1982742309@qq.com> Co-authored-by: JamesMCL44 <epicquarters@gmail.com> Co-authored-by: gitlocalize-app[bot] <55277160+gitlocalize-app[bot]@users.noreply.github.com> Co-authored-by: driverdakid <tamascsiszar99@icloud.com> Co-authored-by: mt-gitlocalize <mt@gitlocalize.com> Co-authored-by: slimcraft <davidelek12@gmail.com> Co-authored-by: GIGABAIT <freebitcoin93@gmail.com>
This commit is contained in:
parent
b1fa9a9da7
commit
7c1deb9384
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
@ -11,21 +11,22 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
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 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
- name: Cache SonarCloud packages
|
- name: Cache SonarCloud packages
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v3
|
||||||
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@v1
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
42
README.md
42
README.md
@ -2,24 +2,9 @@
|
|||||||
[![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.
|
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!
|
||||||
|
|
||||||
## Where to find
|
![Challenges](https://github.com/BentoBoxWorld/Challenges/assets/4407265/9b3c5278-3a9d-45f2-9ee1-2c1fc1199a8d)
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -27,21 +12,32 @@ Unfortunately, default challenges come only in English translation. But with ver
|
|||||||
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.
|
||||||
|
|
||||||
#### Challenges
|
#### Installation
|
||||||
|
|
||||||
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 run time only Admin GUI will be accessible.
|
||||||
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.
|
Admins can create their own challenges or import some default challenges. Default challenges contains 5 levels and 57 challenges.
|
||||||
There exist also Web Library, where users can download public challenges. It is accessible with Admin GUI by clicking on Web icon.
|
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.
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
- [x] BentoBox - 1.14 versions
|
- [x] BentoBok
|
||||||
- [x] BSkyBlock
|
- [x] BSkyBlock
|
||||||
- [x] AcidIsland
|
- [x] AcidIsland
|
||||||
- [x] SkyGrid
|
- [x] SkyGrid
|
||||||
- [x] CaveBlock
|
- [x] CaveBlock
|
||||||
|
|
||||||
## Information
|
## Translations
|
||||||
|
|
||||||
|
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/).
|
|
||||||
|
83
pom.xml
83
pom.xml
@ -35,16 +35,16 @@
|
|||||||
<java.version>17</java.version>
|
<java.version>17</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.17.1-R0.1-SNAPSHOT</spigot.version>
|
<spigot.version>1.20.4-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>1.21.0</bentobox.version>
|
<bentobox.version>2.1.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.1.0</panelutils.version>
|
<panelutils.version>1.2.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.2.0</build.version>
|
<build.version>1.3.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,6 +120,12 @@
|
|||||||
</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>
|
||||||
@ -187,6 +193,11 @@
|
|||||||
<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>
|
||||||
@ -217,6 +228,38 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<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>
|
||||||
|
</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>
|
||||||
@ -325,40 +368,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.4</version>
|
<version>0.8.10</version>
|
||||||
<configuration>
|
|
||||||
<append>true</append>
|
|
||||||
<excludes>
|
|
||||||
<!-- This is required to prevent Jacoco from adding
|
|
||||||
synthetic fields to a JavaBean class (causes errors in testing) -->
|
|
||||||
<exclude>**/*Names*</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>pre-unit-test</id>
|
|
||||||
<goals>
|
|
||||||
<goal>prepare-agent</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>post-unit-test</id>
|
|
||||||
<goals>
|
|
||||||
<goal>report</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.jacoco</groupId>
|
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
|
||||||
<version>0.8.7</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>
|
||||||
@ -378,6 +396,7 @@
|
|||||||
<format>XML</format>
|
<format>XML</format>
|
||||||
</formats>
|
</formats>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -952,6 +952,8 @@ 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
|
||||||
|
@ -7,11 +7,19 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.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.*;
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
|
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;
|
||||||
@ -823,7 +831,7 @@ public class Utils
|
|||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
enchantmentMeta.getEnchants().forEach((enchantment, level) -> {
|
enchantmentMeta.getStoredEnchants().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),
|
||||||
@ -868,8 +876,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.getTitle(),
|
"[title]", bookMeta.hasTitle() ? bookMeta.getTitle() : "",
|
||||||
"[author]", bookMeta.getAuthor());
|
"[author]", bookMeta.hasAuthor() ? bookMeta.getAuthor() : "");
|
||||||
|
|
||||||
return user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
|
return user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
|
||||||
"[type]", prettifyObject(itemType, user),
|
"[type]", prettifyObject(itemType, user),
|
||||||
|
@ -907,7 +907,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 [permissions] permission"
|
permission-single: "&c Requires [permission] 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.
|
||||||
|
1102
src/main/resources/locales/hu.yml
Normal file
1102
src/main/resources/locales/hu.yml
Normal file
File diff suppressed because it is too large
Load Diff
1113
src/main/resources/locales/uk.yml
Normal file
1113
src/main/resources/locales/uk.yml
Normal file
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:INSTANT_HEAL::::1
|
icon: tipped_arrow{CustomPotionColor:11546150}
|
||||||
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:JUMP::::1
|
icon: tipped_arrow{CustomPotionColor:8439583}
|
||||||
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:INSTANT_HEAL::::1
|
icon: tipped_arrow{CustomPotionColor:11546150}
|
||||||
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:JUMP::::1
|
icon: tipped_arrow{CustomPotionColor:8439583}
|
||||||
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:INSTANT_HEAL::::1
|
icon: tipped_arrow{CustomPotionColor:11546150}
|
||||||
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:JUMP::::1
|
icon: tipped_arrow{CustomPotionColor:8439583}
|
||||||
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:
|
||||||
|
@ -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,9 +134,11 @@ 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);
|
||||||
when(settings.isStoreHistory()).thenReturn(true);
|
settings.setStoreAsIslandData(false);
|
||||||
when(settings.getLifeSpan()).thenReturn(10);
|
settings.setStoreHistory(true);
|
||||||
|
settings.setLifeSpan(10);
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
database = new File("database");
|
database = new File("database");
|
||||||
@ -264,7 +266,7 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, world, 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, world, false, user, false));
|
||||||
verify(user).getTranslation("challenges.messages.load-skipping", "[value]", "name");
|
verify(user).getTranslation(world, "challenges.messages.load-skipping", "[value]", "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,7 +278,7 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
||||||
// overwrite
|
// overwrite
|
||||||
assertTrue(cm.loadChallenge(challenge, world, true, user, true));
|
assertTrue(cm.loadChallenge(challenge, world, true, user, true));
|
||||||
verify(user, never()).getTranslation(anyString(), anyString(), anyString());
|
verify(user, never()).getTranslation(any(World.class), anyString(), anyString(), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,7 +290,7 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
assertTrue(cm.loadChallenge(challenge, world, false, user, true));
|
||||||
// overwrite not silent
|
// overwrite not silent
|
||||||
assertTrue(cm.loadChallenge(challenge, world, true, user, false));
|
assertTrue(cm.loadChallenge(challenge, world, true, user, false));
|
||||||
verify(user).getTranslation("challenges.messages.load-overwriting", "[value]", "name");
|
verify(user).getTranslation(world, "challenges.messages.load-overwriting", "[value]", "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -311,7 +313,7 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, world, 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, world, false, user, false));
|
||||||
verify(user).getTranslation("challenges.messages.load-skipping", "[value]", "Novice");
|
verify(user).getTranslation(world, "challenges.messages.load-skipping", "[value]", "Novice");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,7 +325,7 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, world, false, user, true));
|
||||||
// overwrite
|
// overwrite
|
||||||
assertTrue(cm.loadLevel(level, world, true, user, true));
|
assertTrue(cm.loadLevel(level, world, true, user, true));
|
||||||
verify(user, never()).getTranslation(anyString(), anyString(), anyString());
|
verify(user, never()).getTranslation(any(World.class), anyString(), anyString(), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -335,7 +337,7 @@ public class ChallengesManagerTest {
|
|||||||
assertTrue(cm.loadLevel(level, world, false, user, true));
|
assertTrue(cm.loadLevel(level, world, false, user, true));
|
||||||
// overwrite not silent
|
// overwrite not silent
|
||||||
assertTrue(cm.loadLevel(level, world, true, user, false));
|
assertTrue(cm.loadLevel(level, world, true, user, false));
|
||||||
verify(user).getTranslation("challenges.messages.load-overwriting", "[value]", "Novice");
|
verify(user).getTranslation(world, "challenges.messages.load-overwriting", "[value]", "Novice");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,7 +6,6 @@ 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;
|
||||||
@ -17,7 +16,6 @@ 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;
|
||||||
@ -38,7 +36,6 @@ 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;
|
||||||
@ -46,16 +43,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, ChatColor.class, Util.class})
|
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class })
|
||||||
public class ChallengesCommandTest {
|
public class ChallengesCommandTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -143,10 +140,6 @@ 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);
|
||||||
@ -161,6 +154,9 @@ 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);
|
||||||
}
|
}
|
||||||
@ -172,7 +168,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("general.errors.wrong-world");
|
verify(user).getTranslation(world, "general.errors.wrong-world");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,7 +180,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("challenges.errors.no-challenges");
|
verify(user).getTranslation(world, "challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,8 +192,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("challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
verify(user).getTranslation(world, "challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
||||||
verify(user, never()).getTranslation("challenges.errors.no-challenges");
|
verify(user, never()).getTranslation(world, "challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,8 +205,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("challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
verify(user).getTranslation(world, "challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
||||||
verify(user, never()).getTranslation("challenges.errors.no-challenges");
|
verify(user, never()).getTranslation(world, "challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,8 +219,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("challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
verify(user).getTranslation(world, "challenges.errors.no-challenges-admin", "[command]", "bsb challenges");
|
||||||
verify(user, never()).getTranslation("challenges.errors.no-challenges");
|
verify(user, never()).getTranslation(world, "challenges.errors.no-challenges");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,7 +230,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("general.errors.no-island");
|
verify(user).getTranslation(world, "general.errors.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,16 +242,6 @@ 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,7 +19,6 @@ 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;
|
||||||
@ -46,11 +45,12 @@ 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, ChatColor.class, Utils.class, TryToComplete.class, Util.class})
|
@PrepareForTest({ Bukkit.class, BentoBox.class, Utils.class, TryToComplete.class, Util.class })
|
||||||
public class CompleteChallengeCommandTest {
|
public class CompleteChallengeCommandTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@ -149,11 +149,6 @@ 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);
|
||||||
@ -175,6 +170,8 @@ 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);
|
||||||
@ -207,7 +204,8 @@ 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()));
|
||||||
verify(user).getTranslation(eq("challenges.errors.no-name"));
|
PowerMockito.verifyStatic(Utils.class);
|
||||||
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +216,8 @@ 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")));
|
||||||
verify(user).getTranslation(eq("challenges.errors.unknown-challenge"));
|
PowerMockito.verifyStatic(Utils.class);
|
||||||
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +246,8 @@ 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")));
|
||||||
verify(user).getTranslation(eq("challenges.error.no-multiple-permission"));
|
PowerMockito.verifyStatic(Utils.class);
|
||||||
|
Utils.sendMessage(user, world, Constants.ERRORS + "no-multiple-permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,7 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -21,7 +22,6 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -36,7 +36,9 @@ import org.bukkit.inventory.PlayerInventory;
|
|||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@ -60,28 +62,27 @@ import world.bentobox.bentobox.managers.LocalesManager;
|
|||||||
import world.bentobox.bentobox.managers.PlaceholdersManager;
|
import world.bentobox.bentobox.managers.PlaceholdersManager;
|
||||||
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.database.object.Challenge;
|
import world.bentobox.challenges.database.object.Challenge;
|
||||||
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
|
import world.bentobox.challenges.database.object.Challenge.ChallengeType;
|
||||||
import world.bentobox.challenges.database.object.ChallengeLevel;
|
import world.bentobox.challenges.database.object.ChallengeLevel;
|
||||||
import world.bentobox.challenges.database.object.requirements.InventoryRequirements;
|
import world.bentobox.challenges.database.object.requirements.InventoryRequirements;
|
||||||
import world.bentobox.challenges.database.object.requirements.IslandRequirements;
|
import world.bentobox.challenges.database.object.requirements.IslandRequirements;
|
||||||
|
import world.bentobox.challenges.managers.ChallengesManager;
|
||||||
import world.bentobox.challenges.tasks.TryToComplete.ChallengeResult;
|
import world.bentobox.challenges.tasks.TryToComplete.ChallengeResult;
|
||||||
import world.bentobox.challenges.utils.Utils;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Bukkit.class, BentoBox.class, Util.class, Utils.class, ChatColor.class})
|
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class })
|
||||||
public class TryToCompleteTest {
|
public class TryToCompleteTest {
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
private static final String GAME_MODE_NAME = "BSkyBlock";
|
private static final String GAME_MODE_NAME = "BSkyBlock";
|
||||||
private static final String[] NAMES = {"adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe"};
|
private static final String[] NAMES = { "adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry",
|
||||||
|
"ian", "joe" };
|
||||||
|
|
||||||
private TryToComplete ttc;
|
private TryToComplete ttc;
|
||||||
private Challenge challenge;
|
private Challenge challenge;
|
||||||
@ -117,6 +118,7 @@ public class TryToCompleteTest {
|
|||||||
private final ItemStack[] contents = {};
|
private final ItemStack[] contents = {};
|
||||||
@Mock
|
@Mock
|
||||||
private BoundingBox bb;
|
private BoundingBox bb;
|
||||||
|
private Set<Player> onlinePlayers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -134,11 +136,13 @@ public class TryToCompleteTest {
|
|||||||
when(plugin.getAddonsManager()).thenReturn(am);
|
when(plugin.getAddonsManager()).thenReturn(am);
|
||||||
// One game mode
|
// One game mode
|
||||||
when(am.getGameModeAddons()).thenReturn(Collections.singletonList(gameMode));
|
when(am.getGameModeAddons()).thenReturn(Collections.singletonList(gameMode));
|
||||||
AddonDescription desc2 = new AddonDescription.Builder("bentobox", GAME_MODE_NAME, "1.3").description("test").authors("tasty").build();
|
AddonDescription desc2 = new AddonDescription.Builder("bentobox", GAME_MODE_NAME, "1.3").description("test")
|
||||||
|
.authors("tasty").build();
|
||||||
when(gameMode.getDescription()).thenReturn(desc2);
|
when(gameMode.getDescription()).thenReturn(desc2);
|
||||||
|
|
||||||
// Challenge Level
|
// Challenge Level
|
||||||
@NonNull ChallengeLevel level = new ChallengeLevel();
|
@NonNull
|
||||||
|
ChallengeLevel level = new ChallengeLevel();
|
||||||
String levelName = GAME_MODE_NAME + "_novice";
|
String levelName = GAME_MODE_NAME + "_novice";
|
||||||
level.setUniqueId(levelName);
|
level.setUniqueId(levelName);
|
||||||
level.setFriendlyName("Novice");
|
level.setFriendlyName("Novice");
|
||||||
@ -164,6 +168,8 @@ public class TryToCompleteTest {
|
|||||||
when(Util.getWorld(any())).thenReturn(world);
|
when(Util.getWorld(any())).thenReturn(world);
|
||||||
when(Util.prettifyText(anyString())).thenCallRealMethod();
|
when(Util.prettifyText(anyString())).thenCallRealMethod();
|
||||||
when(Util.stripSpaceAfterColorCodes(anyString())).thenCallRealMethod();
|
when(Util.stripSpaceAfterColorCodes(anyString())).thenCallRealMethod();
|
||||||
|
when(Util.translateColorCodes(anyString()))
|
||||||
|
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||||
|
|
||||||
// Island World Manager
|
// Island World Manager
|
||||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||||
@ -200,11 +206,16 @@ public class TryToCompleteTest {
|
|||||||
when(user.hasPermission(anyString())).thenReturn(true);
|
when(user.hasPermission(anyString())).thenReturn(true);
|
||||||
when(user.getPlayer()).thenReturn(player);
|
when(user.getPlayer()).thenReturn(player);
|
||||||
UUID uniqueId = UUID.randomUUID();
|
UUID uniqueId = UUID.randomUUID();
|
||||||
|
when(player.getUniqueId()).thenReturn(uniqueId);
|
||||||
when(user.getUniqueId()).thenReturn(uniqueId);
|
when(user.getUniqueId()).thenReturn(uniqueId);
|
||||||
when(user.getTranslation(anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
when(user.getTranslation(anyString()))
|
||||||
when(user.getTranslation(anyString(), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||||
when(user.getTranslationOrNothing(anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
when(user.getTranslation(anyString(), anyString()))
|
||||||
|
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||||
|
when(user.getTranslationOrNothing(anyString()))
|
||||||
|
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||||
when(user.getName()).thenReturn("tastybento");
|
when(user.getName()).thenReturn("tastybento");
|
||||||
|
User.getInstance(player);
|
||||||
@Nullable
|
@Nullable
|
||||||
Location userLoc = mock(Location.class);
|
Location userLoc = mock(Location.class);
|
||||||
when(userLoc.toString()).thenReturn("location");
|
when(userLoc.toString()).thenReturn("location");
|
||||||
@ -219,9 +230,11 @@ public class TryToCompleteTest {
|
|||||||
LocalesManager lm = mock(LocalesManager.class);
|
LocalesManager lm = mock(LocalesManager.class);
|
||||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||||
when(lm.get(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
when(lm.get(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||||
|
when(lm.get(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||||
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
||||||
when(plugin.getPlaceholdersManager()).thenReturn(phm);
|
when(plugin.getPlaceholdersManager()).thenReturn(phm);
|
||||||
when(phm.replacePlaceholders(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
when(phm.replacePlaceholders(any(), any()))
|
||||||
|
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||||
|
|
||||||
// Survival by default
|
// Survival by default
|
||||||
when(player.getGameMode()).thenReturn(GameMode.SURVIVAL);
|
when(player.getGameMode()).thenReturn(GameMode.SURVIVAL);
|
||||||
@ -233,7 +246,7 @@ public class TryToCompleteTest {
|
|||||||
// Bukkit - online players
|
// Bukkit - online players
|
||||||
Map<UUID, String> online = new HashMap<>();
|
Map<UUID, String> online = new HashMap<>();
|
||||||
|
|
||||||
Set<Player> onlinePlayers = new HashSet<>();
|
onlinePlayers = new HashSet<>();
|
||||||
for (String name : NAMES) {
|
for (String name : NAMES) {
|
||||||
Player p1 = mock(Player.class);
|
Player p1 = mock(Player.class);
|
||||||
UUID uuid2 = UUID.randomUUID();
|
UUID uuid2 = UUID.randomUUID();
|
||||||
@ -243,7 +256,7 @@ public class TryToCompleteTest {
|
|||||||
onlinePlayers.add(p1);
|
onlinePlayers.add(p1);
|
||||||
}
|
}
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
when(Bukkit.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> onlinePlayers);
|
when(Bukkit.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> Set.of(player));
|
||||||
|
|
||||||
// World settings
|
// World settings
|
||||||
Map<String, Boolean> map = new HashMap<>();
|
Map<String, Boolean> map = new HashMap<>();
|
||||||
@ -255,66 +268,70 @@ public class TryToCompleteTest {
|
|||||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||||
|
|
||||||
// ChatColor
|
}
|
||||||
PowerMockito.mockStatic(ChatColor.class, Mockito.RETURNS_MOCKS);
|
|
||||||
when(ChatColor.stripColor(anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
@After
|
||||||
|
public void tearDown() throws IOException {
|
||||||
|
User.clearUsers();
|
||||||
|
Mockito.framework().clearInlineMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#TryToComplete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#TryToComplete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testTryToCompleteChallengesAddonUserChallengeWorldStringString() {
|
public void testTryToCompleteChallengesAddonUserChallengeWorldStringString() {
|
||||||
ttc = new TryToComplete(addon,
|
ttc = new TryToComplete(addon, user, challenge, world, topLabel, permissionPrefix);
|
||||||
user,
|
|
||||||
challenge,
|
|
||||||
world,
|
|
||||||
topLabel,
|
|
||||||
permissionPrefix);
|
|
||||||
verify(addon).getChallengesManager();
|
verify(addon).getChallengesManager();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotDeployed() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotDeployed() {
|
||||||
challenge.setDeployed(false);
|
challenge.setDeployed(false);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.not-deployed");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-deployed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringWrongWorld() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringWrongWorld() {
|
||||||
challenge.setUniqueId("test");
|
challenge.setUniqueId("test");
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("general.errors.wrong-world");
|
verify(user).getTranslation(any(World.class), eq("general.errors.wrong-world"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotOnIsland() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotOnIsland() {
|
||||||
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.setSetting(world, true);
|
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.setSetting(world, true);
|
||||||
when(im.locationIsOnIsland(any(Player.class), any(Location.class))).thenReturn(false);
|
when(im.locationIsOnIsland(any(Player.class), any(Location.class))).thenReturn(false);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.not-on-island");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.not-on-island"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotOnIslandButOk() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotOnIslandButOk() {
|
||||||
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.setSetting(world, false);
|
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.setSetting(world, false);
|
||||||
when(im.locationIsOnIsland(any(Player.class), any(Location.class))).thenReturn(false);
|
when(im.locationIsOnIsland(any(Player.class), any(Location.class))).thenReturn(false);
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"),
|
||||||
|
eq("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,22 +341,24 @@ public class TryToCompleteTest {
|
|||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringLevelNotUnlocked() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringLevelNotUnlocked() {
|
||||||
when(cm.isLevelUnlocked(any(), any(), any())).thenReturn(false);
|
when(cm.isLevelUnlocked(any(), any(), any())).thenReturn(false);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.challenge-level-not-available");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.challenge-level-not-available"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotRepeatable() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotRepeatable() {
|
||||||
challenge.setRepeatable(false);
|
challenge.setRepeatable(false);
|
||||||
when(cm.isChallengeComplete(any(User.class), any(), any())).thenReturn(true);
|
when(cm.isChallengeComplete(any(User.class), any(), any())).thenReturn(true);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.not-repeatable");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-repeatable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotRepeatableFirstTime() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringNotRepeatableFirstTime() {
|
||||||
@ -347,7 +366,8 @@ public class TryToCompleteTest {
|
|||||||
challenge.setMaxTimes(0);
|
challenge.setMaxTimes(0);
|
||||||
when(cm.getChallengeTimes(any(), any(), any(Challenge.class))).thenReturn(0L);
|
when(cm.getChallengeTimes(any(), any(), any(Challenge.class))).thenReturn(0L);
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"),
|
||||||
|
eq("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -357,39 +377,43 @@ public class TryToCompleteTest {
|
|||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringNoRank() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringNoRank() {
|
||||||
when(island.isAllowed(any(), any())).thenReturn(false);
|
when(island.isAllowed(any(), any())).thenReturn(false);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.no-rank");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.no-rank"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntZero() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntZero() {
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 0));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 0));
|
||||||
verify(user).getTranslation("challenges.errors.not-valid-integer");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-valid-integer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntNegative() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntNegative() {
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, -10));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, -10));
|
||||||
verify(user).getTranslation("challenges.errors.not-valid-integer");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-valid-integer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntPositiveWrongEnvinonment() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntPositiveWrongEnvinonment() {
|
||||||
challenge.setEnvironment(Collections.singleton(Environment.NETHER));
|
challenge.setEnvironment(Collections.singleton(Environment.NETHER));
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 100));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 100));
|
||||||
verify(user).getTranslation("challenges.errors.wrong-environment");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.wrong-environment"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntPositiveNoPerm() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntPositiveNoPerm() {
|
||||||
@ -398,34 +422,41 @@ public class TryToCompleteTest {
|
|||||||
when(user.hasPermission(anyString())).thenReturn(false);
|
when(user.hasPermission(anyString())).thenReturn(false);
|
||||||
challenge.setRequirements(req);
|
challenge.setRequirements(req);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 100));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 100));
|
||||||
verify(user).getTranslation("general.errors.no-permission");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.no-permission"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccess() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccess() {
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"),
|
||||||
|
eq("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore("Method is too large for JVM")
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessSingleReq() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessSingleReq() {
|
||||||
InventoryRequirements req = new InventoryRequirements();
|
InventoryRequirements req = new InventoryRequirements();
|
||||||
req.setRequiredItems(Collections.singletonList(new ItemStack(Material.EMERALD_BLOCK)));
|
req.setRequiredItems(Collections.singletonList(new ItemStack(Material.EMERALD_BLOCK)));
|
||||||
challenge.setRequirements(req);
|
challenge.setRequirements(req);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.not-enough-items", "[items]", "challenges.materials.emerald_block");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-enough-items"), eq("[items]"),
|
||||||
|
eq("challenges.materials.emerald_block"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore("Too big for JVM")
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessMultipleReq() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessMultipleReq() {
|
||||||
|
|
||||||
InventoryRequirements req = new InventoryRequirements();
|
InventoryRequirements req = new InventoryRequirements();
|
||||||
@ -454,9 +485,11 @@ public class TryToCompleteTest {
|
|||||||
|
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
// Sufficient emerald blocks
|
// Sufficient emerald blocks
|
||||||
verify(user, never()).getTranslation("challenges.errors.not-enough-items", "[items]", "challenges.materials.emerald_block");
|
verify(user, never()).getTranslation(any(World.class), eq("challenges.errors.not-enough-items"), eq("[items]"),
|
||||||
|
eq("challenges.materials.emerald_block"));
|
||||||
// Not enough books
|
// Not enough books
|
||||||
verify(user).getTranslation("challenges.errors.not-enough-items", "[items]", "challenges.materials.enchanted_book");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.not-enough-items"), eq("[items]"),
|
||||||
|
eq("challenges.materials.enchanted_book"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,11 +499,14 @@ public class TryToCompleteTest {
|
|||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessCreative() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringSuccessCreative() {
|
||||||
when(player.getGameMode()).thenReturn(GameMode.CREATIVE);
|
when(player.getGameMode()).thenReturn(GameMode.CREATIVE);
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
// Creative players automatically complete inventory challenges twice - they have infinite inventory
|
||||||
|
verify(user).getTranslation(world, "challenges.messages.you-repeated-challenge-multiple", "[value]", "name",
|
||||||
|
"[count]", "2");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandBBTooLarge() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandBBTooLarge() {
|
||||||
@ -481,13 +517,15 @@ public class TryToCompleteTest {
|
|||||||
// Trigger big bounding box error
|
// Trigger big bounding box error
|
||||||
when(bb.getWidthX()).thenReturn(50000D);
|
when(bb.getWidthX()).thenReturn(50000D);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(addon).logError("BoundingBox is larger than SearchRadius. | BoundingBox: BoundingBox | Search Distance: 1 | Location: location | Center: center | Range: 0");
|
verify(addon).logError(
|
||||||
|
"BoundingBox is larger than SearchRadius. | BoundingBox: BoundingBox | Search Distance: 1 | Location: location | Center: center | Range: 0");
|
||||||
verify(bb).expand(1);
|
verify(bb).expand(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandSuccessNoEntities() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandSuccessNoEntities() {
|
||||||
@ -496,12 +534,14 @@ public class TryToCompleteTest {
|
|||||||
req.setSearchRadius(1);
|
req.setSearchRadius(1);
|
||||||
challenge.setRequirements(req);
|
challenge.setRequirements(req);
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"),
|
||||||
|
eq("name"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandFailEntities() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandFailEntities() {
|
||||||
@ -512,12 +552,14 @@ public class TryToCompleteTest {
|
|||||||
req.setSearchRadius(1);
|
req.setSearchRadius(1);
|
||||||
challenge.setRequirements(req);
|
challenge.setRequirements(req);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "3", "[item]", "challenges.entities.ghast.name");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("3"),
|
||||||
|
eq("[item]"), eq("challenges.entities.ghast.name"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandFailMultipleEntities() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandFailMultipleEntities() {
|
||||||
@ -531,14 +573,18 @@ public class TryToCompleteTest {
|
|||||||
req.setSearchRadius(1);
|
req.setSearchRadius(1);
|
||||||
challenge.setRequirements(req);
|
challenge.setRequirements(req);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "3", "[item]", "challenges.entities.ghast.name");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("3"),
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "1", "[item]", "challenges.entities.pufferfish.name");
|
eq("[item]"), eq("challenges.entities.ghast.name"));
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "5", "[item]", "challenges.entities.chicken.name");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("1"),
|
||||||
|
eq("[item]"), eq("challenges.entities.pufferfish.name"));
|
||||||
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("5"),
|
||||||
|
eq("[item]"), eq("challenges.entities.chicken.name"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandFailPartialMultipleEntities() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandFailPartialMultipleEntities() {
|
||||||
@ -558,14 +604,18 @@ public class TryToCompleteTest {
|
|||||||
List<Entity> list = Collections.singletonList(ent);
|
List<Entity> list = Collections.singletonList(ent);
|
||||||
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "3", "[item]", "challenges.entities.ghast.name");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("3"),
|
||||||
verify(user, never()).getTranslation("challenges.errors.you-still-need", "[amount]", "1", "[item]", "challenges.entities.pufferfish.name");
|
eq("[item]"), eq("challenges.entities.ghast.name"));
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "5", "[item]", "challenges.entities.chicken.name");
|
verify(user, never()).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"),
|
||||||
|
eq("1"), eq("[item]"), eq("challenges.entities.pufferfish.name"));
|
||||||
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("5"),
|
||||||
|
eq("[item]"), eq("challenges.entities.chicken.name"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandSuccess() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandSuccess() {
|
||||||
@ -583,11 +633,13 @@ public class TryToCompleteTest {
|
|||||||
List<Entity> list = Collections.singletonList(ent);
|
List<Entity> list = Collections.singletonList(ent);
|
||||||
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.messages.you-completed-challenge", "[value]", "name");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-completed-challenge"), eq("[value]"),
|
||||||
|
eq("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandPlayerInOtherEnvironment() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIslandPlayerInOtherEnvironment() {
|
||||||
@ -611,21 +663,26 @@ public class TryToCompleteTest {
|
|||||||
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
when(world.getNearbyEntities(any(BoundingBox.class))).thenReturn(list);
|
||||||
when(netherWorld.getNearbyEntities(any(BoundingBox.class))).thenReturn(Collections.emptyList());
|
when(netherWorld.getNearbyEntities(any(BoundingBox.class))).thenReturn(Collections.emptyList());
|
||||||
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
assertFalse(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix));
|
||||||
verify(user).getTranslation("challenges.errors.you-still-need", "[amount]", "1", "[item]", "challenges.entities.pufferfish.name");
|
verify(user).getTranslation(any(World.class), eq("challenges.errors.you-still-need"), eq("[amount]"), eq("1"),
|
||||||
|
eq("[item]"), eq("challenges.entities.pufferfish.name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#complete(world.bentobox.challenges.ChallengesAddon, world.bentobox.bentobox.api.user.User, world.bentobox.challenges.database.object.Challenge, org.bukkit.World, java.lang.String, java.lang.String, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntMultipleTimesPositiveSuccess() {
|
public void testCompleteChallengesAddonUserChallengeWorldStringStringIntMultipleTimesPositiveSuccess() {
|
||||||
// Try to complete 10 times. Already done 3 times, and max is 10, so it should be only done 7 times
|
// Try to complete 10 times. Already done 3 times, and max is 10, so it should
|
||||||
|
// be only done 7 times
|
||||||
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 10));
|
assertTrue(TryToComplete.complete(addon, user, challenge, world, topLabel, permissionPrefix, 10));
|
||||||
verify(user).getTranslation("challenges.messages.you-repeated-challenge-multiple", "[value]", "name", "[count]", "7");
|
verify(user).getTranslation(any(World.class), eq("challenges.messages.you-repeated-challenge-multiple"),
|
||||||
|
eq("[value]"), eq("name"), eq("[count]"), eq("7"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#build(int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#build(int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBuild() {
|
public void testBuild() {
|
||||||
@ -635,7 +692,8 @@ public class TryToCompleteTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.challenges.tasks.TryToComplete#removeItems(java.util.List, int)}.
|
* Test method for
|
||||||
|
* {@link world.bentobox.challenges.tasks.TryToComplete#removeItems(java.util.List, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveItemsNothing() {
|
public void testRemoveItemsNothing() {
|
||||||
|
Loading…
Reference in New Issue
Block a user