From 275e86dd4f0afc57b44fdc47fe6dc976b3233f24 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 20 Apr 2026 15:22:15 -0700 Subject: [PATCH 1/3] feat: make 'hand' keyword localizable in donate/value commands; sync locales - Add island.donate.hand.keyword locale key (en-US: "hand") so each language can provide its own word for the hand subcommand arg - IslandDonateCommand: accept both English "hand" and the localized keyword; tab-complete shows the localized keyword - IslandValueCommand: same localizable keyword for HAND arg and tab-complete - All 16 non-English locales: add island.donate.hand.keyword (translated) and island.donate.invalid-item (translated) - uk.yml: fully translate donate section (parameters, description, all messages) and update value command parameters/description Co-Authored-By: Claude Sonnet 4.6 --- .../level/commands/IslandDonateCommand.java | 14 +++++-- .../level/commands/IslandValueCommand.java | 5 ++- src/main/resources/locales/cs.yml | 2 + src/main/resources/locales/de.yml | 2 + src/main/resources/locales/en-US.yml | 1 + src/main/resources/locales/es.yml | 2 + src/main/resources/locales/fr.yml | 2 + src/main/resources/locales/hu.yml | 2 + src/main/resources/locales/id.yml | 2 + src/main/resources/locales/ko.yml | 2 + src/main/resources/locales/lv.yml | 2 + src/main/resources/locales/nl.yml | 2 + src/main/resources/locales/pl.yml | 2 + src/main/resources/locales/pt.yml | 2 + src/main/resources/locales/ru.yml | 2 + src/main/resources/locales/tr.yml | 2 + src/main/resources/locales/uk.yml | 41 ++++++++++--------- src/main/resources/locales/vi.yml | 2 + src/main/resources/locales/zh-CN.yml | 2 + .../commands/IslandDonateCommandTest.java | 1 + .../commands/IslandValueCommandTest.java | 4 +- 21 files changed, 69 insertions(+), 27 deletions(-) diff --git a/src/main/java/world/bentobox/level/commands/IslandDonateCommand.java b/src/main/java/world/bentobox/level/commands/IslandDonateCommand.java index 37e1f28..fa76d70 100644 --- a/src/main/java/world/bentobox/level/commands/IslandDonateCommand.java +++ b/src/main/java/world/bentobox/level/commands/IslandDonateCommand.java @@ -60,8 +60,8 @@ public boolean execute(User user, String label, List args) { return false; } - // Handle "hand" subcommand - if (!args.isEmpty() && "hand".equalsIgnoreCase(args.get(0))) { + // Handle "hand" subcommand (accepts English "hand" or the localized keyword) + if (!args.isEmpty() && isHandKeyword(user, args.get(0))) { return handleHandDonation(user, island, args); } @@ -145,10 +145,11 @@ private void performHandDonation(User user, Island island, Material material, in @Override public Optional> tabComplete(User user, String alias, List args) { String lastArg = !args.isEmpty() ? args.get(args.size() - 1) : ""; + String handKeyword = user.getTranslation("island.donate.hand.keyword"); if (args.size() <= 1) { - return Optional.of(Util.tabLimit(List.of("hand"), lastArg)); + return Optional.of(Util.tabLimit(List.of(handKeyword), lastArg)); } - if (args.size() == 2 && "hand".equalsIgnoreCase(args.get(0)) && user.isPlayer()) { + if (args.size() == 2 && isHandKeyword(user, args.get(0)) && user.isPlayer()) { int held = user.getPlayer().getInventory().getItemInMainHand().getAmount(); if (held > 0) { return Optional.of(Util.tabLimit(List.of(String.valueOf(held)), lastArg)); @@ -156,4 +157,9 @@ public Optional> tabComplete(User user, String alias, List } return Optional.of(List.of()); } + + private boolean isHandKeyword(User user, String arg) { + String localized = user.getTranslation("island.donate.hand.keyword"); + return "hand".equalsIgnoreCase(arg) || localized.equalsIgnoreCase(arg); + } } diff --git a/src/main/java/world/bentobox/level/commands/IslandValueCommand.java b/src/main/java/world/bentobox/level/commands/IslandValueCommand.java index c4011f7..92141ff 100644 --- a/src/main/java/world/bentobox/level/commands/IslandValueCommand.java +++ b/src/main/java/world/bentobox/level/commands/IslandValueCommand.java @@ -60,7 +60,8 @@ public boolean execute(User user, String label, List args) { } String arg = args.get(0); - if ("HAND".equalsIgnoreCase(arg)) { + String handKeyword = user.getTranslation("island.donate.hand.keyword"); + if ("HAND".equalsIgnoreCase(arg) || handKeyword.equalsIgnoreCase(arg)) { executeHandCommand(user); return true; } @@ -158,7 +159,7 @@ public Optional> tabComplete(User user, String alias, List List options = new ArrayList<>( Arrays.stream(Material.values()).filter(Material::isBlock).map(Material::name).map(String::toLowerCase).toList()); - options.add("HAND"); + options.add(user.getTranslation("island.donate.hand.keyword")); return Optional.of(Util.tabLimit(options, lastArg)); } diff --git a/src/main/resources/locales/cs.yml b/src/main/resources/locales/cs.yml index 9e7e836..35ec78b 100644 --- a/src/main/resources/locales/cs.yml +++ b/src/main/resources/locales/cs.yml @@ -53,6 +53,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Darovat lze pouze bloky s nakonfigurovanou hodnotou úrovně." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -62,6 +63,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "ruka" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/de.yml b/src/main/resources/locales/de.yml index 2adfc2f..b05dab9 100644 --- a/src/main/resources/locales/de.yml +++ b/src/main/resources/locales/de.yml @@ -54,6 +54,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Es können nur Blöcke mit einem konfigurierten Levelwert gespendet werden." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -63,6 +64,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "hand" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 08f3835..ff81550 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -68,6 +68,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "hand" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/es.yml b/src/main/resources/locales/es.yml index 47f583c..0d93e3f 100644 --- a/src/main/resources/locales/es.yml +++ b/src/main/resources/locales/es.yml @@ -51,6 +51,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Solo se pueden donar bloques con un valor de nivel configurado." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -60,6 +61,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "mano" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/fr.yml b/src/main/resources/locales/fr.yml index 27a1bd8..e1265d1 100644 --- a/src/main/resources/locales/fr.yml +++ b/src/main/resources/locales/fr.yml @@ -53,6 +53,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Seuls les blocs avec une valeur de niveau configurée peuvent être donnés." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -62,6 +63,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "main" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/hu.yml b/src/main/resources/locales/hu.yml index afff3ef..7be400a 100644 --- a/src/main/resources/locales/hu.yml +++ b/src/main/resources/locales/hu.yml @@ -54,6 +54,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Csak konfigurált szintértékkel rendelkező blokkok adományozhatók." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -63,6 +64,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "kez" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/id.yml b/src/main/resources/locales/id.yml index f0c6574..539666b 100644 --- a/src/main/resources/locales/id.yml +++ b/src/main/resources/locales/id.yml @@ -51,6 +51,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Hanya blok dengan nilai level yang dikonfigurasi yang dapat didonasikan." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -60,6 +61,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "tangan" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/ko.yml b/src/main/resources/locales/ko.yml index 6cbb516..f846737 100644 --- a/src/main/resources/locales/ko.yml +++ b/src/main/resources/locales/ko.yml @@ -54,6 +54,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "설정된 레벨 값이 있는 블록만 기부할 수 있습니다." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -63,6 +64,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "hand" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/lv.yml b/src/main/resources/locales/lv.yml index 5792196..7ec2474 100644 --- a/src/main/resources/locales/lv.yml +++ b/src/main/resources/locales/lv.yml @@ -54,6 +54,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Var ziedot tikai blokus ar konfigurētu līmeņa vērtību." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -63,6 +64,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "roka" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/nl.yml b/src/main/resources/locales/nl.yml index 6fe42e4..324b896 100644 --- a/src/main/resources/locales/nl.yml +++ b/src/main/resources/locales/nl.yml @@ -51,6 +51,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Alleen blokken met een geconfigureerde niveauwaarde kunnen worden gedoneerd." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -60,6 +61,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "hand" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml index a40d8fc..da6ad80 100644 --- a/src/main/resources/locales/pl.yml +++ b/src/main/resources/locales/pl.yml @@ -51,6 +51,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Można darować tylko bloki ze skonfigurowaną wartością poziomu." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -60,6 +61,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "reka" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/pt.yml b/src/main/resources/locales/pt.yml index 844402b..57fbabe 100644 --- a/src/main/resources/locales/pt.yml +++ b/src/main/resources/locales/pt.yml @@ -54,6 +54,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Apenas blocos com um valor de nível configurado podem ser doados." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -63,6 +64,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "mao" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/ru.yml b/src/main/resources/locales/ru.yml index 6150490..2dc53da 100644 --- a/src/main/resources/locales/ru.yml +++ b/src/main/resources/locales/ru.yml @@ -54,6 +54,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Можно жертвовать только блоки с настроенным значением уровня." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -63,6 +64,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "рука" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/tr.yml b/src/main/resources/locales/tr.yml index 1be47bb..689f9b8 100644 --- a/src/main/resources/locales/tr.yml +++ b/src/main/resources/locales/tr.yml @@ -58,6 +58,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Yalnızca yapılandırılmış seviye değerine sahip bloklar bağışlanabilir." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -67,6 +68,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "el" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/uk.yml b/src/main/resources/locales/uk.yml index 8bf009b..9ac33d3 100644 --- a/src/main/resources/locales/uk.yml +++ b/src/main/resources/locales/uk.yml @@ -45,24 +45,26 @@ island: in-progress: " Розрахунок рівня острова триває..." time-out: " Розрахунок рівня тривав занадто довго. Будь-ласка спробуйте пізніше." donate: - parameters: "[hand [amount]]" - description: "donate blocks to permanently raise island level" - must-be-on-island: "You must be on your island to donate blocks." - no-permission: "You do not have permission to donate blocks on this island." - no-value: "That block has no level value." - invalid-amount: "Invalid amount. Use a positive number." - empty: "There are no valid blocks to donate." - cancelled: "Donation cancelled. Items returned." - success: "Donated [number] blocks for [points] points! These points are permanent." - confirm: "Confirm - Items will be DESTROYED!" - cancel: "Cancel - Return Items" - gui-title: "Donate Blocks" - gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" - preview: "Points to add: [points]|These items will be destroyed!" + parameters: "[рука [кількість]]" + description: "пожертвувати блоки для постійного підвищення рівня острова" + must-be-on-island: "Щоб пожертвувати блоки, ви повинні бути на своєму острові." + no-permission: "У вас немає дозволу жертвувати блоки на цьому острові." + no-value: "Цей блок не має значення рівня." + invalid-amount: "Недійсна кількість. Використовуйте позитивне число." + invalid-item: "Можна жертвувати лише блоки з налаштованим значенням рівня." + empty: "Немає дійсних блоків для пожертвування." + cancelled: "Пожертвування скасовано. Предмети повернуто." + success: "Пожертвовано [number] блоків за [points] очок! Ці очки є постійними." + confirm: "Підтвердити — Предмети будуть ЗНИЩЕНІ!" + cancel: "Скасувати — Повернути предмети" + gui-title: "Пожертвувати блоки" + gui-info: "Пожертвуйте блоки своєму острову|Пожертвовано: [points] очок|Увага: пожертвувані предмети|знищуються і не можуть бути повернуті!" + preview: "Очок буде додано: [points]|Ці предмети будуть знищені!" hand: - success: "Donated [number] x [material] for [points] permanent points!" - not-block: "You must be holding a placeable block to donate." - confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." + keyword: "рука" + success: "Пожертвовано [number] x [material] за [points] постійних очок!" + not-block: "Ви повинні тримати блок, який можна розмістити." + confirm-prompt: "Буде ЗНИЩЕНО [number] x [material] за [points] постійних очок." top: description: показати першу десятку gui-title: "& Десятка Кращих" @@ -92,9 +94,8 @@ protection: level: commands: value: - parameters: "[hand|]" - description: показує значення блоків. Додайте 'hand' в кінці, щоб відобразити - значення предмета в руках. + parameters: "[рука|<матеріал>]" + description: показує значення блоків. Додайте 'рука' в кінці, щоб відобразити значення предмета в руках. gui: titles: top: " Топ островів" diff --git a/src/main/resources/locales/vi.yml b/src/main/resources/locales/vi.yml index 2c0451e..6d27ce2 100644 --- a/src/main/resources/locales/vi.yml +++ b/src/main/resources/locales/vi.yml @@ -57,6 +57,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "Chỉ có thể quyên góp các khối có giá trị cấp độ được cấu hình." empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -66,6 +67,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "tay" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/main/resources/locales/zh-CN.yml b/src/main/resources/locales/zh-CN.yml index 522a0ed..1901208 100644 --- a/src/main/resources/locales/zh-CN.yml +++ b/src/main/resources/locales/zh-CN.yml @@ -49,6 +49,7 @@ island: no-permission: "You do not have permission to donate blocks on this island." no-value: "That block has no level value." invalid-amount: "Invalid amount. Use a positive number." + invalid-item: "只能捐赠具有配置等级值的方块。" empty: "There are no valid blocks to donate." cancelled: "Donation cancelled. Items returned." success: "Donated [number] blocks for [points] points! These points are permanent." @@ -58,6 +59,7 @@ island: gui-info: "Donate blocks to your island|Currently donated: [points] points|Warning: donated items are|destroyed and cannot be returned!" preview: "Points to add: [points]|These items will be destroyed!" hand: + keyword: "hand" success: "Donated [number] x [material] for [points] permanent points!" not-block: "You must be holding a placeable block to donate." confirm-prompt: "About to DESTROY [number] x [material] for [points] permanent points." diff --git a/src/test/java/world/bentobox/level/commands/IslandDonateCommandTest.java b/src/test/java/world/bentobox/level/commands/IslandDonateCommandTest.java index e7f63fc..bb1f195 100644 --- a/src/test/java/world/bentobox/level/commands/IslandDonateCommandTest.java +++ b/src/test/java/world/bentobox/level/commands/IslandDonateCommandTest.java @@ -64,6 +64,7 @@ public void setUp() throws Exception { when(user.getTranslation(anyString())).thenAnswer(i -> i.getArgument(0, String.class)); when(user.getTranslation(anyString(), anyString(), anyString())).thenAnswer(i -> i.getArgument(0, String.class)); when(user.getTranslation(anyString(), anyString(), anyString(), anyString(), anyString())).thenAnswer(i -> i.getArgument(0, String.class)); + when(user.getTranslation("island.donate.hand.keyword")).thenReturn("hand"); when(user.getLocation()).thenReturn(location); when(player.getInventory()).thenReturn(inventory); diff --git a/src/test/java/world/bentobox/level/commands/IslandValueCommandTest.java b/src/test/java/world/bentobox/level/commands/IslandValueCommandTest.java index 3c8b4fa..a693cb1 100644 --- a/src/test/java/world/bentobox/level/commands/IslandValueCommandTest.java +++ b/src/test/java/world/bentobox/level/commands/IslandValueCommandTest.java @@ -7,6 +7,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -68,6 +69,7 @@ public void setUp() throws Exception { when(user.getTranslation(anyString())).thenAnswer(i -> i.getArgument(0, String.class)); when(user.getTranslation(anyString(), anyString(), anyString())).thenAnswer(i -> i.getArgument(0, String.class)); when(user.getTranslation(anyString(), anyString(), anyString(), anyString(), anyString())).thenAnswer(i -> i.getArgument(0, String.class)); + when(user.getTranslation("island.donate.hand.keyword")).thenReturn("hand"); when(user.getTranslationOrNothing(anyString())).thenReturn(""); when(player.getInventory()).thenReturn(inventory); @@ -109,7 +111,7 @@ public void testExecuteTooManyArgsShowsHelp() { public void testExecuteUnknownMaterial() { assertTrue(cmd.execute(user, "value", List.of("NOTAMATERIAL"))); // Sends unknown-item message via Utils.sendMessage - verify(user).getTranslation(anyString()); // translation called for unknown item message + verify(user, times(2)).getTranslation(anyString()); // keyword lookup + unknown item message } @Test From 1e5e2d125b3e726c32fbd1a320e2a4a3b93f4158 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 20 Apr 2026 19:58:36 -0700 Subject: [PATCH 2/3] Update build.version to 2.25.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0f8a672..b705ea3 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ -LOCAL - 2.24.1 + 2.25.0 BentoBoxWorld_Level bentobox-world https://sonarcloud.io From 5bdbf9629968fc172263d583be8c905d2729d7ec Mon Sep 17 00:00:00 2001 From: tastybento Date: Tue, 21 Apr 2026 08:24:46 -0700 Subject: [PATCH 3/3] feat: add CraftEngine custom block support for island level calculation Adds CraftEngine block detection to processBlock() alongside ItemsAdder, Oraxen, and Nexo. CraftEngine blocks are counted using their native namespaced ID (e.g. mynamespace:my_block) and can be assigned point values in blockconfig.yml. Adds isCraftEngine() to Level and validates CE block IDs in BlockConfig.isOther(). Requires BentoBox 3.15.0-SNAPSHOT. Co-Authored-By: Claude Sonnet 4.6 --- pom.xml | 2 +- src/main/java/world/bentobox/level/Level.java | 8 ++++++++ .../bentobox/level/calculators/IslandLevelCalculator.java | 8 ++++++-- .../java/world/bentobox/level/config/BlockConfig.java | 7 ++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0f8a672..a1b0f1e 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ v1.21-SNAPSHOT 1.21.11-R0.1-SNAPSHOT - 3.14.1-SNAPSHOT + 3.15.0-SNAPSHOT 1.12.0 diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index 20f2094..4af0b59 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -515,4 +515,12 @@ public boolean isNexo() { && Bukkit.getPluginManager().isPluginEnabled("Nexo"); } + /** + * @return true if the CraftEngine plugin is hooked and not disabled in config + */ + public boolean isCraftEngine() { + return !getSettings().getDisabledPluginHooks().contains("CraftEngine") + && getPlugin().getHooks().getHook("CraftEngine").isPresent(); + } + } diff --git a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java index 0769a29..146540d 100644 --- a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java +++ b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java @@ -54,6 +54,7 @@ import us.lynuxcraft.deadsilenceiv.advancedchests.chest.gui.page.ChestPage; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.hooks.CraftEngineHook; import world.bentobox.bentobox.hooks.ItemsAdderHook; import world.bentobox.bentobox.hooks.OraxenHook; import world.bentobox.bentobox.util.Pair; @@ -562,11 +563,11 @@ private void processBlock(ChunkPair cp, int x, int y, int z, int globalX, int gl // Create a Location object only when needed for more complex checks. Location loc = null; - // === Custom Block Hooks (ItemsAdder, Oraxen, Nexo) === + // === Custom Block Hooks (ItemsAdder, Oraxen, Nexo, CraftEngine) === // These hooks can define custom blocks that override vanilla behavior. // They must be checked first. if (addon.isItemsAdder() || BentoBox.getInstance().getHooks().getHook("Oraxen").isPresent() - || addon.isNexo()) { + || addon.isNexo() || addon.isCraftEngine()) { loc = new Location(cp.world, globalX, y, globalZ); String customBlockId = null; if (addon.isItemsAdder()) { @@ -584,6 +585,9 @@ private void processBlock(ChunkPair cp, int x, int y, int z, int globalX, int gl customBlockId = "nexo:" + nexoMechanic.getItemID(); } } + if (customBlockId == null && addon.isCraftEngine()) { + customBlockId = CraftEngineHook.getBlockId(loc); + } if (customBlockId != null) { // If a custom block is found, count it and stop further processing for this block. diff --git a/src/main/java/world/bentobox/level/config/BlockConfig.java b/src/main/java/world/bentobox/level/config/BlockConfig.java index 2c9793a..62350c3 100644 --- a/src/main/java/world/bentobox/level/config/BlockConfig.java +++ b/src/main/java/world/bentobox/level/config/BlockConfig.java @@ -22,6 +22,7 @@ import com.nexomc.nexo.api.NexoItems; import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.hooks.CraftEngineHook; import world.bentobox.bentobox.hooks.ItemsAdderHook; import world.bentobox.bentobox.hooks.OraxenHook; import world.bentobox.level.Level; @@ -111,7 +112,11 @@ private boolean isOther(String key) { return NexoItems.exists(key.substring(5)); } // Check ItemsAdder - return addon.isItemsAdder() && ItemsAdderHook.isInRegistry(key); + if (addon.isItemsAdder() && ItemsAdderHook.isInRegistry(key)) { + return true; + } + // Check CraftEngine — block IDs are already namespaced (e.g. "mynamespace:my_block") + return addon.isCraftEngine() && CraftEngineHook.exists(key); } private boolean isSpawner(String key) {