Clean up Constants a bit.

This commit is contained in:
BONNe 2021-09-19 21:04:09 +03:00
parent 89c51211cd
commit 2bc71b5f52
21 changed files with 827 additions and 271 deletions

View File

@ -15,6 +15,7 @@ import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.utils.Constants;
import world.bentobox.challenges.utils.Utils; import world.bentobox.challenges.utils.Utils;
@ -109,8 +110,8 @@ public class CompleteCommand extends CompositeCommand
if (user.isPlayer()) if (user.isPlayer())
{ {
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.completed", Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.completed",
"[name]", challenge.getFriendlyName(), Constants.PARAMETER_NAME, challenge.getFriendlyName(),
"[player]", User.getInstance(targetUUID).getName())); Constants.PARAMETER_PLAYER, User.getInstance(targetUUID).getName()));
} }
else else
{ {

View File

@ -15,6 +15,7 @@ import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.database.object.Challenge;
import world.bentobox.challenges.utils.Constants;
import world.bentobox.challenges.utils.Utils; import world.bentobox.challenges.utils.Utils;
@ -103,7 +104,7 @@ public class ResetCommand extends CompositeCommand
if (user.isPlayer()) if (user.isPlayer())
{ {
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.reset-all", Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.reset-all",
"[player]", User.getInstance(targetUUID).getName())); Constants.PARAMETER_PLAYER, User.getInstance(targetUUID).getName()));
} }
else else
{ {
@ -127,8 +128,8 @@ public class ResetCommand extends CompositeCommand
if (user.isPlayer()) if (user.isPlayer())
{ {
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.reset", Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.reset",
"[name]", challenge.getFriendlyName(), Constants.PARAMETER_NAME, challenge.getFriendlyName(),
"[player]", User.getInstance(targetUUID).getName())); Constants.PARAMETER_PLAYER, User.getInstance(targetUUID).getName()));
} }
else else
{ {

View File

@ -82,7 +82,7 @@ public class ChallengesImportManager
{ {
if (user != null) if (user != null)
{ {
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-file", Constants.FILE, file)); Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-file", Constants.PARAMETER_FILE, file));
} }
return; return;
@ -99,7 +99,7 @@ public class ChallengesImportManager
if (user != null) if (user != null)
{ {
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-load", Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-load",
Constants.FILE, file, TextVariables.DESCRIPTION, e.getMessage())); Constants.PARAMETER_FILE, file, TextVariables.DESCRIPTION, e.getMessage()));
} }
else else
{ {
@ -117,7 +117,7 @@ public class ChallengesImportManager
{ {
Utils.sendMessage(user, Utils.sendMessage(user,
user.getTranslation(Constants.ERRORS + "not-a-gamemode-world", user.getTranslation(Constants.ERRORS + "not-a-gamemode-world",
Constants.WORLD, world.getName())); Constants.PARAMETER_WORLD, world.getName()));
} }
else else
{ {
@ -805,7 +805,7 @@ public class ChallengesImportManager
{ {
Utils.sendMessage(user, Utils.sendMessage(user,
user.getTranslation(Constants.ERRORS + "file-exist", user.getTranslation(Constants.ERRORS + "file-exist",
Constants.FILE, fileName)); Constants.PARAMETER_FILE, fileName));
} }
else else
{ {
@ -872,7 +872,7 @@ public class ChallengesImportManager
{ {
Utils.sendMessage(user, Utils.sendMessage(user,
user.getTranslation(Constants.ERRORS + "no-load", user.getTranslation(Constants.ERRORS + "no-load",
Constants.FILE, fileName, Constants.PARAMETER_FILE, fileName,
TextVariables.DESCRIPTION, e.getMessage())); TextVariables.DESCRIPTION, e.getMessage()));
} }
@ -884,8 +884,8 @@ public class ChallengesImportManager
{ {
Utils.sendMessage(user, Utils.sendMessage(user,
user.getTranslation(Constants.CONVERSATIONS + "database-export-completed", user.getTranslation(Constants.CONVERSATIONS + "database-export-completed",
Constants.WORLD, world.getName(), Constants.PARAMETER_WORLD, world.getName(),
Constants.FILE, fileName)); Constants.PARAMETER_FILE, fileName));
} }
else else
{ {

View File

@ -128,7 +128,7 @@ public abstract class CommonPagedPanel extends CommonPanel
if (button == CommonButtons.NEXT) if (button == CommonButtons.NEXT)
{ {
description.add(this.user.getTranslation(reference + "description", description.add(this.user.getTranslation(reference + "description",
Constants.NUMBER, String.valueOf(this.pageIndex + 2))); Constants.PARAMETER_NUMBER, String.valueOf(this.pageIndex + 2)));
icon = new ItemStack(Material.OAK_SIGN, this.pageIndex + 2); icon = new ItemStack(Material.OAK_SIGN, this.pageIndex + 2);
clickHandler = (panel, user, clickType, slot) -> clickHandler = (panel, user, clickType, slot) ->
@ -141,7 +141,7 @@ public abstract class CommonPagedPanel extends CommonPanel
else if (button == CommonButtons.PREVIOUS) else if (button == CommonButtons.PREVIOUS)
{ {
description.add(this.user.getTranslation(reference + "description", description.add(this.user.getTranslation(reference + "description",
Constants.NUMBER, String.valueOf(this.pageIndex))); Constants.PARAMETER_NUMBER, String.valueOf(this.pageIndex)));
icon = new ItemStack(Material.OAK_SIGN, Math.max(1, this.pageIndex)); icon = new ItemStack(Material.OAK_SIGN, Math.max(1, this.pageIndex));
clickHandler = (panel, user, clickType, slot) -> clickHandler = (panel, user, clickType, slot) ->

View File

@ -156,9 +156,9 @@ public abstract class CommonPanel
if (!description.replaceAll("(?m)^[ \\t]*\\r?\\n", "").isEmpty()) if (!description.replaceAll("(?m)^[ \\t]*\\r?\\n", "").isEmpty())
{ {
String returnString = this.user.getTranslationOrNothing(reference + "lore", String returnString = this.user.getTranslationOrNothing(reference + "lore",
Constants.REQUIREMENTS, requirements, "[requirements]", requirements,
Constants.REWARDS, rewards, "[rewards]", rewards,
Constants.STATUS, status); "[status]", status);
// remove empty lines from the generated text. // remove empty lines from the generated text.
List<String> collect = List<String> collect =
@ -170,9 +170,9 @@ public abstract class CommonPanel
for (int i = 0; i < collect.size(); i++) for (int i = 0; i < collect.size(); i++)
{ {
if (collect.get(i).contains(Constants.DESCRIPTION)) if (collect.get(i).contains(Constants.PARAMETER_DESCRIPTION))
{ {
collect.set(i, collect.get(i).replace(Constants.DESCRIPTION, description)); collect.set(i, collect.get(i).replace(Constants.PARAMETER_DESCRIPTION, description));
} }
} }
@ -181,10 +181,10 @@ public abstract class CommonPanel
else else
{ {
String returnString = this.user.getTranslationOrNothing(reference + "lore", String returnString = this.user.getTranslationOrNothing(reference + "lore",
Constants.DESCRIPTION, description, Constants.PARAMETER_DESCRIPTION, description,
Constants.REQUIREMENTS, requirements, "[requirements]", requirements,
Constants.REWARDS, rewards, "[rewards]", rewards,
Constants.STATUS, status); "[status]", status);
// Remove empty lines and returns as a list. // Remove empty lines and returns as a list.
@ -214,7 +214,7 @@ public abstract class CommonPanel
else if (challenge.getEnvironment().size() == 1) else if (challenge.getEnvironment().size() == 1)
{ {
environment = this.user.getTranslationOrNothing(reference + "environment-single", environment = this.user.getTranslationOrNothing(reference + "environment-single",
Constants.ENVIRONMENT, Constants.PARAMETER_ENVIRONMENT,
Utils.prettifyObject(challenge.getEnvironment().iterator().next(), this.user)); Utils.prettifyObject(challenge.getEnvironment().iterator().next(), this.user));
} }
else else
@ -225,7 +225,7 @@ public abstract class CommonPanel
{ {
builder.append("\n"); builder.append("\n");
builder.append(this.user.getTranslationOrNothing(reference + "environment-single", builder.append(this.user.getTranslationOrNothing(reference + "environment-single",
Constants.ENVIRONMENT, Constants.PARAMETER_ENVIRONMENT,
Utils.prettifyObject(en, this.user))); Utils.prettifyObject(en, this.user)));
}); });
@ -247,7 +247,7 @@ public abstract class CommonPanel
if (missingPermissions.size() == 1) if (missingPermissions.size() == 1)
{ {
permissionBuilder.append(this.user.getTranslationOrNothing(reference + "permission-single", permissionBuilder.append(this.user.getTranslationOrNothing(reference + "permission-single",
Constants.PERMISSION, missingPermissions.get(0))); Constants.PARAMETER_PERMISSION, missingPermissions.get(0)));
} }
else if (!missingPermissions.isEmpty()) else if (!missingPermissions.isEmpty())
{ {
@ -256,7 +256,7 @@ public abstract class CommonPanel
{ {
permissionBuilder.append("\n"); permissionBuilder.append("\n");
permissionBuilder.append(this.user.getTranslationOrNothing(reference + "permissions-list", permissionBuilder.append(this.user.getTranslationOrNothing(reference + "permissions-list",
Constants.PERMISSION, permission)); Constants.PARAMETER_PERMISSION, permission));
}); });
} }
@ -275,9 +275,9 @@ public abstract class CommonPanel
}; };
return this.user.getTranslationOrNothing(reference + "lore", return this.user.getTranslationOrNothing(reference + "lore",
Constants.ENVIRONMENT, environment, Constants.PARAMETER_ENVIRONMENT, environment,
Constants.TYPE_REQUIREMENT, typeRequirement, "[type-requirement]", typeRequirement,
Constants.PERMISSIONS, permissions); "[permissions]", permissions);
} }
@ -305,13 +305,13 @@ public abstract class CommonPanel
if (entry.getValue() > 1) if (entry.getValue() > 1)
{ {
builder.append(this.user.getTranslationOrNothing(reference + "blocks-value", builder.append(this.user.getTranslationOrNothing(reference + "blocks-value",
Constants.NUMBER, String.valueOf(entry.getValue()), Constants.PARAMETER_NUMBER, String.valueOf(entry.getValue()),
Constants.MATERIAL, Utils.prettifyObject(entry.getKey(), this.user))); Constants.PARAMETER_MATERIAL, Utils.prettifyObject(entry.getKey(), this.user)));
} }
else else
{ {
builder.append(this.user.getTranslationOrNothing(reference + "block-value", builder.append(this.user.getTranslationOrNothing(reference + "block-value",
Constants.MATERIAL, Utils.prettifyObject(entry.getKey(), this.user))); Constants.PARAMETER_MATERIAL, Utils.prettifyObject(entry.getKey(), this.user)));
} }
}); });
@ -337,13 +337,13 @@ public abstract class CommonPanel
if (entry.getValue() > 1) if (entry.getValue() > 1)
{ {
builder.append(this.user.getTranslationOrNothing(reference + "entities-value", builder.append(this.user.getTranslationOrNothing(reference + "entities-value",
Constants.NUMBER, String.valueOf(entry.getValue()), Constants.PARAMETER_NUMBER, String.valueOf(entry.getValue()),
Constants.ENTITY, Utils.prettifyObject(entry.getKey(), this.user))); Constants.PARAMETER_ENTITY, Utils.prettifyObject(entry.getKey(), this.user)));
} }
else else
{ {
builder.append(this.user.getTranslationOrNothing(reference + "entity-value", builder.append(this.user.getTranslationOrNothing(reference + "entity-value",
Constants.ENTITY, Utils.prettifyObject(entry.getKey(), this.user))); Constants.PARAMETER_ENTITY, Utils.prettifyObject(entry.getKey(), this.user)));
} }
}); });
@ -355,7 +355,7 @@ public abstract class CommonPanel
} }
String searchRadius = this.user.getTranslationOrNothing(reference + "search-radius", String searchRadius = this.user.getTranslationOrNothing(reference + "search-radius",
Constants.NUMBER, String.valueOf(requirement.getSearchRadius())); Constants.PARAMETER_NUMBER, String.valueOf(requirement.getSearchRadius()));
String warningBlocks = requirement.isRemoveBlocks() ? String warningBlocks = requirement.isRemoveBlocks() ?
this.user.getTranslationOrNothing(reference + "warning-block") : ""; this.user.getTranslationOrNothing(reference + "warning-block") : "";
@ -547,7 +547,7 @@ public abstract class CommonPanel
if (maxCompletions > 1) if (maxCompletions > 1)
{ {
return this.user.getTranslationOrNothing(reference + "completed-times-reached", return this.user.getTranslationOrNothing(reference + "completed-times-reached",
Constants.MAX, String.valueOf(maxCompletions)); Constants.PARAMETER_MAX, String.valueOf(maxCompletions));
} }
else else
{ {
@ -559,13 +559,13 @@ public abstract class CommonPanel
if (maxCompletions > 0) if (maxCompletions > 0)
{ {
return this.user.getTranslationOrNothing(reference + "completed-times-of", return this.user.getTranslationOrNothing(reference + "completed-times-of",
Constants.MAX, String.valueOf(maxCompletions), Constants.PARAMETER_MAX, String.valueOf(maxCompletions),
Constants.NUMBER, String.valueOf(completionCount)); Constants.PARAMETER_NUMBER, String.valueOf(completionCount));
} }
else else
{ {
return this.user.getTranslationOrNothing(reference + "completed-times", return this.user.getTranslationOrNothing(reference + "completed-times",
Constants.NUMBER, String.valueOf(completionCount)); Constants.PARAMETER_NUMBER, String.valueOf(completionCount));
} }
} }
else else

