diff --git a/README.md b/README.md
index f05cd5a..edffd8a 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,7 @@
本插件由 [墨豆Mordo](https://www.mordo.cn)、[子墨Zimrs](https://www.zimrs.cn) 资助本人开发,经过授权后开源。
> 本插件已发布于 [MCBBS](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1292631) 和 [SpigotMC]() 。
+
## 功能介绍
本插件允许配置多个不同功能的仓库,玩家通过 击杀生物/挖掘方块/捡起收集 获得的原版物品可以自动被放入仓库中。
@@ -173,13 +174,9 @@
展开查看所有权限
```text
-
# UltraDepository.use
- 超级仓库的基本使用权限 (默认所有人都有)
-# UltraDepository.silent
-- 拥有该权限将不再接收到放入背包的提示。
-
# UltraDepository.Command.Sell
- 玩家使用Sell指令的权限
@@ -195,9 +192,12 @@
- 若玩家缺失该权限或“UltraDepository.auto”权限,则自动收集物品功能不会启用。
- 您可以自己使用GUI创建一个按钮,后通过给玩家添加/删除该权限决定玩家是否开启自动收集。
+# UltraDepository.silent
+- 拥有该权限将不再接收到放入背包的提示。
+- 您可以自己使用GUI创建一个按钮,后通过给玩家添加/删除该权限决定玩家是否开启收集提示。
+
# UltraDepository.admin
- "超级仓库的管理权限"
-
```
diff --git a/pom.xml b/pom.xml
index aed95a0..2b7bcfc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,13 +9,13 @@
11
UTF-8
UTF-8
- 1.3.4
+ 1.3.5
cc.carm.plugin
ultradepository
jar
- 1.2.4
+ 1.2.5
UltraDepository
超级仓库插件,支持设定不同物品的存储仓库。
diff --git a/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginConfig.java b/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginConfig.java
index 02e9456..f64cada 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginConfig.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginConfig.java
@@ -47,6 +47,7 @@ public class PluginConfig {
public static class Sounds {
public static final ConfigSound COLLECT = new ConfigSound("sounds.collect", Sound.ENTITY_VILLAGER_CELEBRATE);
+ public static final ConfigSound TAKEOUT = new ConfigSound("sounds.collect");
public static final ConfigSound SELL_SUCCESS = new ConfigSound("sounds.sell-success");
public static final ConfigSound SELL_FAIL = new ConfigSound("sounds.sell-fail");
public static final ConfigSound GUI_CLICK = new ConfigSound("sounds.gui-click");
@@ -56,20 +57,49 @@ public class PluginConfig {
* 通用配置
*/
public static class General {
+
/**
* 针对每一件物品的额外介绍
* 将添加到背包界面内的物品上,避免重复配置
*/
- public static final ConfigMessageList ADDITIONAL_LORE = new ConfigMessageList(
- ConfigManager::getPluginConfig, "general.additional-lore", new String[]{},
- new String[]{
- "%(item_name)", "%(amount)", "%(price)", "%(sold)", "%(remain)", "%(limit)"
- });
+ public static class AdditionalLore {
+
+ public static final ConfigMessageList AVAILABLE_FOR_SALE = new ConfigMessageList(
+ ConfigManager::getPluginConfig, "general.additional-lore.available-for-sale",
+ new String[]{},
+ new String[]{
+ "%(item_name)", "%(amount)", "%(price)", "%(sold)", "%(remain)", "%(limit)"
+ });
+
+ public static final ConfigMessageList NOT_FOR_SALE = new ConfigMessageList(
+ ConfigManager::getPluginConfig, "general.additional-lore.not-for-sale",
+ new String[]{}, new String[]{
+ "%(item_name)", "%(amount)"
+ });
+
+ }
/**
* 提示玩家点击行为的介绍
* 将添加到背包界面内的物品上,避免重复配置
*/
+ public static class ClickLore {
+ public static final ConfigMessageList AVAILABLE_FOR_SALE = new ConfigMessageList(
+ ConfigManager::getPluginConfig,
+ "general.click-lore.available-for-sale",
+ new String[]{}, new String[]{
+ "%(item_name)", "%(amount)", "%(price)"
+ });
+
+ public static final ConfigMessageList NOT_FOR_SALE = new ConfigMessageList(
+ ConfigManager::getPluginConfig, "general.click-lore.not-for-sale",
+ new String[]{},
+ new String[]{
+ "%(item_name)", "%(amount)"
+ });
+ }
+
+
public static final ConfigMessageList CLICK_LORE = new ConfigMessageList(
ConfigManager::getPluginConfig,
"general.click-lore",
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 73d1b42..8043b13 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/configuration/PluginMessages.java
@@ -1,88 +1,98 @@
package cc.carm.plugin.ultradepository.configuration;
+import cc.carm.lib.easyplugin.configuration.language.EasyMessage;
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 extends MessagesRoot {
- @MessagesSection("help")
- public static class Usages {
+ @MessagesSection("help")
+ public static class Usages {
- 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 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 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 = 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_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_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 EasyMessageList ITEM_TAKEOUT = 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 EasyMessageList NO_SPACE = new EasyMessageList(
- "&f您仓库内没有足够的空间取出物品!"
- );
+ public static final EasyMessage ITEM_COLLECT_ACTIONBAR = new EasyMessage(
+ "&r%(item)&7x%(amount) &f-> &6%(depository)",
+ new String[]{"%(item)", "%(amount)", "%(depository)"}
+ );
- public static final EasyMessageList NO_ECONOMY = new EasyMessageList(
- "&f本服务器暂未启用出售功能。"
- );
+ public static final EasyMessageList NO_SPACE = new EasyMessageList(
+ "&f您背包内没有足够的空间取出物品!"
+ );
- public static final EasyMessageList NO_DEPOSITORY = new EasyMessageList(
- "&f不存在该仓库,请检查仓库ID是否正确。"
- );
+ public static final EasyMessageList NO_ECONOMY = new EasyMessageList(
+ "&f本服务器暂未启用出售功能。"
+ );
- public static final EasyMessageList NO_ITEM = new EasyMessageList(
- "&f仓库中不存在该物品,请检查物品ID是否正确。"
- );
+ public static final EasyMessageList NO_DEPOSITORY = new EasyMessageList(
+ "&f不存在该仓库,请检查仓库ID是否正确。"
+ );
- public static final EasyMessageList NO_ENOUGH_ITEM = new EasyMessageList(
- "&f仓库中不存在足够的物品。"
- );
+ public static final EasyMessageList NO_ITEM = new EasyMessageList(
+ "&f仓库中不存在该物品,请检查物品ID是否正确。"
+ );
- public static final EasyMessageList WRONG_NUMBER = new EasyMessageList(
- "&f数目输入错误,请输入正确的数字!"
- );
+ public static final EasyMessageList NO_ENOUGH_ITEM = new EasyMessageList(
+ "&f仓库中不存在足够的物品。"
+ );
+
+ public static final EasyMessageList WRONG_NUMBER = new EasyMessageList(
+ "&f数目输入错误,请输入正确的数字!"
+ );
}
diff --git a/src/main/java/cc/carm/plugin/ultradepository/configuration/depository/DepositoryItem.java b/src/main/java/cc/carm/plugin/ultradepository/configuration/depository/DepositoryItem.java
index 59b8022..17742b6 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/configuration/depository/DepositoryItem.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/configuration/depository/DepositoryItem.java
@@ -116,8 +116,8 @@ public class DepositoryItem {
return new DepositoryItem(
depository, material, data,
section.getInt("slot", 0),
- section.getDouble("price", 0),
- section.getInt("limit", 0),
+ section.getDouble("price", -1),
+ section.getInt("limit", -1),
section.getString("name", material.name()),
section.getStringList("lore")
);
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 2429789..7e0fb52 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/manager/DepositoryManager.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/manager/DepositoryManager.java
@@ -179,6 +179,12 @@ public class DepositoryManager {
finalAmount, depository.getName()
});
PluginConfig.Sounds.COLLECT.play(player);
+
+ PluginMessages.ITEM_COLLECT_ACTIONBAR.sendBar(player, new Object[]{
+ depository.getItems().get(typeID).getName(),
+ finalAmount, depository.getName()
+ }); // Support action bar
+
}
UltraDepository.getInstance().debug("Item collected successfully.");
return true;
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 5d139f8..859c792 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/ui/DepositoryGUI.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/ui/DepositoryGUI.java
@@ -13,8 +13,10 @@ import cc.carm.plugin.ultradepository.data.UserData;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
+import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
@@ -24,7 +26,7 @@ public class DepositoryGUI extends GUI {
UserData userData;
Depository depository;
- public DepositoryGUI(Player player, Depository depository) {
+ private DepositoryGUI(Player player, Depository depository) {
super(depository.getGUIConfiguration().getGUIType(), depository.getGUIConfiguration().getTitle());
this.player = player;
@@ -35,53 +37,53 @@ public class DepositoryGUI extends GUI {
}
public void setupItems() {
+ loadConfigItems();
+ loadDepositoryItems();
+ }
+
+ public void loadConfigItems() {
depository.getGUIConfiguration().setupItems(player, this);
+ }
+
+ public void loadDepositoryItems() {
depository.getItems().values().forEach(depositoryItem -> setItem(depositoryItem.getSlot(), createGUIItem(depositoryItem)));
}
-
private GUIItem createGUIItem(DepositoryItem item) {
- DepositoryItemData itemData = userData.getItemData(item);
- int canSell = item.getLimit() - itemData.getSold();
-
- ItemStackFactory factory = new ItemStackFactory(item.getDisplayItem());
- List additionalLore = PluginConfig.General.ADDITIONAL_LORE.get(player, new Object[]{
- item.getName(), itemData.getAmount(), item.getPrice(),
- itemData.getSold(), canSell, item.getLimit()
- });
-
- additionalLore.forEach(factory::addLore);
- List clickLore = PluginConfig.General.CLICK_LORE.get(player, new Object[]{
- item.getName(), itemData.getAmount(), item.getPrice()
- });
- clickLore.forEach(factory::addLore);
-
- return new GUIItem(factory.toItemStack()) {
+ return new GUIItem(getItemIcon(player, userData, item)) {
@Override
public void onClick(ClickType type) {
+ DepositoryItemData itemData = userData.getItemData(item);
if (itemData.getAmount() < 1) {
+ PluginConfig.Sounds.SELL_FAIL.play(player);
PluginMessages.NO_ENOUGH_ITEM.send(player);
return;
}
- if (type == ClickType.LEFT) {
- if (canSell >= 1) {
+ if (canSell(item) && type == ClickType.LEFT) {
+ int sellableAmount = item.getLimit() - itemData.getSold();
+ if (sellableAmount >= 1) {
SellItemGUI.open(player, userData, itemData, depository, item);
} else {
PluginConfig.Sounds.SELL_FAIL.play(player);
- PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{canSell, item.getLimit()});
+ PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{sellableAmount, item.getLimit()});
player.closeInventory();
}
} else if (type == ClickType.RIGHT) {
if (hasEmptySlot(player)) {
- int pickupAmount = Math.min(itemData.getAmount(), item.getMaterial().getMaxStackSize());
- userData.removeItemAmount(item.getDepository().getIdentifier(), item.getTypeID(), pickupAmount);
- player.getInventory().addItem(item.getRawItem(pickupAmount));
- PluginMessages.ITEM_PICKUP.send(player, new Object[]{
- item.getName(), pickupAmount
+ int takeoutAmount = Math.min(itemData.getAmount(), item.getMaterial().getMaxStackSize());
+ userData.removeItemAmount(
+ item.getDepository().getIdentifier(), item.getTypeID(), takeoutAmount
+ );
+ player.getInventory().addItem(item.getRawItem(takeoutAmount));
+ PluginMessages.ITEM_TAKEOUT.send(player, new Object[]{
+ item.getName(), takeoutAmount
});
- setupItems(); //刷新GUI
+ PluginConfig.Sounds.TAKEOUT.play(player);
+
+ setDisplay(getItemIcon(player, userData, item)); // 刷新物品显示
+ loadConfigItems(); // 更新配置中的其他物品
updateView();
} else {
PluginMessages.NO_SPACE.send(player);
@@ -92,12 +94,51 @@ public class DepositoryGUI extends GUI {
};
}
- private boolean hasEmptySlot(Player player) {
+ public static boolean hasEmptySlot(Player player) {
return IntStream.range(0, 36)
.mapToObj(i -> player.getInventory().getItem(i))
.anyMatch(i -> i == null || i.getType() == Material.AIR);
}
+ public static ItemStack getItemIcon(@NotNull Player player,
+ @NotNull UserData userData,
+ @NotNull DepositoryItem item) {
+ DepositoryItemData itemData = userData.getItemData(item);
+ ItemStackFactory factory = new ItemStackFactory(item.getDisplayItem());
+ getExtraLore(player, itemData).forEach(factory::addLore);
+ return factory.toItemStack();
+ }
+
+ public static List getExtraLore(@NotNull Player player,
+ @NotNull DepositoryItemData itemData) {
+ DepositoryItem item = itemData.getSource();
+ int canSell = item.getLimit() - itemData.getSold();
+
+ List lore = new ArrayList<>();
+ if (canSell(item)) {
+ lore.addAll(PluginConfig.General.AdditionalLore.AVAILABLE_FOR_SALE.get(player, new Object[]{
+ item.getName(), itemData.getAmount(), item.getPrice(),
+ itemData.getSold(), canSell, item.getLimit()
+ }));
+ lore.addAll(PluginConfig.General.ClickLore.AVAILABLE_FOR_SALE.get(player, new Object[]{
+ item.getName(), itemData.getAmount(), item.getPrice()
+ }));
+ } else {
+ lore.addAll(PluginConfig.General.AdditionalLore.NOT_FOR_SALE.get(player, new Object[]{
+ item.getName(), itemData.getAmount()
+ }));
+ lore.addAll(PluginConfig.General.ClickLore.NOT_FOR_SALE.get(player, new Object[]{
+ item.getName(), itemData.getAmount()
+ }));
+ }
+ return lore;
+ }
+
+ public static boolean canSell(DepositoryItem item) {
+ return UltraDepository.getEconomyManager().isInitialized()
+ && item.getLimit() > 0 && item.getPrice() > 0;
+ }
+
public static void open(@NotNull Player player, @NotNull Depository depository) {
player.closeInventory();
DepositoryGUI gui = new DepositoryGUI(player, depository);
diff --git a/src/main/java/cc/carm/plugin/ultradepository/ui/SellItemGUI.java b/src/main/java/cc/carm/plugin/ultradepository/ui/SellItemGUI.java
index 4ef8c86..bf470f9 100644
--- a/src/main/java/cc/carm/plugin/ultradepository/ui/SellItemGUI.java
+++ b/src/main/java/cc/carm/plugin/ultradepository/ui/SellItemGUI.java
@@ -15,6 +15,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.List;
import static cc.carm.plugin.ultradepository.configuration.PluginConfig.General.SellGUI.Items.*;
@@ -51,10 +53,11 @@ public class SellItemGUI extends GUI {
private void load(int amount) {
this.currentAmount = Math.max(1, amount); // 不可小于1
ItemStackFactory factory = new ItemStackFactory(this.itemDisplay);
- List additionalLore = PluginConfig.General.ADDITIONAL_LORE.get(player, new Object[]{
- getItemName(), getReUltraDepositoryAmount(), getItemPrice(),
- getSoldAmount(), (getSellLimit() - getSoldAmount()), getSellLimit()
- });
+ List additionalLore = PluginConfig.General.AdditionalLore.AVAILABLE_FOR_SALE
+ .get(player, new Object[]{
+ getItemName(), getDepositoryAmount(), getItemPrice(),
+ getSoldAmount(), (getSellLimit() - getSoldAmount()), getSellLimit()
+ });
additionalLore.forEach(factory::addLore);
setItem(9, getCurrentAmount() > 1000 ? getRemoveItem(1000) : null);
@@ -67,7 +70,7 @@ public class SellItemGUI extends GUI {
setItem(16, getAddableAmount() >= 100 ? getAddItem(100) : null);
setItem(17, getAddableAmount() >= 1000 ? getAddItem(1000) : null);
- if (getCurrentAmount() >= 1) setItem(getConfirmItem(), 27, 28, 29, 30);
+ setItem(getCurrentAmount() >= 1 ? getConfirmItem() : null, 27, 28, 29, 30);
setItem(getCancelItem(), 32, 33, 34, 35);
}
@@ -104,7 +107,7 @@ public class SellItemGUI extends GUI {
})) {
@Override
public void onClick(ClickType type) {
- int amount = Math.min(getCurrentAmount(), Math.min(getReUltraDepositoryAmount(), getSellLimit() - getSoldAmount()));
+ int amount = Math.min(getCurrentAmount(), Math.min(getDepositoryAmount(), getSellLimit() - getSoldAmount()));
if (amount > 0) UltraDepository.getEconomyManager().sellItem(player, userData, item, amount);
player.closeInventory();
}
@@ -138,10 +141,11 @@ public class SellItemGUI extends GUI {
}
private double getTotalMoney() {
- return getCurrentAmount() * getItemPrice();
+ BigDecimal money = BigDecimal.valueOf(getCurrentAmount() * getItemPrice()).setScale(2, RoundingMode.DOWN);
+ return money.doubleValue();
}
- private int getReUltraDepositoryAmount() {
+ private int getDepositoryAmount() {
return userData.getItemData(this.item).getAmount();
}
@@ -150,7 +154,7 @@ public class SellItemGUI extends GUI {
}
private int getAddableAmount() {
- return Math.min(getReUltraDepositoryAmount(), getSellLimit() - getSoldAmount()) - getCurrentAmount();
+ return Math.min(getDepositoryAmount(), getSellLimit() - getSoldAmount()) - getCurrentAmount();
}
public static void open(Player player, UserData userData, DepositoryItemData itemData,
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 7f86ce4..4ef87ac 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -20,7 +20,7 @@ storage:
# 选择 yaml/json 存储方式时的存储路径
# 默认为相对路径,相对于插件生成的配置文件夹下的路径
- # 支持绝对路径,如 “/var/data/ub/"(linux) 或 "D:\data\ub\"(windows)
+ # 支持绝对路径,如 “/var/data/ud/"(linux) 或 "D:\data\ud\"(windows)
# 使用绝对路径时请注意权限问题
file-path: data
@@ -44,6 +44,7 @@ collect:
sounds:
collect: "ENTITY_EXPERIENCE_ORB_PICKUP:0.5"
+ takeout: "ENTITY_HORSE_ARMOR:0.5"
sell-success: "ENTITY_VILLAGER_CELEBRATE"
sell-fail: "ENTITY_VILLAGER_NO"
gui-click: "UI_BUTTON_CLICK"
@@ -51,20 +52,34 @@ sounds:
# 通用配置
general:
- # 针对每一件物品的额外介绍
+ # 针对可出售物品的额外介绍
# 将添加到背包界面内的物品上,避免重复配置
additional-lore:
- - " "
- - "&f仓库内数量 &a%(amount)"
- - "&f该物品单价 &a%(price)"
- - "&f今日可出售 &a%(remain)&8/%(limit)"
+ available-for-sale:
+ # 可出售物品的介绍
+ - " "
+ - "&f仓库内数量 &a%(amount)"
+ - "&f该物品单价 &a%(price)"
+ - "&f今日可出售 &a%(remain)&8/%(limit)"
+ not-for-sale:
+ # 针对不可出售的物品的额外介绍
+ # (当 未安装经济插件 或 每日可售出数量<=0 或 单价<=0 时判断为不可出售)
+ - " "
+ - "&f仓库内数量 &a%(amount)"
+
# 提示玩家点击行为的介绍
# 将添加到背包界面内的物品上,避免重复配置
click-lore:
- - " "
- - "&a&l左键点击 &8| &f按量售出该物品"
- - "&a&l右键点击 &8| &f取出一组该物品"
+ available-for-sale:
+ - " "
+ - "&a&l左键点击 &8| &f按量售出该物品"
+ - "&a&l右键点击 &8| &f取出一组该物品"
+ not-for-sale:
+ # 针对不可出售的物品的额外介绍
+ # (当 未安装经济插件 或 每日可售出数量<=0 或 单价<=0 时判断为不可出售)
+ - " "
+ - "&a&l右键点击 &8| &f取出一组该物品"
# 售出界面的配置
sell-gui:
diff --git a/src/main/resources/i18n/en_US/config.yml b/src/main/resources/i18n/en_US/config.yml
index f309a69..dbed32e 100644
--- a/src/main/resources/i18n/en_US/config.yml
+++ b/src/main/resources/i18n/en_US/config.yml
@@ -20,7 +20,7 @@ storage:
method: yaml
# The storage file path when choosing "yaml"/"json" method.
- # Support absolute paths, e.g. “/var/data/ub/"(linux) or "D:\data\ub\"(windows)
+ # Support absolute paths, e.g. “/var/data/ud/"(linux) or "D:\data\ud\"(windows)
# **Be aware of permission issues when using absolute paths!**
file-path: data
@@ -52,17 +52,36 @@ general:
# Hints lore for the item's information
# Will add to items in BackpackGUI and SellGUI.
additional-lore:
- - " "
- - "&fAmount &a%(amount)"
- - "&fPrice &a%(price)"
- - "&fSold &a%(remain)&8/%(limit)"
+ available-for-sale:
+ - " "
+ - "&fAmount &a%(amount)"
+ - "&fPrice &a%(price)"
+ - "&fSold &a%(remain)&8/%(limit)"
+ not-for-sale:
+ # Display when :
+ # 1. Vault not installed
+ # 2. No economy plugins
+ # 3. daily sell limit <= 0
+ # 4. item price <=0
+ - " "
+ - "&fAmount &a%(amount)"
# Hints lore for the player's click
# Will add to items in BackpackGUI.
click-lore:
- - " "
- - "&a&lLEFT-CLICK &8| &fSell items"
- - "&a&lRIGHT-CLICK &8| &fTake one Stack"
+ available-for-sale:
+ - " "
+ - "&a&lLEFT-CLICK &8| &fSell items"
+ - "&a&lRIGHT-CLICK &8| &fTake one Stack"
+ not-for-sale:
+ # Display when :
+ # 1. Vault not installed
+ # 2. No economy plugins
+ # 3. daily sell limit <= 0
+ # 4. item price <=0
+ - " "
+ - "&a&lRIGHT-CLICK &8| &fTake one Stack"
+
# Configuration of the SellGUI
sell-gui:
diff --git a/src/main/resources/i18n/en_US/messages.yml b/src/main/resources/i18n/en_US/messages.yml
new file mode 100644
index 0000000..ff2222c
--- /dev/null
+++ b/src/main/resources/i18n/en_US/messages.yml
@@ -0,0 +1,48 @@
+help:
+ 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 该指令受到玩家每日售出数量的限制。'
+ 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 该指令受到玩家每日售出数量的限制。'
+item-sold:
+- '&f您出售了 &r%(item)&7x%(amount) &f,共赚取 &6%(money) &f元。'
+item-sold-limit:
+- '&f该物品今日剩余可出售额度为 &a%(amount)&8/%(limit) &f个。'
+item-pickup:
+- '&f您拾取了 &r%(item)&7x%(amount) &f,已自动放入到您的仓库中。'
+item-takeout:
+- '&f您从仓库中拿取了 &r%(item)&7x%(amount) &f放入到您的背包中。'
+item-collect:
+- '&f您收集了 &r%(item)&7x%(amount) &f,已自动放入到您的 &6%(depository) &f中。'
+item-collect-actionbar: '&r%(item)&7x%(amount) &f-> &6%(depository)'
+no-space:
+- '&f您背包内没有足够的空间取出物品!'
+no-economy:
+- '&f本服务器暂未启用出售功能。'
+no-depository:
+- '&f不存在该仓库,请检查仓库ID是否正确。'
+no-item:
+- '&f仓库中不存在该物品,请检查物品ID是否正确。'
+no-enough-item:
+- '&f仓库中不存在足够的物品。'
+wrong-number:
+- '&f数目输入错误,请输入正确的数字!'
diff --git a/src/main/resources/i18n/ko_KR/config.yml b/src/main/resources/i18n/ko_KR/config.yml
index f309a69..f98c941 100644
--- a/src/main/resources/i18n/ko_KR/config.yml
+++ b/src/main/resources/i18n/ko_KR/config.yml
@@ -20,7 +20,7 @@ storage:
method: yaml
# The storage file path when choosing "yaml"/"json" method.
- # Support absolute paths, e.g. “/var/data/ub/"(linux) or "D:\data\ub\"(windows)
+ # Support absolute paths, e.g. “/var/data/ud/"(linux) or "D:\data\ud\"(windows)
# **Be aware of permission issues when using absolute paths!**
file-path: data
@@ -52,17 +52,35 @@ general:
# Hints lore for the item's information
# Will add to items in BackpackGUI and SellGUI.
additional-lore:
- - " "
- - "&fAmount &a%(amount)"
- - "&fPrice &a%(price)"
- - "&fSold &a%(remain)&8/%(limit)"
+ available-for-sale:
+ - " "
+ - "&fAmount &a%(amount)"
+ - "&fPrice &a%(price)"
+ - "&fSold &a%(remain)&8/%(limit)"
+ not-for-sale:
+ # Display when :
+ # 1. Vault not installed
+ # 2. No economy plugins
+ # 3. daily sell limit <= 0
+ # 4. item price <=0
+ - " "
+ - "&fAmount &a%(amount)"
# Hints lore for the player's click
# Will add to items in BackpackGUI.
click-lore:
- - " "
- - "&a&lLEFT-CLICK &8| &fSell items"
- - "&a&lRIGHT-CLICK &8| &fTake one Stack"
+ available-for-sale:
+ - " "
+ - "&a&lLEFT-CLICK &8| &fSell items"
+ - "&a&lRIGHT-CLICK &8| &fTake one Stack"
+ not-for-sale:
+ # Display when :
+ # 1. Vault not installed
+ # 2. No economy plugins
+ # 3. daily sell limit <= 0
+ # 4. item price <=0
+ - " "
+ - "&a&lRIGHT-CLICK &8| &fTake one Stack"
# Configuration of the SellGUI
sell-gui:
diff --git a/src/main/resources/i18n/ko_KR/messages.yml b/src/main/resources/i18n/ko_KR/messages.yml
new file mode 100644
index 0000000..ff2222c
--- /dev/null
+++ b/src/main/resources/i18n/ko_KR/messages.yml
@@ -0,0 +1,48 @@
+help:
+ 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 该指令受到玩家每日售出数量的限制。'
+ 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 该指令受到玩家每日售出数量的限制。'
+item-sold:
+- '&f您出售了 &r%(item)&7x%(amount) &f,共赚取 &6%(money) &f元。'
+item-sold-limit:
+- '&f该物品今日剩余可出售额度为 &a%(amount)&8/%(limit) &f个。'
+item-pickup:
+- '&f您拾取了 &r%(item)&7x%(amount) &f,已自动放入到您的仓库中。'
+item-takeout:
+- '&f您从仓库中拿取了 &r%(item)&7x%(amount) &f放入到您的背包中。'
+item-collect:
+- '&f您收集了 &r%(item)&7x%(amount) &f,已自动放入到您的 &6%(depository) &f中。'
+item-collect-actionbar: '&r%(item)&7x%(amount) &f-> &6%(depository)'
+no-space:
+- '&f您背包内没有足够的空间取出物品!'
+no-economy:
+- '&f本服务器暂未启用出售功能。'
+no-depository:
+- '&f不存在该仓库,请检查仓库ID是否正确。'
+no-item:
+- '&f仓库中不存在该物品,请检查物品ID是否正确。'
+no-enough-item:
+- '&f仓库中不存在足够的物品。'
+wrong-number:
+- '&f数目输入错误,请输入正确的数字!'