mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Part.2 Continue impl the multi-language system
This commit is contained in:
1 parent
1fd8dfcc89
commit
a218ffade7
16 files changed
+43
-49
No files matched your search
@@ -26,7 +26,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
@@ -87,7 +87,7 @@ public class CommandContainer {
|
||||
} else if (StringUtils.isNotEmpty(this.getDisablePlaceholder())) {
|
||||
return this.getDisablePlaceholder();
|
||||
} else {
|
||||
return MsgUtil.getMessage("command.feature-not-enabled", null);
|
||||
return QuickShop.getInstance().text().of(sender,"command.feature-not-enabled").forLocale();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,7 +292,8 @@ public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
.permission("quickshop.create.changeamount")
|
||||
.executor(new SubCommand_Size(plugin))
|
||||
.disabled(!plugin.isAllowStack())
|
||||
.disablePlaceholder(MsgUtil.getMessage("command.feature-not-enabled", null))
|
||||
// TODO: Check the sender
|
||||
.disablePlaceholder(plugin.text().of("command.feature-not-enabled").forLocale())
|
||||
.build());
|
||||
registerCmd(CommandContainer.builder()
|
||||
.prefix("item")
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SubCommand_About implements CommandHandler<CommandSender> {
|
||||
+ ChatColor.YELLOW
|
||||
+ ">> "
|
||||
+ ChatColor.GREEN
|
||||
+ MsgUtil.getMessage("updatenotify.label.lts", sender));
|
||||
+plugin.text().of(sender,"updatenotify.label.lts").forLocale());
|
||||
} else if (QuickShop.getInstance().getBuildInfo().getGitBranch().toUpperCase().contains("RELEASE")) {
|
||||
MsgUtil.sendDirectMessage(sender,
|
||||
ChatColor.AQUA
|
||||
@@ -58,7 +58,7 @@ public class SubCommand_About implements CommandHandler<CommandSender> {
|
||||
+ ChatColor.YELLOW
|
||||
+ ">> "
|
||||
+ ChatColor.GREEN
|
||||
+ MsgUtil.getMessage("updatenotify.label.stable", sender));
|
||||
+plugin.text().of(sender,"updatenotify.label.stable").forLocale());
|
||||
} else {
|
||||
MsgUtil.sendDirectMessage(sender,
|
||||
ChatColor.AQUA
|
||||
@@ -66,7 +66,7 @@ public class SubCommand_About implements CommandHandler<CommandSender> {
|
||||
+ ChatColor.YELLOW
|
||||
+ ">> "
|
||||
+ ChatColor.GREEN
|
||||
+ MsgUtil.getMessage("updatenotify.label.unstable", sender));
|
||||
+ plugin.text().of(sender,"updatenotify.label.unstable").forLocale());
|
||||
}
|
||||
MsgUtil.sendDirectMessage(sender,
|
||||
ChatColor.AQUA
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -53,7 +52,7 @@ public class SubCommand_Amount implements CommandHandler<Player> {
|
||||
@Override
|
||||
public List<String> onTabComplete(
|
||||
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
|
||||
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -160,14 +160,14 @@ public class SubCommand_Create implements CommandHandler<Player> {
|
||||
public List<String> onTabComplete(
|
||||
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length == 1) {
|
||||
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.price", sender));
|
||||
return Collections.singletonList(plugin.text().of(sender,"tabcomplete.price").forLocale());
|
||||
}
|
||||
if (sender.getInventory().getItemInMainHand().getType().isAir()) {
|
||||
if (cmdArg.length == 2) {
|
||||
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.item", sender));
|
||||
return Collections.singletonList(plugin.text().of(sender,"tabcomplete.item").forLocale());
|
||||
}
|
||||
if (cmdArg.length == 3) {
|
||||
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender));
|
||||
return Collections.singletonList(plugin.text().of(sender,"tabcomplete.amount").forLocale());
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -126,14 +126,14 @@ public class SubCommand_Find implements CommandHandler<Player> {
|
||||
PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
plugin.text().of(sender, "nearby-shop-this-way", String.valueOf(closest.getValue().intValue())).send();
|
||||
} else {
|
||||
StringBuilder stringBuilder = new StringBuilder(MsgUtil.getMessage("nearby-shop-header", sender, lookFor)).append("\n");
|
||||
StringBuilder stringBuilder = new StringBuilder(plugin.text().of(sender, "nearby-shop-header", lookFor).forLocale()).append("\n");
|
||||
for (Map.Entry<Shop, Double> shopDoubleEntry : sortedShops) {
|
||||
Shop shop = shopDoubleEntry.getKey();
|
||||
Location location = shop.getLocation();
|
||||
// "nearby-shop-entry": "&a- Info:{0} &aPrice:&b{1} &ax:&b{2} &ay:&b{3} &az:&b{4} &adistance: &b{5} &ablock(s)"
|
||||
stringBuilder.append(MsgUtil.getMessage("nearby-shop-entry", sender, shop.getSignText()[1], shop.getSignText()[3], location.getBlockX(), location.getBlockY(), location.getBlockZ(), shopDoubleEntry.getValue().intValue())).append("\n");
|
||||
stringBuilder.append(plugin.text().of(sender, "nearby-shop-entry", shop.getSignText()[1], shop.getSignText()[3], String.valueOf(location.getBlockX()), String.valueOf(location.getBlockY()), String.valueOf(location.getBlockZ()), String.valueOf(shopDoubleEntry.getValue().intValue())).forLocale()).append("\n");
|
||||
MsgUtil.sendDirectMessage(sender, stringBuilder.toString());
|
||||
}
|
||||
MsgUtil.sendDirectMessage(sender, stringBuilder.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandContainer;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -73,7 +72,7 @@ public class SubCommand_Help implements CommandHandler<CommandSender> {
|
||||
if (!passed) {
|
||||
continue;
|
||||
}
|
||||
String commandDesc = MsgUtil.getMessage("command.description." + container.getPrefix(), s);
|
||||
String commandDesc = plugin.text().of(s, "command.description." + container.getPrefix()).forLocale();
|
||||
if (container.getDescription() != null) {
|
||||
commandDesc = container.getDescription();
|
||||
if (commandDesc == null) {
|
||||
@@ -82,10 +81,10 @@ public class SubCommand_Help implements CommandHandler<CommandSender> {
|
||||
}
|
||||
if (container.isDisabled()) {
|
||||
if (QuickShop.getPermissionManager().hasPermission(s, "quickshop.showdisabled")) {
|
||||
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), container.getDisableText(s)));
|
||||
plugin.text().of(s, "command.format", commandLabel, container.getPrefix(), container.getDisableText(s));
|
||||
}
|
||||
} else {
|
||||
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), commandDesc));
|
||||
plugin.text().of(s, "command.format", commandLabel, container.getPrefix(), commandDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
@Override
|
||||
public List<String> onTabComplete(
|
||||
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.price", sender)) : Collections.emptyList();
|
||||
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.price").forLocale()) : Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -79,7 +78,7 @@ public class SubCommand_Refill implements CommandHandler<Player> {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
|
||||
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.PriceLimiter;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@@ -97,6 +96,6 @@ public class SubCommand_Size implements CommandHandler<Player> {
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
|
||||
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -71,14 +71,14 @@ public class SubCommand_Staff implements CommandHandler<Player> {
|
||||
if (staffs.isEmpty()) {
|
||||
MsgUtil.sendDirectMessage(sender,
|
||||
ChatColor.GREEN
|
||||
+ MsgUtil.getMessage("tableformat.left_begin", sender)
|
||||
+ plugin.text().of(sender,"tableformat.left_begin").forLocale()
|
||||
+ "Empty");
|
||||
return;
|
||||
}
|
||||
for (UUID uuid : staffs) {
|
||||
MsgUtil.sendDirectMessage(sender,
|
||||
ChatColor.GREEN
|
||||
+ MsgUtil.getMessage("tableformat.left_begin", sender)
|
||||
+ plugin.text().of(sender,"tableformat.left_begin").forLocale()
|
||||
+ Bukkit.getOfflinePlayer(uuid).getName());
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Info;
|
||||
import org.maxgamer.quickshop.shop.ShopAction;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -76,7 +75,7 @@ public class SubCommand_SuperCreate implements CommandHandler<Player> {
|
||||
@Override
|
||||
public List<String> onTabComplete(
|
||||
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
|
||||
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.event.*;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.PriceLimiter;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@@ -1033,15 +1032,15 @@ public class ContainerShop implements Shop {
|
||||
signs.add(sign);
|
||||
} else {
|
||||
String header = lines[0];
|
||||
String adminShopHeader = MsgUtil.getMessage("signs.header", null, MsgUtil.getMessage("admin-shop", null));
|
||||
String signHeaderUsername = MsgUtil.getMessage("signs.header", null, this.ownerName(true));
|
||||
String adminShopHeader = plugin.text().of("signs.header",plugin.text().of("admin-shop").forLocale()).forLocale();
|
||||
String signHeaderUsername = plugin.text().of("signs.header", this.ownerName(true)).forLocale();
|
||||
if (header.contains(adminShopHeader) || header.contains(signHeaderUsername)) {
|
||||
signs.add(sign);
|
||||
//TEXT SIGN
|
||||
//continue
|
||||
} else {
|
||||
adminShopHeader = MsgUtil.getMessage("signs.header", null, MsgUtil.getMessage("admin-shop", null), "");
|
||||
signHeaderUsername = MsgUtil.getMessage("signs.header", null, this.ownerName(true), "");
|
||||
adminShopHeader = plugin.text().of("signs.header", plugin.text().of("admin-shop").forLocale(), "").forLocale();
|
||||
signHeaderUsername = plugin.text().of("signs.header", this.ownerName(true), "").forLocale();
|
||||
adminShopHeader = ChatColor.stripColor(adminShopHeader).trim();
|
||||
signHeaderUsername = ChatColor.stripColor(signHeaderUsername).trim();
|
||||
if (header.contains(adminShopHeader) || header.contains(signHeaderUsername)) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.event.ShopInventoryPreviewEvent;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
import org.maxgamer.quickshop.util.holder.QuickShopPreviewGUIHolder;
|
||||
|
||||
@@ -113,7 +112,7 @@ public class InventoryPreview implements Listener {
|
||||
}
|
||||
final int size = 9;
|
||||
|
||||
inventory = plugin.getServer().createInventory(new QuickShopPreviewGUIHolder(), size, MsgUtil.getMessage("menu.preview", player));
|
||||
inventory = plugin.getServer().createInventory(new QuickShopPreviewGUIHolder(), size, plugin.text().of(player,"menu.preview").forLocale());
|
||||
for (int i = 0; i < size; i++) {
|
||||
inventory.setItem(i, itemStack);
|
||||
}
|
||||
|
||||
@@ -716,16 +716,16 @@ public class ShopManager implements Reloadable {
|
||||
Player player = plugin.getServer().getPlayer(buyer);
|
||||
|
||||
|
||||
String msg = MsgUtil.getMessage(buyer, "player-sold-to-your-store",
|
||||
String msg = plugin.text().of(buyer, "player-sold-to-your-store",
|
||||
player != null ? player.getName() : buyer.toString(),
|
||||
String.valueOf(amount),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
Util.getItemStackName(shop.getItem())).forLocale();
|
||||
|
||||
if (space == amount) {
|
||||
msg += "\n" + MsgUtil.getMessage(buyer, "shop-out-of-space",
|
||||
msg += "\n" + plugin.text().of(buyer, "shop-out-of-space",
|
||||
Integer.toString(shop.getLocation().getBlockX()),
|
||||
Integer.toString(shop.getLocation().getBlockY()),
|
||||
Integer.toString(shop.getLocation().getBlockZ()));
|
||||
Integer.toString(shop.getLocation().getBlockZ())).forLocale();
|
||||
}
|
||||
|
||||
MsgUtil.TransactionMessage transactionMessage = new MsgUtil.TransactionMessage(msg, Util.serialize(shop.getItem()), null);
|
||||
@@ -1080,26 +1080,26 @@ public class ShopManager implements Reloadable {
|
||||
// Notify the shop owner //TODO: move to a standalone method
|
||||
Player player = plugin.getServer().getPlayer(seller);
|
||||
if (plugin.getConfig().getBoolean("show-tax")) {
|
||||
msg = MsgUtil.getMessage(seller, "player-bought-from-your-store-tax",
|
||||
msg = plugin.text().of(seller, "player-bought-from-your-store-tax",
|
||||
player != null ? player.getName() : seller.toString(),
|
||||
Integer.toString(amount * shop.getItem().getAmount()),
|
||||
Util.getItemStackName(shop.getItem()),
|
||||
Double.toString(total),
|
||||
Util.format(CalculateUtil.multiply(taxModifier, total), shop));
|
||||
Util.format(CalculateUtil.multiply(taxModifier, total), shop)).forLocale();
|
||||
} else {
|
||||
msg = MsgUtil.getMessage(seller, "player-bought-from-your-store",
|
||||
msg = plugin.text().of(seller, "player-bought-from-your-store",
|
||||
player != null ? player.getName() : seller.toString(),
|
||||
Integer.toString(amount * shop.getItem().getAmount()),
|
||||
Util.getItemStackName(shop.getItem()),
|
||||
Double.toString(total));
|
||||
Double.toString(total)).forLocale();
|
||||
}
|
||||
// Transfers the item from A to B
|
||||
if (stock == amount) {
|
||||
msg += "\n" + MsgUtil.getMessage(seller, "shop-out-of-stock",
|
||||
msg += "\n" +plugin.text().of(seller, "shop-out-of-stock",
|
||||
Integer.toString(shop.getLocation().getBlockX()),
|
||||
Integer.toString(shop.getLocation().getBlockY()),
|
||||
Integer.toString(shop.getLocation().getBlockZ()),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
Util.getItemStackName(shop.getItem())).forLocale();
|
||||
}
|
||||
|
||||
MsgUtil.TransactionMessage transactionMessage = new MsgUtil.TransactionMessage(msg, Util.serialize(shop.getItem()), null);
|
||||
|
||||
@@ -44,9 +44,9 @@ public class ChatSheetPrinter {
|
||||
if (!text.isEmpty()) {
|
||||
MsgUtil.sendDirectMessage(p,
|
||||
ChatColor.DARK_PURPLE
|
||||
+ MsgUtil.getMessage("tableformat.left_half_line", p)
|
||||
+ QuickShop.getInstance().text().of(p,"tableformat.left_half_line").forLocale()
|
||||
+ text
|
||||
+ MsgUtil.getMessage("tableformat.right_half_line", p));
|
||||
+ QuickShop.getInstance().text().of(p,"tableformat.right_half_line").forLocale());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,18 +60,18 @@ public class ChatSheetPrinter {
|
||||
}
|
||||
|
||||
public void printFooter() {
|
||||
MsgUtil.sendDirectMessage(p, ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.full_line", p));
|
||||
MsgUtil.sendDirectMessage(p, ChatColor.DARK_PURPLE +QuickShop.getInstance().text().of(p,"tableformat.full_line").forLocale());
|
||||
}
|
||||
|
||||
public void printHeader() {
|
||||
MsgUtil.sendDirectMessage(p, ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.full_line", p));
|
||||
MsgUtil.sendDirectMessage(p, ChatColor.DARK_PURPLE + QuickShop.getInstance().text().of(p,"tableformat.full_line").forLocale());
|
||||
}
|
||||
|
||||
public void printLine(@NotNull String text) {
|
||||
String[] texts = text.split("\n");
|
||||
for (String str : texts) {
|
||||
if (!str.isEmpty()) {
|
||||
MsgUtil.sendDirectMessage(p, ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.left_begin", p) + str);
|
||||
MsgUtil.sendDirectMessage(p, ChatColor.DARK_PURPLE + QuickShop.getInstance().text().of(p,"tableformat.left_begin").forLocale() + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user