1
mirror of https://github.com/CarmJos/ScriptItems synced 2024-09-19 21:35:50 +00:00

完善消息提示

This commit is contained in:
Carm Jos 2022-03-13 17:41:10 +08:00
parent 1a6f2071df
commit 5243b1f786
2 changed files with 14 additions and 13 deletions

View File

@ -52,7 +52,7 @@ public class ScriptItemsCommand implements CommandExecutor, TabCompleter {
ItemSettings settings = ScriptItemsAPI.getItemsManager().getItemSettings(args[1]);
if (settings == null) {
PluginMessages.NOT_EXISTS.send(sender);
PluginMessages.NOT_EXISTS.send(sender, args[1]);
return true;
}
@ -78,13 +78,13 @@ public class ScriptItemsCommand implements CommandExecutor, TabCompleter {
Player player = Bukkit.getPlayer(args[1]);
if (player == null) {
PluginMessages.NOT_ONLINE.send(sender);
PluginMessages.NOT_ONLINE.send(sender, args[1]);
return true;
}
ItemSettings settings = ScriptItemsAPI.getItemsManager().getItemSettings(args[2]);
if (settings == null) {
PluginMessages.NOT_EXISTS.send(sender);
PluginMessages.NOT_EXISTS.send(sender, args[2]);
return true;
}
@ -109,10 +109,10 @@ public class ScriptItemsCommand implements CommandExecutor, TabCompleter {
HashMap<Integer, ItemStack> remain = player.getInventory().addItem(item);
if (remain.isEmpty()) {
PluginMessages.GIVEN_ALL.send(sender, player, item.getAmount(), settings.getName());
PluginMessages.GIVEN_ALL.send(sender, player.getName(), item.getAmount(), settings.getName());
} else {
int remainAmount = remain.values().stream().mapToInt(ItemStack::getAmount).sum();
PluginMessages.GIVEN_SOME.send(sender, player, item.getAmount() - remainAmount, settings.getName(), remainAmount);
PluginMessages.GIVEN_SOME.send(sender, player.getName(), item.getAmount() - remainAmount, settings.getName(), remainAmount);
}
return true;
@ -141,7 +141,7 @@ public class ScriptItemsCommand implements CommandExecutor, TabCompleter {
break;
}
case 2: {
String aim = args[args.length - 1];
String aim = args[0];
if (aim.equalsIgnoreCase("give")) {
allCompletes = Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList());
} else if (aim.equalsIgnoreCase("apply")) {
@ -150,7 +150,7 @@ public class ScriptItemsCommand implements CommandExecutor, TabCompleter {
break;
}
case 3: {
String aim = args[args.length - 1];
String aim = args[0];
if (aim.equalsIgnoreCase("give")) {
allCompletes = new ArrayList<>(ScriptItemsAPI.getItemsManager().listItemSettings().keySet());
}

View File

@ -44,17 +44,18 @@ public class PluginMessages extends MessagesRoot {
.build();
public final static EasyMessageList GIVEN_ALL = EasyMessageList.builder()
.contents("&f您成功给予 &a%(player) &f了 &a%(amount) &f个 &a%(item) &f。")
.params("player", "amount", "item").build();
.contents("&f您成功给予 &a%(player) &f了 &a%(amount) &f个 &a%(name) &f。")
.params("player", "amount", "name").build();
public final static EasyMessageList GIVEN_SOME = EasyMessageList.builder().contents(
"&f您成功给予 &a%(player) &f了 &a%(amount) &f个 &a%(item) &f。",
"&f但由于目标玩家背包已满仍有 &a%(remain) &f个 &a%(item) &f未成功放入背包。"
).params("player", "amount", "item", "remain").build();
"&f您成功给予 &a%(player) &f了 &a%(amount) &f个 &a%(name) &f。",
"&f但由于目标玩家背包已满仍有 &a%(remain) &f个 &a%(name) &f未成功放入背包。"
).params("player", "amount", "name", "remain").build();
public final static EasyMessageList APPLIED = EasyMessageList.builder()
.contents("&f已成功为手上物品绑定脚本。").build();
.contents("&f成功为手上的 &2%(type) &f绑定了脚本 &a%(name) &f。")
.params("type", "name").build();
public static class Restrictions {