View File

@ -198,7 +198,7 @@ public class ConversationUtils
String invalidInput) String invalidInput)
{ {
return user.getTranslation(failTranslationLocation, return user.getTranslation(failTranslationLocation,
Constants.ID, Constants.PARAMETER_ID,
Utils.sanitizeInput(invalidInput)); Utils.sanitizeInput(invalidInput));
} }
@ -303,7 +303,7 @@ public class ConversationUtils
@Override @Override
protected String getInputNotNumericText(ConversationContext context, String invalidInput) protected String getInputNotNumericText(ConversationContext context, String invalidInput)
{ {
return user.getTranslation(Constants.CONVERSATIONS + "numeric-only", Constants.VALUE, invalidInput); return user.getTranslation(Constants.CONVERSATIONS + "numeric-only", Constants.PARAMETER_VALUE, invalidInput);
} }
@ -319,9 +319,9 @@ public class ConversationUtils
protected String getFailedValidationText(ConversationContext context, Number invalidInput) protected String getFailedValidationText(ConversationContext context, Number invalidInput)
{ {
return user.getTranslation(Constants.CONVERSATIONS + "not-valid-value", return user.getTranslation(Constants.CONVERSATIONS + "not-valid-value",
Constants.VALUE, invalidInput.toString(), Constants.PARAMETER_VALUE, invalidInput.toString(),
Constants.MIN, Double.toString(minValue.doubleValue()), Constants.PARAMETER_MIN, Double.toString(minValue.doubleValue()),
Constants.MAX, Double.toString(maxValue.doubleValue())); Constants.PARAMETER_MAX, Double.toString(maxValue.doubleValue()));
} }

