From 90ae98e59994f1e91b603a5eda4411f4752b1f4b Mon Sep 17 00:00:00 2001 From: DeadSilenceIV Date: Thu, 14 Jul 2022 17:53:27 -0500 Subject: [PATCH 01/10] Support for AdvancedChests was updated. (#266) --- pom.xml | 2 +- .../bentobox/level/calculators/IslandLevelCalculator.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index b0c45ca..d49376f 100644 --- a/pom.xml +++ b/pom.xml @@ -209,7 +209,7 @@ com.github.DeadSilenceIV AdvancedChestsAPI - 1.8 + 2.9-BETA provided diff --git a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java index 065f5e0..9c9fb43 100644 --- a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java +++ b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java @@ -425,11 +425,11 @@ public class IslandLevelCalculator { for (BlockState bs : chunk.getTileEntities()) { if (bs instanceof Container) { if (addon.isAdvChestEnabled()) { - AdvancedChest aChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(bs.getLocation()); - if (aChest != null) { + AdvancedChest aChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(bs.getLocation()); + if (aChest != null && aChest.getChestType().getName().equals("NORMAL")) { aChest.getPages().stream().map(ChestPage::getItems).forEach(c -> { - for (ItemStack i : c) { - countItemStack(i); + for (Object i : c) { + countItemStack((ItemStack)i); } }); continue; From dae3db6c98887ad3b22e442a968909f7c926f90d Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 21 Aug 2022 13:00:56 +0300 Subject: [PATCH 02/10] Implements visit/warp actions in top gui Add 2 new actions for island buttons in TOP GUI: - Visit -> allows to visit island, but it requires Visit Addon - Warp -> allows to warp to island, but it requires Warp Addon Requested via Discord. --- pom.xml | 16 ++++ src/main/java/world/bentobox/level/Level.java | 76 ++++++++++++++++++- .../bentobox/level/panels/TopLevelPanel.java | 61 +++++++++++++-- src/main/resources/locales/en-US.yml | 3 + src/main/resources/panels/top_panel.yml | 70 +++++++++++++++++ 5 files changed, 216 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index d49376f..c36d67d 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,10 @@ 1.16.5-R0.1-SNAPSHOT 1.20.0 + + 1.12.0 + + 1.4.0 1.1.0 @@ -185,6 +189,18 @@ ${bentobox.version} provided + + world.bentobox + warps + ${warps.version} + provided + + + world.bentobox + visit + ${visit.version} + provided + lv.id.bonne panelutils diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index 33c76a0..b1e65df 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -42,6 +42,9 @@ import world.bentobox.level.objects.LevelsData; import world.bentobox.level.objects.TopTenData; import world.bentobox.level.requests.LevelRequestHandler; import world.bentobox.level.requests.TopTenRequestHandler; +import world.bentobox.visit.VisitAddon; +import world.bentobox.warps.Warp; + /** * @author tastybento @@ -63,6 +66,17 @@ public class Level extends Addon implements Listener { private boolean roseStackersEnabled; private final List registeredGameModes = new ArrayList<>(); + /** + * Local variable that stores if warpHook is present. + */ + private Warp warpHook; + + /** + * Local variable that stores if visitHook is present. + */ + private VisitAddon visitHook; + + @Override public void onLoad() { // Save the default config from config.yml @@ -125,10 +139,10 @@ public class Level extends Addon implements Listener { advChestEnabled = advChest != null; if (advChestEnabled) { // Check version - if (compareVersions(advChest.getDescription().getVersion(), "14.2") > 0) { + if (compareVersions(advChest.getDescription().getVersion(), "23.0") > 0) { log("Hooked into AdvancedChests."); } else { - logError("Could not hook into AdvancedChests " + advChest.getDescription().getVersion() + " - requires version 14.3 or later"); + logError("Could not hook into AdvancedChests " + advChest.getDescription().getVersion() + " - requires version 23.0 or later"); advChestEnabled = false; } } @@ -139,6 +153,45 @@ public class Level extends Addon implements Listener { } } + @Override + public void allLoaded() + { + super.allLoaded(); + + if (this.isEnabled()) + { + this.hookExtensions(); + } + } + + + /** + * This method tries to hook into addons and plugins + */ + private void hookExtensions() + { + // Try to find Visit addon and if it does not exist, display a warning + this.getAddonByName("Visit").ifPresentOrElse(addon -> + { + this.visitHook = (VisitAddon) addon; + this.log("Likes Addon hooked into Visit addon."); + }, () -> + { + this.visitHook = null; + }); + + // Try to find Warps addon and if it does not exist, display a warning + this.getAddonByName("Warps").ifPresentOrElse(addon -> + { + this.warpHook = (Warp) addon; + this.log("Likes Addon hooked into Warps addon."); + }, () -> + { + this.warpHook = null; + }); + } + + /** * Compares versions * @param version1 @@ -507,4 +560,23 @@ public class Level extends Addon implements Listener { return roseStackersEnabled; } + /** + * Method Level#getVisitHook returns the visitHook of this object. + * + * @return {@code Visit} of this object, {@code null} otherwise. + */ + public VisitAddon getVisitHook() + { + return this.visitHook; + } + + /** + * Method Level#getWarpHook returns the warpHook of this object. + * + * @return {@code Warp} of this object, {@code null} otherwise. + */ + public Warp getWarpHook() + { + return this.warpHook; + } } diff --git a/src/main/java/world/bentobox/level/panels/TopLevelPanel.java b/src/main/java/world/bentobox/level/panels/TopLevelPanel.java index 23c313a..937de87 100644 --- a/src/main/java/world/bentobox/level/panels/TopLevelPanel.java +++ b/src/main/java/world/bentobox/level/panels/TopLevelPanel.java @@ -13,6 +13,7 @@ import java.io.File; import java.util.*; import java.util.stream.Collectors; +import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.TemplatedPanel; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; @@ -185,22 +186,66 @@ public class TopLevelPanel List activeActions = new ArrayList<>(template.actions()); activeActions.removeIf(action -> - "VIEW".equalsIgnoreCase(action.actionType()) && island.getOwner() == null && - island.getMemberSet(RanksManager.MEMBER_RANK). - contains(this.user.getUniqueId())); + { + switch (action.actionType().toUpperCase()) + { + case "WARP" -> { + return island.getOwner() == null || + this.addon.getWarpHook() == null || + !this.addon.getWarpHook().getWarpSignsManager().hasWarp(this.world, island.getOwner()); + } + case "VISIT" -> { + return island.getOwner() == null || + this.addon.getVisitHook() == null || + !this.addon.getVisitHook().getAddonManager().preprocessTeleportation(this.user, island); + } + case "VIEW" -> { + return island.getOwner() == null || + !island.getMemberSet(RanksManager.MEMBER_RANK).contains(this.user.getUniqueId()); + } + default -> { + return false; + } + } + }); // Add Click handler builder.clickHandler((panel, user, clickType, i) -> { for (ItemTemplateRecord.ActionRecords action : activeActions) { - if ((clickType == action.clickType() || action.clickType() == ClickType.UNKNOWN) && - "VIEW".equalsIgnoreCase(action.actionType())) + if (clickType == action.clickType() || action.clickType() == ClickType.UNKNOWN) { - this.user.closeInventory(); - // Open Detailed GUI. + switch (action.actionType().toUpperCase()) + { + case "WARP" -> { + this.user.closeInventory(); + this.addon.getWarpHook().getWarpSignsManager().warpPlayer(this.world, this.user, island.getOwner()); + } + case "VISIT" -> { + // The command call implementation solves necessity to check for all visits options, + // like cool down, confirmation and preprocess in single go. Would it be better to write + // all logic here? - DetailsPanel.openPanel(this.addon, this.world, this.user); + this.addon.getPlugin().getIWM().getAddon(this.world). + flatMap(GameModeAddon::getPlayerCommand).ifPresent(command -> + { + String mainCommand = + this.addon.getVisitHook().getSettings().getPlayerMainCommand(); + + if (!mainCommand.isBlank()) + { + this.user.closeInventory(); + this.user.performCommand(command.getTopLabel() + " " + mainCommand + " " + island.getOwner()); + } + }); + } + case "VIEW" -> { + this.user.closeInventory(); + // Open Detailed GUI. + DetailsPanel.openPanel(this.addon, this.world, this.user); + } + } } } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index af9d584..6456818 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -175,6 +175,9 @@ level: right-click-to-clear: "&e Right Click &7 to clear." click-to-asc: "&e Click &7 to sort in increasing order." click-to-desc: "&e Click &7 to sort in decreasing order." + click-to-warp: "&e Click &7 to warp." + click-to-visit: "&e Click &7 to visit." + right-click-to-visit: "&e Right Click &7 to visit." conversations: # Prefix for messages that are send from server. prefix: "&l&6 [BentoBox]: &r" diff --git a/src/main/resources/panels/top_panel.yml b/src/main/resources/panels/top_panel.yml index 2260c3a..3b80784 100644 --- a/src/main/resources/panels/top_panel.yml +++ b/src/main/resources/panels/top_panel.yml @@ -17,6 +17,13 @@ top_panel: data: type: TOP index: 1 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -28,6 +35,13 @@ top_panel: data: type: TOP index: 2 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -38,6 +52,13 @@ top_panel: data: type: TOP index: 3 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -49,6 +70,13 @@ top_panel: data: type: TOP index: 4 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -59,6 +87,13 @@ top_panel: data: type: TOP index: 5 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -69,6 +104,13 @@ top_panel: data: type: TOP index: 6 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -79,6 +121,13 @@ top_panel: data: type: TOP index: 7 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -89,6 +138,13 @@ top_panel: data: type: TOP index: 8 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -99,6 +155,13 @@ top_panel: data: type: TOP index: 9 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty @@ -109,6 +172,13 @@ top_panel: data: type: TOP index: 10 + actions: + warp: + click-type: LEFT + tooltip: level.gui.tips.click-to-warp + visit: + click-type: RIGHT + tooltip: level.gui.tips.right-click-to-visit fallback: icon: LIME_STAINED_GLASS_PANE title: level.gui.buttons.island.empty From 2ca4e0a0709c0e6a03b0a095c81bc2ea74612d30 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 21 Aug 2022 17:31:42 +0300 Subject: [PATCH 03/10] Fixes a Level addon crash on startup. Level addon crashed at the startup if Visit or Warps addon were not installed. It happened because Level addon main class were implementing Listener interface. To avoid it and fix the crash, I moved migration listener to a separate class. Fixes #2012 --- src/main/java/world/bentobox/level/Level.java | 46 ++------------ .../world/bentobox/level/LevelsManager.java | 5 +- .../level/listeners/MigrationListener.java | 61 +++++++++++++++++++ 3 files changed, 69 insertions(+), 43 deletions(-) create mode 100644 src/main/java/world/bentobox/level/listeners/MigrationListener.java diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index b1e65df..f41830d 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -13,8 +13,6 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; @@ -22,7 +20,6 @@ import org.eclipse.jdt.annotation.Nullable; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.configuration.Config; -import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.util.Util; @@ -38,6 +35,7 @@ import world.bentobox.level.config.BlockConfig; import world.bentobox.level.config.ConfigSettings; import world.bentobox.level.listeners.IslandActivitiesListeners; import world.bentobox.level.listeners.JoinLeaveListener; +import world.bentobox.level.listeners.MigrationListener; import world.bentobox.level.objects.LevelsData; import world.bentobox.level.objects.TopTenData; import world.bentobox.level.requests.LevelRequestHandler; @@ -50,7 +48,7 @@ import world.bentobox.warps.Warp; * @author tastybento * */ -public class Level extends Addon implements Listener { +public class Level extends Addon { // The 10 in top ten public static final int TEN = 10; @@ -112,7 +110,8 @@ public class Level extends Addon implements Listener { // Register listeners this.registerListener(new IslandActivitiesListeners(this)); this.registerListener(new JoinLeaveListener(this)); - this.registerListener(this); + this.registerListener(new MigrationListener(this)); + // Register commands for GameModes registeredGameModes.clear(); getPlugin().getAddonsManager().getGameModeAddons().stream() @@ -174,7 +173,7 @@ public class Level extends Addon implements Listener { this.getAddonByName("Visit").ifPresentOrElse(addon -> { this.visitHook = (VisitAddon) addon; - this.log("Likes Addon hooked into Visit addon."); + this.log("Level Addon hooked into Visit addon."); }, () -> { this.visitHook = null; @@ -184,7 +183,7 @@ public class Level extends Addon implements Listener { this.getAddonByName("Warps").ifPresentOrElse(addon -> { this.warpHook = (Warp) addon; - this.log("Likes Addon hooked into Warps addon."); + this.log("Level Addon hooked into Warps addon."); }, () -> { this.warpHook = null; @@ -217,39 +216,6 @@ public class Level extends Addon implements Listener { return comparisonResult; } - @EventHandler - public void onBentoBoxReady(BentoBoxReadyEvent e) { - // Perform upgrade check - manager.migrate(); - // Load TopTens - manager.loadTopTens(); - /* - * DEBUG code to generate fake islands and then try to level them all. - Bukkit.getScheduler().runTaskLater(getPlugin(), () -> { - getPlugin().getAddonsManager().getGameModeAddons().stream() - .filter(gm -> !settings.getGameModes().contains(gm.getDescription().getName())) - .forEach(gm -> { - for (int i = 0; i < 1000; i++) { - try { - NewIsland.builder().addon(gm).player(User.getInstance(UUID.randomUUID())).name("default").reason(Reason.CREATE).noPaste().build(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - }); - // Queue all islands DEBUG - - getIslands().getIslands().stream().filter(Island::isOwned).forEach(is -> { - - this.getManager().calculateLevel(is.getOwner(), is).thenAccept(r -> - log("Result for island calc " + r.getLevel() + " at " + is.getCenter())); - - }); - }, 60L);*/ - } - - private void registerPlaceholders(GameModeAddon gm) { if (getPlugin().getPlaceholdersManager() == null) return; // Island Level diff --git a/src/main/java/world/bentobox/level/LevelsManager.java b/src/main/java/world/bentobox/level/LevelsManager.java index 2c182a8..a7fc4a7 100644 --- a/src/main/java/world/bentobox/level/LevelsManager.java +++ b/src/main/java/world/bentobox/level/LevelsManager.java @@ -35,7 +35,6 @@ import world.bentobox.level.objects.TopTenData; public class LevelsManager { private static final String INTOPTEN = "intopten"; private static final TreeMap LEVELS; - private static final int[] SLOTS = new int[] {4, 12, 14, 19, 20, 21, 22, 23, 24, 25}; private static final BigInteger THOUSAND = BigInteger.valueOf(1000); static { LEVELS = new TreeMap<>(); @@ -45,7 +44,7 @@ public class LevelsManager { LEVELS.put(THOUSAND.pow(3), "G"); LEVELS.put(THOUSAND.pow(4), "T"); } - private Level addon; + private final Level addon; // Database handler for level data private final Database handler; @@ -341,7 +340,7 @@ public class LevelsManager { /** * Loads all the top tens from the database */ - void loadTopTens() { + public void loadTopTens() { topTenLists.clear(); Bukkit.getScheduler().runTaskAsynchronously(addon.getPlugin(), () -> { addon.log("Generating rankings"); diff --git a/src/main/java/world/bentobox/level/listeners/MigrationListener.java b/src/main/java/world/bentobox/level/listeners/MigrationListener.java new file mode 100644 index 0000000..640a26c --- /dev/null +++ b/src/main/java/world/bentobox/level/listeners/MigrationListener.java @@ -0,0 +1,61 @@ +// +// Created by BONNe +// Copyright - 2022 +// + + +package world.bentobox.level.listeners; + + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; +import world.bentobox.level.Level; + + +/** + * This listener checks when BentoBox is ready and then tries to migrate Levels addon database, if it is required. + */ +public class MigrationListener implements Listener +{ + public MigrationListener(Level addon) + { + this.addon = addon; + } + + @EventHandler + public void onBentoBoxReady(BentoBoxReadyEvent e) { + // Perform upgrade check + this.addon.getManager().migrate(); + // Load TopTens + this.addon.getManager().loadTopTens(); + /* + * DEBUG code to generate fake islands and then try to level them all. + Bukkit.getScheduler().runTaskLater(getPlugin(), () -> { + getPlugin().getAddonsManager().getGameModeAddons().stream() + .filter(gm -> !settings.getGameModes().contains(gm.getDescription().getName())) + .forEach(gm -> { + for (int i = 0; i < 1000; i++) { + try { + NewIsland.builder().addon(gm).player(User.getInstance(UUID.randomUUID())).name("default").reason(Reason.CREATE).noPaste().build(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + // Queue all islands DEBUG + + getIslands().getIslands().stream().filter(Island::isOwned).forEach(is -> { + + this.getManager().calculateLevel(is.getOwner(), is).thenAccept(r -> + log("Result for island calc " + r.getLevel() + " at " + is.getCenter())); + + }); + }, 60L);*/ + } + + + private final Level addon; +} From 32690630d6a6eeef9de2229a459c480766c5f7df Mon Sep 17 00:00:00 2001 From: "gitlocalize-app[bot]" <55277160+gitlocalize-app[bot]@users.noreply.github.com> Date: Sat, 27 Aug 2022 15:14:55 +0300 Subject: [PATCH 04/10] Translate pl.yml via GitLocalize (#269) Co-authored-by: wiktorm12 --- src/main/resources/locales/pl.yml | 133 ++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 7 deletions(-) diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml index fec739d..93473c9 100644 --- a/src/main/resources/locales/pl.yml +++ b/src/main/resources/locales/pl.yml @@ -5,6 +5,9 @@ admin: description: oblicza poziom wyspy sethandicap: parameters: " " + description: ustawić 0 poziom wyspy, zwykle poziom wyspy startowej + changed: "&a Początkowy poziom wysp został zmieniony z [number] na [new_number]." + invalid-level: "&c Nieprawidłowy poziom. Użyj liczby całkowitej." levelstatus: description: pokazuje ile wysp znajduje się w kolejce do skanowania islands-in-queue: "&a Wyspy w kolejce: [number]" @@ -23,7 +26,7 @@ island: estimated-wait: "&a Szacowany czas: [number] sekund" in-queue: "&a Jestes numerem [number] w kolejce" island-level-is: "&aPoziom wyspy wynosi &b[level]" - required-points-to-next-level: "&a[points] punktów do następnego poziomu" + required-points-to-next-level: "&aPozostało [points] punktów do następnego poziomu" deaths: "&c([number] śmierci)" cooldown: "&cMusisz zaczekać &b[time] &csekund przed następnym obliczeniem poziomu" in-progress: "&6 Trwa obliczanie poziomu twojej wyspy..." @@ -44,9 +47,125 @@ island: names-island: Wyspa gracza [name] syntax: "[name] x [number]" hint: "&c Uruchom poziom, aby wyświetlić raport o blokach" - value: - description: pokazuje wartość dowolnego przedmiotu - success: "&7Wartość punktowa tego bloku wynosi: &e[value]" - success-underwater: "&7Wartość tego bloku poniżej poziomu morza: &e[value]" - empty-hand: "&cNie trzymasz żadnego bloku." - no-value: "&cTen przedmiot nie ma wartości :(" +level: + commands: + value: + parameters: "[hand|]" + description: pokazuje wartość bloków. Dodaj „hand” na końcu, aby wyświetlić + wartość pozycji w ręku. + gui: + titles: + top: "&0&l Najlepsze wyspy" + detail-panel: "&0&l Wyspa gracza [name] " + value-panel: "&0&l Wartości bloków" + buttons: + island: + empty: "&f&l [name]. miejsce" + name: "&f&l [name]" + description: |- + [owner] + [members] + [place] + [level] + owners-island: wyspa gracza [player] + owner: "&7&l Lider: &r&b [player]" + members-title: "&7&l Członkowie:" + member: "&b - [player]" + unknown: nieznany + place: "&7&o [number]. &r&7 miejsce" + level: "&7 Poziom: &o [number]" + material: + name: "&f&l [number] x [material]" + description: |- + [description] + [count] + [value] + [calculated] + [limit] + [id] + id: "&7 Identyfikator bloku: &e [id]" + value: "&7 Wartość bloku: &e [number]" + limit: "&7 Limit bloków: &e [number]" + count: "&7 Numer bloku: &e [number]" + calculated: "&7 Obliczona wartość: &e [number]" + all_blocks: + name: "&f&l Wszystkie bloki" + description: |- + &7 Wyświetl wszystkie bloki + &7 na wyspie. + above_sea_level: + name: "&f&l Bloki nad poziomem morza" + description: |- + &7 Wyświetlaj tylko bloki + &7 które są nad poziomem + &7 morza + underwater: + name: "&f&l Bloki pod poziomem morza" + description: |- + &7 Wyświetlaj tylko bloki + &7 ponad poziomem morza + spawner: + name: "&f&l Spawnery" + description: "&7 Wyświetlaj tylko spawnery." + filters: + name: + name: "&f&l Sortuj według nazwy" + description: "&7 Sortuj wszystkie bloki według nazwy." + value: + name: "&f&l Sortuj według wartości" + description: "&7 Sortuj wszystkie bloki według ich wartości." + count: + name: "&f&l Sortuj według liczby" + description: "&7 Sortuj wszystkie bloki według ich ilości." + value: + name: "&f&l [material]" + description: |- + [description] + [value] + [underwater] + [limit] + [id] + id: "&7 Identyfikator bloku: &e [id]" + value: "&7 Wartość bloku: &e [number]" + underwater: "&7 Poniżej poziomu morza: &e [number]" + limit: "&7 Limit bloku: &e [number]" + previous: + name: "&f&l Poprzednia strona" + description: "&7 Przełącz na stronę [number]" + next: + name: "&f&l Następna strona" + description: "&7 Przełącz na stronę [number]" + search: + name: "&f&l Szukaj" + description: |- + &7 Wyszukaj konkretną + &7 wartość. + search: "&b Wartość: [value]" + tips: + click-to-view: "&e Kliknij &7, aby wyświetlić." + click-to-previous: "&e Kliknij &7, aby wyświetlić poprzednią stronę." + click-to-next: "&e Kliknij &7, aby wyświetlić następną stronę." + click-to-select: "&e Kliknij &7, aby wybrać." + left-click-to-cycle-up: "&e Kliknij lewym przyciskiem &7, aby przejść w górę." + right-click-to-cycle-down: "&e Kliknij prawym przyciskiem &7, aby przejść w + dół." + left-click-to-change: "&e Kliknij lewym przyciskiem &7, aby edytować." + right-click-to-clear: "&e Kliknij prawym przyciskiem &7, aby wyczyścić." + click-to-asc: "&e Kliknij &7, aby posortować w porządku rosnącym." + click-to-desc: "&e Kliknij &7, aby posortować w porządku malejącym." + click-to-warp: "&e Kliknij&7, aby przenieść" + click-to-visit: "&e Kliknij&7, aby odwiedzić" + right-click-to-visit: "&e Kliknij prawym przyciskiem &7, aby odwiedzić." + conversations: + prefix: "&l&6 [BentoBox]: &r" + no-data: "&c Wykonaj sprawdzenie poziomu, przed raportem bloków" + cancel-string: anuluj + exit-string: cancel, exit, quit, anuluj + write-search: "&e Wprowadź wartość wyszukiwania. (Napisz „anuluj”, aby wyjść)" + search-updated: "&a Zaktualizowano wartość wyszukiwania." + cancelled: "&c Rozmowa została anulowana!" + no-value: "&c Ten element nie ma wartości." + unknown-item: "&c „[material]” nie istnieje w grze." + value: "&7 Wartość '[material]' to: &e[value]" + value-underwater: "&7 Wartość „[material]” poniżej poziomu morza: &e[value]" + empty-hand: "&c W twojej ręce nie ma bloków" From 97d95225638aa2613460ff903edc7b775cf5c30b Mon Sep 17 00:00:00 2001 From: "gitlocalize-app[bot]" <55277160+gitlocalize-app[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 08:22:33 +0200 Subject: [PATCH 05/10] Translate fr.yml via GitLocalize (#272) Co-authored-by: organizatsiya --- src/main/resources/locales/fr.yml | 131 ++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 8 deletions(-) diff --git a/src/main/resources/locales/fr.yml b/src/main/resources/locales/fr.yml index a7fc26f..f7d914b 100644 --- a/src/main/resources/locales/fr.yml +++ b/src/main/resources/locales/fr.yml @@ -1,7 +1,7 @@ --- admin: level: - parameters: "" + parameters: "" description: calcule le niveau d'île d'un joueur sethandicap: parameters: " " @@ -18,7 +18,7 @@ admin: display: "&f[rank]. &a[name] &7- &b[level]" remove: description: retire le joueur du top 10 - parameters: "" + parameters: "" island: level: parameters: "[joueur]" @@ -49,12 +49,127 @@ island: names-island: île de [name] syntax: "[name] x [number]" hint: "&c Exécuter level pour voir le rapport des blocs" - value: - description: affiche la valeur d'un bloc - success: "&7Valeur de ce bloc : &e[value]" - success-underwater: "&7Valeur de ce bloc en dessous du niveau de la mer : &e[value]" - empty-hand: "&cIl n'y a aucun bloc dans votre main" - no-value: "&cCet objet n'a pas de valeur." +level: + commands: + value: + parameters: "[hand|]" + description: affiche la valeur des blocs. Ajoutez 'hand' à la fin pour afficher + la valeur de l'objet en main. + gui: + titles: + top: "&0&l Top Islands" + detail-panel: "&0&l [name]'s island" + value-panel: "&0&l Block Values" + buttons: + island: + empty: "&f&l [name]. place" + name: "&f&l [name]" + description: |- + [owner] + [members] + [place] + [level] + owners-island: "[player]'s Island" + owner: "&7&l Propriétaire: &r&b [player]" + members-title: "&7&l Membres:" + member: "&b - [player]" + unknown: inconnue + place: "&7&o [number]. &r&7 place" + level: "&7 Level: &o [number]" + material: + name: "&f&l [number] x [material]" + description: |- + [description] + [count] + [value] + [calculated] + [limit] + [id] + id: "&7 Block id: &e [id]" + value: "&7 Block value: &e [number]" + limit: "&7 Block limit: &e [number]" + count: "&7 Nombre de blocs: &e [number]" + calculated: "&7 Valeur calculée: &e [number]" + all_blocks: + name: "&f&l Tous les blocs" + description: |- + &7 Afficher tous les blocs + &7 sur l'île. + above_sea_level: + name: "&f&l Blocs au-dessus du niveau de la mer" + description: |- + &7 Afficher uniquement les blocs + &7 qui sont au-dessus du niveau + &7 de la mer. + underwater: + name: "&f&l Blocs sous le niveau de la mer" + description: |- + &7 Afficher uniquement les blocs + &7 situés sous le niveau + &7 de la mer. + spawner: + name: "&f&l Spawners" + description: "&7 Afficher uniquement les spawners." + filters: + name: + name: "&f&l STrier par nom" + description: "&7 Trier tous les blocs par nom." + value: + name: "&f&l Trier par valeur" + description: "&7 Triez tous les blocs par leur valeur." + count: + name: "&f&l Trier par nombre" + description: "&7 Trier tous les blocs par leur montant." + value: + name: "&f&l [material]" + description: |- + [description] + [value] + [underwater] + [limit] + [id] + id: "&7 Block id: &e [id]" + value: "&7 Block value: &e [number]" + underwater: "&7 Sous le niveau de la mer : &e [number]" + limit: "&7 Block limit: &e [number]" + previous: + name: "&f&l Page précédente" + description: "&7 Passer à la page [number]" + next: + name: "&f&l Page suivante" + description: "&7 Passer à la page [number]" + search: + name: "&f&l Rechercher" + description: "&7 Recherche une valeur \n&7 spécifique." + search: "&b Valeur : [value]" + tips: + click-to-view: "&e Cliquez &7 pour afficher." + click-to-previous: "&e Cliquez &7 pour afficher la page précédente." + click-to-next: "&e Cliquez &7 pour afficher la page suivante." + click-to-select: "&e Cliquez &7 pour sélectionner." + left-click-to-cycle-up: "&e Clic gauche &7 pour monter." + right-click-to-cycle-down: "&e Clic droit &7 pour descendre." + left-click-to-change: "&e Clic gauche &7 pour éditer." + right-click-to-clear: "&e Clic droit &7 pour effacer." + click-to-asc: "&e Cliquez &7 pour trier par ordre croissant." + click-to-desc: "&e Cliquez &7 pour trier par ordre décroissant." + click-to-warp: "&e Cliquer &7 to warp." + click-to-visit: "&e Cliquer &7 pour visiter." + right-click-to-visit: "&e Clic droit&7 pour visiter." + conversations: + prefix: "&l&6 [BentoBox]: &r" + no-data: "&c Niveau d'exécution pour voir le rapport de blocage." + cancel-string: annuler + exit-string: annuler, sortir, quitter + write-search: "&e Veuillez entrer une valeur de recherche. (Ecrivez 'cancel' pour + quitter)" + search-updated: "&a Valeur de recherche mise à jour." + cancelled: "&c Conversation annulée !" + no-value: "&c Cet item n'a aucune valeur." + unknown-item: "&c Le '[material]' n'existe pas dans le jeu." + value: "&7 La valeur de '[material]' est : &e[value]" + value-underwater: "&7 La valeur de '[material]' sous le niveau de la mer : &e[value]" + empty-hand: "&c Il n'y a pas de blocs dans votre main" meta: authors: '0': plagoutte From 51338d280d67cc1056e9e16cd5da8e7651a35035 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 26 Nov 2022 17:48:55 -0800 Subject: [PATCH 06/10] Update to Java 17 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c36d67d..5290900 100644 --- a/pom.xml +++ b/pom.xml @@ -54,11 +54,11 @@ UTF-8 UTF-8 - 16 + 17 2.0.9 - 1.16.5-R0.1-SNAPSHOT + 1.19.2-R0.1-SNAPSHOT 1.20.0 1.12.0 @@ -71,7 +71,7 @@ -LOCAL - 2.9.1 + 2.10.0 BentoBoxWorld_Level bentobox-world https://sonarcloud.io From 3988659dcc5e2d55919d8a377da05042c5dd4047 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 26 Nov 2022 17:52:31 -0800 Subject: [PATCH 07/10] Update Github workflow to Java 17 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9cf60c..c771fd5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 16 + java-version: 17 - name: Cache SonarCloud packages uses: actions/cache@v1 with: From f3ee8a381c698836642a3d63ab9c7a60c1ce9a59 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 26 Nov 2022 18:20:14 -0800 Subject: [PATCH 08/10] Adds %Level_[gamemode]_island_level_max% placeholder This records the lifetime maximum level the island has ever had. Addresses #271 --- src/main/java/world/bentobox/level/Level.java | 3 +++ .../world/bentobox/level/LevelsManager.java | 13 +++++++++++++ .../bentobox/level/objects/IslandLevels.java | 17 +++++++++++++++++ .../world/bentobox/level/LevelsManagerTest.java | 9 +++++++++ 4 files changed, 42 insertions(+) diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index f41830d..ee2b70c 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -228,6 +228,9 @@ public class Level extends Addon { getPlugin().getPlaceholdersManager().registerPlaceholder(this, gm.getDescription().getName().toLowerCase() + "_points_to_next_level", user -> getManager().getPointsToNextString(gm.getOverWorld(), user.getUniqueId())); + getPlugin().getPlaceholdersManager().registerPlaceholder(this, + gm.getDescription().getName().toLowerCase() + "_island_level_max", + user -> String.valueOf(getManager().getIslandMaxLevel(gm.getOverWorld(), user.getUniqueId()))); // Visited Island Level getPlugin().getPlaceholdersManager().registerPlaceholder(this, diff --git a/src/main/java/world/bentobox/level/LevelsManager.java b/src/main/java/world/bentobox/level/LevelsManager.java index a7fc4a7..08352de 100644 --- a/src/main/java/world/bentobox/level/LevelsManager.java +++ b/src/main/java/world/bentobox/level/LevelsManager.java @@ -231,6 +231,19 @@ public class LevelsManager { return island == null ? 0L : getLevelsData(island).getLevel(); } + /** + * Get the maximum level ever given to this island + * @param world - world where the island is + * @param targetPlayer - target player UUID + * @return Max level of the player's island or zero if player is unknown or UUID is null + */ + public long getIslandMaxLevel(@NonNull World world, @Nullable UUID targetPlayer) { + if (targetPlayer == null) return 0L; + // Get the island + Island island = addon.getIslands().getIsland(world, targetPlayer); + return island == null ? 0L : getLevelsData(island).getMaxLevel(); + } + /** * Returns a formatted string of the target player's island level * @param world - world where the island is diff --git a/src/main/java/world/bentobox/level/objects/IslandLevels.java b/src/main/java/world/bentobox/level/objects/IslandLevels.java index 532b509..7dd0123 100644 --- a/src/main/java/world/bentobox/level/objects/IslandLevels.java +++ b/src/main/java/world/bentobox/level/objects/IslandLevels.java @@ -43,6 +43,11 @@ public class IslandLevels implements DataObject { */ @Expose private long pointsToNextLevel; + /** + * The maximum level this island has ever had + */ + @Expose + private long maxLevel; /** * Underwater count @@ -94,6 +99,10 @@ public class IslandLevels implements DataObject { */ public void setLevel(long level) { this.level = level; + // Track maximum level + if (level > this.maxLevel) { + maxLevel = level; + } } /** @@ -124,6 +133,14 @@ public class IslandLevels implements DataObject { this.pointsToNextLevel = pointsToNextLevel; } + /** + * Get the maximum level ever set using {@link #setLevel(long)} + * @return the maxLevel + */ + public long getMaxLevel() { + return maxLevel; + } + /** * @return the uwCount */ diff --git a/src/test/java/world/bentobox/level/LevelsManagerTest.java b/src/test/java/world/bentobox/level/LevelsManagerTest.java index 94ead55..f6b5d54 100644 --- a/src/test/java/world/bentobox/level/LevelsManagerTest.java +++ b/src/test/java/world/bentobox/level/LevelsManagerTest.java @@ -270,6 +270,15 @@ public class LevelsManagerTest { //Map tt = lm.getTopTen(world, 10); //assertEquals(1, tt.size()); //assertTrue(tt.get(uuid) == 10000); + assertEquals(10000L, lm.getIslandMaxLevel(world, uuid)); + + results.setLevel(5000); + lm.calculateLevel(uuid, island); + // Complete the pipelined completable future + cf.complete(results); + assertEquals(5000L, lm.getLevelsData(island).getLevel()); + // Still should be 10000 + assertEquals(10000L, lm.getIslandMaxLevel(world, uuid)); } From 93869cb34aba3eee0be1553bc97da74818bacb40 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 26 Nov 2022 18:29:03 -0800 Subject: [PATCH 09/10] Only shows Members or higher in the top members placeholder Fixes #267 --- src/main/java/world/bentobox/level/Level.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index ee2b70c..66303de 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -22,6 +22,7 @@ import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.configuration.Config; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.managers.RanksManager; import world.bentobox.bentobox.util.Util; import world.bentobox.level.calculators.Pipeliner; import world.bentobox.level.commands.AdminLevelCommand; @@ -286,6 +287,7 @@ public class Level extends Addon { if (island != null) { // Sort members by rank return island.getMembers().entrySet().stream() + .filter(e -> e.getValue() >= RanksManager.MEMBER_RANK) .sorted(Collections.reverseOrder(Map.Entry.comparingByValue())) .map(Map.Entry::getKey) .map(getPlayers()::getName) From ac6bead52e199f32486db1e91aeea63fdbcc5f48 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 14:16:14 -0800 Subject: [PATCH 10/10] Add natural log to level-calc formula parsing Relates to #274 --- .../bentobox/level/calculators/IslandLevelCalculator.java | 3 +++ src/main/java/world/bentobox/level/config/ConfigSettings.java | 2 +- src/main/resources/config.yml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java index 9c9fb43..09f6218 100644 --- a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java +++ b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java @@ -135,6 +135,9 @@ public class IslandLevelCalculator { case "tan": x = Math.tan(Math.toRadians(x)); break; + case "log": + x = Math.log(x); + break; default: throw new RuntimeException("Unknown function: " + func); } diff --git a/src/main/java/world/bentobox/level/config/ConfigSettings.java b/src/main/java/world/bentobox/level/config/ConfigSettings.java index 67f7b91..3e8099e 100644 --- a/src/main/java/world/bentobox/level/config/ConfigSettings.java +++ b/src/main/java/world/bentobox/level/config/ConfigSettings.java @@ -90,7 +90,7 @@ public class ConfigSettings implements ConfigObject { @ConfigComment("Island level calculation formula") @ConfigComment("blocks - the sum total of all block values, less any death penalty") @ConfigComment("level_cost - in a linear equation, the value of one level") - @ConfigComment("This formula can include +,=,*,/,sqrt,^,sin,cos,tan. Result will always be rounded to a long integer") + @ConfigComment("This formula can include +,=,*,/,sqrt,^,sin,cos,tan,log (natural log). Result will always be rounded to a long integer") @ConfigComment("for example, an alternative non-linear option could be: 3 * sqrt(blocks / level_cost)") @ConfigEntry(path = "level-calc") private String levelCalc = "blocks / level_cost"; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9b7c685..7f2ed95 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -53,7 +53,7 @@ levelcost: 100 # Island level calculation formula # blocks - the sum total of all block values, less any death penalty # level_cost - in a linear equation, the value of one level -# This formula can include +,=,*,/,sqrt,^,sin,cos,tan. Result will always be rounded to a long integer +# This formula can include +,=,*,/,sqrt,^,sin,cos,tan,log (natural log). Result will always be rounded to a long integer # for example, an alternative non-linear option could be: 3 * sqrt(blocks / level_cost) level-calc: blocks / level_cost #