From 2aa437f071183ea33192df016a9dfc580d4416d2 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 10 Oct 2019 00:35:25 -0500 Subject: [PATCH] English update (#193) * Organized imports * Minor code cleanup * Updated English locale file. --- .../bentobox/challenges/ChallengesAddon.java | 3 +- .../challenges/ChallengesImportManager.java | 13 +- .../challenges/ChallengesManager.java | 3 +- .../commands/ChallengesCommand.java | 2 +- .../commands/ChallengesUserCommand.java | 1 - .../commands/CompleteChallengeCommand.java | 4 +- .../challenges/commands/admin/Challenges.java | 2 +- .../commands/admin/CompleteCommand.java | 6 +- .../commands/admin/ReloadChallenges.java | 4 +- .../commands/admin/ResetCommand.java | 6 +- .../commands/admin/ShowChallenges.java | 3 +- .../bentobox/challenges/config/Settings.java | 3 +- .../database/object/ChallengeLevel.java | 8 +- .../database/object/ChallengesPlayerData.java | 11 +- .../object/adapters/RequirementsAdapter.java | 3 +- .../requirements/InventoryRequirements.java | 6 +- .../requirements/IslandRequirements.java | 8 +- .../requirements/OtherRequirements.java | 7 +- .../object/requirements/Requirements.java | 3 +- .../handlers/ChallengeDataRequestHandler.java | 1 - .../handlers/ChallengeListRequestHandler.java | 3 +- .../CompletedChallengesRequestHandler.java | 7 +- .../handlers/LevelListRequestHandler.java | 3 +- .../challenges/listeners/ResetListener.java | 3 +- .../challenges/listeners/SaveListener.java | 1 - .../bentobox/challenges/panel/CommonGUI.java | 6 +- .../challenges/panel/GameModesGUI.java | 6 +- .../challenges/panel/admin/AdminGUI.java | 6 +- .../panel/admin/EditChallengeGUI.java | 9 +- .../challenges/panel/admin/EditLevelGUI.java | 6 +- .../challenges/panel/admin/EditLoreGUI.java | 11 +- .../panel/admin/EditSettingsGUI.java | 21 +- .../panel/admin/ListChallengesGUI.java | 3 +- .../challenges/panel/admin/ListLevelsGUI.java | 3 +- .../panel/admin/ListLibraryGUI.java | 5 +- .../challenges/panel/admin/ListUsersGUI.java | 9 +- .../panel/admin/ManageBlocksGUI.java | 8 +- .../panel/admin/ManageEntitiesGUI.java | 8 +- .../challenges/panel/user/ChallengesGUI.java | 3 +- .../challenges/panel/user/MultipleGUI.java | 4 +- .../panel/util/ChallengeTypeGUI.java | 5 +- .../panel/util/ConfirmationGUI.java | 4 +- .../challenges/panel/util/ItemSwitchGUI.java | 9 +- .../challenges/panel/util/NumberGUI.java | 1018 +++++++++-------- .../panel/util/SelectBlocksGUI.java | 9 +- .../panel/util/SelectChallengeGUI.java | 10 +- .../panel/util/SelectEntityGUI.java | 11 +- .../panel/util/SelectEnvironmentGUI.java | 5 +- .../challenges/panel/util/StringListGUI.java | 15 +- .../challenges/tasks/TryToComplete.java | 18 +- .../bentobox/challenges/utils/GuiUtils.java | 9 +- .../bentobox/challenges/utils/HeadLib.java | 15 +- .../bentobox/challenges/utils/Utils.java | 5 +- .../bentobox/challenges/web/WebManager.java | 11 +- .../challenges/web/object/LibraryEntry.java | 3 +- src/main/resources/locales/en-US.yml | 210 ++-- .../challenges/tasks/TryToCompleteTest.java | 8 +- 57 files changed, 847 insertions(+), 740 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesAddon.java b/src/main/java/world/bentobox/challenges/ChallengesAddon.java index d632dfb..8a5ef3a 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesAddon.java +++ b/src/main/java/world/bentobox/challenges/ChallengesAddon.java @@ -1,11 +1,12 @@ package world.bentobox.challenges; -import org.bukkit.Material; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import org.bukkit.Material; + import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.configuration.Config; diff --git a/src/main/java/world/bentobox/challenges/ChallengesImportManager.java b/src/main/java/world/bentobox/challenges/ChallengesImportManager.java index 709d999..dfec22d 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesImportManager.java +++ b/src/main/java/world/bentobox/challenges/ChallengesImportManager.java @@ -1,8 +1,5 @@ package world.bentobox.challenges; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.Expose; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; @@ -21,12 +18,16 @@ import java.util.stream.Collectors; import org.bukkit.World; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; + +import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.json.BentoboxTypeAdapterFactory; import world.bentobox.bentobox.database.objects.DataObject; -import world.bentobox.challenges.database.object.ChallengeLevel; -import world.bentobox.challenges.database.object.Challenge; -import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.util.Util; +import world.bentobox.challenges.database.object.Challenge; +import world.bentobox.challenges.database.object.ChallengeLevel; import world.bentobox.challenges.utils.Utils; diff --git a/src/main/java/world/bentobox/challenges/ChallengesManager.java b/src/main/java/world/bentobox/challenges/ChallengesManager.java index 4deebb5..601d0ff 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesManager.java +++ b/src/main/java/world/bentobox/challenges/ChallengesManager.java @@ -1,8 +1,6 @@ package world.bentobox.challenges; -import org.eclipse.jdt.annotation.NonNull; - import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -20,6 +18,7 @@ import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.World; +import org.eclipse.jdt.annotation.NonNull; import world.bentobox.bentobox.api.logs.LogEntry; import world.bentobox.bentobox.api.user.User; diff --git a/src/main/java/world/bentobox/challenges/commands/ChallengesCommand.java b/src/main/java/world/bentobox/challenges/commands/ChallengesCommand.java index e0e2502..b26a194 100644 --- a/src/main/java/world/bentobox/challenges/commands/ChallengesCommand.java +++ b/src/main/java/world/bentobox/challenges/commands/ChallengesCommand.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.Optional; import world.bentobox.bentobox.api.addons.GameModeAddon; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.panel.user.ChallengesGUI; diff --git a/src/main/java/world/bentobox/challenges/commands/ChallengesUserCommand.java b/src/main/java/world/bentobox/challenges/commands/ChallengesUserCommand.java index f30bd2c..4c90d22 100644 --- a/src/main/java/world/bentobox/challenges/commands/ChallengesUserCommand.java +++ b/src/main/java/world/bentobox/challenges/commands/ChallengesUserCommand.java @@ -6,7 +6,6 @@ import java.util.List; import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; - import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.config.SettingsUtils.GuiMode; import world.bentobox.challenges.panel.GameModesGUI; diff --git a/src/main/java/world/bentobox/challenges/commands/CompleteChallengeCommand.java b/src/main/java/world/bentobox/challenges/commands/CompleteChallengeCommand.java index 306348a..2259f13 100644 --- a/src/main/java/world/bentobox/challenges/commands/CompleteChallengeCommand.java +++ b/src/main/java/world/bentobox/challenges/commands/CompleteChallengeCommand.java @@ -1,7 +1,9 @@ package world.bentobox.challenges.commands; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import world.bentobox.bentobox.api.addons.Addon; diff --git a/src/main/java/world/bentobox/challenges/commands/admin/Challenges.java b/src/main/java/world/bentobox/challenges/commands/admin/Challenges.java index 1377c9a..1567503 100644 --- a/src/main/java/world/bentobox/challenges/commands/admin/Challenges.java +++ b/src/main/java/world/bentobox/challenges/commands/admin/Challenges.java @@ -2,9 +2,9 @@ package world.bentobox.challenges.commands.admin; import java.util.List; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.panel.admin.AdminGUI; diff --git a/src/main/java/world/bentobox/challenges/commands/admin/CompleteCommand.java b/src/main/java/world/bentobox/challenges/commands/admin/CompleteCommand.java index 7e73eb9..d0d3f67 100644 --- a/src/main/java/world/bentobox/challenges/commands/admin/CompleteCommand.java +++ b/src/main/java/world/bentobox/challenges/commands/admin/CompleteCommand.java @@ -1,7 +1,11 @@ package world.bentobox.challenges.commands.admin; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; import world.bentobox.bentobox.api.addons.Addon; diff --git a/src/main/java/world/bentobox/challenges/commands/admin/ReloadChallenges.java b/src/main/java/world/bentobox/challenges/commands/admin/ReloadChallenges.java index 05be3fb..6022895 100644 --- a/src/main/java/world/bentobox/challenges/commands/admin/ReloadChallenges.java +++ b/src/main/java/world/bentobox/challenges/commands/admin/ReloadChallenges.java @@ -2,11 +2,11 @@ package world.bentobox.challenges.commands.admin; import java.util.List; -import world.bentobox.challenges.ChallengesAddon; -import world.bentobox.challenges.ChallengesManager; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; +import world.bentobox.challenges.ChallengesManager; /** diff --git a/src/main/java/world/bentobox/challenges/commands/admin/ResetCommand.java b/src/main/java/world/bentobox/challenges/commands/admin/ResetCommand.java index d8b5089..649b728 100644 --- a/src/main/java/world/bentobox/challenges/commands/admin/ResetCommand.java +++ b/src/main/java/world/bentobox/challenges/commands/admin/ResetCommand.java @@ -1,7 +1,11 @@ package world.bentobox.challenges.commands.admin; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; import world.bentobox.bentobox.api.addons.Addon; diff --git a/src/main/java/world/bentobox/challenges/commands/admin/ShowChallenges.java b/src/main/java/world/bentobox/challenges/commands/admin/ShowChallenges.java index 6226fc5..a735dc3 100644 --- a/src/main/java/world/bentobox/challenges/commands/admin/ShowChallenges.java +++ b/src/main/java/world/bentobox/challenges/commands/admin/ShowChallenges.java @@ -1,12 +1,11 @@ package world.bentobox.challenges.commands.admin; import java.util.List; -import java.util.logging.Level; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; public class ShowChallenges extends CompositeCommand { diff --git a/src/main/java/world/bentobox/challenges/config/Settings.java b/src/main/java/world/bentobox/challenges/config/Settings.java index 0688599..49df416 100644 --- a/src/main/java/world/bentobox/challenges/config/Settings.java +++ b/src/main/java/world/bentobox/challenges/config/Settings.java @@ -13,10 +13,9 @@ import world.bentobox.bentobox.api.configuration.ConfigComment; import world.bentobox.bentobox.api.configuration.ConfigEntry; import world.bentobox.bentobox.api.configuration.ConfigObject; import world.bentobox.bentobox.api.configuration.StoreAt; - import world.bentobox.bentobox.database.objects.adapters.Adapter; -import world.bentobox.challenges.config.SettingsUtils.GuiMode; import world.bentobox.challenges.config.SettingsUtils.ChallengeLore; +import world.bentobox.challenges.config.SettingsUtils.GuiMode; import world.bentobox.challenges.config.SettingsUtils.LevelLore; import world.bentobox.challenges.config.SettingsUtils.VisibilityMode; import world.bentobox.challenges.database.object.adapters.ChallengeLoreAdapter; diff --git a/src/main/java/world/bentobox/challenges/database/object/ChallengeLevel.java b/src/main/java/world/bentobox/challenges/database/object/ChallengeLevel.java index ae22355..7fb26bf 100644 --- a/src/main/java/world/bentobox/challenges/database/object/ChallengeLevel.java +++ b/src/main/java/world/bentobox/challenges/database/object/ChallengeLevel.java @@ -1,15 +1,17 @@ package world.bentobox.challenges.database.object; -import com.google.gson.annotations.Expose; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import com.google.gson.annotations.Expose; + import world.bentobox.bentobox.api.configuration.ConfigComment; import world.bentobox.bentobox.database.objects.DataObject; import world.bentobox.challenges.ChallengesManager; diff --git a/src/main/java/world/bentobox/challenges/database/object/ChallengesPlayerData.java b/src/main/java/world/bentobox/challenges/database/object/ChallengesPlayerData.java index 820c17a..3f81b5b 100644 --- a/src/main/java/world/bentobox/challenges/database/object/ChallengesPlayerData.java +++ b/src/main/java/world/bentobox/challenges/database/object/ChallengesPlayerData.java @@ -1,9 +1,16 @@ package world.bentobox.challenges.database.object; -import com.google.gson.annotations.Expose; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + import org.eclipse.jdt.annotation.NonNull; -import java.util.*; + +import com.google.gson.annotations.Expose; import world.bentobox.bentobox.api.logs.LogEntry; import world.bentobox.bentobox.database.objects.DataObject; diff --git a/src/main/java/world/bentobox/challenges/database/object/adapters/RequirementsAdapter.java b/src/main/java/world/bentobox/challenges/database/object/adapters/RequirementsAdapter.java index 63ddb5a..4d4e90b 100644 --- a/src/main/java/world/bentobox/challenges/database/object/adapters/RequirementsAdapter.java +++ b/src/main/java/world/bentobox/challenges/database/object/adapters/RequirementsAdapter.java @@ -7,6 +7,8 @@ package world.bentobox.challenges.database.object.adapters; +import java.lang.reflect.Type; + import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -15,7 +17,6 @@ import com.google.gson.JsonParseException; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import java.lang.reflect.Type; import world.bentobox.challenges.database.object.requirements.Requirements; diff --git a/src/main/java/world/bentobox/challenges/database/object/requirements/InventoryRequirements.java b/src/main/java/world/bentobox/challenges/database/object/requirements/InventoryRequirements.java index 0a2f24e..7023a2a 100644 --- a/src/main/java/world/bentobox/challenges/database/object/requirements/InventoryRequirements.java +++ b/src/main/java/world/bentobox/challenges/database/object/requirements/InventoryRequirements.java @@ -7,13 +7,15 @@ package world.bentobox.challenges.database.object.requirements; -import com.google.gson.annotations.Expose; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.inventory.ItemStack; + +import com.google.gson.annotations.Expose; + /** * This class contains all necessary requirements to complete inventory type challenge. diff --git a/src/main/java/world/bentobox/challenges/database/object/requirements/IslandRequirements.java b/src/main/java/world/bentobox/challenges/database/object/requirements/IslandRequirements.java index abfd0d9..dac9ab4 100644 --- a/src/main/java/world/bentobox/challenges/database/object/requirements/IslandRequirements.java +++ b/src/main/java/world/bentobox/challenges/database/object/requirements/IslandRequirements.java @@ -7,14 +7,16 @@ package world.bentobox.challenges.database.object.requirements; -import com.google.gson.annotations.Expose; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +import com.google.gson.annotations.Expose; + /** * This class contains all necessary requirements to complete island type challenge. diff --git a/src/main/java/world/bentobox/challenges/database/object/requirements/OtherRequirements.java b/src/main/java/world/bentobox/challenges/database/object/requirements/OtherRequirements.java index 92aadf7..fb1bf44 100644 --- a/src/main/java/world/bentobox/challenges/database/object/requirements/OtherRequirements.java +++ b/src/main/java/world/bentobox/challenges/database/object/requirements/OtherRequirements.java @@ -7,12 +7,9 @@ package world.bentobox.challenges.database.object.requirements; -import com.google.gson.annotations.Expose; -import org.eclipse.jdt.annotation.NonNull; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; -import java.util.Set; + +import com.google.gson.annotations.Expose; /** diff --git a/src/main/java/world/bentobox/challenges/database/object/requirements/Requirements.java b/src/main/java/world/bentobox/challenges/database/object/requirements/Requirements.java index 9b3538e..09a54f5 100644 --- a/src/main/java/world/bentobox/challenges/database/object/requirements/Requirements.java +++ b/src/main/java/world/bentobox/challenges/database/object/requirements/Requirements.java @@ -7,10 +7,11 @@ package world.bentobox.challenges.database.object.requirements; -import com.google.gson.annotations.Expose; import java.util.HashSet; import java.util.Set; +import com.google.gson.annotations.Expose; + /** * This abstract class allows to define requirements for each challenge. diff --git a/src/main/java/world/bentobox/challenges/handlers/ChallengeDataRequestHandler.java b/src/main/java/world/bentobox/challenges/handlers/ChallengeDataRequestHandler.java index 303b4de..c099961 100644 --- a/src/main/java/world/bentobox/challenges/handlers/ChallengeDataRequestHandler.java +++ b/src/main/java/world/bentobox/challenges/handlers/ChallengeDataRequestHandler.java @@ -5,7 +5,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; - import world.bentobox.bentobox.api.addons.request.AddonRequestHandler; import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.database.object.Challenge; diff --git a/src/main/java/world/bentobox/challenges/handlers/ChallengeListRequestHandler.java b/src/main/java/world/bentobox/challenges/handlers/ChallengeListRequestHandler.java index c270bb3..5c067cf 100644 --- a/src/main/java/world/bentobox/challenges/handlers/ChallengeListRequestHandler.java +++ b/src/main/java/world/bentobox/challenges/handlers/ChallengeListRequestHandler.java @@ -1,10 +1,11 @@ package world.bentobox.challenges.handlers; -import org.bukkit.Bukkit; import java.util.Collections; import java.util.Map; +import org.bukkit.Bukkit; + import world.bentobox.bentobox.api.addons.request.AddonRequestHandler; import world.bentobox.challenges.ChallengesAddon; diff --git a/src/main/java/world/bentobox/challenges/handlers/CompletedChallengesRequestHandler.java b/src/main/java/world/bentobox/challenges/handlers/CompletedChallengesRequestHandler.java index 3452a34..3ea05bb 100644 --- a/src/main/java/world/bentobox/challenges/handlers/CompletedChallengesRequestHandler.java +++ b/src/main/java/world/bentobox/challenges/handlers/CompletedChallengesRequestHandler.java @@ -1,10 +1,13 @@ package world.bentobox.challenges.handlers; +import java.util.Collections; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + import org.bukkit.Bukkit; import org.bukkit.World; -import java.util.*; -import java.util.stream.Collectors; import world.bentobox.bentobox.api.addons.request.AddonRequestHandler; import world.bentobox.challenges.ChallengesAddon; diff --git a/src/main/java/world/bentobox/challenges/handlers/LevelListRequestHandler.java b/src/main/java/world/bentobox/challenges/handlers/LevelListRequestHandler.java index 8d8f809..7917046 100644 --- a/src/main/java/world/bentobox/challenges/handlers/LevelListRequestHandler.java +++ b/src/main/java/world/bentobox/challenges/handlers/LevelListRequestHandler.java @@ -1,10 +1,11 @@ package world.bentobox.challenges.handlers; -import org.bukkit.Bukkit; import java.util.Collections; import java.util.Map; +import org.bukkit.Bukkit; + import world.bentobox.bentobox.api.addons.request.AddonRequestHandler; import world.bentobox.challenges.ChallengesAddon; diff --git a/src/main/java/world/bentobox/challenges/listeners/ResetListener.java b/src/main/java/world/bentobox/challenges/listeners/ResetListener.java index 5f5f043..294ea8d 100644 --- a/src/main/java/world/bentobox/challenges/listeners/ResetListener.java +++ b/src/main/java/world/bentobox/challenges/listeners/ResetListener.java @@ -7,10 +7,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import world.bentobox.bentobox.api.user.User; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.bentobox.api.events.island.IslandEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.Reason; +import world.bentobox.challenges.ChallengesAddon; /** * Resets challenges when the island is reset diff --git a/src/main/java/world/bentobox/challenges/listeners/SaveListener.java b/src/main/java/world/bentobox/challenges/listeners/SaveListener.java index ccb043a..f20e588 100644 --- a/src/main/java/world/bentobox/challenges/listeners/SaveListener.java +++ b/src/main/java/world/bentobox/challenges/listeners/SaveListener.java @@ -6,7 +6,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.world.WorldSaveEvent; import world.bentobox.challenges.ChallengesAddon; diff --git a/src/main/java/world/bentobox/challenges/panel/CommonGUI.java b/src/main/java/world/bentobox/challenges/panel/CommonGUI.java index e33e8aa..5d41ac0 100644 --- a/src/main/java/world/bentobox/challenges/panel/CommonGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/CommonGUI.java @@ -9,7 +9,11 @@ import java.util.function.Consumer; import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.conversations.*; +import org.bukkit.conversations.Conversation; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; +import org.bukkit.conversations.StringPrompt; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/world/bentobox/challenges/panel/GameModesGUI.java b/src/main/java/world/bentobox/challenges/panel/GameModesGUI.java index bbc26c8..d60e7a4 100644 --- a/src/main/java/world/bentobox/challenges/panel/GameModesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/GameModesGUI.java @@ -1,12 +1,12 @@ package world.bentobox.challenges.panel; -import org.bukkit.Material; -import org.bukkit.World; - import java.util.List; import java.util.Optional; +import org.bukkit.Material; +import org.bukkit.World; + import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.panels.PanelItem; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java index 0355542..c65e9f7 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java @@ -1,6 +1,9 @@ package world.bentobox.challenges.panel.admin; +import java.util.function.Consumer; +import java.util.function.Function; + import org.bukkit.Material; import org.bukkit.World; import org.bukkit.conversations.Conversation; @@ -11,9 +14,6 @@ import org.bukkit.conversations.ValidatingPrompt; import org.bukkit.inventory.ItemStack; import org.eclipse.jdt.annotation.NonNull; -import java.util.function.Consumer; -import java.util.function.Function; - import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java index 1884278..b94a1f4 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java @@ -1,10 +1,6 @@ package world.bentobox.challenges.panel.admin; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -12,6 +8,11 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java index db7a81f..8938d98 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java @@ -22,7 +22,11 @@ import world.bentobox.challenges.ChallengesManager; import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.database.object.ChallengeLevel; import world.bentobox.challenges.panel.CommonGUI; -import world.bentobox.challenges.panel.util.*; +import world.bentobox.challenges.panel.util.ItemSwitchGUI; +import world.bentobox.challenges.panel.util.NumberGUI; +import world.bentobox.challenges.panel.util.SelectBlocksGUI; +import world.bentobox.challenges.panel.util.SelectChallengeGUI; +import world.bentobox.challenges.panel.util.StringListGUI; import world.bentobox.challenges.utils.GuiUtils; import world.bentobox.challenges.utils.Utils; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditLoreGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditLoreGUI.java index 1f53843..ac229fd 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditLoreGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditLoreGUI.java @@ -1,14 +1,17 @@ package world.bentobox.challenges.panel.admin; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.stream.Collectors; + import org.bukkit.Material; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.ItemStack; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.stream.Collectors; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.PanelListener; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java index b1a6b3d..40abf68 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java @@ -128,7 +128,6 @@ public class EditSettingsGUI extends CommonGUI } - @SuppressWarnings("deprecation") private PanelItem getSettingsButton(Button button) { ItemStack icon; @@ -434,7 +433,7 @@ public class EditSettingsGUI extends CommonGUI if (status) { materials.forEach(material -> - this.settings.setLockedLevelIcon(new ItemStack(material))); + this.settings.setLockedLevelIcon(new ItemStack(material))); } this.build(); @@ -501,14 +500,14 @@ public class EditSettingsGUI extends CommonGUI values.add(this.user.getTranslation("challenges.gui.descriptions.admin.visibility-mode")); values.add((this.settings.getVisibilityMode().equals(VisibilityMode.VISIBLE) ? "&2" : "&c") + - this.user.getTranslation("challenges.gui.descriptions.visibility.visible")); + this.user.getTranslation("challenges.gui.descriptions.visibility.visible")); values.add((this.settings.getVisibilityMode().equals(VisibilityMode.HIDDEN) ? "&2" : "&c") + - this.user.getTranslation("challenges.gui.descriptions.visibility.hidden")); + this.user.getTranslation("challenges.gui.descriptions.visibility.hidden")); values.add((this.settings.getVisibilityMode().equals(VisibilityMode.TOGGLEABLE) ? "&2" : "&c") + - this.user.getTranslation("challenges.gui.descriptions.visibility.toggleable")); + this.user.getTranslation("challenges.gui.descriptions.visibility.toggleable")); values.add(this.user.getTranslation("challenges.gui.descriptions.current-value", - "[value]",this.settings.getVisibilityMode().name())); + "[value]",this.settings.getVisibilityMode().name())); description = values; @@ -529,19 +528,19 @@ public class EditSettingsGUI extends CommonGUI if (clickType.isRightClick()) { this.settings.setVisibilityMode( - Utils.getPreviousValue(VisibilityMode.values(), - this.settings.getVisibilityMode())); + Utils.getPreviousValue(VisibilityMode.values(), + this.settings.getVisibilityMode())); } else { this.settings.setVisibilityMode( - Utils.getNextValue(VisibilityMode.values(), - this.settings.getVisibilityMode())); + Utils.getNextValue(VisibilityMode.values(), + this.settings.getVisibilityMode())); } // Rebuild just this icon panel.getInventory().setItem(slot, - this.getSettingsButton(button).getItem()); + this.getSettingsButton(button).getItem()); return true; }; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java index 3894efe..ccdb1cf 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java @@ -1,10 +1,11 @@ package world.bentobox.challenges.panel.admin; +import java.util.List; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.World; -import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java index d51ffdf..4a9dad5 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java @@ -1,10 +1,11 @@ package world.bentobox.challenges.panel.admin; +import java.util.List; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.World; -import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListLibraryGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListLibraryGUI.java index 4ee9d11..179cbb1 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListLibraryGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListLibraryGUI.java @@ -1,11 +1,12 @@ package world.bentobox.challenges.panel.admin; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.World; -import java.util.ArrayList; -import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java index db38cbf..e22eead 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java @@ -1,16 +1,17 @@ package world.bentobox.challenges.panel.admin; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; + import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ManageBlocksGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ManageBlocksGUI.java index c24e6d9..eab6371 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ManageBlocksGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ManageBlocksGUI.java @@ -1,10 +1,16 @@ package world.bentobox.challenges.panel.admin; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.commons.lang.WordUtils; import org.bukkit.Material; import org.bukkit.World; -import java.util.*; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ManageEntitiesGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ManageEntitiesGUI.java index 135621d..ed29747 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ManageEntitiesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ManageEntitiesGUI.java @@ -1,11 +1,17 @@ package world.bentobox.challenges.panel.admin; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.commons.lang.WordUtils; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.EntityType; -import java.util.*; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java index f29f873..fd336ea 100644 --- a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java @@ -1,11 +1,12 @@ package world.bentobox.challenges.panel.user; +import java.util.List; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.inventory.ItemStack; -import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/user/MultipleGUI.java b/src/main/java/world/bentobox/challenges/panel/user/MultipleGUI.java index 509f29c..26a9690 100644 --- a/src/main/java/world/bentobox/challenges/panel/user/MultipleGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/user/MultipleGUI.java @@ -1,10 +1,10 @@ package world.bentobox.challenges.panel.user; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; import java.util.function.Consumer; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; import world.bentobox.bentobox.api.panels.Panel; import world.bentobox.bentobox.api.panels.PanelItem; diff --git a/src/main/java/world/bentobox/challenges/panel/util/ChallengeTypeGUI.java b/src/main/java/world/bentobox/challenges/panel/util/ChallengeTypeGUI.java index 7956082..68bf018 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/ChallengeTypeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/ChallengeTypeGUI.java @@ -7,12 +7,13 @@ package world.bentobox.challenges.panel.util; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; import java.util.function.BiConsumer; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + import world.bentobox.bentobox.api.panels.Panel; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/util/ConfirmationGUI.java b/src/main/java/world/bentobox/challenges/panel/util/ConfirmationGUI.java index 20bfb13..5a979cc 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/ConfirmationGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/ConfirmationGUI.java @@ -1,10 +1,10 @@ package world.bentobox.challenges.panel.util; -import org.bukkit.Material; - import java.util.function.Consumer; +import org.bukkit.Material; + import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; diff --git a/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java b/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java index 4969f1e..e7caf56 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java @@ -1,14 +1,15 @@ package world.bentobox.challenges.panel.util; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.BiConsumer; + import org.bukkit.Material; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.BiConsumer; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.PanelListener; diff --git a/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java b/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java index 5ae5d9b..a80decd 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java @@ -1,13 +1,18 @@ package world.bentobox.challenges.panel.util; -import org.bukkit.Material; -import org.bukkit.conversations.*; -import org.bukkit.inventory.ItemStack; -import org.eclipse.jdt.annotation.NonNull; import java.util.function.BiConsumer; import java.util.function.Consumer; +import org.bukkit.Material; +import org.bukkit.conversations.Conversation; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.NumericPrompt; +import org.bukkit.conversations.Prompt; +import org.bukkit.inventory.ItemStack; +import org.eclipse.jdt.annotation.NonNull; + import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; @@ -21,505 +26,508 @@ import world.bentobox.challenges.utils.GuiUtils; */ public class NumberGUI { - public NumberGUI(User user, int value, int lineLength, BiConsumer consumer) - { - this(user, value, Integer.MIN_VALUE, Integer.MAX_VALUE, lineLength, consumer); - } - - - public NumberGUI(User user, int value, int minValue, int lineLength, BiConsumer consumer) - { - this(user, value, minValue, Integer.MAX_VALUE, lineLength, consumer); - } - - - public NumberGUI(User user, int value, int minValue, int maxValue, int lineLength, BiConsumer consumer) - { - this.user = user; - this.value = value; - this.consumer = consumer; - - this.minValue = minValue; - this.maxValue = maxValue; - - this.currentOperation = Button.SET; - - this.lineLength = lineLength; - - this.build(); - } - - - /** - * This method builds panel that allows to change given number value. - */ - private void build() - { - PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.title.admin.manage-numbers")); - - GuiUtils.fillBorder(panelBuilder); - - // Others - panelBuilder.item(1, this.getButton(Button.SAVE)); - - panelBuilder.item(19, this.getButton(Button.VALUE)); - panelBuilder.item(44, this.getButton(Button.CANCEL)); - - panelBuilder.item(2, this.getButton(Button.INPUT)); - - // operations - panelBuilder.item(3, this.getButton(Button.SET)); - panelBuilder.item(4, this.getButton(Button.INCREASE)); - panelBuilder.item(5, this.getButton(Button.REDUCE)); - panelBuilder.item(6, this.getButton(Button.MULTIPLY)); - - // Numbers - panelBuilder.item(11, this.createNumberButton(1)); - panelBuilder.item(12, this.createNumberButton(10)); - panelBuilder.item(13, this.createNumberButton(100)); - panelBuilder.item(14, this.createNumberButton(1000)); - panelBuilder.item(15, this.createNumberButton(10000)); - - panelBuilder.item(20, this.createNumberButton(2)); - panelBuilder.item(21, this.createNumberButton(20)); - panelBuilder.item(22, this.createNumberButton(200)); - panelBuilder.item(23, this.createNumberButton(2000)); - panelBuilder.item(24, this.createNumberButton(20000)); - - panelBuilder.item(29, this.createNumberButton(5)); - panelBuilder.item(30, this.createNumberButton(50)); - panelBuilder.item(31, this.createNumberButton(500)); - panelBuilder.item(32, this.createNumberButton(5000)); - panelBuilder.item(33, this.createNumberButton(50000)); - - panelBuilder.build(); - } - - - /** - * This method creates PanelItem with required functionality. - * @param button Functionality requirement. - * @return PanelItem with functionality. - */ - private PanelItem getButton(Button button) - { - ItemStack icon; - String name; - String description; - PanelItem.ClickHandler clickHandler; - boolean glow; - - switch (button) - { - case SAVE: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.save"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.save"); - icon = new ItemStack(Material.COMMAND_BLOCK); - clickHandler = (panel, user, clickType, slot) -> { - this.consumer.accept(true, this.value); - return true; - }; - glow = false; - break; - } - case CANCEL: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.cancel"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.cancel"); - icon = new ItemStack(Material.OAK_DOOR); - clickHandler = (panel, user, clickType, slot) -> { - this.consumer.accept(false, this.value); - return true; - }; - glow = false; - break; - } - case INPUT: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.input"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.input"); - icon = new ItemStack(Material.ANVIL); - clickHandler = (panel, user, clickType, slot) -> { - - this.getNumberInput(number -> { - this.value = number.intValue(); - this.build(); - }, - this.user.getTranslation("challenges.gui.questions.admin.number")); - - return true; - }; - glow = false; - break; - } - case VALUE: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.value"); - description = this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Integer.toString(this.value)); - icon = new ItemStack(Material.PAPER); - clickHandler = (panel, user, clickType, slot) -> true; - glow = false; - break; - } - case SET: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.set"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.set"); - icon = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); - clickHandler = (panel, user, clickType, slot) -> { - this.currentOperation = Button.SET; - this.build(); - return true; - }; - glow = this.currentOperation.equals(Button.SET); - break; - } - case INCREASE: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.increase"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.increase"); - icon = new ItemStack(Material.GREEN_STAINED_GLASS_PANE); - clickHandler = (panel, user, clickType, slot) -> { - this.currentOperation = Button.INCREASE; - this.build(); - return true; - }; - glow = this.currentOperation.equals(Button.INCREASE); - break; - } - case REDUCE: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.reduce"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.reduce"); - icon = new ItemStack(Material.RED_STAINED_GLASS_PANE); - clickHandler = (panel, user, clickType, slot) -> { - this.currentOperation = Button.REDUCE; - this.build(); - return true; - }; - glow = this.currentOperation.equals(Button.REDUCE); - break; - } - case MULTIPLY: - { - name = this.user.getTranslation("challenges.gui.buttons.admin.multiply"); - description = this.user.getTranslation("challenges.gui.descriptions.admin.multiply"); - icon = new ItemStack(Material.BLUE_STAINED_GLASS_PANE); - clickHandler = (panel, user, clickType, slot) -> { - this.currentOperation = Button.MULTIPLY; - this.build(); - return true; - }; - glow = this.currentOperation.equals(Button.MULTIPLY); - break; - } - default: - return null; - } - - return new PanelItemBuilder(). - icon(icon). - name(name). - description(GuiUtils.stringSplit(description, this.lineLength)). - glow(glow). - clickHandler(clickHandler). - build(); - } - - - /** - * This method creates Number Button based on input number. - * @param number Number which button must be created. - * @return PanelItem that represents number button. - */ - private PanelItem createNumberButton(int number) - { - PanelItemBuilder itemBuilder = new PanelItemBuilder(); - - switch (this.currentOperation) - { - case SET: - { - itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); - itemBuilder.icon(Material.WHITE_STAINED_GLASS_PANE); - itemBuilder.clickHandler((panel, user1, clickType, i) -> { - this.value = number; - - if (this.value > this.maxValue) - { - this.user.sendMessage("challenges.errors.not-valid-integer", - "[value]", Integer.toString(this.value), - "[min]", Integer.toString(this.minValue), - "[max]", Integer.toString(this.maxValue)); - - this.value = this.maxValue; - } - - if (this.value < this.minValue) - { - this.user.sendMessage("challenges.errors.not-valid-integer", - "[value]", Integer.toString(this.value), - "[min]", Integer.toString(this.minValue), - "[max]", Integer.toString(this.maxValue)); - - this.value = this.minValue; - } - - this.build(); - return true; - }); - - break; - } - case INCREASE: - { - itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); - itemBuilder.icon(Material.GREEN_STAINED_GLASS_PANE); - itemBuilder.clickHandler((panel, user1, clickType, i) -> { - this.value += number; - - if (this.value > this.maxValue) - { - this.user.sendMessage("challenges.errors.not-valid-integer", - "[value]", Integer.toString(this.value), - "[min]", Integer.toString(this.minValue), - "[max]", Integer.toString(this.maxValue)); - - this.value = this.maxValue; - } - - this.build(); - return true; - }); - - break; - } - case REDUCE: - { - itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); - itemBuilder.icon(Material.RED_STAINED_GLASS_PANE); - itemBuilder.clickHandler((panel, user1, clickType, i) -> { - this.value -= number; - - if (this.value < this.minValue) - { - this.user.sendMessage("challenges.errors.not-valid-integer", - "[value]", Integer.toString(this.value), - "[min]", Integer.toString(this.minValue), - "[max]", Integer.toString(this.maxValue)); - - this.value = this.minValue; - } - - this.build(); - return true; - }); - - break; - } - case MULTIPLY: - { - itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); - itemBuilder.icon(Material.BLUE_STAINED_GLASS_PANE); - itemBuilder.clickHandler((panel, user1, clickType, i) -> { - this.value *= number; - - if (this.value > this.maxValue) - { - this.user.sendMessage("challenges.errors.not-valid-integer", - "[value]", Integer.toString(this.value), - "[min]", Integer.toString(this.minValue), - "[max]", Integer.toString(this.maxValue)); - - this.value = this.maxValue; - } - - this.build(); - return true; - }); - - break; - } - } - - return itemBuilder.build(); - } - - -// --------------------------------------------------------------------- -// Section: Conversation -// --------------------------------------------------------------------- - - - /** - * This method will close opened gui and writes inputText in chat. After players answers on - * inputText in chat, message will trigger consumer and gui will reopen. - * @param consumer Consumer that accepts player output text. - * @param question Message that will be displayed in chat when player triggers conversion. - */ - private void getNumberInput(Consumer consumer, @NonNull String question) - { - final User user = this.user; - - Conversation conversation = - new ConversationFactory(BentoBox.getInstance()).withFirstPrompt( - new NumericPrompt() - { - /** - * Override this method to perform some action - * with the user's integer response. - * - * @param context Context information about the - * conversation. - * @param input The user's response as a {@link - * Number}. - * @return The next {@link Prompt} in the prompt - * graph. - */ - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) - { - // Add answer to consumer. - consumer.accept(input); - // Reopen GUI - NumberGUI.this.build(); - // End conversation - return Prompt.END_OF_CONVERSATION; - } - - - /** - * Override this method to do further validation on the numeric player - * input after the input has been determined to actually be a number. - * - * @param context Context information about the conversation. - * @param input The number the player provided. - * @return The validity of the player's input. - */ - protected boolean isNumberValid(ConversationContext context, Number input) - { - return input.intValue() >= NumberGUI.this.minValue && - input.intValue() <= NumberGUI.this.maxValue; - } - - - /** - * Optionally override this method to display an additional message if the - * user enters an invalid number. - * - * @param context Context information about the conversation. - * @param invalidInput The invalid input provided by the user. - * @return A message explaining how to correct the input. - */ - @Override - protected String getInputNotNumericText(ConversationContext context, - String invalidInput) - { - return NumberGUI.this.user.getTranslation("challenges.errors.not-a-integer", "[value]", invalidInput); - } - - - /** - * Optionally override this method to display an additional message if the - * user enters an invalid numeric input. - * - * @param context Context information about the conversation. - * @param invalidInput The invalid input provided by the user. - * @return A message explaining how to correct the input. - */ - @Override - protected String getFailedValidationText(ConversationContext context, - Number invalidInput) - { - return NumberGUI.this.user.getTranslation("challenges.errors.not-valid-integer", - "[value]", invalidInput.toString(), - "[min]", Integer.toString(NumberGUI.this.minValue), - "[max]", Integer.toString(NumberGUI.this.maxValue)); - } - - - /** - * @see Prompt#getPromptText(ConversationContext) - */ - @Override - public String getPromptText(ConversationContext conversationContext) - { - // Close input GUI. - user.closeInventory(); - - // There are no editable message. Just return question. - return question; - } - }). - withLocalEcho(false). - withPrefix(context -> - NumberGUI.this.user.getTranslation("challenges.gui.questions.prefix")). - buildConversation(user.getPlayer()); - - conversation.begin(); - } - - -// --------------------------------------------------------------------- -// Section: Enums -// --------------------------------------------------------------------- - - - /** - * This enum contains all button types. - */ - private enum Button - { - SAVE, - CANCEL, - INPUT, - - VALUE, - - SET, - INCREASE, - REDUCE, - MULTIPLY - } - - -// --------------------------------------------------------------------- -// Section: Variables -// --------------------------------------------------------------------- - - /** - * This variable stores current GUI consumer. - */ - private BiConsumer consumer; - - /** - * User who runs GUI. - */ - private User user; - - /** - * Current value. - */ - private int value; - - /** - * Minimal value that is allowed to set. - */ - private int minValue; - - /** - * Maximal value that is allowed to set. - */ - private int maxValue; - - /** - * This variable holds which operation now is processed. - */ - private Button currentOperation; - - /** - * This variable stores how large line can be, before warp it. - */ - private int lineLength; + public NumberGUI(User user, int value, int lineLength, BiConsumer consumer) + { + this(user, value, Integer.MIN_VALUE, Integer.MAX_VALUE, lineLength, consumer); + } + + + public NumberGUI(User user, int value, int minValue, int lineLength, BiConsumer consumer) + { + this(user, value, minValue, Integer.MAX_VALUE, lineLength, consumer); + } + + + public NumberGUI(User user, int value, int minValue, int maxValue, int lineLength, BiConsumer consumer) + { + this.user = user; + this.value = value; + this.consumer = consumer; + + this.minValue = minValue; + this.maxValue = maxValue; + + this.currentOperation = Button.SET; + + this.lineLength = lineLength; + + this.build(); + } + + + /** + * This method builds panel that allows to change given number value. + */ + private void build() + { + PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.title.admin.manage-numbers")); + + GuiUtils.fillBorder(panelBuilder); + + // Others + panelBuilder.item(1, this.getButton(Button.SAVE)); + + panelBuilder.item(19, this.getButton(Button.VALUE)); + panelBuilder.item(44, this.getButton(Button.CANCEL)); + + panelBuilder.item(2, this.getButton(Button.INPUT)); + + // operations + panelBuilder.item(3, this.getButton(Button.SET)); + panelBuilder.item(4, this.getButton(Button.INCREASE)); + panelBuilder.item(5, this.getButton(Button.REDUCE)); + panelBuilder.item(6, this.getButton(Button.MULTIPLY)); + + // Numbers + panelBuilder.item(11, this.createNumberButton(1)); + panelBuilder.item(12, this.createNumberButton(10)); + panelBuilder.item(13, this.createNumberButton(100)); + panelBuilder.item(14, this.createNumberButton(1000)); + panelBuilder.item(15, this.createNumberButton(10000)); + + panelBuilder.item(20, this.createNumberButton(2)); + panelBuilder.item(21, this.createNumberButton(20)); + panelBuilder.item(22, this.createNumberButton(200)); + panelBuilder.item(23, this.createNumberButton(2000)); + panelBuilder.item(24, this.createNumberButton(20000)); + + panelBuilder.item(29, this.createNumberButton(5)); + panelBuilder.item(30, this.createNumberButton(50)); + panelBuilder.item(31, this.createNumberButton(500)); + panelBuilder.item(32, this.createNumberButton(5000)); + panelBuilder.item(33, this.createNumberButton(50000)); + + panelBuilder.build(); + } + + + /** + * This method creates PanelItem with required functionality. + * @param button Functionality requirement. + * @return PanelItem with functionality. + */ + private PanelItem getButton(Button button) + { + ItemStack icon; + String name; + String description; + PanelItem.ClickHandler clickHandler; + boolean glow; + + switch (button) + { + case SAVE: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.save"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.save"); + icon = new ItemStack(Material.COMMAND_BLOCK); + clickHandler = (panel, user, clickType, slot) -> { + this.consumer.accept(true, this.value); + return true; + }; + glow = false; + break; + } + case CANCEL: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.cancel"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.cancel"); + icon = new ItemStack(Material.OAK_DOOR); + clickHandler = (panel, user, clickType, slot) -> { + this.consumer.accept(false, this.value); + return true; + }; + glow = false; + break; + } + case INPUT: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.input"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.input"); + icon = new ItemStack(Material.ANVIL); + clickHandler = (panel, user, clickType, slot) -> { + + this.getNumberInput(number -> { + this.value = number.intValue(); + this.build(); + }, + this.user.getTranslation("challenges.gui.questions.admin.number")); + + return true; + }; + glow = false; + break; + } + case VALUE: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.value"); + description = this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Integer.toString(this.value)); + icon = new ItemStack(Material.PAPER); + clickHandler = (panel, user, clickType, slot) -> true; + glow = false; + break; + } + case SET: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.set"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.set"); + icon = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + clickHandler = (panel, user, clickType, slot) -> { + this.currentOperation = Button.SET; + this.build(); + return true; + }; + glow = this.currentOperation.equals(Button.SET); + break; + } + case INCREASE: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.increase"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.increase"); + icon = new ItemStack(Material.GREEN_STAINED_GLASS_PANE); + clickHandler = (panel, user, clickType, slot) -> { + this.currentOperation = Button.INCREASE; + this.build(); + return true; + }; + glow = this.currentOperation.equals(Button.INCREASE); + break; + } + case REDUCE: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.reduce"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.reduce"); + icon = new ItemStack(Material.RED_STAINED_GLASS_PANE); + clickHandler = (panel, user, clickType, slot) -> { + this.currentOperation = Button.REDUCE; + this.build(); + return true; + }; + glow = this.currentOperation.equals(Button.REDUCE); + break; + } + case MULTIPLY: + { + name = this.user.getTranslation("challenges.gui.buttons.admin.multiply"); + description = this.user.getTranslation("challenges.gui.descriptions.admin.multiply"); + icon = new ItemStack(Material.BLUE_STAINED_GLASS_PANE); + clickHandler = (panel, user, clickType, slot) -> { + this.currentOperation = Button.MULTIPLY; + this.build(); + return true; + }; + glow = this.currentOperation.equals(Button.MULTIPLY); + break; + } + default: + return null; + } + + return new PanelItemBuilder(). + icon(icon). + name(name). + description(GuiUtils.stringSplit(description, this.lineLength)). + glow(glow). + clickHandler(clickHandler). + build(); + } + + + /** + * This method creates Number Button based on input number. + * @param number Number which button must be created. + * @return PanelItem that represents number button. + */ + private PanelItem createNumberButton(int number) + { + PanelItemBuilder itemBuilder = new PanelItemBuilder(); + + switch (this.currentOperation) + { + case SET: + { + itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); + itemBuilder.icon(Material.WHITE_STAINED_GLASS_PANE); + itemBuilder.clickHandler((panel, user1, clickType, i) -> { + this.value = number; + + if (this.value > this.maxValue) + { + this.user.sendMessage("challenges.errors.not-valid-integer", + "[value]", Integer.toString(this.value), + "[min]", Integer.toString(this.minValue), + "[max]", Integer.toString(this.maxValue)); + + this.value = this.maxValue; + } + + if (this.value < this.minValue) + { + this.user.sendMessage("challenges.errors.not-valid-integer", + "[value]", Integer.toString(this.value), + "[min]", Integer.toString(this.minValue), + "[max]", Integer.toString(this.maxValue)); + + this.value = this.minValue; + } + + this.build(); + return true; + }); + + break; + } + case INCREASE: + { + itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); + itemBuilder.icon(Material.GREEN_STAINED_GLASS_PANE); + itemBuilder.clickHandler((panel, user1, clickType, i) -> { + this.value += number; + + if (this.value > this.maxValue) + { + this.user.sendMessage("challenges.errors.not-valid-integer", + "[value]", Integer.toString(this.value), + "[min]", Integer.toString(this.minValue), + "[max]", Integer.toString(this.maxValue)); + + this.value = this.maxValue; + } + + this.build(); + return true; + }); + + break; + } + case REDUCE: + { + itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); + itemBuilder.icon(Material.RED_STAINED_GLASS_PANE); + itemBuilder.clickHandler((panel, user1, clickType, i) -> { + this.value -= number; + + if (this.value < this.minValue) + { + this.user.sendMessage("challenges.errors.not-valid-integer", + "[value]", Integer.toString(this.value), + "[min]", Integer.toString(this.minValue), + "[max]", Integer.toString(this.maxValue)); + + this.value = this.minValue; + } + + this.build(); + return true; + }); + + break; + } + case MULTIPLY: + { + itemBuilder.name(this.user.getTranslation("challenges.gui.buttons.admin.number","[number]", Integer.toString(number))); + itemBuilder.icon(Material.BLUE_STAINED_GLASS_PANE); + itemBuilder.clickHandler((panel, user1, clickType, i) -> { + this.value *= number; + + if (this.value > this.maxValue) + { + this.user.sendMessage("challenges.errors.not-valid-integer", + "[value]", Integer.toString(this.value), + "[min]", Integer.toString(this.minValue), + "[max]", Integer.toString(this.maxValue)); + + this.value = this.maxValue; + } + + this.build(); + return true; + }); + + break; + } + default: + break; + } + + return itemBuilder.build(); + } + + + // --------------------------------------------------------------------- + // Section: Conversation + // --------------------------------------------------------------------- + + + /** + * This method will close opened gui and writes inputText in chat. After players answers on + * inputText in chat, message will trigger consumer and gui will reopen. + * @param consumer Consumer that accepts player output text. + * @param question Message that will be displayed in chat when player triggers conversion. + */ + private void getNumberInput(Consumer consumer, @NonNull String question) + { + final User user = this.user; + + Conversation conversation = + new ConversationFactory(BentoBox.getInstance()).withFirstPrompt( + new NumericPrompt() + { + /** + * Override this method to perform some action + * with the user's integer response. + * + * @param context Context information about the + * conversation. + * @param input The user's response as a {@link + * Number}. + * @return The next {@link Prompt} in the prompt + * graph. + */ + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) + { + // Add answer to consumer. + consumer.accept(input); + // Reopen GUI + NumberGUI.this.build(); + // End conversation + return Prompt.END_OF_CONVERSATION; + } + + + /** + * Override this method to do further validation on the numeric player + * input after the input has been determined to actually be a number. + * + * @param context Context information about the conversation. + * @param input The number the player provided. + * @return The validity of the player's input. + */ + @Override + protected boolean isNumberValid(ConversationContext context, Number input) + { + return input.intValue() >= NumberGUI.this.minValue && + input.intValue() <= NumberGUI.this.maxValue; + } + + + /** + * Optionally override this method to display an additional message if the + * user enters an invalid number. + * + * @param context Context information about the conversation. + * @param invalidInput The invalid input provided by the user. + * @return A message explaining how to correct the input. + */ + @Override + protected String getInputNotNumericText(ConversationContext context, + String invalidInput) + { + return NumberGUI.this.user.getTranslation("challenges.errors.not-a-integer", "[value]", invalidInput); + } + + + /** + * Optionally override this method to display an additional message if the + * user enters an invalid numeric input. + * + * @param context Context information about the conversation. + * @param invalidInput The invalid input provided by the user. + * @return A message explaining how to correct the input. + */ + @Override + protected String getFailedValidationText(ConversationContext context, + Number invalidInput) + { + return NumberGUI.this.user.getTranslation("challenges.errors.not-valid-integer", + "[value]", invalidInput.toString(), + "[min]", Integer.toString(NumberGUI.this.minValue), + "[max]", Integer.toString(NumberGUI.this.maxValue)); + } + + + /** + * @see Prompt#getPromptText(ConversationContext) + */ + @Override + public String getPromptText(ConversationContext conversationContext) + { + // Close input GUI. + user.closeInventory(); + + // There are no editable message. Just return question. + return question; + } + }). + withLocalEcho(false). + withPrefix(context -> + NumberGUI.this.user.getTranslation("challenges.gui.questions.prefix")). + buildConversation(user.getPlayer()); + + conversation.begin(); + } + + + // --------------------------------------------------------------------- + // Section: Enums + // --------------------------------------------------------------------- + + + /** + * This enum contains all button types. + */ + private enum Button + { + SAVE, + CANCEL, + INPUT, + + VALUE, + + SET, + INCREASE, + REDUCE, + MULTIPLY + } + + + // --------------------------------------------------------------------- + // Section: Variables + // --------------------------------------------------------------------- + + /** + * This variable stores current GUI consumer. + */ + private BiConsumer consumer; + + /** + * User who runs GUI. + */ + private User user; + + /** + * Current value. + */ + private int value; + + /** + * Minimal value that is allowed to set. + */ + private int minValue; + + /** + * Maximal value that is allowed to set. + */ + private int maxValue; + + /** + * This variable holds which operation now is processed. + */ + private Button currentOperation; + + /** + * This variable stores how large line can be, before warp it. + */ + private int lineLength; } diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java index 2a924e4..d3ffdcb 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java @@ -1,17 +1,20 @@ package world.bentobox.challenges.panel.util; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; + import org.apache.commons.lang.WordUtils; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import java.util.*; -import java.util.function.BiConsumer; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.utils.GuiUtils; diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java index 1b37a97..16cc3b7 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java @@ -1,17 +1,21 @@ package world.bentobox.challenges.panel.util; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.event.inventory.ClickType; -import java.util.*; -import java.util.function.BiConsumer; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.utils.GuiUtils; diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java index b4019f6..4104f8a 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectEntityGUI.java @@ -1,18 +1,23 @@ package world.bentobox.challenges.panel.util; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; + import org.apache.commons.lang.WordUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; -import java.util.*; -import java.util.function.BiConsumer; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.utils.GuiUtils; diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectEnvironmentGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectEnvironmentGUI.java index 313f103..928998a 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectEnvironmentGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectEnvironmentGUI.java @@ -1,12 +1,13 @@ package world.bentobox.challenges.panel.util; -import org.bukkit.Material; -import org.bukkit.World; import java.util.Collections; import java.util.Set; import java.util.function.BiConsumer; +import org.bukkit.Material; +import org.bukkit.World; + import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; diff --git a/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java b/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java index 39daf73..62df5c7 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java @@ -1,11 +1,6 @@ package world.bentobox.challenges.panel.util; -import org.bukkit.Material; -import org.bukkit.conversations.*; -import org.bukkit.inventory.ItemStack; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -13,6 +8,16 @@ import java.util.List; import java.util.function.BiConsumer; import java.util.function.Consumer; +import org.bukkit.Material; +import org.bukkit.conversations.Conversation; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; +import org.bukkit.conversations.StringPrompt; +import org.bukkit.inventory.ItemStack; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; + import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.TextComponent; import world.bentobox.bentobox.BentoBox; diff --git a/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java b/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java index 7db1474..5e53e6e 100644 --- a/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java +++ b/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java @@ -5,7 +5,21 @@ package world.bentobox.challenges.tasks; -import org.bukkit.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.PriorityQueue; +import java.util.Queue; +import java.util.stream.Collectors; + +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; @@ -13,8 +27,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.util.BoundingBox; -import java.util.*; -import java.util.stream.Collectors; import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.user.User; diff --git a/src/main/java/world/bentobox/challenges/utils/GuiUtils.java b/src/main/java/world/bentobox/challenges/utils/GuiUtils.java index 62076be..fea25bd 100644 --- a/src/main/java/world/bentobox/challenges/utils/GuiUtils.java +++ b/src/main/java/world/bentobox/challenges/utils/GuiUtils.java @@ -1,15 +1,16 @@ package world.bentobox.challenges.utils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.apache.commons.lang.WordUtils; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; diff --git a/src/main/java/world/bentobox/challenges/utils/HeadLib.java b/src/main/java/world/bentobox/challenges/utils/HeadLib.java index 3dcae81..1bbae6a 100644 --- a/src/main/java/world/bentobox/challenges/utils/HeadLib.java +++ b/src/main/java/world/bentobox/challenges/utils/HeadLib.java @@ -15,14 +15,21 @@ package world.bentobox.challenges.utils; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.lang.reflect.Field; -import java.util.*; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; import world.bentobox.bentobox.BentoBox; diff --git a/src/main/java/world/bentobox/challenges/utils/Utils.java b/src/main/java/world/bentobox/challenges/utils/Utils.java index d5ad9a2..45508d8 100644 --- a/src/main/java/world/bentobox/challenges/utils/Utils.java +++ b/src/main/java/world/bentobox/challenges/utils/Utils.java @@ -1,11 +1,12 @@ package world.bentobox.challenges.utils; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.Material; import org.bukkit.World; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.List; import world.bentobox.bentobox.BentoBox; diff --git a/src/main/java/world/bentobox/challenges/web/WebManager.java b/src/main/java/world/bentobox/challenges/web/WebManager.java index 48b088e..d2545f6 100644 --- a/src/main/java/world/bentobox/challenges/web/WebManager.java +++ b/src/main/java/world/bentobox/challenges/web/WebManager.java @@ -1,11 +1,16 @@ package world.bentobox.challenges.web; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Comparator; +import java.util.List; + +import org.bukkit.World; + import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.bukkit.World; -import java.nio.charset.StandardCharsets; -import java.util.*; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; diff --git a/src/main/java/world/bentobox/challenges/web/object/LibraryEntry.java b/src/main/java/world/bentobox/challenges/web/object/LibraryEntry.java index 15f384c..69e6528 100644 --- a/src/main/java/world/bentobox/challenges/web/object/LibraryEntry.java +++ b/src/main/java/world/bentobox/challenges/web/object/LibraryEntry.java @@ -1,11 +1,12 @@ package world.bentobox.challenges.web.object; -import com.google.gson.JsonObject; import org.bukkit.Material; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; +import com.google.gson.JsonObject; + /** * This objects allows to load each Challenges Catalog library entry. diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 36a4a68..3e460bd 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -20,32 +20,32 @@ challenges: description: 'Reload challenges from the database|Parameter hard means that addon will reset connection to database.' parameters: '[hard]' show: - description: 'This method prints in chat all challenges that exist in world.' + description: 'Prints in chat all challenges that exist in world.' parameters: '' defaults: - description: 'This method shows subcommands that allows to import/export default challenges.' + description: 'Show subcommands to import/export default challenges.' parameters: '[command]' defaults-import: - description: 'This method allows to import default challenges.' + description: 'Import default challenges.' parameters: '' defaults-generate: - description: 'This method allows to export existing challenges into default.json file.' + description: 'Export existing challenges to default.json file.' parameters: '[overwrite] - allows to overwrite existing file.' complete: - description: 'This command allows to complete challenge for player without GUI.' + description: 'Complete challenge for player.' parameters: ' ' reset: - description: 'This command allows to reset challenge for player without GUI. If "challenge_id" is set to "all", then it will reset all challenges.' + description: 'Reset challenge for player. If "challenge_id" is set to "all", then it will reset all challenges.' parameters: ' ' migrate: - description: 'This method allows to migrate challenges data that refers to current game mode world to new 0.8.0 storage format.' + description: 'Migrate current game world challenges data to 0.8.0 storage format.' parameters: '' user: main: - description: 'This method opens Challenges GUI.' + description: 'Open Challenges GUI.' parameters: '' complete: - description: 'This method allows to complete challenge without GUI.' + description: 'Complete challenge.' parameters: ' [count]' gui: title: @@ -160,7 +160,7 @@ challenges: gui-view-mode: 'Display All GameModes' gui-mode: 'Single Challenges GUI' history-store: 'Challenges History' - history-lifespan: 'History LifeSpan' + history-lifespan: 'History Lifespan' island-store: 'Store per Island' default-locked-icon: 'Locked Level Icon' input-mode: 'Switch input mode' @@ -195,104 +195,104 @@ challenges: increase: 'Increase operation. Clicking on numbers will increase value by selected number.' reduce: 'Reduce operation. Clicking on numbers will reduce value by selected number.' multiply: 'Multiply operation. Clicking on numbers will multiply value by selected number.' - import: 'Allows to import ASkyblock Challenges.|On right click it enables/disables overwrite mode.|Place Challenges.yml inside ./BentoBox/addons/Challenges folder.' - complete: 'Allows to complete challenges for any user.|User will not get reward for completion.' - reset: 'Allows to reset completed user challenges.|Right click enables/disables Reset all functionality.' - create-challenge: 'Allows to add new Challenge.|By default it will be in free challenges list.' - create-level: 'Allows to add new Level.' - edit-challenge: 'Allows to edit any Challenge settings.' - edit-level: 'Allows to edit any Level settings.' - delete-challenge: 'Allows remove any Challenge.' - delete-level: 'Allows remove any Level.' - settings: 'Allows to change addon settings.' - properties: 'Allows to change general properties' - requirements: 'Allows to manage requirements' - rewards: 'Allows to manage rewards' - challenges: 'Allows to manage level challenges (add / remove).' + import: 'Import ASkyblock Challenges.|On right click it enables/disables overwrite mode.|Place Challenges.yml inside ./BentoBox/addons/Challenges folder.' + complete: 'Complete challenges for any user.|User will not get reward for completion.' + reset: 'Reset completed user challenges.|Right click enables/disables Reset all functionality.' + create-challenge: 'Add new Challenge.|By default it will be in free challenges list.' + create-level: 'Add new Level.' + edit-challenge: 'Edit Challenge settings.' + edit-level: 'Edit Level settings.' + delete-challenge: 'Remove a Challenge.' + delete-level: 'Remove a Level.' + settings: 'Change settings.' + properties: 'Change general properties' + requirements: 'Manage requirements' + rewards: 'Manage rewards' + challenges: 'manage level challenges (add / remove).' deployment: 'Allows users to complete (view) challenge.' icon-challenge: 'Icon that will be displayed in GUI panels for this challenge.' icon-level: 'Icon that will be displayed in GUI panels for this level.' locked-icon: 'Icon that will be displayed in GUI panels if level is locked.' - description: 'Allows to edit description.' - order: 'Allows to change order number.' - environment: 'Allows to change environment where challenge operates.' - remove-on-complete: 'Allows to remove challenge from player GUI after it is completed.' - name-challenge: 'Allows to change challenge display name.' - name-level: 'Allows to change level display name.' - required-entities: 'Allows to add/edit/remove required entities.|Entities:|' - remove-entities: 'Allows to remove (kill) entities on challenge completion.' - required-blocks: 'Allows to add/edit/remove required blocks.|Blocks:|' - remove-blocks: 'Allows to remove (replace with air) blocks on challenge completion.' - search-radius: 'Radius around player location where required entities and blocks will be searched.' + description: 'Edit description.' + order: 'Change order number.' + environment: 'Change challenge environment.' + remove-on-complete: 'Remove challenge from player GUI after it is completed.' + name-challenge: 'Change challenge display name.' + name-level: 'Change level display name.' + required-entities: 'Add/edit/remove required entities.|Entities:|' + remove-entities: 'Remove (kill) entities on challenge completion.' + required-blocks: 'Add/edit/remove required blocks.|Blocks:|' + remove-blocks: 'Remove (replace with air) blocks on challenge completion.' + search-radius: "Radius around player's location where required entities and blocks will be searched." required-permissions: 'Required permissions for player to be able to complete challenge.|Permission:' required-items: 'Required items in player"s inventory.|Items:' - remove-items: 'Allows to remove items from player inventory after challenge completion.' - required-experience: 'Allows to define required experience for user to complete challenge.' - remove-experience: 'Allows to remove remove required experience.' - required-level: 'Allows to define required island level for this challenge.|&cRequires Level addon.' - required-money: 'Allows to define required money in player"s account.|&cRequires Vault and Economy plugin.' - remove-money: 'Allows to remove required money from player"s account.|&cRequires Vault and Economy plugin.' - reward-text: 'Allows to change message that will be sent to player after challenges completion.' - reward-items: 'Allows to change first time completion reward items.|Items:' - reward-experience: 'Allows to change first time completion reward Experience.' - reward-money: 'Allows to change first time completion reward Money.|&cRequires Vault and Economy plugin.' - reward-commands: 'Allows to define reward commands that will be called after first time completion.|***Adding "[SELF]" at the start means that command will be run by player, f.e. "/kill"|***String "[player]" will be replaced with player name, f.e. "/kill [player]" will be transformed to "/kill BONNe1704"|Commands:' - repeatable: 'Allows to define if challenge is repeatable or not.' - repeat-count: 'Allows to define maximal repeat count. If value is set 0 or smaller, then there are no limitations.' - repeat-reward-text: 'Allows to change message that will be sent to player after challenge repeated completion.' - repeat-reward-items: 'Allows to change repeated completion reward items.|Items:' - repeat-reward-experience: 'Allows to change repeated completion reward Experience.' - repeat-reward-money: 'Allows to change repeated completion reward Money.|&cRequires Vault and Economy plugin.' - repeat-reward-commands: 'Allows to define reward commands that will be called after challenge repeated completion.|***Adding "[SELF]" at the start means that command will be run by player, f.e. "/kill"|***String "[player]" will be replaced with player name, f.e. "/kill [player]" will be transformed to "/kill BONNe1704"|Commands:' - waiver-amount: 'Allows to set how many challenges can be left undone to unlock next level.' - reward-text-level: 'Allows to change message that will be sent to player after completing all challenges in level.' - add-challenge: 'Allows to add existing challenge to current level.' - remove-challenge: 'Allows remove any challenge from current level.' - reset-on-new: 'Enables/Disables option, that resets all player challenges if player restarts island, leave island or was kicked out.' + remove-items: 'Remove items from player inventory after challenge completion.' + required-experience: 'Define required experience for user to complete challenge.' + remove-experience: 'Remove remove required experience.' + required-level: 'Define required island level for this challenge.|&cRequires Level addon.' + required-money: 'Define required money in player"s account.|&cRequires Vault and Economy plugin.' + remove-money: 'Remove required money from player"s account.|&cRequires Vault and Economy plugin.' + reward-text: 'Change message that will be sent to player after challenges completion.' + reward-items: 'Change first time completion reward items.|Items:' + reward-experience: 'Change first time completion reward Experience.' + reward-money: 'Change first time completion reward Money.|&cRequires Vault and Economy plugin.' + reward-commands: 'Define reward commands that will be called after first time completion.|***Adding "[SELF]" at the start means that command will be run by player, f.e. "/kill"|***String "[player]" will be replaced with player name, f.e. "/kill [player]" will be transformed to "/kill BONNe1704"|Commands:' + repeatable: 'Define if challenge is repeatable or not.' + repeat-count: 'Define maximal repeat count. If value is set 0 or smaller, then there are no limitations.' + repeat-reward-text: 'Change message that will be sent to player after challenge repeated completion.' + repeat-reward-items: 'Change repeated completion reward items.|Items:' + repeat-reward-experience: 'Change repeated completion reward Experience.' + repeat-reward-money: 'Change repeated completion reward Money.|&cRequires Vault and Economy plugin.' + repeat-reward-commands: 'Define reward commands that will be called after challenge repeated completion.|***Adding "[SELF]" at the start means that command will be run by player, f.e. "/kill"|***String "[player]" will be replaced with player name, f.e. "/kill [player]" will be transformed to "/kill BONNe1704"|Commands:' + waiver-amount: 'Set how many challenges can be left undone to unlock next level.' + reward-text-level: 'Change message that will be sent to player after completing all challenges in level.' + add-challenge: 'Add existing challenge to current level.' + remove-challenge: 'Remove a challenge from current level.' + reset-on-new: 'Enables/Disables resets of all player challenges if player restarts island, leaves island or is kicked.' broadcast: 'Enables/Disables broadcast to online players about first time challenge completion.' remove-completed: 'Enables/Disables hiding challenges that are completed and cannot be repeated.' glow: 'Enables/Disables glowing effect for completed challenges.' - free-at-top: 'Allows to change free challenges location. True mean that challenges will be first, otherwise they will be last.' - line-length: 'Allows to modify maximal line length in lore box. Will not affect stored objects.' + free-at-top: 'Change free challenges location. True means that challenges will be first, otherwise they will be last.' + line-length: 'Modify the maximum line length in lore box. Will not affect stored objects.' toggle-user-list: 'Switch to different player list.' mode-online: 'Players which currently are online.' - mode-in-world: 'Players which is in GameMode world.' - mode-with-island: 'Players which has island in GameMode.' + mode-in-world: 'Players in GameMode world.' + mode-with-island: 'Players that have an island in GameMode.' selected: 'Selected' - remove-selected: 'Remove selected elements.|You can select elements with right mouse button.' + remove-selected: 'Remove selected elements.|Select elements with the right mouse button.' show-eggs: 'Switch entity view between Egg mode or Head mode.' - level-lore: 'Allows to modify which elements of level description should be visible.' - challenge-lore: 'Allows to modify which elements of challenge description should be visible.' - gui-view-mode: 'Allows to set if /challenges GUI should show GameModes or challenges in players world.' - history-store: 'Allows to enable/disable challenges history storage.' - history-lifespan: 'Allows to modify how many days history data will be saved.|0 means forever.' - island-store: 'Allows to enable/disable challenges data storing per island. This means that challenges will be the same on whole team, if this is enabled.|Will NOT convert data on click. PROGRESS WILL BE LOST.' - default-locked-icon: 'Allows to change default locked level icon.|This option can be overwritten by each level.' - gui-mode: 'Allows to enable/disable single challenges GUI.|&2Requires server restart.' + level-lore: 'Modify which level description elements should be visible.' + challenge-lore: 'Modify which challenge description elements should be visible.' + gui-view-mode: "Set if /challenges GUI should show GameModes or challenges in player's world." + history-store: 'Enable/disable challenges history storage.' + history-lifespan: 'Modify how many days history data will be saved.|0 means forever.' + island-store: 'Enable/disable challenges data storing per island. This means that challenges will be the same for the whole team if this is enabled.|Will NOT convert data on click. PROGRESS WILL BE LOST.' + default-locked-icon: 'Change default locked level icon.|This option can be overwritten by each level.' + gui-mode: 'Enable/disable single challenges GUI.|&2Requires server restart.' - visibility-mode: 'Allows to switch if undeployed challenges should be displayed or not.' + visibility-mode: 'Display/hide undeployed challenges.' click-to-edit: '&4Click here to edit input.' edit-text-line: '&6 Edit text message!' add-text-line: '&6 Add new text message!' input-mode: 'Switch between chat and anvil input modes.' - title-enable: 'Allows to enable/disable title message that will be showed when player complete challenge.' - title-showtime: 'Allows to modify how long title message will be visible for player.' - default-import: 'Allows to import default challenges.' - default-export: 'Allows to export existing challenges into defaults.json file.' - complete-wipe: 'Allows to completely clear all challenges addon databases. Includes player data!' + title-enable: 'Enable/disable the title message that will be showed when player complete challenge.' + title-showtime: 'Modify how long title message will be visible to player.' + default-import: 'Import default challenges.' + default-export: 'Export existing challenges to defaults.json file.' + complete-wipe: 'Completely clear all challenges addon databases. Includes player data!' - challenge-wipe: 'Allows to completely clear challenges and their level databases!' - players-wipe: 'Allows to completely clear player database!' + challenge-wipe: 'Completely clear challenges and their level databases!' + players-wipe: 'Completely clear player database!' - library: 'Opens GUI that shows all available public Challenges Libraries.' + library: 'Open GUI that shows all available public Challenges Libraries.' library-author: 'by &e[author]' - library-version: '&9Made on Challenges [version]' + library-version: '&9Made in Challenges [version]' library-lang: '&aLanguage: [lang]' library-gamemode: '&aPrimary for [gamemode]' - download: 'Allows manually update available challenges libraries. |Right click to enable cache clearing.' + download: 'Manually update available challenges libraries. |Right click to enable cache clearing.' download-disabled: 'GitHub data downloader is disabled in BentoBox. Without it, you cannot use Libraries!' lore: @@ -321,9 +321,9 @@ challenges: enabled: 'Active' disabled: 'Disabled' type: - island: '&aallows to require blocks or mobs around player' - inventory: '&aallows to require items in players inventory' - other: '&aallows to require things from other plugins/addons' + island: '&arequire blocks or mobs around player' + inventory: '&arequire items in players inventory' + other: '&arequire things from other plugins/addons' the-end: '- The End' nether: '- Nether' normal: '- Overworld' @@ -341,9 +341,9 @@ challenges: reduce-by: "&cReduce completion count by [value]" visibility: - visible: "All challenges are visible for everyone" + visible: "All challenges are visible to everyone" hidden: "Only Deployed challenges are visible." - toggleable: "Allows to toggle if undeployed challenges should be displayed" + toggleable: "Toggle if undeployed challenges should be displayed" challenge-description: level: '&FLevel: [level]' @@ -370,7 +370,7 @@ challenges: level-description: completed: '&BCompleted' completed-challenges-of: '&3You have completed [number] of [max] challenges in this level.' - waver-amount: '&6Can skip [value] challenges to unlock next level.' + waver-amount: '&6[value] challenges can be skipped to unlock next level.' experience-reward: '&6Exp reward: [value]' money-reward: '&6Money reward: $[value]' reward-items: '&6Reward Items:' @@ -399,12 +399,12 @@ challenges: admin: number: "Write a number in chat and press enter to accept it and press enter." - unique-id: "Write object unique name and press enter." - challenge-name: "Write in chat display name for current challenge." - level-name: "Write in chat display name for current level." + unique-id: "Write the object's unique name and press enter." + challenge-name: "Write the display name in chat for current challenge." + level-name: "Write display name in chat for current level." titles: -# Title and subtitle my contain variable in [] that will be replaced with proper message from challenge object. +# Title and subtitle my contain variables in [] that will be replaced with proper message from challenge object. # [friendlyName] will be replaced with challenge friendly name. # [level] will be replaced with level friendly name. # [rewardText] will be replaced with challenge reward text. @@ -420,10 +420,10 @@ challenges: hit-things: 'Hit things to add them to the list of things required. Right click when done.' you-added: 'You added one [thing] to the challenge' challenge-created: '[challenge]&r created!' - complete-wipe: '&cHope you have backups, as you just empty all Challenges Addon databases!' + complete-wipe: '&cHope you have backups, as you just erased all the Challenges Addon databases!' - challenge-wipe: '&cHope you have backups, as you just empty Challenges and their levels from databases!' - players-wipe: '&cHope you have backups, as you just empty player completed challenges from databases!' + challenge-wipe: '&cHope you have backups, as you just erased all the Challenges and their levels!' + players-wipe: '&cHope you have backups, as you just erase all the player completed challenges!' completed: '&2You completed challenge [name] for [player]!' already-completed: '&2This challenge was already completed!' @@ -432,7 +432,7 @@ challenges: not-completed: '&2This challenge is not completed yet!' migrate-start: '&2Start migrating challenges addon data.' - migrate-end: '&2Challenges addon data is updated to new format.' + migrate-end: '&2Challenges addon data updated to new format.' migrate-not: '&2All data is valid.' start-downloading: '&5Starting to download and import Challenges Library.' @@ -462,11 +462,11 @@ challenges: not-on-island: '&cYou must be on your island to do that!' challenge-level-not-available: '&cYou have not unlocked level to complete this challenge.' not-repeatable: '&cThis challenge is not repeatable!' - wrong-environment: '&cYou are in wrong environment!' + wrong-environment: '&cYou are in the wrong environment!' not-enough-items: '&cYou do not have enough [items] to complete this challenge!' not-close-enough: '&cYou must be standing within [number] blocks of all required items.' you-still-need: '&cYou still need [amount] x [item]' - missing-addon: '&cCannot complete challenge. Required addon or plugin is missing.' + missing-addon: '&cCannot complete challenge: Required addon or plugin is missing.' incorrect: '&cCannot complete challenge. Requirements are incorrect.' not-enough-money: '&cIt is necessary to have [value] on your account to complete the challenge.' not-enough-experience: '&cIt is necessary to have [value] EXP to complete challenge.' @@ -474,23 +474,23 @@ challenges: import-no-file: '&cCould not find challenges.yml file to import!' no-load: '&cError: Could not load challenges.yml. [message]' load-error: '&cError: Cannot load [value].' - no-rank: "&cYou do not have rank to do that." + no-rank: "&cYou do not have a high enough rank to do that." cannot-remove-items: '&cSome items cannot be removed from inventory!' - exist-challenges-or-levels: '&cIn your world already exist challenges. Cannot proceed!' + exist-challenges-or-levels: '&cChallenges already exist in your world. Cannot proceed!' defaults-file-exist: '&cdefaults.json already exists. Use overwrite mode to replace it!' defaults-file-error: '&cThere was an error while creating defaults.json file! Check console!' - no-challenges: '&cChallenges are not implemented in current world!' - no-challenges-admin: '&cChallenges are not implemented in current world! You should use &5/[command] &cto adding them!' - missing-level: '&cChallenge Level [level] is not defined in database. It may case some errors!' + no-challenges: '&cChallenges are not implemented in this world yet!' + no-challenges-admin: '&cChallenges are not implemented in this world yet! Use &5/[command] &cto add them!' + missing-level: '&cChallenge Level [level] is not defined in the database. It may cause errors!' missing-arguments: '&cCommand is missing arguments.' - no-multiple-permission: "&cYou do not have permission to complete challenge multiple times at once." + no-multiple-permission: "&cYou do not have permission to complete this challenge multiple times at once." protection: flags: CHALLENGES_ISLAND_PROTECTION: description: "&5&oToggle who can\n&5&ocomplete challenges" name: "Challenges protection" CHALLENGES_WORLD_PROTECTION: - description: "&5&oThis allows to enable/disable\n&5&orequirement for players to\n&5&obe on their island to\n&5&ocomplete a challenge." + description: "&5&oEnable/disable\n&5&orequirement for players to\n&5&obe on their island to\n&5&ocomplete a challenge." name: "Challenges Island limitation" hint: "No challenges outside island" version: 11 diff --git a/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java b/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java index 083b699..b5bd660 100644 --- a/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java +++ b/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java @@ -1,7 +1,9 @@ package world.bentobox.challenges.tasks; -import static org.junit.Assert.*; -import static org.mockito.Matchers.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -24,8 +26,8 @@ import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import world.bentobox.challenges.ChallengesAddon; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.ChallengesAddon; /** * @author tastybento