Skip to content

Commit

Permalink
Bug fix release (#228)
Browse files Browse the repository at this point in the history
* Fix issue when users could not select non-block items as icons for challenges and levels. (#190)

* English update (#193)

* Organized imports

* Minor code cleanup

* Updated English locale file.

* Translate zh-CN.yml via GitLocalize (#188)

* Make default translation looking a bit nicer (#192)

* Make default translation looking a bit nicer
* Updating a few friendly names and rewording some phrases
* Add generic .gitignore

* Fix novice level

Update `chiseledmaker` name in `novice` level.

* Adapt literal style (#197)

Improve translations and process as a YAML string.

* Test coverage (#199)

* Test coverage for Challenges Command

* Added CompleteChallengeCommand test class

* Added Utils test class

* Added ChallengesGUI test class

* Fix code smells from sonarcloud analysis

* Added .gitignore

* Added Travis CI config file

* WIP ChallengesManager Test class

* Added ChallengesManager test class

* Removed debug

* Removed code smells.

* Added ChallengesAddon test class.

* Added onDisbale test

* Added new TryToComplete test class - WIP

Covers inventory challenges.

* Added Island Challenge entity tests to TryToComplete test class

* Fix a bug with challenge deletion.

If challenge has been left in a level, then system did not remove challenge from it and was kept as ghost challenge, preventing from completing level.

* Fixes tests

* Updated travis.yml

* All strings to spanish (#200)

* Translate es.yml via GitLocalize

* Translate es.yml via GitLocalize

* Translate es.yml via GitLocalize

* Fix LevelListRequestHandler.
This handler did not return list of strings but list of challenge levels, that is incorrect.
Not it should work correctly.

* Create ro.yml

* Create id.yml

* Remove blanks files now that GitLocalize is fixed.

* Initial Russian translation (#207)

* Translate ru.yml via GitLocalize

Co-authored-by: @mt-gitlocalize @IPeredero @LoveBiscuit

* Changed build character from # to b

* Add German translation (#210)

* Translate de.yml via GitLocalize

* Translate de.yml via GitLocalize

* Translate de.yml via GitLocalize

Co-authored-by: xXjojojXx <36734820+xXjojojXx@users.noreply.github.com>
Co-authored-by: FunnysBanana <51290016+FunnysBanana@users.noreply.github.com>
Co-authored-by: mt-gitlocalize <mt@gitlocalize.com>

* Czech translation. Credit @Polda18

* Added a uniqueId sanitization when creating challenges/levels
This will help fixing issues with spaces, hyphens and accents in non-English languages.

* Fixes bug with checking entities in nether and end (#219)

#218

Adds test case to check for compliance.

* Add 7 new placeholders for Challenges Addon.

- `[gamemode]_challenge_total_completion_count` returns number of sum of challenge completions for user.
- `[gamemode]_challenge_completed_count` returns number of completed challenges (at least once) for user.
- `[gamemode]_challenge_uncompleted_count` returns number of uncompleted challenges for user.
- `[gamemode]_challenge_completed_level_count` returns number of completed levels for user.
- `[gamemode]_challenge_uncompleted_level_count` returns number of uncompleted levels for user.
- `[gamemode]_challenge_unlocked_level_count` returns number of unlocked levels for user.
- `[gamemode]_challenge_locked_level_count` returns number of locked levels for user.

Fixes #224

* Add 2 new placeholders:

- `[gamemode]_challenge_latest_level_name` returns latest unlocked challenge level name
- `[gamemode]_challenge_latest_level_id` returns latest unlocked challenge level id

Fixes #226

* Fix broken tests due to placeholder additions.

b5ecffb
2958ca8

* Added default perms for aoneblock

* Downgrade to 0.8.1 version

* Add option to quit from conversation by writing "cancel" in chat.
Move sanitizeInput to a GuiUtil class.

* Change latest version to 0.8.1
  • Loading branch information
BONNe committed Apr 21, 2020
1 parent 29a5057 commit 8383c93
Show file tree
Hide file tree
Showing 76 changed files with 9,577 additions and 3,807 deletions.
134 changes: 134 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
### Others ###
*.cmd
*.sh
*.prefs

### Maven ###
/mvn
/target/lib
/target/maven-archiver
/target/classes
/target/maven-status
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
out/


### Java ###
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/shelf

# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries
.gradle

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties


### Eclipse ###
*.pydevproject
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath

# Eclipse Core
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Java annotation processor (APT)
.factorypath

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans
/target/
checkstyle.xml
classes/
/.DS_Store
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: java
sudo: false
addons:
sonarcloud:
organization: "bentobox-world"

jdk:
- openjdk8
- openjdk11

matrix:
allow_failures:
- jdk: openjdk11

script:
#- sonar-scanner
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.projectKey=BentoBoxWorld_Challenges
#- echo "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Add-on for BentoBox to provide challenges for any BentoBox GameMode.
## Where to find

Currently Challenges Addon is in **Beta stage**, so it may or may not contain bugs... a lot of bugs. Also it means, that some features are not working or implemented.
Latest official **Beta Release is 0.8.0**, and you can download it from [Release tab](https://github.com/BentoBoxWorld/Challenges/releases)
Latest official **Beta Release is 0.8.1**, and you can download it from [Release tab](https://github.com/BentoBoxWorld/Challenges/releases)
But it will work with BentoBox 1.6.x and BentoBox 1.7.x.

Latest development builds will be based on **Minecraft 1.14.4** and **BentoBox 1.8.0**.
Expand Down
43 changes: 22 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<powermock.version>1.7.4</powermock.version>
<powermock.version>2.0.2</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.14.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.7.0</bentobox.version>
Expand All @@ -42,7 +42,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>0.8.0</build.version>
<build.version>0.8.1</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand All @@ -56,7 +56,7 @@
</activation>
<properties>
<!-- Override only if necessary -->
<build.number>-#${env.BUILD_NUMBER}</build.number>
<build.number>-b${env.BUILD_NUMBER}</build.number>
<!-- GIT_BRANCH -->
</properties>
</profile>
Expand Down Expand Up @@ -129,24 +129,25 @@
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<!-- Mockito (Unit testing) -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
Expand Down
85 changes: 79 additions & 6 deletions src/main/java/world/bentobox/challenges/ChallengesAddon.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package world.bentobox.challenges;


import org.bukkit.Material;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;

import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.Config;
Expand All @@ -18,6 +21,7 @@
import world.bentobox.challenges.commands.admin.Challenges;
import world.bentobox.challenges.commands.admin.ChallengesAdminCommand;
import world.bentobox.challenges.config.Settings;
import world.bentobox.challenges.database.object.ChallengeLevel;
import world.bentobox.challenges.handlers.ChallengeDataRequestHandler;
import world.bentobox.challenges.handlers.ChallengeListRequestHandler;
import world.bentobox.challenges.handlers.CompletedChallengesRequestHandler;
Expand Down Expand Up @@ -87,15 +91,15 @@ public class ChallengesAddon extends Addon {
* This flag allows to complete challenges in any part of the world. It will not limit
* player to their island. Useful for skygrid without protection flags.
*/
public static Flag CHALLENGES_WORLD_PROTECTION =
public static final Flag CHALLENGES_WORLD_PROTECTION =
new Flag.Builder("CHALLENGES_WORLD_PROTECTION", Material.GRASS_BLOCK).type(Flag.Type.WORLD_SETTING).defaultSetting(true).build();

/**
* This flag allows to define which users can complete challenge. F.e. it can be set
* that only Island owner can complete challenge.
* By default it is set to Visitor.
*/
public static Flag CHALLENGES_ISLAND_PROTECTION =
public static final Flag CHALLENGES_ISLAND_PROTECTION =
new Flag.Builder("CHALLENGES_ISLAND_PROTECTION", Material.COMMAND_BLOCK).defaultRank(RanksManager.VISITOR_RANK).build();


Expand Down Expand Up @@ -154,7 +158,8 @@ public void onEnable() {
List<GameModeAddon> hookedGameModes = new ArrayList<>();

this.getPlugin().getAddonsManager().getGameModeAddons().forEach(gameModeAddon -> {
if (!this.settings.getDisabledGameModes().contains(gameModeAddon.getDescription().getName()))
if (!this.settings.getDisabledGameModes().contains(
gameModeAddon.getDescription().getName()))
{
if (gameModeAddon.getPlayerCommand().isPresent())
{
Expand All @@ -172,6 +177,8 @@ public void onEnable() {

CHALLENGES_WORLD_PROTECTION.addGameModeAddon(gameModeAddon);
CHALLENGES_ISLAND_PROTECTION.addGameModeAddon(gameModeAddon);

this.registerPlaceholders(gameModeAddon);
}
});

Expand Down Expand Up @@ -237,7 +244,7 @@ public void onEnable() {

if (this.settings.getAutoSaveTimer() > 0)
{
this.getPlugin().getServer().getScheduler().runTaskTimerAsynchronously(
Bukkit.getScheduler().runTaskTimerAsynchronously(
this.getPlugin(),
bukkitTask -> ChallengesAddon.this.challengesManager.save(),
this.settings.getAutoSaveTimer() * 60 * 20,
Expand All @@ -263,7 +270,7 @@ public void onReload()
{
this.loadSettings();
this.challengesManager.reload();
this.getLogger().info("Challenges addon reloaded.");
this.log("Challenges addon reloaded.");
}
}

Expand Down Expand Up @@ -308,6 +315,72 @@ private boolean isInCompatibleDatabase()
}


/**
* This method registers placeholders into GameMode addon.
* @param gameModeAddon GameMode addon where placeholders must be hooked in.
*/
private void registerPlaceholders(GameModeAddon gameModeAddon)
{
final String gameMode = gameModeAddon.getDescription().getName().toLowerCase();
final World world = gameModeAddon.getOverWorld();

// Number of completions for all challenges placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_total_completion_count",
user -> String.valueOf(this.challengesManager.getTotalChallengeCompletionCount(user, world)));

// Completed challenge count placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_completed_count",
user -> String.valueOf(this.challengesManager.getCompletedChallengeCount(user, world)));

// Uncompleted challenge count placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_uncompleted_count",
user -> String.valueOf(this.challengesManager.getChallengeCount(world) -
this.challengesManager.getCompletedChallengeCount(user, world)));

// Completed challenge level count placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_completed_level_count",
user -> String.valueOf(this.challengesManager.getCompletedLevelCount(user, world)));

// Uncompleted challenge level count placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_uncompleted_level_count",
user -> String.valueOf(this.challengesManager.getLevelCount(world) -
this.challengesManager.getCompletedLevelCount(user, world)));

// Unlocked challenge level count placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_unlocked_level_count",
user -> String.valueOf(this.challengesManager.getLevelCount(world) -
this.challengesManager.getUnlockedLevelCount(user, world)));

// Locked challenge level count placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_locked_level_count",
user -> String.valueOf(this.challengesManager.getLevelCount(world) -
this.challengesManager.getUnlockedLevelCount(user, world)));

// Latest challenge level name placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_latest_level_name",
user -> {
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
return level != null ? level.getFriendlyName() : "";
});

// Latest challenge level id placeholder
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
gameMode + "_challenge_latest_level_id",
user -> {
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
return level != null ? level.getUniqueId() : "";
});
}


// ---------------------------------------------------------------------
// Section: Getters
// ---------------------------------------------------------------------
Expand Down

0 comments on commit 8383c93

Please sign in to comment.