View File

@ -218,7 +218,7 @@ public class AdminPanel extends CommonPanel
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "write-name"), this.user.getTranslation(Constants.CONVERSATIONS + "write-name"),
this.user.getTranslation(Constants.CONVERSATIONS + "new-object-created", this.user.getTranslation(Constants.CONVERSATIONS + "new-object-created",
Constants.WORLD, this.world.getName()), Constants.PARAMETER_WORLD, this.world.getName()),
Constants.CONVERSATIONS + "object-already-exists"); Constants.CONVERSATIONS + "object-already-exists");
return true; return true;
@ -262,7 +262,7 @@ public class AdminPanel extends CommonPanel
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "write-name"), this.user.getTranslation(Constants.CONVERSATIONS + "write-name"),
this.user.getTranslation(Constants.CONVERSATIONS + "new-object-created", this.user.getTranslation(Constants.CONVERSATIONS + "new-object-created",
Constants.GAMEMODE, Utils.getGameMode(this.world)), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)),
Constants.CONVERSATIONS + "object-already-exists"); Constants.CONVERSATIONS + "object-already-exists");
return true; return true;
@ -379,7 +379,7 @@ public class AdminPanel extends CommonPanel
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "exported-file-name"), this.user.getTranslation(Constants.CONVERSATIONS + "exported-file-name"),
this.user.getTranslation(Constants.CONVERSATIONS + "database-export-completed", this.user.getTranslation(Constants.CONVERSATIONS + "database-export-completed",
Constants.WORLD, world.getName()), Constants.PARAMETER_WORLD, world.getName()),
Constants.CONVERSATIONS + "file-name-exist"); Constants.CONVERSATIONS + "file-name-exist");
return true; return true;
@ -438,9 +438,9 @@ public class AdminPanel extends CommonPanel
consumer, consumer,
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "confirm-all-data-deletion", this.user.getTranslation(Constants.CONVERSATIONS + "confirm-all-data-deletion",
Constants.GAMEMODE, Utils.getGameMode(this.world)), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)),
this.user.getTranslation(Constants.CONVERSATIONS + "all-data-removed", this.user.getTranslation(Constants.CONVERSATIONS + "all-data-removed",
Constants.GAMEMODE, Utils.getGameMode(this.world))); Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)));
} }
return true; return true;
@ -477,9 +477,9 @@ public class AdminPanel extends CommonPanel
consumer, consumer,
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "confirm-challenge-data-deletion", this.user.getTranslation(Constants.CONVERSATIONS + "confirm-challenge-data-deletion",
Constants.GAMEMODE, Utils.getGameMode(this.world)), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)),
this.user.getTranslation(Constants.CONVERSATIONS + "challenge-data-removed", this.user.getTranslation(Constants.CONVERSATIONS + "challenge-data-removed",
Constants.GAMEMODE, Utils.getGameMode(this.world))); Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)));
} }
return true; return true;
@ -508,9 +508,9 @@ public class AdminPanel extends CommonPanel
consumer, consumer,
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "confirm-user-data-deletion", this.user.getTranslation(Constants.CONVERSATIONS + "confirm-user-data-deletion",
Constants.GAMEMODE, Utils.getGameMode(this.world)), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)),
this.user.getTranslation(Constants.CONVERSATIONS + "user-data-removed", this.user.getTranslation(Constants.CONVERSATIONS + "user-data-removed",
Constants.GAMEMODE, Utils.getGameMode(this.world))); Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)));
return true; return true;
}; };

View File

@ -377,7 +377,7 @@ public class EditChallengePanel extends CommonPanel
{ {
case NAME -> { case NAME -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
"[name]", this.challenge.getFriendlyName())); Constants.PARAMETER_NAME, this.challenge.getFriendlyName()));
icon = new ItemStack(Material.NAME_TAG); icon = new ItemStack(Material.NAME_TAG);
@ -501,7 +501,7 @@ public class EditChallengePanel extends CommonPanel
} }
case ORDER -> { case ORDER -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challenge.getOrder()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challenge.getOrder())));
icon = new ItemStack(Material.HOPPER, Math.max(1, this.challenge.getOrder())); icon = new ItemStack(Material.HOPPER, Math.max(1, this.challenge.getOrder()));
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
@ -801,7 +801,7 @@ public class EditChallengePanel extends CommonPanel
} }
case SEARCH_RADIUS -> { case SEARCH_RADIUS -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(requirements.getSearchRadius()))); Constants.PARAMETER_NUMBER, String.valueOf(requirements.getSearchRadius())));
icon = new ItemStack(Material.COBBLESTONE_WALL); icon = new ItemStack(Material.COBBLESTONE_WALL);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -959,7 +959,7 @@ public class EditChallengePanel extends CommonPanel
{ {
case REQUIRED_EXPERIENCE -> { case REQUIRED_EXPERIENCE -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(requirements.getRequiredExperience()))); Constants.PARAMETER_NUMBER, String.valueOf(requirements.getRequiredExperience())));
icon = new ItemStack(Material.EXPERIENCE_BOTTLE); icon = new ItemStack(Material.EXPERIENCE_BOTTLE);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1001,7 +1001,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REQUIRED_LEVEL -> { case REQUIRED_LEVEL -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(requirements.getRequiredIslandLevel()))); Constants.PARAMETER_NUMBER, String.valueOf(requirements.getRequiredIslandLevel())));
icon = new ItemStack(this.addon.isLevelProvided() ? Material.BEACON : Material.BARRIER); icon = new ItemStack(this.addon.isLevelProvided() ? Material.BEACON : Material.BARRIER);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1028,7 +1028,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REQUIRED_MONEY -> { case REQUIRED_MONEY -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(requirements.getRequiredMoney()))); Constants.PARAMETER_NUMBER, String.valueOf(requirements.getRequiredMoney())));
icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER); icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1132,7 +1132,7 @@ public class EditChallengePanel extends CommonPanel
} }
case STATISTIC_AMOUNT -> { case STATISTIC_AMOUNT -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(requirements.getAmount()))); Constants.PARAMETER_NUMBER, String.valueOf(requirements.getAmount())));
icon = new ItemStack(Material.CHEST); icon = new ItemStack(Material.CHEST);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1371,7 +1371,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REWARD_EXPERIENCE -> { case REWARD_EXPERIENCE -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challenge.getRewardExperience()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challenge.getRewardExperience())));
icon = new ItemStack(Material.EXPERIENCE_BOTTLE); icon = new ItemStack(Material.EXPERIENCE_BOTTLE);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1398,7 +1398,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REWARD_MONEY -> { case REWARD_MONEY -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challenge.getRewardMoney()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challenge.getRewardMoney())));
icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER); icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1485,7 +1485,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REPEAT_COUNT -> { case REPEAT_COUNT -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challenge.getMaxTimes()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challenge.getMaxTimes())));
icon = new ItemStack(Material.COBBLESTONE_WALL); icon = new ItemStack(Material.COBBLESTONE_WALL);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1594,7 +1594,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REPEAT_REWARD_EXPERIENCE -> { case REPEAT_REWARD_EXPERIENCE -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challenge.getRepeatExperienceReward()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challenge.getRepeatExperienceReward())));
icon = new ItemStack(Material.EXPERIENCE_BOTTLE); icon = new ItemStack(Material.EXPERIENCE_BOTTLE);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -1621,7 +1621,7 @@ public class EditChallengePanel extends CommonPanel
} }
case REPEAT_REWARD_MONEY -> { case REPEAT_REWARD_MONEY -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challenge.getRepeatMoneyReward()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challenge.getRepeatMoneyReward())));
icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_NUGGET : Material.BARRIER); icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_NUGGET : Material.BARRIER);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {

View File

@ -401,7 +401,7 @@ public class EditLevelPanel extends CommonPagedPanel
} }
case REWARD_EXPERIENCE -> { case REWARD_EXPERIENCE -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challengeLevel.getRewardExperience()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challengeLevel.getRewardExperience())));
icon = new ItemStack(Material.EXPERIENCE_BOTTLE); icon = new ItemStack(Material.EXPERIENCE_BOTTLE);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -428,7 +428,7 @@ public class EditLevelPanel extends CommonPagedPanel
} }
case REWARD_MONEY -> { case REWARD_MONEY -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challengeLevel.getRewardMoney()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challengeLevel.getRewardMoney())));
icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER); icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER);
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> { Consumer<Number> numberConsumer = number -> {
@ -500,7 +500,7 @@ public class EditLevelPanel extends CommonPagedPanel
} }
case NAME -> { case NAME -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
"[name]", this.challengeLevel.getFriendlyName())); Constants.PARAMETER_NAME, this.challengeLevel.getFriendlyName()));
icon = new ItemStack(Material.NAME_TAG); icon = new ItemStack(Material.NAME_TAG);
@ -602,7 +602,7 @@ public class EditLevelPanel extends CommonPagedPanel
} }
case ORDER -> { case ORDER -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challengeLevel.getOrder()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challengeLevel.getOrder())));
icon = new ItemStack(Material.HOPPER, Math.max(1, this.challengeLevel.getOrder())); icon = new ItemStack(Material.HOPPER, Math.max(1, this.challengeLevel.getOrder()));
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
@ -631,7 +631,7 @@ public class EditLevelPanel extends CommonPagedPanel
} }
case WAIVER_AMOUNT -> { case WAIVER_AMOUNT -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.challengeLevel.getWaiverAmount()))); Constants.PARAMETER_NUMBER, String.valueOf(this.challengeLevel.getWaiverAmount())));
icon = new ItemStack(Material.HOPPER, Math.max(1, this.challengeLevel.getWaiverAmount())); icon = new ItemStack(Material.HOPPER, Math.max(1, this.challengeLevel.getWaiverAmount()));
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {

View File

@ -269,7 +269,7 @@ public class EditSettingsPanel extends CommonPanel
} }
case PURGE_HISTORY -> { case PURGE_HISTORY -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.settings.getLifeSpan()))); Constants.PARAMETER_NUMBER, String.valueOf(this.settings.getLifeSpan())));
icon = new ItemStack(Material.FLINT_AND_STEEL, Math.max(1, this.settings.getLifeSpan())); icon = new ItemStack(Material.FLINT_AND_STEEL, Math.max(1, this.settings.getLifeSpan()));
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {
@ -379,7 +379,7 @@ public class EditSettingsPanel extends CommonPanel
} }
case TITLE_SHOWTIME -> { case TITLE_SHOWTIME -> {
description.add(this.user.getTranslation(reference + "value", description.add(this.user.getTranslation(reference + "value",
Constants.NUMBER, String.valueOf(this.settings.getTitleShowtime()))); Constants.PARAMETER_NUMBER, String.valueOf(this.settings.getTitleShowtime())));
icon = new ItemStack(Material.CLOCK, Math.max(1, this.settings.getTitleShowtime())); icon = new ItemStack(Material.CLOCK, Math.max(1, this.settings.getTitleShowtime()));
clickHandler = (panel, user, clickType, i) -> { clickHandler = (panel, user, clickType, i) -> {

View File

@ -312,9 +312,9 @@ public class LibraryPanel extends CommonPagedPanel
consumer, consumer,
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "confirm-data-replacement", this.user.getTranslation(Constants.CONVERSATIONS + "confirm-data-replacement",
Constants.GAMEMODE, Utils.getGameMode(this.world)), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)),
this.user.getTranslation(Constants.CONVERSATIONS + "new-challenges-imported", this.user.getTranslation(Constants.CONVERSATIONS + "new-challenges-imported",
Constants.GAMEMODE, Utils.getGameMode(this.world))); Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world)));
} }

