Skip to content

Commit a218ffa

Browse files
committed
Part.2 Continue impl the multi-language system
1 parent 1fd8dfc commit a218ffa

16 files changed

+43
-49
lines changed

src/main/java/org/maxgamer/quickshop/command/CommandContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.bukkit.command.CommandSender;
2727
import org.jetbrains.annotations.NotNull;
2828
import org.jetbrains.annotations.Nullable;
29-
import org.maxgamer.quickshop.util.MsgUtil;
29+
import org.maxgamer.quickshop.QuickShop;
3030

3131
import java.lang.reflect.Method;
3232
import java.util.List;
@@ -87,7 +87,7 @@ public void bakeExecutorType() {
8787
} else if (StringUtils.isNotEmpty(this.getDisablePlaceholder())) {
8888
return this.getDisablePlaceholder();
8989
} else {
90-
return MsgUtil.getMessage("command.feature-not-enabled", null);
90+
return QuickShop.getInstance().text().of(sender,"command.feature-not-enabled").forLocale();
9191
}
9292
}
9393
}

src/main/java/org/maxgamer/quickshop/command/CommandManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ public CommandManager(QuickShop plugin) {
292292
.permission("quickshop.create.changeamount")
293293
.executor(new SubCommand_Size(plugin))
294294
.disabled(!plugin.isAllowStack())
295-
.disablePlaceholder(MsgUtil.getMessage("command.feature-not-enabled", null))
295+
// TODO: Check the sender
296+
.disablePlaceholder(plugin.text().of("command.feature-not-enabled").forLocale())
296297
.build());
297298
registerCmd(CommandContainer.builder()
298299
.prefix("item")

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_About.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,23 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabe
5050
+ ChatColor.YELLOW
5151
+ ">> "
5252
+ ChatColor.GREEN
53-
+ MsgUtil.getMessage("updatenotify.label.lts", sender));
53+
+plugin.text().of(sender,"updatenotify.label.lts").forLocale());
5454
} else if (QuickShop.getInstance().getBuildInfo().getGitBranch().toUpperCase().contains("RELEASE")) {
5555
MsgUtil.sendDirectMessage(sender,
5656
ChatColor.AQUA
5757
+ "Release "
5858
+ ChatColor.YELLOW
5959
+ ">> "
6060
+ ChatColor.GREEN
61-
+ MsgUtil.getMessage("updatenotify.label.stable", sender));
61+
+plugin.text().of(sender,"updatenotify.label.stable").forLocale());
6262
} else {
6363
MsgUtil.sendDirectMessage(sender,
6464
ChatColor.AQUA
6565
+ "Release "
6666
+ ChatColor.YELLOW
6767
+ ">> "
6868
+ ChatColor.GREEN
69-
+ MsgUtil.getMessage("updatenotify.label.unstable", sender));
69+
+ plugin.text().of(sender,"updatenotify.label.unstable").forLocale());
7070
}
7171
MsgUtil.sendDirectMessage(sender,
7272
ChatColor.AQUA

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Amount.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.jetbrains.annotations.NotNull;
2525
import org.maxgamer.quickshop.QuickShop;
2626
import org.maxgamer.quickshop.command.CommandHandler;
27-
import org.maxgamer.quickshop.util.MsgUtil;
2827

2928
import java.util.Collections;
3029
import java.util.List;
@@ -53,7 +52,7 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
5352
@Override
5453
public List<String> onTabComplete(
5554
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
56-
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
55+
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
5756
}
5857

5958
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Create.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
160160
public List<String> onTabComplete(
161161
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
162162
if (cmdArg.length == 1) {
163-
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.price", sender));
163+
return Collections.singletonList(plugin.text().of(sender,"tabcomplete.price").forLocale());
164164
}
165165
if (sender.getInventory().getItemInMainHand().getType().isAir()) {
166166
if (cmdArg.length == 2) {
167-
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.item", sender));
167+
return Collections.singletonList(plugin.text().of(sender,"tabcomplete.item").forLocale());
168168
}
169169
if (cmdArg.length == 3) {
170-
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender));
170+
return Collections.singletonList(plugin.text().of(sender,"tabcomplete.amount").forLocale());
171171
}
172172
}
173173
return Collections.emptyList();

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Find.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
126126
PlayerTeleportEvent.TeleportCause.UNKNOWN);
127127
plugin.text().of(sender, "nearby-shop-this-way", String.valueOf(closest.getValue().intValue())).send();
128128
} else {
129-
StringBuilder stringBuilder = new StringBuilder(MsgUtil.getMessage("nearby-shop-header", sender, lookFor)).append("\n");
129+
StringBuilder stringBuilder = new StringBuilder(plugin.text().of(sender, "nearby-shop-header", lookFor).forLocale()).append("\n");
130130
for (Map.Entry<Shop, Double> shopDoubleEntry : sortedShops) {
131131
Shop shop = shopDoubleEntry.getKey();
132132
Location location = shop.getLocation();
133133
// "nearby-shop-entry": "&a- Info:{0} &aPrice:&b{1} &ax:&b{2} &ay:&b{3} &az:&b{4} &adistance: &b{5} &ablock(s)"
134-
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");
134+
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");
135+
MsgUtil.sendDirectMessage(sender, stringBuilder.toString());
135136
}
136-
MsgUtil.sendDirectMessage(sender, stringBuilder.toString());
137137
}
138138
}
139139
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Help.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.maxgamer.quickshop.QuickShop;
2626
import org.maxgamer.quickshop.command.CommandContainer;
2727
import org.maxgamer.quickshop.command.CommandHandler;
28-
import org.maxgamer.quickshop.util.MsgUtil;
2928

