mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 00:15:56 +02:00
progress on translation system
This commit is contained in:
parent
6e61ac815f
commit
fda211fe5b
16 changed files with 69 additions and 30 deletions
|
|
@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -33,7 +34,7 @@ public class ConfirmActionGui extends AbstractAskGui {
|
|||
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ public class ConfirmActionGui extends AbstractAskGui {
|
|||
}
|
||||
|
||||
if (!success) {
|
||||
event.getWhoClicked().sendMessage("§cAction could not be completed. ");
|
||||
MsgUI.INSTANCE.getCONFIRM_ACTION_FAILED().send(player);
|
||||
}
|
||||
backOnConfirm.show(player);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -36,7 +37,7 @@ public class SelectItemTypeGui extends AbstractAskGui {
|
|||
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -52,13 +53,12 @@ public abstract class MappedElementListConfigGui<T, S> extends ElementListConfig
|
|||
// check permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
player.closeInventory();
|
||||
|
||||
player.sendMessage("§eWrite the " + genericDisplayedName() + " name you want to create in the chat.\n" +
|
||||
"§eOr write §ccancel §eto go back to " + genericDisplayedName() + " config menu");
|
||||
MsgUI.INSTANCE.getELEMENT_LIST_INSTRUCTION_NEW().send(player, genericDisplayedName());
|
||||
|
||||
CustomAnvil.Companion.getChatListener().setListenedCallback(player, prepareCreateItemConsumer(player));
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.gui.config.list.elements.ElementMappedToListGui;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
import xyz.alexcrea.cuanvil.util.LazyValue;
|
||||
|
||||
import java.util.Locale;
|
||||
|
|
@ -69,13 +70,13 @@ public abstract class MappedGuiListConfigGui<T, S extends MappedGuiListConfigGui
|
|||
|
||||
// check permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = message.toLowerCase(Locale.ROOT);
|
||||
if ("cancel".equalsIgnoreCase(message)) {
|
||||
player.sendMessage(genericDisplayedName() + " creation cancelled...");
|
||||
MsgUI.INSTANCE.getELEMENT_LIST_CANCELLED_NEW().send(player, genericDisplayedName());
|
||||
show(player);
|
||||
return;
|
||||
}
|
||||
|
|
@ -86,7 +87,7 @@ public abstract class MappedGuiListConfigGui<T, S extends MappedGuiListConfigGui
|
|||
// Not the most efficient on large number of conflict, but it should not run often.
|
||||
for (T generic : getDisplayableInstanceOfGeneric()) {
|
||||
if (generic.toString().equalsIgnoreCase(message)) {
|
||||
player.sendMessage("§cPlease enter a " + genericDisplayedName() + " name that do not already exist...");
|
||||
MsgUI.INSTANCE.getELEMENT_LIST_DUPLICATED_NEW().send(player, genericDisplayedName());
|
||||
// wait next message.
|
||||
CustomAnvil.Companion.getChatListener().setListenedCallback(player, selfRef.get());
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import xyz.alexcrea.cuanvil.gui.config.list.elements.ElementMappedToListGui;
|
|||
import xyz.alexcrea.cuanvil.gui.config.settings.DoubleSettingGui;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||
|
||||
|
|
@ -70,11 +71,11 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<Namespaced
|
|||
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
|
||||
|
||||
if (!(meta instanceof Damageable)) {
|
||||
player.sendMessage("§cThis item can't be damaged, so it can't be repaired.");
|
||||
MsgUI.INSTANCE.getUNIT_REPAIR_ELEMENT_CANNOT_REPAIR_NEW().send(player);
|
||||
return;
|
||||
}
|
||||
if (type.equals(this.parentMaterial)) {
|
||||
player.sendMessage("§cItem can't repair something of the same type.");
|
||||
MsgUI.INSTANCE.getUNIT_REPAIR_ELEMENT_SAME_TYPE_NEW().send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import xyz.alexcrea.cuanvil.gui.config.settings.MaterialSelectSettingGui;
|
|||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -113,7 +114,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
|
|||
// Do not allow to open inventory if player do not have edit configuration permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
// test if group is used & cancel & warn user if so
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import xyz.alexcrea.cuanvil.gui.config.list.MappedElementListConfigGui;
|
|||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||
|
||||
|
|
@ -156,7 +157,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Namespa
|
|||
// Do not allow to save configuration if player do not have edit configuration permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
if(testCantSave()) return;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
|||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType;
|
||||
import xyz.alexcrea.cuanvil.gui.config.global.BasicConfigGui;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
|
|
@ -73,7 +74,7 @@ public class WorkPenaltyTypeSettingGui extends AbstractSettingGui {
|
|||
// Do not allow to open inventory if player do not have edit configuration permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
new WorkPenaltyTypeSettingGui(parent).show(player);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -17,8 +18,6 @@ import java.util.function.Consumer;
|
|||
*/
|
||||
public class GuiGlobalActions {
|
||||
|
||||
public static final String NO_EDIT_PERM = "§cYou do not have permission to edit the config";
|
||||
|
||||
/**
|
||||
* A Consumer that should be used if the item goal is to do nothing on click.
|
||||
*/
|
||||
|
|
@ -44,7 +43,7 @@ public class GuiGlobalActions {
|
|||
// Do not allow to open inventory if player do not have edit configuration permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
@ -102,7 +101,7 @@ public class GuiGlobalActions {
|
|||
// Do not allow to open inventory if player do not have edit configuration permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
goal.show(player);
|
||||
|
|
@ -127,7 +126,7 @@ public class GuiGlobalActions {
|
|||
// Do not allow to save configuration if player do not have edit configuration permission
|
||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(NO_EDIT_PERM);
|
||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import org.bukkit.command.CommandExecutor
|
|||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.command.TabCompleter
|
||||
import xyz.alexcrea.cuanvil.lang.MsgCommand
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil
|
||||
|
||||
class CustomAnvilCommand(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
|||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.config.global.EnchantConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.config.global.ItemConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions
|
||||
import xyz.alexcrea.cuanvil.lang.Message
|
||||
import xyz.alexcrea.cuanvil.lang.MsgCommand
|
||||
import xyz.alexcrea.cuanvil.lang.MsgUI
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class EditConfigExecutor : CASubCommand {
|
|||
if(sender !is HumanEntity) return false
|
||||
|
||||
if(!allowed(sender)) {
|
||||
sender.sendMessage(GuiGlobalActions.NO_EDIT_PERM)
|
||||
MsgUI.SHARED_CONFIG_NO_EDIT_PERM.send(sender)
|
||||
return false
|
||||
}
|
||||
if(PlatformUtil.isFolia) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import xyz.alexcrea.cuanvil.dependency.scheduler.FoliaScheduler
|
|||
import xyz.alexcrea.cuanvil.dependency.scheduler.TaskScheduler
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
||||
import xyz.alexcrea.cuanvil.lang.MsgWarning
|
||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
||||
import java.lang.IllegalStateException
|
||||
|
|
@ -158,18 +159,14 @@ object DependencyManager {
|
|||
}
|
||||
|
||||
private fun logException(target: CommandSender, e: Exception) {
|
||||
CustomAnvil.instance.logger.log(
|
||||
Level.SEVERE,
|
||||
CustomAnvil.logError(
|
||||
"Error while trying to handle custom anvil supported plugin: ",
|
||||
e
|
||||
)
|
||||
trackError(e)
|
||||
|
||||
// Finally, warn the player
|
||||
target.sendMessage(
|
||||
"[" + ChatColor.YELLOW.toString() + "CustomAnvil" + ChatColor.WHITE.toString() + "] " +
|
||||
ChatColor.RED.toString() + "Error while handling the anvil."
|
||||
)
|
||||
MsgWarning.DEPENDENCY_GENERIC_EXCEPTION.send(target)
|
||||
}
|
||||
|
||||
private fun logExceptionAndClear(view: AnvilView, e: Exception) {
|
||||
|
|
|
|||
|
|
@ -144,4 +144,4 @@ class ErrorMessage(key: String, vararg params: String) : Message("error.$key", *
|
|||
}
|
||||
|
||||
class CommandMessage(key: String, vararg params: String) : Message("command.$key", *params)
|
||||
class UIMessage(key: String, vararg params: String) : Message("ui.$key", *params)
|
||||
class UIMessage(key: String, vararg params: String) : Message("config-ui.$key", *params)
|
||||
|
|
@ -1,6 +1,21 @@
|
|||
package xyz.alexcrea.cuanvil.lang
|
||||
|
||||
import xyz.alexcrea.cuanvil.lang.UIMessage as Message
|
||||
|
||||
object MsgUI {
|
||||
|
||||
val SHARED_CONFIG_NO_EDIT_PERM = Message("shared.no-permission")
|
||||
|
||||
val CONFIRM_ACTION_FAILED = Message("confirm-action.fail")
|
||||
|
||||
val ELEMENT_LIST_INSTRUCTION_NEW = Message("element-list.instruction-new", "type")
|
||||
val ELEMENT_LIST_CANCELLED_NEW = Message("element-list.cancelled-new", "type")
|
||||
val ELEMENT_LIST_DUPLICATED_NEW = Message("element-list.duplicated-new", "type")
|
||||
|
||||
val UNIT_REPAIR_ELEMENT_TITLE = Message("unit-repair.element.title")
|
||||
val UNIT_REPAIR_ELEMENT_DESCRIPTION = Message("unit-repair.element.description")
|
||||
val UNIT_REPAIR_ELEMENT_CANNOT_REPAIR_NEW = Message("unit-repair.element.cannot-damage-new")
|
||||
val UNIT_REPAIR_ELEMENT_SAME_TYPE_NEW = Message("unit-repair.element.same-type-new")
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -15,4 +15,6 @@ object MsgWarning {
|
|||
val LOAD_LEGACY_SPIGOT = Message("load.legacy.spigot")
|
||||
val LOAD_LEGACY_SPIGOT_OLD = Message("load.legacy.spigot-old")
|
||||
|
||||
val DEPENDENCY_GENERIC_EXCEPTION = Message("config-ui.shared.no-permission")
|
||||
|
||||
}
|
||||
|
|
@ -89,4 +89,24 @@ command:
|
|||
start: "<yellow>Reloading config..."
|
||||
success: "<green>Config reloaded !"
|
||||
fail: "<red>Config was not able to be reloaded..."
|
||||
hard-fail: "<red>Hard fail, plugin disabled"
|
||||
hard-fail: "<red>Hard fail, plugin disabled"
|
||||
|
||||
config-ui:
|
||||
shared:
|
||||
no-permission: "<red>You do not have permission to edit the config"
|
||||
confirm-action:
|
||||
fail: "<red>Action could not be completed."
|
||||
element-list:
|
||||
instruction-new:
|
||||
1: "<yellow>Write the %type name you want to create in the chat."
|
||||
2: "<yellow>Or write <red>cancel <yellow>to go back to %type config menu"
|
||||
cancelled-new: "%type creation cancelled..."
|
||||
duplicated-new: "<red>Please enter a %type name that do not already exist..."
|
||||
unit-repair:
|
||||
element:
|
||||
title: "Select item to be repaired."
|
||||
description:
|
||||
1: "<gray>Click here with an item to set the item"
|
||||
2: "<gray>You like to be repaired by %name"
|
||||
cannot-damage-new: "<red>This item can't be damaged, so it can't be repaired."
|
||||
same-type-new: "<red>Item can't repair something of the same type."
|
||||
Loading…
Add table
Add a link
Reference in a new issue