View File

@ -167,11 +167,11 @@ public class ListChallengesPanel extends CommonPagedPanel
consumer, consumer,
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "confirm-challenge-deletion", this.user.getTranslation(Constants.CONVERSATIONS + "confirm-challenge-deletion",
Constants.GAMEMODE, Utils.getGameMode(this.world), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world),
Constants.CHALLENGE, challenge.getFriendlyName()), Constants.PARAMETER_CHALLENGE, challenge.getFriendlyName()),
this.user.getTranslation(Constants.CONVERSATIONS + "challenge-removed", this.user.getTranslation(Constants.CONVERSATIONS + "challenge-removed",
Constants.GAMEMODE, Utils.getGameMode(this.world), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world),
Constants.CHALLENGE, challenge.getFriendlyName())); Constants.PARAMETER_CHALLENGE, challenge.getFriendlyName()));
return true; return true;
}); });
} }

View File

@ -166,11 +166,11 @@ public class ListLevelsPanel extends CommonPagedPanel
consumer, consumer,
this.user, this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "confirm-level-deletion", this.user.getTranslation(Constants.CONVERSATIONS + "confirm-level-deletion",
Constants.GAMEMODE, Utils.getGameMode(this.world), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world),
Constants.LEVEL, challengeLevel.getFriendlyName()), Constants.PARAMETER_LEVEL, challengeLevel.getFriendlyName()),
this.user.getTranslation(Constants.CONVERSATIONS + "level-removed", this.user.getTranslation(Constants.CONVERSATIONS + "level-removed",
Constants.GAMEMODE, Utils.getGameMode(this.world), Constants.PARAMETER_GAMEMODE, Utils.getGameMode(this.world),
Constants.LEVEL, challengeLevel.getFriendlyName())); Constants.PARAMETER_LEVEL, challengeLevel.getFriendlyName()));
return true; return true;
}); });
} }

View File

@ -138,7 +138,7 @@ public class ListUsersPanel extends CommonPagedPanel
if (island == null) if (island == null)
{ {
return new PanelItemBuilder(). return new PanelItemBuilder().
name(this.user.getTranslation(reference + "name", "[name]", player.getName())). name(this.user.getTranslation(reference + "name", Constants.PARAMETER_NAME, player.getName())).
icon(Material.BARRIER). icon(Material.BARRIER).
description(this.user.getTranslation(reference + "no-island")). description(this.user.getTranslation(reference + "no-island")).
build(); build();
@ -146,7 +146,7 @@ public class ListUsersPanel extends CommonPagedPanel
List<String> description = new ArrayList<>(4); List<String> description = new ArrayList<>(4);
description.add(this.user.getTranslation(reference + "description", description.add(this.user.getTranslation(reference + "description",
"[owner]", this.addon.getPlayers().getName(island.getOwner()))); Constants.PARAMETER_OWNER, this.addon.getPlayers().getName(island.getOwner())));
// Is owner in his own island member set? I assume yes. Need testing. // Is owner in his own island member set? I assume yes. Need testing.
if (island.getMemberSet().size() > 1) if (island.getMemberSet().size() > 1)
@ -156,7 +156,7 @@ public class ListUsersPanel extends CommonPagedPanel
if (member != island.getOwner()) if (member != island.getOwner())
{ {
description.add(this.user.getTranslation(reference + "member", description.add(this.user.getTranslation(reference + "member",
"[name]", this.addon.getPlayers().getName(member))); Constants.PARAMETER_NAME, this.addon.getPlayers().getName(member)));
} }
}); });
} }
@ -173,7 +173,7 @@ public class ListUsersPanel extends CommonPagedPanel
} }
return new PanelItemBuilder(). return new PanelItemBuilder().
name(this.user.getTranslation(reference + "name", "[name]", player.getName())). name(this.user.getTranslation(reference + "name", Constants.PARAMETER_NAME, player.getName())).
icon(player.getName()). icon(player.getName()).
description(description). description(description).
glow(this.operationMode == Mode.RESET_ALL && this.selectedPlayer == player). glow(this.operationMode == Mode.RESET_ALL && this.selectedPlayer == player).

