diff --git a/README.md b/README.md
index c19ffd5..f5ba0ee 100644
--- a/README.md
+++ b/README.md
@@ -207,9 +207,9 @@
详见源文件。
-### 消息配置文件 ([messages.yml](src/main/resources/messages.yml))
+### 消息配置文件 ([messages.yml](src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java))
-详见源文件。
+详见代码文件中默认值,相关文件将在首次运行时创建。
### 仓库配置文件 ([depositories/<仓库ID>.yml](.examples/depositories/full-example.yml))
diff --git a/pom.xml b/pom.xml
index d3b7983..fd809f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,13 +9,13 @@
11
UTF-8
UTF-8
- 1.2.0
+ 1.3.0
cc.carm.plugin
ultradepository
jar
- 1.2.3
+ 1.2.4
UltraDepository
超级仓库插件,支持设定不同物品的存储仓库。
diff --git a/src/main/java/cc/carm/plugin/ultradepository/command/DepositoryCommand.java b/src/main/java/cc/carm/plugin/ultradepository/command/DepositoryCommand.java
index 0fcac61..ee5467a 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/command/DepositoryCommand.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/command/DepositoryCommand.java
@@ -29,457 +29,457 @@ import java.util.stream.Collectors;
public class DepositoryCommand implements CommandExecutor, TabCompleter {
- private boolean helpConsole(CommandSender sender) {
- PluginMessages.HELP_CONSOLE.send(sender);
- return true;
- }
+ private boolean helpConsole(CommandSender sender) {
+ PluginMessages.Usages.CONSOLE.send(sender);
+ return true;
+ }
- private boolean helpPlayer(Player player) {
- PluginMessages.HELP_PLAYER.send(player);
- return true;
- }
+ private boolean helpPlayer(Player player) {
+ PluginMessages.Usages.PLAYER.send(player);
+ return true;
+ }
- @Override
- public boolean onCommand(
- @NotNull CommandSender sender, @NotNull Command command,
- @NotNull String alias, @NotNull String[] args) {
- if (sender instanceof Player) {
- Player player = (Player) sender;
- if (args.length < 1) return helpPlayer(player);
- switch (args[0].toLowerCase()) {
- case "open": {
- if (!player.hasPermission("UltraDepository.use")) {
- return false;
- }
- if (args.length < 2) return helpPlayer(player);
- Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
- if (depository == null) {
- PluginMessages.NO_DEPOSITORY.send(player);
- return true;
- }
- DepositoryGUI.open((Player) sender, depository);
- return true;
- }
- case "sell": {
- if (!player.hasPermission("UltraDepository.Command.Sell")) {
- return false;
- }
- if (!UltraDepository.getEconomyManager().isInitialized()) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_ECONOMY.send(player);
- return true;
- }
- if (args.length < 4) return helpPlayer(player);
- Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
- if (depository == null) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_DEPOSITORY.send(player);
- return true;
- }
+ @Override
+ public boolean onCommand(
+ @NotNull CommandSender sender, @NotNull Command command,
+ @NotNull String alias, @NotNull String[] args) {
+ if (sender instanceof Player) {
+ Player player = (Player) sender;
+ if (args.length < 1) return helpPlayer(player);
+ switch (args[0].toLowerCase()) {
+ case "open": {
+ if (!player.hasPermission("UltraDepository.use")) {
+ return false;
+ }
+ if (args.length < 2) return helpPlayer(player);
+ Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
+ if (depository == null) {
+ PluginMessages.NO_DEPOSITORY.send(player);
+ return true;
+ }
+ DepositoryGUI.open((Player) sender, depository);
+ return true;
+ }
+ case "sell": {
+ if (!player.hasPermission("UltraDepository.Command.Sell")) {
+ return false;
+ }
+ if (!UltraDepository.getEconomyManager().isInitialized()) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_ECONOMY.send(player);
+ return true;
+ }
+ if (args.length < 4) return helpPlayer(player);
+ Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
+ if (depository == null) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_DEPOSITORY.send(player);
+ return true;
+ }
- DepositoryItem item = depository.getItems().get(args[2]);
- if (item == null) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_ITEM.send(player);
- return true;
- }
+ DepositoryItem item = depository.getItems().get(args[2]);
+ if (item == null) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_ITEM.send(player);
+ return true;
+ }
- int amount = -1;
- try {
- amount = Integer.parseInt(args[3]);
- } catch (Exception ignore) {
- }
- if (amount <= 0) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.WRONG_NUMBER.send(player);
- return true;
- }
+ int amount = -1;
+ try {
+ amount = Integer.parseInt(args[3]);
+ } catch (Exception ignore) {
+ }
+ if (amount <= 0) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.WRONG_NUMBER.send(player);
+ return true;
+ }
- UserData userData = UltraDepository.getUserManager().getData(player);
- DepositoryItemData itemData = userData.getItemData(item);
- int limit = item.getLimit();
- int sold = itemData.getSold();
- int currentAmount = itemData.getAmount();
+ UserData userData = UltraDepository.getUserManager().getData(player);
+ DepositoryItemData itemData = userData.getItemData(item);
+ int limit = item.getLimit();
+ int sold = itemData.getSold();
+ int currentAmount = itemData.getAmount();
- if (currentAmount < amount) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_ENOUGH_ITEM.send(player);
- return true;
- }
+ if (currentAmount < amount) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_ENOUGH_ITEM.send(player);
+ return true;
+ }
- if (amount > (limit - sold)) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{(limit - sold), limit});
- return true;
- }
+ if (amount > (limit - sold)) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{(limit - sold), limit});
+ return true;
+ }
- UltraDepository.getEconomyManager().sellItem(player, userData, item, amount);
- return true;
- }
- case "sellall": {
- if (!player.hasPermission("UltraDepository.Command.SellAll")) {
- return false;
- }
- if (!UltraDepository.getEconomyManager().isInitialized()) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_ECONOMY.send(player);
- return true;
- }
- UserData userData = UltraDepository.getUserManager().getData(player);
+ UltraDepository.getEconomyManager().sellItem(player, userData, item, amount);
+ return true;
+ }
+ case "sellall": {
+ if (!player.hasPermission("UltraDepository.Command.SellAll")) {
+ return false;
+ }
+ if (!UltraDepository.getEconomyManager().isInitialized()) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_ECONOMY.send(player);
+ return true;
+ }
+ UserData userData = UltraDepository.getUserManager().getData(player);
- String depositoryID = args.length >= 2 ? args[1] : null;
- String itemID = args.length >= 3 ? args[2] : null;
+ String depositoryID = args.length >= 2 ? args[1] : null;
+ String itemID = args.length >= 3 ? args[2] : null;
- Depository depository = null;
- if (depositoryID != null) {
- depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
- if (depository == null) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_DEPOSITORY.send(player);
- return true;
- }
- }
+ Depository depository = null;
+ if (depositoryID != null) {
+ depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
+ if (depository == null) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_DEPOSITORY.send(player);
+ return true;
+ }
+ }
- if (depository == null) {
- UltraDepository.getEconomyManager().sellAllItem(player, userData);
- sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
- return true;
- }
+ if (depository == null) {
+ UltraDepository.getEconomyManager().sellAllItem(player, userData);
+ sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
+ return true;
+ }
- DepositoryItem item = null;
- if (itemID != null) {
- item = depository.getItems().get(itemID);
- if (item == null) {
- PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.NO_ITEM.send(player);
- return true;
- }
- }
+ DepositoryItem item = null;
+ if (itemID != null) {
+ item = depository.getItems().get(itemID);
+ if (item == null) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
+ PluginMessages.NO_ITEM.send(player);
+ return true;
+ }
+ }
- if (item == null) {
- UltraDepository.getEconomyManager().sellAllItem(player, userData, depository);
- return true;
- }
+ if (item == null) {
+ UltraDepository.getEconomyManager().sellAllItem(player, userData, depository);
+ return true;
+ }
- UltraDepository.getEconomyManager().sellAllItem(player, userData, item);
- return true;
- }
- default:
- return helpPlayer(player);
- }
- } else {
- if (args.length < 1) return helpConsole(sender);
- switch (args[0].toLowerCase()) {
- case "info": {
- if (args.length < 2) return helpConsole(sender);
- Player player = Bukkit.getPlayer(args[1]);
- if (player == null) {
- sender.sendMessage("Player does not exist.");
- return false;
- }
- UserData userData = UltraDepository.getUserManager().getData(player);
+ UltraDepository.getEconomyManager().sellAllItem(player, userData, item);
+ return true;
+ }
+ default:
+ return helpPlayer(player);
+ }
+ } else {
+ if (args.length < 1) return helpConsole(sender);
+ switch (args[0].toLowerCase()) {
+ case "info": {
+ if (args.length < 2) return helpConsole(sender);
+ Player player = Bukkit.getPlayer(args[1]);
+ if (player == null) {
+ sender.sendMessage("Player does not exist.");
+ return false;
+ }
+ UserData userData = UltraDepository.getUserManager().getData(player);
- String depositoryID = args.length >= 3 ? args[2] : null;
- String itemID = args.length >= 4 ? args[3] : null;
+ String depositoryID = args.length >= 3 ? args[2] : null;
+ String itemID = args.length >= 4 ? args[3] : null;
- Depository depository = null;
- if (depositoryID != null) {
- depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
- if (depository == null) {
- PluginMessages.NO_DEPOSITORY.send(player);
- return true;
- }
- }
- sender.sendMessage(ColorParser.parse("&fInfo &6" + player.getName() + " &f:"));
- if (depository == null) {
- userData.getDepositories().values().forEach(depositoryData -> {
- MessageUtils.send(sender, "&8# &e" + depositoryData.getIdentifier());
- depositoryData.getContents().values().forEach(itemData -> {
- String typeID = itemData.getSource().getTypeID();
- int amount = itemData.getAmount();
- int sold = itemData.getSold();
- MessageUtils.send(sender, "&8- &f" + typeID + " &7[&f " + amount + "&8|&f " + sold + "&7]");
- });
- });
- return true;
- }
+ Depository depository = null;
+ if (depositoryID != null) {
+ depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
+ if (depository == null) {
+ PluginMessages.NO_DEPOSITORY.send(player);
+ return true;
+ }
+ }
+ sender.sendMessage(ColorParser.parse("&fInfo &6" + player.getName() + " &f:"));
+ if (depository == null) {
+ userData.getDepositories().values().forEach(depositoryData -> {
+ MessageUtils.send(sender, "&8# &e" + depositoryData.getIdentifier());
+ depositoryData.getContents().values().forEach(itemData -> {
+ String typeID = itemData.getSource().getTypeID();
+ int amount = itemData.getAmount();
+ int sold = itemData.getSold();
+ MessageUtils.send(sender, "&8- &f" + typeID + " &7[&f " + amount + "&8|&f " + sold + "&7]");
+ });
+ });
+ return true;
+ }
- DepositoryItem item = null;
- if (itemID != null) {
- item = depository.getItems().get(itemID);
- if (item == null) {
- PluginMessages.NO_ITEM.send(player);
- return true;
- }
- }
+ DepositoryItem item = null;
+ if (itemID != null) {
+ item = depository.getItems().get(itemID);
+ if (item == null) {
+ PluginMessages.NO_ITEM.send(player);
+ return true;
+ }
+ }
- if (item == null) {
- DepositoryData depositoryData = userData.getDepositoryData(depository);
- MessageUtils.send(sender, "&8# &e" + depositoryData.getIdentifier());
- depositoryData.getContents().values().forEach(itemData -> {
- String typeID = itemData.getSource().getTypeID();
- int amount = itemData.getAmount();
- int sold = itemData.getSold();
- MessageUtils.send(sender, "&8- &f" + typeID + " &7[&f " + amount + "&8|&f " + sold + "&7]");
- });
- return true;
- }
+ if (item == null) {
+ DepositoryData depositoryData = userData.getDepositoryData(depository);
+ MessageUtils.send(sender, "&8# &e" + depositoryData.getIdentifier());
+ depositoryData.getContents().values().forEach(itemData -> {
+ String typeID = itemData.getSource().getTypeID();
+ int amount = itemData.getAmount();
+ int sold = itemData.getSold();
+ MessageUtils.send(sender, "&8- &f" + typeID + " &7[&f " + amount + "&8|&f " + sold + "&7]");
+ });
+ return true;
+ }
- DepositoryItemData itemData = userData.getItemData(item);
- String typeID = itemData.getSource().getTypeID();
- int amount = itemData.getAmount();
- int sold = itemData.getSold();
+ DepositoryItemData itemData = userData.getItemData(item);
+ String typeID = itemData.getSource().getTypeID();
+ int amount = itemData.getAmount();
+ int sold = itemData.getSold();
- MessageUtils.send(sender, "&8# &e" + depository.getIdentifier());
- MessageUtils.send(sender, "&8- &f" + typeID + " &7[&f " + amount + "&8|&f " + sold + "&7]");
- return true;
- }
- case "add": {
- if (args.length < 5) return true;
- Player player = Bukkit.getPlayer(args[1]);
- if (player == null) {
- sender.sendMessage("Player does not exist.");
- return false;
- }
+ MessageUtils.send(sender, "&8# &e" + depository.getIdentifier());
+ MessageUtils.send(sender, "&8- &f" + typeID + " &7[&f " + amount + "&8|&f " + sold + "&7]");
+ return true;
+ }
+ case "add": {
+ if (args.length < 5) return true;
+ Player player = Bukkit.getPlayer(args[1]);
+ if (player == null) {
+ sender.sendMessage("Player does not exist.");
+ return false;
+ }
- Depository depository = UltraDepository.getDepositoryManager().getDepository(args[2]);
- if (depository == null) {
- PluginMessages.NO_DEPOSITORY.send(sender);
- return true;
- }
+ Depository depository = UltraDepository.getDepositoryManager().getDepository(args[2]);
+ if (depository == null) {
+ PluginMessages.NO_DEPOSITORY.send(sender);
+ return true;
+ }
- DepositoryItem item = depository.getItems().get(args[3]);
- if (item == null) {
- PluginMessages.NO_ITEM.send(sender);
- return true;
- }
+ DepositoryItem item = depository.getItems().get(args[3]);
+ if (item == null) {
+ PluginMessages.NO_ITEM.send(sender);
+ return true;
+ }
- int amount = -1;
- try {
- amount = Integer.parseInt(args[4]);
- } catch (Exception ignore) {
- }
- if (amount <= 0) {
- PluginMessages.WRONG_NUMBER.send(sender);
- return true;
- }
+ int amount = -1;
+ try {
+ amount = Integer.parseInt(args[4]);
+ } catch (Exception ignore) {
+ }
+ if (amount <= 0) {
+ PluginMessages.WRONG_NUMBER.send(sender);
+ return true;
+ }
- Integer after = UltraDepository.getUserManager().getData(player)
- .addItemAmount(depository.getIdentifier(), item.getTypeID(), amount);
+ Integer after = UltraDepository.getUserManager().getData(player)
+ .addItemAmount(depository.getIdentifier(), item.getTypeID(), amount);
- if (after != null) {
- sender.sendMessage("Success! Now " + player.getName() + "'s " + item.getTypeID() + " is " + after + " .");
- } else {
- sender.sendMessage("Failed!");
- }
+ if (after != null) {
+ sender.sendMessage("Success! Now " + player.getName() + "'s " + item.getTypeID() + " is " + after + " .");
+ } else {
+ sender.sendMessage("Failed!");
+ }
- return true;
- }
- case "remove": {
- if (args.length < 4) return true;
- Player player = Bukkit.getPlayer(args[1]);
- if (player == null) {
- sender.sendMessage("Player does not exist.");
- return false;
- }
+ return true;
+ }
+ case "remove": {
+ if (args.length < 4) return true;
+ Player player = Bukkit.getPlayer(args[1]);
+ if (player == null) {
+ sender.sendMessage("Player does not exist.");
+ return false;
+ }
- Depository depository = UltraDepository.getDepositoryManager().getDepository(args[2]);
- if (depository == null) {
- PluginMessages.NO_DEPOSITORY.send(sender);
- return true;
- }
+ Depository depository = UltraDepository.getDepositoryManager().getDepository(args[2]);
+ if (depository == null) {
+ PluginMessages.NO_DEPOSITORY.send(sender);
+ return true;
+ }
- DepositoryItem item = depository.getItems().get(args[3]);
- if (item == null) {
- PluginMessages.NO_ITEM.send(sender);
- return true;
- }
+ DepositoryItem item = depository.getItems().get(args[3]);
+ if (item == null) {
+ PluginMessages.NO_ITEM.send(sender);
+ return true;
+ }
- Integer amount = null;
- try {
- amount = Integer.parseInt(args[4]);
- } catch (Exception ignore) {
- }
- if (amount != null && amount < 0) {
- PluginMessages.WRONG_NUMBER.send(sender);
- return true;
- }
+ Integer amount = null;
+ try {
+ amount = Integer.parseInt(args[4]);
+ } catch (Exception ignore) {
+ }
+ if (amount != null && amount < 0) {
+ PluginMessages.WRONG_NUMBER.send(sender);
+ return true;
+ }
- UserData userData = UltraDepository.getUserManager().getData(player);
- if (amount != null) {
- Integer after = userData.removeItemAmount(depository.getIdentifier(), item.getTypeID(), amount);
- if (after != null) {
- sender.sendMessage("Success! Now " + player.getName() + "'s " + item.getTypeID() + " is " + after + " .");
- } else {
- sender.sendMessage("Failed!");
- }
- } else {
- userData.setItemAmount(depository.getIdentifier(), item.getTypeID(), 0);
- sender.sendMessage("Success! Cleared " + player.getName() + "'s " + item.getTypeID() + " .");
- }
- return true;
- }
- case "sell": {
- if (args.length < 2) return true;
- Player player = Bukkit.getPlayer(args[1]);
- if (player == null) {
- sender.sendMessage("Player does not exist.");
- return false;
- }
- String depositoryID = args.length >= 3 ? args[2] : null;
- String itemID = args.length >= 4 ? args[3] : null;
+ UserData userData = UltraDepository.getUserManager().getData(player);
+ if (amount != null) {
+ Integer after = userData.removeItemAmount(depository.getIdentifier(), item.getTypeID(), amount);
+ if (after != null) {
+ sender.sendMessage("Success! Now " + player.getName() + "'s " + item.getTypeID() + " is " + after + " .");
+ } else {
+ sender.sendMessage("Failed!");
+ }
+ } else {
+ userData.setItemAmount(depository.getIdentifier(), item.getTypeID(), 0);
+ sender.sendMessage("Success! Cleared " + player.getName() + "'s " + item.getTypeID() + " .");
+ }
+ return true;
+ }
+ case "sell": {
+ if (args.length < 2) return true;
+ Player player = Bukkit.getPlayer(args[1]);
+ if (player == null) {
+ sender.sendMessage("Player does not exist.");
+ return false;
+ }
+ String depositoryID = args.length >= 3 ? args[2] : null;
+ String itemID = args.length >= 4 ? args[3] : null;
- Depository depository = null;
- if (depositoryID != null) {
- depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
- if (depository == null) {
- PluginMessages.NO_DEPOSITORY.send(sender);
- return true;
- }
- }
+ Depository depository = null;
+ if (depositoryID != null) {
+ depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
+ if (depository == null) {
+ PluginMessages.NO_DEPOSITORY.send(sender);
+ return true;
+ }
+ }
- UserData userData = UltraDepository.getUserManager().getData(player);
+ UserData userData = UltraDepository.getUserManager().getData(player);
- if (depository == null) {
- UltraDepository.getEconomyManager().sellAllItem(player, userData);
- sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
- return true;
- }
+ if (depository == null) {
+ UltraDepository.getEconomyManager().sellAllItem(player, userData);
+ sender.sendMessage("Success! " + player.getName() + "'s items had been sold.");
+ return true;
+ }
- DepositoryItem item = null;
- if (itemID != null) {
- item = depository.getItems().get(itemID);
- if (item == null) {
- PluginMessages.NO_ITEM.send(player);
- return true;
- }
- }
- if (item == null) {
- UltraDepository.getEconomyManager().sellAllItem(player, userData, depository);
- sender.sendMessage("Success! " + player.getName() + "'s " + depository.getIdentifier() + " had been sold.");
- return true;
- }
+ DepositoryItem item = null;
+ if (itemID != null) {
+ item = depository.getItems().get(itemID);
+ if (item == null) {
+ PluginMessages.NO_ITEM.send(player);
+ return true;
+ }
+ }
+ if (item == null) {
+ UltraDepository.getEconomyManager().sellAllItem(player, userData, depository);
+ sender.sendMessage("Success! " + player.getName() + "'s " + depository.getIdentifier() + " had been sold.");
+ return true;
+ }
- Integer amount = null;
- if (args.length >= 5) {
- try {
- amount = Integer.parseInt(args[4]);
- } catch (Exception ignore) {
- }
- }
+ Integer amount = null;
+ if (args.length >= 5) {
+ try {
+ amount = Integer.parseInt(args[4]);
+ } catch (Exception ignore) {
+ }
+ }
- if (amount != null && amount < 0) {
- PluginMessages.WRONG_NUMBER.send(sender);
- return true;
- }
+ if (amount != null && amount < 0) {
+ PluginMessages.WRONG_NUMBER.send(sender);
+ return true;
+ }
- if (amount == null) {
- UltraDepository.getEconomyManager().sellAllItem(player, userData, item);
- sender.sendMessage("Success! " + player.getName() + "'s " + item.getTypeID() + " had been sold.");
- return true;
- }
+ if (amount == null) {
+ UltraDepository.getEconomyManager().sellAllItem(player, userData, item);
+ sender.sendMessage("Success! " + player.getName() + "'s " + item.getTypeID() + " had been sold.");
+ return true;
+ }
- DepositoryItemData itemData = userData.getItemData(item);
+ DepositoryItemData itemData = userData.getItemData(item);
- int limit = item.getLimit();
- int sold = itemData.getSold();
- int currentAmount = itemData.getAmount();
+ int limit = item.getLimit();
+ int sold = itemData.getSold();
+ int currentAmount = itemData.getAmount();
- if (currentAmount < amount) {
- PluginMessages.NO_ENOUGH_ITEM.send(sender);
- return true;
- }
+ if (currentAmount < amount) {
+ PluginMessages.NO_ENOUGH_ITEM.send(sender);
+ return true;
+ }
- if (currentAmount > (limit - sold)) {
- PluginMessages.ITEM_SOLD_LIMIT.send(sender, new Object[]{(limit - sold), limit});
- return true;
- }
+ if (currentAmount > (limit - sold)) {
+ PluginMessages.ITEM_SOLD_LIMIT.send(sender, new Object[]{(limit - sold), limit});
+ return true;
+ }
- UltraDepository.getEconomyManager().sellItem(player, userData, item, amount);
- sender.sendMessage("Success! " + player.getName() + "'s " + amount + " " + item.getTypeID() + " had been sold.");
- return true;
- }
- default:
- return helpConsole(sender);
- }
- }
- }
+ UltraDepository.getEconomyManager().sellItem(player, userData, item, amount);
+ sender.sendMessage("Success! " + player.getName() + "'s " + amount + " " + item.getTypeID() + " had been sold.");
+ return true;
+ }
+ default:
+ return helpConsole(sender);
+ }
+ }
+ }
- @Nullable
- @Override
- public List onTabComplete(
- @NotNull CommandSender sender, @NotNull Command command,
- @NotNull String alias, @NotNull String[] args) {
- List allCompletes = new ArrayList<>();
- if (sender instanceof Player) {
- // 玩家指令部分
- Player player = (Player) sender;
- if (player.hasPermission("UltraDepository.use")) {
- switch (args.length) {
- case 1: {
- allCompletes.add("open");
- if (player.hasPermission("UltraDepository.Command.Sell")) allCompletes.add("sell");
- if (player.hasPermission("UltraDepository.Command.SellAll")) allCompletes.add("sellAll");
- break;
- }
- case 2: {
- String aim = args[0];
- if (aim.equalsIgnoreCase("open")
- || (aim.equalsIgnoreCase("sell")
- && player.hasPermission("UltraDepository.Command.Sell"))
- || (aim.equalsIgnoreCase("sellAll")
- && player.hasPermission("UltraDepository.Command.SellAll"))) {
- allCompletes.addAll(UltraDepository.getDepositoryManager().getDepositories().keySet());
- }
- break;
- }
- case 3: {
- String aim = args[0];
- String depositoryID = args[1];
- if ((aim.equalsIgnoreCase("sell")
- && player.hasPermission("UltraDepository.Command.Sell"))
- || (aim.equalsIgnoreCase("sellAll")
- && player.hasPermission("UltraDepository.Command.SellAll"))) {
- Depository depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
- if (depository != null) {
- allCompletes.addAll(depository.getItems().keySet());
- }
- }
- break;
- }
- }
- }
- } else {
- //后台指令部分
- switch (args.length) {
- case 1: {
- allCompletes.add("info");
- allCompletes.add("add");
- allCompletes.add("remove");
- allCompletes.add("sell");
- break;
- }
- case 2: {
- allCompletes = Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList());
- break;
- }
- case 3: {
- allCompletes.addAll(UltraDepository.getDepositoryManager().getDepositories().keySet());
- break;
- }
- case 4: {
- Depository depository = UltraDepository.getDepositoryManager().getDepository(args[2]);
- if (depository != null) {
- allCompletes.addAll(depository.getItems().keySet());
- }
- break;
- }
- }
- }
+ @Nullable
+ @Override
+ public List onTabComplete(
+ @NotNull CommandSender sender, @NotNull Command command,
+ @NotNull String alias, @NotNull String[] args) {
+ List allCompletes = new ArrayList<>();
+ if (sender instanceof Player) {
+ // 玩家指令部分
+ Player player = (Player) sender;
+ if (player.hasPermission("UltraDepository.use")) {
+ switch (args.length) {
+ case 1: {
+ allCompletes.add("open");
+ if (player.hasPermission("UltraDepository.Command.Sell")) allCompletes.add("sell");
+ if (player.hasPermission("UltraDepository.Command.SellAll")) allCompletes.add("sellAll");
+ break;
+ }
+ case 2: {
+ String aim = args[0];
+ if (aim.equalsIgnoreCase("open")
+ || (aim.equalsIgnoreCase("sell")
+ && player.hasPermission("UltraDepository.Command.Sell"))
+ || (aim.equalsIgnoreCase("sellAll")
+ && player.hasPermission("UltraDepository.Command.SellAll"))) {
+ allCompletes.addAll(UltraDepository.getDepositoryManager().getDepositories().keySet());
+ }
+ break;
+ }
+ case 3: {
+ String aim = args[0];
+ String depositoryID = args[1];
+ if ((aim.equalsIgnoreCase("sell")
+ && player.hasPermission("UltraDepository.Command.Sell"))
+ || (aim.equalsIgnoreCase("sellAll")
+ && player.hasPermission("UltraDepository.Command.SellAll"))) {
+ Depository depository = UltraDepository.getDepositoryManager().getDepository(depositoryID);
+ if (depository != null) {
+ allCompletes.addAll(depository.getItems().keySet());
+ }
+ }
+ break;
+ }
+ }
+ }
+ } else {
+ //后台指令部分
+ switch (args.length) {
+ case 1: {
+ allCompletes.add("info");
+ allCompletes.add("add");
+ allCompletes.add("remove");
+ allCompletes.add("sell");
+ break;
+ }
+ case 2: {
+ allCompletes = Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList());
+ break;
+ }
+ case 3: {
+ allCompletes.addAll(UltraDepository.getDepositoryManager().getDepositories().keySet());
+ break;
+ }
+ case 4: {
+ Depository depository = UltraDepository.getDepositoryManager().getDepository(args[2]);
+ if (depository != null) {
+ allCompletes.addAll(depository.getItems().keySet());
+ }
+ break;
+ }
+ }
+ }
- return allCompletes.stream()
- .filter(s -> StringUtil.startsWithIgnoreCase(s, args[args.length - 1]))
- .limit(10).collect(Collectors.toList());
- }
+ return allCompletes.stream()
+ .filter(s -> StringUtil.startsWithIgnoreCase(s, args[args.length - 1]))
+ .limit(10).collect(Collectors.toList());
+ }
}
diff --git a/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java b/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java
index 137c81f..73d1b42 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java
@@ -1,46 +1,88 @@
package cc.carm.plugin.ultradepository.configuration;
-import cc.carm.lib.easyplugin.configuration.message.ConfigMessageList;
+import cc.carm.lib.easyplugin.configuration.language.EasyMessageList;
+import cc.carm.lib.easyplugin.configuration.language.MessagesRoot;
+import cc.carm.lib.easyplugin.configuration.language.MessagesSection;
-public class PluginMessages {
+public class PluginMessages extends MessagesRoot {
- public static final ConfigMessageList HELP_CONSOLE = new ConfigMessageList("help.console");
+ @MessagesSection("help")
+ public static class Usages {
- public static final ConfigMessageList HELP_PLAYER = new ConfigMessageList("help.player");
+ public static final EasyMessageList CONSOLE = new EasyMessageList(
+ "&6&l超级仓库 &f后台指令帮助",
+ "&8#&f info &6<玩家> &e[仓库ID] &e[物品ID]",
+ "&8-&7 得到玩家的相关物品信息。",
+ "&8#&f add &6<玩家> &6<仓库ID> &6<物品ID> &6<数量>",
+ "&8-&7 为玩家添加对应仓库中对于物品的数量。",
+ "&8#&f remove &6<玩家> &6<仓库ID> &6<物品ID> &e[数量]",
+ "&8-&7 为玩家减少对应仓库中对于物品的数量。",
+ "&8-&7 若不填写数量,则清空对应仓库的对应物品。",
+ "&8#&f sell &6<玩家> &e[仓库ID] &e[物品ID] &e[数量]",
+ "&8-&7 为玩家售出相关物品。",
+ "&8-&7 若不填写数量,则售出所有对应仓库的对应物品。",
+ "&8-&7 若不填写物品,则售出对应仓库内所有物品。",
+ "&8-&7 若不填写仓库,则售出所有仓库内所有物品。",
+ "&8-&7 该指令受到玩家每日售出数量的限制。"
+ );
+
+ public static final EasyMessageList PLAYER = new EasyMessageList(
+ "&6&l超级仓库 &f玩家指令帮助",
+ "&8#&f open &e[仓库ID]",
+ "&8-&7 打开对应仓库的界面。",
+ "&8#&f sell &6<仓库ID> &6<物品ID> &6<数量>",
+ "&8-&7 售出对应数量的对应物品。",
+ "&8-&7 该指令受到玩家每日售出数量的限制。",
+ "&8#&f sellAll &e[仓库ID] &e[物品ID]",
+ "&8-&7 该指令受到玩家每日售出数量的限制。"
+ );
+
+ }
+
+ public static final EasyMessageList ITEM_SOLD = new EasyMessageList(
+ new String[]{"&f您出售了 &r%(item)&7x%(amount) &f,共赚取 &6%(money) &f元。"},
+ new String[]{"%(item)", "%(amount)", "%(money)"}
+ );
+
+ public static final EasyMessageList ITEM_SOLD_LIMIT = new EasyMessageList(
+ new String[]{"&f该物品今日剩余可出售额度为 &a%(amount)&8/%(limit) &f个。"},
+ new String[]{"%(amount)", "%(limit)"}
+ );
+
+ public static final EasyMessageList ITEM_PICKUP = new EasyMessageList(
+ new String[]{"&f您拾取了 &r%(item)&7x%(amount) &f,已自动放入到您的仓库中。"},
+ new String[]{"%(item)", "%(amount)"}
+ );
+
+ public static final EasyMessageList ITEM_COLLECT = new EasyMessageList(
+ new String[]{"&f您收集了 &r%(item)&7x%(amount) &f,已自动放入到您的 &6%(depository) &f中。"},
+ new String[]{"%(item)", "%(amount)", "%(depository)"}
+ );
- public static final ConfigMessageList SOLD = new ConfigMessageList(
- "item-sold", new String[0], new String[]{
- "%(item)", "%(amount)", "%(money)"
- });
+ public static final EasyMessageList NO_SPACE = new EasyMessageList(
+ "&f您仓库内没有足够的空间取出物品!"
+ );
- public static final ConfigMessageList PICKUP = new ConfigMessageList(
- "item-pickup", new String[0], new String[]{
- "%(item)", "%(amount)"
- });
+ public static final EasyMessageList NO_ECONOMY = new EasyMessageList(
+ "&f本服务器暂未启用出售功能。"
+ );
- public static final ConfigMessageList COLLECTED = new ConfigMessageList(
- "item-collected", new String[0], new String[]{
- "%(item)", "%(amount)", "%(depository)"
- });
+ public static final EasyMessageList NO_DEPOSITORY = new EasyMessageList(
+ "&f不存在该仓库,请检查仓库ID是否正确。"
+ );
+ public static final EasyMessageList NO_ITEM = new EasyMessageList(
+ "&f仓库中不存在该物品,请检查物品ID是否正确。"
+ );
- public static final ConfigMessageList NO_ECONOMY = new ConfigMessageList("no-economy");
+ public static final EasyMessageList NO_ENOUGH_ITEM = new EasyMessageList(
+ "&f仓库中不存在足够的物品。"
+ );
- public static final ConfigMessageList NO_SPACE = new ConfigMessageList("no-space");
+ public static final EasyMessageList WRONG_NUMBER = new EasyMessageList(
+ "&f数目输入错误,请输入正确的数字!"
+ );
- public static final ConfigMessageList NO_DEPOSITORY = new ConfigMessageList("no-depository");
-
- public static final ConfigMessageList NO_ITEM = new ConfigMessageList("no-item");
-
- public static final ConfigMessageList NO_ENOUGH_ITEM = new ConfigMessageList("no-enough-item");
-
-
- public static final ConfigMessageList ITEM_SOLD_LIMIT = new ConfigMessageList(
- "item-sold-limit", new String[0], new String[]{
- "%(amount)", "%(limit)"
- });
-
- public static final ConfigMessageList WRONG_NUMBER = new ConfigMessageList("wrong-number");
}
diff --git a/src/main/java/cc/carm/plugin/ultradepository/manager/ConfigManager.java b/src/main/java/cc/carm/plugin/ultradepository/manager/ConfigManager.java
index c66e397..4b4c7cb 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/manager/ConfigManager.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/manager/ConfigManager.java
@@ -2,50 +2,57 @@ package cc.carm.plugin.ultradepository.manager;
import cc.carm.lib.easyplugin.configuration.file.FileConfig;
+import cc.carm.lib.easyplugin.configuration.language.MessagesConfig;
+import cc.carm.lib.easyplugin.configuration.language.MessagesInitializer;
import cc.carm.plugin.ultradepository.UltraDepository;
+import cc.carm.plugin.ultradepository.configuration.PluginMessages;
public class ConfigManager {
- private static FileConfig pluginConfiguration;
- private static FileConfig messageConfiguration;
+ private static FileConfig pluginConfiguration;
+ private static MessagesConfig messageConfiguration;
- public static boolean initialize() {
- try {
- pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
- messageConfiguration = new FileConfig(UltraDepository.getInstance(), "messages.yml");
+ public static boolean initialize() {
+ try {
+ pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
+ messageConfiguration = new MessagesConfig(UltraDepository.getInstance(), "messages.yml");
- FileConfig.pluginConfiguration = () -> pluginConfiguration;
- FileConfig.messageConfiguration = () -> messageConfiguration;
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
+ FileConfig.pluginConfiguration = () -> pluginConfiguration;
+ FileConfig.messageConfiguration = () -> messageConfiguration;
- public static FileConfig getPluginConfig() {
- return pluginConfiguration;
- }
+ MessagesInitializer.initialize(messageConfiguration, PluginMessages.class);
- public static FileConfig getMessageConfig() {
- return messageConfiguration;
- }
+ return true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ }
- public static void reload() {
- try {
- getPluginConfig().reload();
- getMessageConfig().reload();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+ public static FileConfig getPluginConfig() {
+ return pluginConfiguration;
+ }
- public static void saveConfig() {
- try {
- getPluginConfig().save();
- getMessageConfig().save();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+ public static MessagesConfig getMessageConfig() {
+ return messageConfiguration;
+ }
+
+ public static void reload() {
+ try {
+ getPluginConfig().reload();
+ getMessageConfig().reload();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public static void saveConfig() {
+ try {
+ getPluginConfig().save();
+ getMessageConfig().save();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
}
diff --git a/src/main/java/cc/carm/plugin/ultradepository/manager/DepositoryManager.java b/src/main/java/cc/carm/plugin/ultradepository/manager/DepositoryManager.java
index 09dd02a..dc5a919 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/manager/DepositoryManager.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/manager/DepositoryManager.java
@@ -166,7 +166,7 @@ public class DepositoryManager {
collectItemEvent.getUserData().addItemAmount(depository.getIdentifier(), typeID, finalAmount);
if (!player.hasPermission("UltraDepository.silent")) {
- PluginMessages.COLLECTED.send(player, new Object[]{
+ PluginMessages.ITEM_COLLECT.send(player, new Object[]{
depository.getItems().get(typeID).getName(),
finalAmount, depository.getName()
});
diff --git a/src/main/java/cc/carm/plugin/ultradepository/manager/EconomyManager.java b/src/main/java/cc/carm/plugin/ultradepository/manager/EconomyManager.java
index de0ceed..5de2716 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/manager/EconomyManager.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/manager/EconomyManager.java
@@ -89,7 +89,7 @@ public class EconomyManager {
player, depositoryItem, changes[0] + amount, changes[0], money
));
- PluginMessages.SOLD.send(player, new Object[]{depositoryItem.getName(), amount, money});
+ PluginMessages.ITEM_SOLD.send(player, new Object[]{depositoryItem.getName(), amount, money});
if (playSound) PluginConfig.Sounds.SELL_SUCCESS.play(player);
}
diff --git a/src/main/java/cc/carm/plugin/ultradepository/ui/DepositoryGUI.java b/src/main/java/cc/carm/plugin/ultradepository/ui/DepositoryGUI.java
index 05f89ad..5d139f8 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/ui/DepositoryGUI.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/ui/DepositoryGUI.java
@@ -78,7 +78,7 @@ public class DepositoryGUI extends GUI {
int pickupAmount = Math.min(itemData.getAmount(), item.getMaterial().getMaxStackSize());
userData.removeItemAmount(item.getDepository().getIdentifier(), item.getTypeID(), pickupAmount);
player.getInventory().addItem(item.getRawItem(pickupAmount));
- PluginMessages.PICKUP.send(player, new Object[]{
+ PluginMessages.ITEM_PICKUP.send(player, new Object[]{
item.getName(), pickupAmount
});
setupItems(); //刷新GUI
diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml
deleted file mode 100644
index 1bf31c1..0000000
--- a/src/main/resources/messages.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-help:
-
- player:
- - "&6&l超级仓库 &f玩家指令帮助"
- - "&8#&f open &e[仓库ID]"
- - "&8-&7 打开对应仓库的界面。"
- - "&8#&f sell &6<仓库ID> &6<物品ID> &6<数量>"
- - "&8-&7 售出对应数量的对应物品。"
- - "&8-&7 该指令受到玩家每日售出数量的限制。"
- - "&8#&f sellAll &e[仓库ID] &e[物品ID]"
- - "&8-&7 该指令受到玩家每日售出数量的限制。"
- console:
- - "&6&l超级仓库 &f后台指令帮助"
- - "&8#&f info &6<玩家> &e[仓库ID] &e[物品ID]"
- - "&8-&7 得到玩家的相关物品信息。"
- - "&8#&f add &6<玩家> &6<仓库ID> &6<物品ID> &6<数量>"
- - "&8-&7 为玩家添加对应仓库中对于物品的数量。"
- - "&8#&f remove &6<玩家> &6<仓库ID> &6<物品ID> &e[数量]"
- - "&8-&7 为玩家减少对应仓库中对于物品的数量。"
- - "&8-&7 若不填写数量,则清空对应仓库的对应物品。"
- - "&8#&f sell &6<玩家> &e[仓库ID] &e[物品ID] &e[数量]"
- - "&8-&7 为玩家售出相关物品。"
- - "&8-&7 若不填写数量,则售出所有对应仓库的对应物品。"
- - "&8-&7 若不填写物品,则售出对应仓库内所有物品。"
- - "&8-&7 若不填写仓库,则售出所有仓库内所有物品。"
- - "&8-&7 该指令受到玩家每日售出数量的限制。"
-
-item-collected:
- - "&f您收集了 &r%(item)&7x%(amount) &f,已自动放入到您的 &6%(depository) &f中。"
-
-item-pickup:
- - "&f您取出了 &r%(item)&7x%(amount) &f,已自动放入到您的仓库中。"
-
-item-sold:
- - "&f您出售了 &r%(item)&7x%(amount) &f,共赚取 &6%(money) &f元。"
-
-item-sold-limit:
- - "&f该物品今日剩余可出售额度为 &a%(amount)&8/%(limit) &f个。"
-
-
-no-economy:
- - "&f本服务器暂未启用出售功能。"
-
-no-space:
- - "&f您仓库内没有足够的空间取出物品!"
-
-no-depository:
- - "&f不存在该仓库,请检查仓库ID是否正确。"
-
-no-item:
- - "&f仓库中不存在该物品,请检查物品ID是否正确。"
-
-no-enough-item:
- - "&f仓库中不存在足够的物品。"
-
-
-wrong-number:
- - "&f数目输入错误,请输入正确的数字!"
\ No newline at end of file