3029
import java.util.List;
3130

@@ -73,7 +72,7 @@ private void sendHelp(@NotNull CommandSender s, @NotNull String commandLabel) {
7372
if (!passed) {
7473
continue;
7574
}
76-
String commandDesc = MsgUtil.getMessage("command.description." + container.getPrefix(), s);
75+
String commandDesc = plugin.text().of(s, "command.description." + container.getPrefix()).forLocale();
7776
if (container.getDescription() != null) {
7877
commandDesc = container.getDescription();
7978
if (commandDesc == null) {
@@ -82,10 +81,10 @@ private void sendHelp(@NotNull CommandSender s, @NotNull String commandLabel) {
8281
}
8382
if (container.isDisabled()) {
8483
if (QuickShop.getPermissionManager().hasPermission(s, "quickshop.showdisabled")) {
85-
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), container.getDisableText(s)));
84+
plugin.text().of(s, "command.format", commandLabel, container.getPrefix(), container.getDisableText(s));
8685
}
8786
} else {
88-
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), commandDesc));
87+
plugin.text().of(s, "command.format", commandLabel, container.getPrefix(), commandDesc);
8988
}
9089
}
9190
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Price.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ else if (cs.getPrice() > nextTo.getPrice()) {
184184
@Override
185185
public List<String> onTabComplete(
186186
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
187-
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.price", sender)) : Collections.emptyList();
187+
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.price").forLocale()) : Collections.emptyList();
188188
}
189189

190190
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Refill.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.maxgamer.quickshop.QuickShop;
2929
import org.maxgamer.quickshop.command.CommandHandler;
3030
import org.maxgamer.quickshop.shop.Shop;
31-
import org.maxgamer.quickshop.util.MsgUtil;
3231

3332
import java.util.Collections;
3433
import java.util.List;
@@ -79,7 +78,7 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
7978
@NotNull
8079
@Override
8180
public List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
82-
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
81+
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
8382
}
8483

8584
}

src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Size.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.maxgamer.quickshop.QuickShop;
3030
import org.maxgamer.quickshop.command.CommandHandler;
3131
import org.maxgamer.quickshop.shop.Shop;
32-
import org.maxgamer.quickshop.util.MsgUtil;
3332
import org.maxgamer.quickshop.util.PriceLimiter;
3433
import org.maxgamer.quickshop.util.Util;
3534

@@ -97,6 +96,6 @@ public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @Not
9796

9897
@Override
9998
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
100-
return cmdArg.length == 1 ? Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender)) : Collections.emptyList();
99+
return cmdArg.length == 1 ? Collections.singletonList(QuickShop.getInstance().text().of(sender,"tabcomplete.amount").forLocale()) : Collections.emptyList();
101100
}
102101
}

0 commit comments

Comments
 (0)