View File

@ -224,7 +224,7 @@ public class ChallengesPanel extends CommonPanel
if (template.title() != null && !template.title().isBlank()) if (template.title() != null && !template.title().isBlank())
{ {
builder.name(this.user.getTranslation(this.world, template.title(), builder.name(this.user.getTranslation(this.world, template.title(),
Constants.CHALLENGE, challenge.getFriendlyName())); Constants.PARAMETER_CHALLENGE, challenge.getFriendlyName()));
} }
else else
{ {
@ -402,7 +402,7 @@ public class ChallengesPanel extends CommonPanel
if (template.title() != null && !template.title().isBlank()) if (template.title() != null && !template.title().isBlank())
{ {
builder.name(this.user.getTranslation(this.world, template.title(), builder.name(this.user.getTranslation(this.world, template.title(),
Constants.LEVEL, level.getLevel().getFriendlyName())); Constants.PARAMETER_LEVEL, level.getLevel().getFriendlyName()));
} }
else else
{ {
@ -580,7 +580,7 @@ public class ChallengesPanel extends CommonPanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(this.world, template.description()), builder.description(this.user.getTranslation(this.world, template.description()),
Constants.NUMBER, String.valueOf(nextPageIndex)); Constants.PARAMETER_NUMBER, String.valueOf(nextPageIndex));
} }
// Add ClickHandler // Add ClickHandler
@ -673,7 +673,7 @@ public class ChallengesPanel extends CommonPanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(this.world, template.description()), builder.description(this.user.getTranslation(this.world, template.description()),
Constants.NUMBER, String.valueOf(previousPageIndex)); Constants.PARAMETER_NUMBER, String.valueOf(previousPageIndex));
} }
// Add ClickHandler // Add ClickHandler

View File

@ -14,11 +14,9 @@ import org.eclipse.jdt.annotation.Nullable;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.TemplatedPanel; import world.bentobox.bentobox.api.panels.TemplatedPanel;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
@ -147,7 +145,7 @@ public class GameModePanel extends CommonPanel
if (template.title() != null && !template.title().isBlank()) if (template.title() != null && !template.title().isBlank())
{ {
builder.name(this.user.getTranslation(this.world, template.title(), builder.name(this.user.getTranslation(this.world, template.title(),
Constants.GAMEMODE, gameModeAddon.getDescription().getName())); Constants.PARAMETER_GAMEMODE, gameModeAddon.getDescription().getName()));
} }
else else
{ {
@ -258,7 +256,7 @@ public class GameModePanel extends CommonPanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(this.world, template.description()), builder.description(this.user.getTranslation(this.world, template.description()),
Constants.NUMBER, String.valueOf(nextPageIndex)); Constants.PARAMETER_NUMBER, String.valueOf(nextPageIndex));
} }
// Add ClickHandler // Add ClickHandler
@ -334,7 +332,7 @@ public class GameModePanel extends CommonPanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(this.world, template.description()), builder.description(this.user.getTranslation(this.world, template.description()),
Constants.NUMBER, String.valueOf(previousPageIndex)); Constants.PARAMETER_NUMBER, String.valueOf(previousPageIndex));
} }
// Add ClickHandler // Add ClickHandler

View File

@ -90,7 +90,7 @@ public class MultiplePanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(template.description(), builder.description(this.user.getTranslation(template.description(),
Constants.NUMBER, String.valueOf(increaseValue))); Constants.PARAMETER_NUMBER, String.valueOf(increaseValue)));
} }
// Add ClickHandler // Add ClickHandler
@ -144,7 +144,7 @@ public class MultiplePanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(template.description(), builder.description(this.user.getTranslation(template.description(),
Constants.NUMBER, String.valueOf(decreaseValue))); Constants.PARAMETER_NUMBER, String.valueOf(decreaseValue)));
} }
// Add ClickHandler // Add ClickHandler
@ -196,7 +196,7 @@ public class MultiplePanel
if (template.description() != null) if (template.description() != null)
{ {
builder.description(this.user.getTranslation(template.description(), builder.description(this.user.getTranslation(template.description(),
Constants.NUMBER, String.valueOf(completionValue))); Constants.PARAMETER_NUMBER, String.valueOf(completionValue)));
} }
// Add ClickHandler // Add ClickHandler

View File

@ -118,7 +118,7 @@ public abstract class PagedSelector<T>
if (button == CommonButtons.NEXT) if (button == CommonButtons.NEXT)
{ {
description.add(this.user.getTranslation(reference + "description", description.add(this.user.getTranslation(reference + "description",
Constants.NUMBER, String.valueOf(this.pageIndex + 2))); Constants.PARAMETER_NUMBER, String.valueOf(this.pageIndex + 2)));
icon = new ItemStack(Material.OAK_SIGN, this.pageIndex + 2); icon = new ItemStack(Material.OAK_SIGN, this.pageIndex + 2);
clickHandler = (panel, user, clickType, slot) -> clickHandler = (panel, user, clickType, slot) ->
@ -131,7 +131,7 @@ public abstract class PagedSelector<T>
else if (button == CommonButtons.PREVIOUS) else if (button == CommonButtons.PREVIOUS)
{ {
description.add(this.user.getTranslation(reference + "description", description.add(this.user.getTranslation(reference + "description",
Constants.NUMBER, String.valueOf(this.pageIndex))); Constants.PARAMETER_NUMBER, String.valueOf(this.pageIndex)));
icon = new ItemStack(Material.OAK_SIGN, Math.max(1, this.pageIndex)); icon = new ItemStack(Material.OAK_SIGN, Math.max(1, this.pageIndex));
clickHandler = (panel, user, clickType, slot) -> clickHandler = (panel, user, clickType, slot) ->

View File

@ -41,6 +41,7 @@ import world.bentobox.challenges.database.object.requirements.InventoryRequireme
import world.bentobox.challenges.database.object.requirements.IslandRequirements; import world.bentobox.challenges.database.object.requirements.IslandRequirements;
import world.bentobox.challenges.database.object.requirements.OtherRequirements; import world.bentobox.challenges.database.object.requirements.OtherRequirements;
import world.bentobox.challenges.database.object.requirements.StatisticRequirements; import world.bentobox.challenges.database.object.requirements.StatisticRequirements;
import world.bentobox.challenges.utils.Constants;
import world.bentobox.challenges.utils.Utils; import world.bentobox.challenges.utils.Utils;
@ -313,7 +314,7 @@ public class TryToComplete
forEach(user -> { forEach(user -> {
Utils.sendMessage(user, user.getTranslation( Utils.sendMessage(user, user.getTranslation(
"challenges.messages.name-has-completed-challenge", "challenges.messages.name-has-completed-challenge",
"[name]", this.user.getName(), Constants.PARAMETER_NAME, this.user.getName(),
"[value]", this.challenge.getFriendlyName())); "[value]", this.challenge.getFriendlyName()));
}); });
} }
@ -423,7 +424,7 @@ public class TryToComplete
forEach(user -> { forEach(user -> {
Utils.sendMessage(user, user.getTranslation( Utils.sendMessage(user, user.getTranslation(
"challenges.messages.name-has-completed-level", "challenges.messages.name-has-completed-level",
"[name]", this.user.getName(), Constants.PARAMETER_NAME, this.user.getName(),
"[value]", level.getFriendlyName())); "[value]", level.getFriendlyName()));
}); });
} }
@ -812,7 +813,7 @@ public class TryToComplete
{ {
String alert = "Running command '" + cmd + "' as " + this.user.getName(); String alert = "Running command '" + cmd + "' as " + this.user.getName();
this.addon.getLogger().info(alert); this.addon.getLogger().info(alert);
cmd = cmd.substring(6, cmd.length()).replace("[player]", this.user.getName()).trim(); cmd = cmd.substring(6, cmd.length()).replace(Constants.PARAMETER_PLAYER, this.user.getName()).trim();
try try
{ {
if (!user.performCommand(cmd)) if (!user.performCommand(cmd))
@ -831,7 +832,7 @@ public class TryToComplete
try try
{ {
if (!this.addon.getServer().dispatchCommand(this.addon.getServer().getConsoleSender(), if (!this.addon.getServer().dispatchCommand(this.addon.getServer().getConsoleSender(),
cmd.replace("[player]", this.user.getName()))) cmd.replace(Constants.PARAMETER_PLAYER, this.user.getName())))
{ {
this.showError(cmd); this.showError(cmd);
} }

View File

@ -56,16 +56,6 @@ public class Constants
*/ */
public static final String BUTTON = GUI + "buttons."; public static final String BUTTON = GUI + "buttons.";
/**
* Reference string to Biome group Buttons in translations.
*/
public static final String BIOME_GROUP_BUTTON = BUTTON + "biome-groups.";
/**
* Reference string to generator type Buttons in translations.
*/
public static final String GENERATOR_TYPE_BUTTON = BUTTON + "generator-types.";
/** /**
* Reference string to TIPS in translations. * Reference string to TIPS in translations.
*/ */
@ -95,11 +85,6 @@ public class Constants
// Section: Other // Section: Other
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
/**
* Reference string to Biomes in translations.
*/
public static final String BIOMES = ADDON_NAME + "biomes.";
/** /**
* Reference string to materials in translations. * Reference string to materials in translations.
*/ */
@ -111,181 +96,131 @@ public class Constants
public static final String ENTITIES = ADDON_NAME + "entities."; public static final String ENTITIES = ADDON_NAME + "entities.";
/** /**
* Reference string to Types in translations. * Reference string to environments in translations.
*/ */
public static final String TYPES = ADDON_NAME + "types."; public static final String ENVIRONMENTS = ADDON_NAME + "environments.";
/**
* Reference string to statistics in translations.
*/
public static final String STATISTICS = ADDON_NAME + "statistics.";
/**
* Reference string to item stacks in translations.
*/
public static final String ITEM_STACKS = ADDON_NAME + "item-stacks.";
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Section: Parameters // Section: Parameters
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
/**
* Reference string to generator parameter in translations.
*/
public static final String GENERATOR = "[generator]";
/**
* Reference string to bundle parameter in translations.
*/
public static final String BUNDLE = "[bundle]";
/** /**
* Reference string to gamemode parameter in translations. * Reference string to gamemode parameter in translations.
*/ */
public static final String GAMEMODE = "[gamemode]"; public static final String PARAMETER_GAMEMODE = "[gamemode]";
/** /**
* Reference string to world parameter in translations. * Reference string to world parameter in translations.
*/ */
public static final String WORLD = "[world]"; public static final String PARAMETER_WORLD = "[world]";
/** /**
* Reference string to value parameter in translations. * Reference string to value parameter in translations.
*/ */
public static final String VALUE = "[value]"; public static final String PARAMETER_VALUE = "[value]";
/** /**
* Reference string to block parameter in translations. * Reference string to block parameter in translations.
*/ */
public static final String BLOCK = "[material]"; public static final String PARAMETER_MATERIAL = "[material]";
/**
* Reference string to entity parameter in translations.
*/
public static final String PARAMETER_ENTITY = "[entity]";
/**
* Reference string to environment parameter in translations.
*/
public static final String PARAMETER_ENVIRONMENT = "[environment]";
/** /**
* Reference string to file parameter in translations. * Reference string to file parameter in translations.
*/ */
public static final String FILE = "[file]"; public static final String PARAMETER_FILE = "[file]";
/** /**
* Reference string to id parameter in translations. * Reference string to id parameter in translations.
*/ */
public static final String ID = "[id]"; public static final String PARAMETER_ID = "[id]";
/** /**
* Reference string to min parameter in translations. * Reference string to min parameter in translations.
*/ */
public static final String MIN = "[min]"; public static final String PARAMETER_MIN = "[min]";
/** /**
* Reference string to max parameter in translations. * Reference string to max parameter in translations.
*/ */
public static final String MAX = "[max]"; public static final String PARAMETER_MAX = "[max]";
/** /**
* Reference to an author parameter in translation. * Reference to an author parameter in translation.
*/ */
public static final String AUTHOR = "[author]"; public static final String PARAMETER_AUTHOR = "[author]";
/** /**
* Reference to an lang parameter in translation. * Reference to an lang parameter in translation.
*/ */
public static final String LANG = "[lang]"; public static final String PARAMETER_LANG = "[lang]";
/** /**
* Reference to an version parameter in translation. * Reference to an version parameter in translation.
*/ */
public static final String VERSION = "[version]"; public static final String PARAMETER_VERSION = "[version]";
/**
* Reference to an generators parameter in translation.
*/
public static final String GENERATORS = "[generators]";
/**
* Reference to an bundles parameter in translation.
*/
public static final String BUNDLES = "[bundles]";
/**
* Reference to number formant in 0.X
*/
public static final String TENS = "[#.#]";
/**
* Reference to number formant in 0.0X
*/
public static final String HUNDREDS = "[#.##]";
/**
* Reference to number formant in 0.00X
*/
public static final String THOUSANDS = "[#.###]";
/**
* Reference to number formant in 0.000X
*/
public static final String TEN_THOUSANDS = "[#.####]";
/**
* Reference to number formant in 0.0000X
*/
public static final String HUNDRED_THOUSANDS = "[#.#####]";
/** /**
* Reference to island in translations. * Reference to island in translations.
*/ */
public static final String ISLAND = "[island]"; public static final String PARAMETER_ISLAND = "[island]";
/** /**
* Reference string to number parameter in translations. * Reference string to number parameter in translations.
*/ */
public static final String NUMBER = "[number]"; public static final String PARAMETER_NUMBER = "[number]";
/**
* Reference string to type parameter in translations.
*/
public static final String TYPE = "[type]";
/** /**
* Reference string to permission parameter in translations. * Reference string to permission parameter in translations.
*/ */
public static final String PERMISSION = "[permission]"; public static final String PARAMETER_PERMISSION = "[permission]";
/**
* Reference string to biome parameter in translations.
*/
public static final String BIOME = "[biome]";
/** /**
* Reference string to player parameter in translations. * Reference string to player parameter in translations.
*/ */
public static final String PLAYER = "[player]"; public static final String PARAMETER_PLAYER = "[player]";
/** /**
* Reference string to owner parameter in translations. * Reference string to owner parameter in translations.
*/ */
public static final String OWNER = "[owner]"; public static final String PARAMETER_OWNER = "[owner]";
/**
* Reference string to members parameter in translations.
*/
public static final String MEMBERS = "[members]";
/** /**
* Reference string to name parameter in translations. * Reference string to name parameter in translations.
*/ */
public static final String NAME = "[name]"; public static final String PARAMETER_NAME = "[name]";
/**
* Reference string to level parameter in translations.
*/
public static final String PARAMETER_LEVEL = "[level]";
/** /**
* Reference string to description parameter in translations. * Reference string to description parameter in translations.
*/ */
public static final String DESCRIPTION = "[description]"; public static final String PARAMETER_DESCRIPTION = "[description]";
public static final String CHALLENGE = "[challenge]"; /**
* Reference string to challenge parameter in translations.
public static final String REQUIREMENTS = "[requirements]"; */
public static final String PARAMETER_CHALLENGE = "[challenge]";
public static final String REWARDS = "[rewards]";
public static final String STATUS = "[status]";
public static final String LEVEL = "[level]";
public static final String ENVIRONMENT = "[environment]";
public static final String TYPE_REQUIREMENT = "[type-requirement]";
public static final String PERMISSIONS = "[permissions]";
public static final String MATERIAL = "[material]";
public static final String ENTITY = "[entity]";
} }

View File

@ -9,12 +9,19 @@ import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.LangUtilsHook;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
@ -188,74 +195,687 @@ public class Utils
} }
/**
* Prettify World.Environment object for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified string for World.Environment.
*/
public static String prettifyObject(World.Environment object, User user) public static String prettifyObject(World.Environment object, User user)
{ {
return Util.prettifyText(object.name()); // Find addon structure with:
} // [addon]:
// environments:
// [environment]:
// name: [name]
String translation = user.getTranslationOrNothing(Constants.ENVIRONMENTS + object.name().toLowerCase() + ".name");
public static String prettifyObject(@Nullable Material object, User user) if (!translation.isEmpty())
{
if (object == null)
{ {
return ""; // We found our translation.
} return translation;
return Util.prettifyText(object.name());
}
public static String prettifyObject(@Nullable EntityType object, User user)
{
if (object == null)
{
return "";
}
return Util.prettifyText(object.name());
}
public static String prettifyObject(@Nullable ItemStack object, User user)
{
if (object == null)
{
return "";
}
return Util.prettifyText(object.getType().name());
}
public static String prettifyObject(@Nullable Statistic object, User user)
{
if (object == null)
{
return "";
}
return Util.prettifyText(object.name());
}
public static String prettifyDescription(@Nullable Statistic object, User user)
{
if (object == null)
{
return "";
} }
// Find addon structure with:
// [addon]:
// environments:
// [environment]: [name]
translation = user.getTranslationOrNothing(Constants.ENVIRONMENTS + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find general structure with:
// environments:
// [environment]: [name]
translation = user.getTranslationOrNothing("environments." + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Lang Utils do not have Environment :(
//LangUtilsHook.getEnvrionmentName(object, user);
// Nothing was found. Use just a prettify text function.
return Util.prettifyText(object.name()); return Util.prettifyText(object.name());
} }
/**
* Prettify World.Environment object description for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified description string for World.Environment.
*/
public static String prettifyDescription(World.Environment object, User user) public static String prettifyDescription(World.Environment object, User user)
{ {
// Find addon structure with:
// [addon]:
// environments:
// [environment]:
// description: [text]
String translation = user.getTranslationOrNothing(Constants.ENVIRONMENTS + object.name().toLowerCase() + ".description");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// No text to return.
return "";
}
/**
* Prettify Material object for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified string for Material.
*/
public static String prettifyObject(@Nullable Material object, User user)
{
// Nothing to translate
if (object == null) if (object == null)
{ {
return ""; return "";
} }
// Find addon structure with:
// [addon]:
// materials:
// [material]:
// name: [name]
String translation = user.getTranslationOrNothing(Constants.MATERIALS + object.name().toLowerCase() + ".name");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find addon structure with:
// [addon]:
// materials:
// [material]: [name]
translation = user.getTranslationOrNothing(Constants.MATERIALS + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find general structure with:
// materials:
// [material]: [name]
translation = user.getTranslationOrNothing("materials." + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Use Lang Utils Hook to translate material
return LangUtilsHook.getMaterialName(object, user);
}
/**
* Prettify Material object description for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified description string for Material.
*/
public static String prettifyDescription(@Nullable Material object, User user)
{
// Nothing to translate
if (object == null)
{
return "";
}
// Find addon structure with:
// [addon]:
// materials:
// [material]:
// description: [text]
String translation = user.getTranslationOrNothing(Constants.MATERIALS + object.name().toLowerCase() + ".description");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// No text to return.
return "";
}
/**
* Prettify EntityType object for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified string for EntityType.
*/
public static String prettifyObject(@Nullable EntityType object, User user)
{
// Nothing to translate
if (object == null)
{
return "";
}
// Find addon structure with:
// [addon]:
// entities:
// [entity]:
// name: [name]
String translation = user.getTranslationOrNothing(Constants.ENTITIES + object.name().toLowerCase() + ".name");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find addon structure with:
// [addon]:
// entities:
// [entity]: [name]
translation = user.getTranslationOrNothing(Constants.ENTITIES + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find general structure with:
// entities:
// [entity]: [name]
translation = user.getTranslationOrNothing("entities." + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Use Lang Utils Hook to translate material
return LangUtilsHook.getEntityName(object, user);
}
/**
* Prettify EntityType object description for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified description string for EntityType.
*/
public static String prettifyDescription(@Nullable EntityType object, User user)
{
// Nothing to translate
if (object == null)
{
return "";
}
// Find addon structure with:
// [addon]:
// entities:
// [entity]:
// description: [text]
String translation = user.getTranslationOrNothing(Constants.ENTITIES + object.name().toLowerCase() + ".description");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// No text to return.
return "";
}
/**
* Prettify Statistic object for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified string for Statistic.
*/
public static String prettifyObject(@Nullable Statistic object, User user)
{
// Nothing to translate
if (object == null)
{
return "";
}
// Find addon structure with:
// [addon]:
// statistics:
// [statistic]:
// name: [name]
String translation = user.getTranslationOrNothing(Constants.STATISTICS + object.name().toLowerCase() + ".name");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find addon structure with:
// [addon]:
// statistics:
// [statistic]: [name]
translation = user.getTranslationOrNothing(Constants.STATISTICS + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find general structure with:
// statistics:
// [statistic]: [name]
translation = user.getTranslationOrNothing("statistics." + object.name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Use Lang Utils Hook to translate material
//return LangUtilsHook.getStatisticName(object, user);
return Util.prettifyText(object.name()); return Util.prettifyText(object.name());
} }
/**
* Prettify Statistic object description for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified description string for Statistic.
*/
public static String prettifyDescription(@Nullable Statistic object, User user)
{
// Nothing to translate
if (object == null)
{
return "";
}
// Find addon structure with:
// [addon]:
// statistics:
// [statistic]:
// description: [text]
String translation = user.getTranslationOrNothing(Constants.STATISTICS + object.name().toLowerCase() + ".description");
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// No text to return.
return "";
}
/**
* Prettify ItemStack object for user.
* @param object Object that must be pretty.
* @param user User who will see the object.
* @return Prettified string for ItemStack.
*/
public static String prettifyObject(@Nullable ItemStack object, User user)
{
// Nothing to translate
if (object == null)
{
return "";
}
// Find addon structure with:
// [addon]:
// item-stacks:
// [material]: ...
// meta:
// potion-type: ...
// ...
// generic: [amount] [name] [meta]
String translation;
switch (object.getType())
{
case POTION, SPLASH_POTION, LINGERING_POTION, TIPPED_ARROW -> {
// Get Potion Meta
translation = prettifyObject(object, (PotionMeta) object.getItemMeta(), user);
}
case PLAYER_HEAD, PLAYER_WALL_HEAD -> {
translation = prettifyObject(object, (SkullMeta) object.getItemMeta(), user);
}
case ENCHANTED_BOOK -> {
translation = prettifyObject(object, (EnchantmentStorageMeta) object.getItemMeta(), user);
}
case WRITTEN_BOOK, WRITABLE_BOOK -> {
translation = prettifyObject(object, (BookMeta) object.getItemMeta(), user);
}
case LEATHER_BOOTS,LEATHER_CHESTPLATE,LEATHER_HELMET,LEATHER_LEGGINGS,LEATHER_HORSE_ARMOR,
TRIDENT,CROSSBOW,CHAINMAIL_HELMET,CHAINMAIL_CHESTPLATE,CHAINMAIL_LEGGINGS,CHAINMAIL_BOOTS,IRON_HELMET,
IRON_CHESTPLATE,IRON_LEGGINGS,IRON_BOOTS,DIAMOND_HELMET,DIAMOND_CHESTPLATE,DIAMOND_LEGGINGS,DIAMOND_BOOTS,
GOLDEN_HELMET,GOLDEN_CHESTPLATE,GOLDEN_LEGGINGS,GOLDEN_BOOTS,NETHERITE_HELMET,NETHERITE_CHESTPLATE,
NETHERITE_LEGGINGS,NETHERITE_BOOTS,WOODEN_SWORD,WOODEN_SHOVEL,WOODEN_PICKAXE,WOODEN_AXE,WOODEN_HOE,
STONE_SWORD,STONE_SHOVEL,STONE_PICKAXE,STONE_AXE,STONE_HOE,GOLDEN_SWORD,GOLDEN_SHOVEL,GOLDEN_PICKAXE,
GOLDEN_AXE,GOLDEN_HOE,IRON_SWORD,IRON_SHOVEL,IRON_PICKAXE,IRON_AXE,IRON_HOE,DIAMOND_SWORD,DIAMOND_SHOVEL,
DIAMOND_PICKAXE,DIAMOND_AXE,DIAMOND_HOE,NETHERITE_SWORD,NETHERITE_SHOVEL,NETHERITE_PICKAXE,NETHERITE_AXE,
NETHERITE_HOE,TURTLE_HELMET,SHEARS,SHIELD,FLINT_AND_STEEL,BOW -> {
translation = prettifyObject(object, object.getItemMeta(), user);
}
default ->
translation = "";
}
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find addon structure with:
// [addon]:
// materials:
// [material]: [name]
translation = user.getTranslationOrNothing(Constants.MATERIALS + object.getType().name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Find general structure with:
// materials:
// [material]: [name]
translation = user.getTranslationOrNothing("materials." + object.getType().name().toLowerCase());
if (!translation.isEmpty())
{
// We found our translation.
return translation;
}
// Use Lang Utils
return LangUtilsHook.getItemDisplayName(object, user);
}
/**
* Prettify enchant string.
*
* @param enchantment the enchantment
* @param user the user
* @return the string
*/
public static String prettifyObject(Enchantment enchantment, User user)
{
if (enchantment == null)
{
return "";
}
String type = user.getTranslationOrNothing(Constants.ITEM_STACKS + "enchant." + enchantment.getKey().getKey());
if (type.isEmpty())
{
type = LangUtilsHook.getEnchantName(enchantment, user);
}
return type;
}
/**
* Prettify effect string.
*
* @param effect the enchantment
* @param user the user
* @return the string
*/
public static String prettifyObject(PotionEffectType effect, User user)
{
if (effect == null)
{
return "";
}
String type = user.getTranslationOrNothing(Constants.ITEM_STACKS + "potion-effect." + effect.getName().toLowerCase());
if (type.isEmpty())
{
type = LangUtilsHook.getPotionEffectName(effect, user);
}
return type;
}
/**
* Prettify potion item string.
*
* @param item the item
* @param potionMeta the potion meta
* @param user the user
* @return the string
*/
public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionMeta, User user)
{
if (potionMeta == null)
{
return "";
}
Material itemType = item.getType();
final String itemReference = Constants.ITEM_STACKS + itemType.name().toLowerCase() + ".";
final String metaReference = Constants.ITEM_STACKS + "meta.";
PotionData potionData = potionMeta.getBasePotionData();
// Check custom translation for potions.
String type = user.getTranslationOrNothing(itemReference + potionData.getType().name().toLowerCase());
if (type.isEmpty())
{
// Check potion types translation.
type = prettifyObject(potionData.getType().getEffectType(), user);
}
String upgraded = user.getTranslationOrNothing(metaReference + "upgraded");
String extended = user.getTranslationOrNothing(metaReference + "extended");
// Get item specific translation.
String specific = user.getTranslationOrNothing(itemReference + "name",
"[type]", type,
"[upgraded]", (potionData.isUpgraded() ? upgraded : ""),
"[extended]", (potionData.isExtended() ? extended : ""));
if (specific.isEmpty())
{
// Use generic translation.
String meta = user.getTranslationOrNothing(metaReference + "potion-meta",
"[type]", type,
"[upgraded]", (potionData.isUpgraded() ? upgraded : ""),
"[extended]", (potionData.isExtended() ? extended : ""));
specific = user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
"[type]", prettifyObject(itemType, user),
"[meta]", meta);
}
return specific;
}
/**
* Prettify skull item string.
*
* @param item the item
* @param skullMeta the skull meta
* @param user the user
* @return the string
*/
public static String prettifyObject(ItemStack item, @Nullable SkullMeta skullMeta, User user)
{
if (skullMeta == null)
{
return "";
}
Material itemType = item.getType();
final String metaReference = Constants.ITEM_STACKS + "meta.";
String meta = user.getTranslationOrNothing(metaReference + "skull-meta",
"[player-name]", skullMeta.getDisplayName());
return user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
"[type]", prettifyObject(itemType, user),
"[meta]", meta);
}
/**
* Prettify item string.
*
* @param item the item
* @param itemMeta the item meta
* @param user the user
* @return the string
*/
public static String prettifyObject(ItemStack item, @Nullable ItemMeta itemMeta, User user)
{
if (itemMeta == null)
{
return "";
}
StringBuilder builder = new StringBuilder();
itemMeta.getEnchants().forEach((enchantment, level) -> {
builder.append("\n");
builder.append(user.getTranslationOrNothing(Constants.ITEM_STACKS + "meta.enchant-meta",
"[type]", prettifyObject(enchantment, user),
"[level]", String.valueOf(level)));
});
Material itemType = item.getType();
final String itemReference = Constants.ITEM_STACKS + itemType.name().toLowerCase() + ".";
String translation = user.getTranslationOrNothing(itemReference + "name",
"[type]", prettifyObject(itemType, user),
"[enchant]", builder.toString());
if (translation.isEmpty())
{
translation = user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
"[type]", prettifyObject(itemType, user),
"[meta]", builder.toString());
}
return translation;
}
/**
* Prettify enchantment storage string.
*
* @param item the item
* @param enchantmentMeta the enchantment storage meta
* @param user the user
* @return the string
*/
public static String prettifyObject(ItemStack item, @Nullable EnchantmentStorageMeta enchantmentMeta, User user)
{
if (enchantmentMeta == null)
{
return "";
}
StringBuilder builder = new StringBuilder();
enchantmentMeta.getEnchants().forEach((enchantment, level) -> {
builder.append("\n");
builder.append(user.getTranslationOrNothing(Constants.ITEM_STACKS + "meta.enchant-meta",
"[type]", prettifyObject(enchantment, user),
"[level]", String.valueOf(level)));
});
Material itemType = item.getType();
final String itemReference = Constants.ITEM_STACKS + itemType.name().toLowerCase() + ".";
String translation = user.getTranslationOrNothing(itemReference + "name",
"[type]", prettifyObject(itemType, user),
"[enchant]", builder.toString());
if (translation.isEmpty())
{
translation = user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
"[type]", prettifyObject(itemType, user),
"[meta]", builder.toString());
}
return translation;
}
/**
* Prettify book item string.
*
* @param item the item
* @param bookMeta the book meta
* @param user the user
* @return the string
*/
public static String prettifyObject(ItemStack item, @Nullable BookMeta bookMeta, User user)
{
if (bookMeta == null)
{
return "";
}
Material itemType = item.getType();
final String metaReference = Constants.ITEM_STACKS + "meta.";
String meta = user.getTranslationOrNothing(metaReference + "book-meta",
"[title]", bookMeta.getTitle(),
"[author]", bookMeta.getAuthor());
return user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
"[type]", prettifyObject(itemType, user),
"[meta]", meta);
}
} }