mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-05 00:58:22 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 988fe600ce | |||
| 52df1863f4 | |||
| 4c46af55d0 | |||
| 123ae0b039 | |||
| dd5793427a | |||
| 6bf8e261d0 | |||
| fcdda893f1 | |||
| 27ad14c7ab | |||
| b6a6502713 | |||
| d8d589ba76 |
@@ -176,6 +176,9 @@
|
|||||||
# UltraDepository.use
|
# UltraDepository.use
|
||||||
- 超级仓库的基本使用权限 (默认所有人都有)
|
- 超级仓库的基本使用权限 (默认所有人都有)
|
||||||
|
|
||||||
|
# UltraDepository.silent
|
||||||
|
- 拥有该权限将不再接收到放入背包的提示。
|
||||||
|
|
||||||
# UltraDepository.Command.Sell
|
# UltraDepository.Command.Sell
|
||||||
- 玩家使用Sell指令的权限
|
- 玩家使用Sell指令的权限
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
<easyplugin.version>1.1.0</easyplugin.version>
|
<easyplugin.version>1.1.3</easyplugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>ultradepository</artifactId>
|
<artifactId>ultradepository</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.1.7</version>
|
<version>1.2.2</version>
|
||||||
|
|
||||||
<name>UltraDepository</name>
|
<name>UltraDepository</name>
|
||||||
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||||
|
|||||||
@@ -36,30 +36,27 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
protected void load() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
log("加载配置文件...");
|
|
||||||
ConfigManager.initConfig();
|
|
||||||
|
|
||||||
GUI.initialize(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean initialize() {
|
protected boolean initialize() {
|
||||||
|
|
||||||
log("初始化存储方式...");
|
log("加载配置文件...");
|
||||||
StorageMethod storageMethod = PluginConfig.STORAGE_METHOD.get();
|
if (!ConfigManager.initialize()) {
|
||||||
if (storageMethod == null) {
|
log("初始化配置文件失败,放弃加载。");
|
||||||
log("初始化存储方式失败,放弃加载");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage = storageMethod.createStorage();
|
log("初始化存储方式...");
|
||||||
|
StorageMethod storageMethod = PluginConfig.STORAGE_METHOD.getOptional().orElse(StorageMethod.YAML);
|
||||||
log(" 正在使用 " + storageMethod.name() + " 进行数据存储");
|
log(" 正在使用 " + storageMethod.name() + " 进行数据存储");
|
||||||
|
|
||||||
|
storage = storageMethod.createStorage();
|
||||||
if (!storage.initialize()) {
|
if (!storage.initialize()) {
|
||||||
error("存储初始化失败,请检查配置文件。");
|
error("初始化存储失败,请检查配置文件。");
|
||||||
|
storage.shutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +76,7 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
log("加载仓库管理器...");
|
log("加载仓库管理器...");
|
||||||
depositoryManager = new DepositoryManager();
|
depositoryManager = new DepositoryManager();
|
||||||
getDepositoryManager().loadDepositories();
|
getDepositoryManager().loadDepositories();
|
||||||
|
GUI.initialize(this);
|
||||||
|
|
||||||
log("注册监听器...");
|
log("注册监听器...");
|
||||||
regListener(new UserListener());
|
regListener(new UserListener());
|
||||||
@@ -101,7 +99,7 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
"active_depositories",
|
"active_depositories",
|
||||||
() -> getDepositoryManager().getDepositories().size())
|
() -> getDepositoryManager().getDepositories().size())
|
||||||
);
|
);
|
||||||
metrics.addCustomChart(new SimplePie("storage_method", () -> getStorage().getClass().getSimpleName()));
|
metrics.addCustomChart(new SimplePie("storage_method", storageMethod::name));
|
||||||
metrics.addCustomChart(new SimplePie("economy_enabled", () -> economyManager.isInitialized() ? "YES" : "NO"));
|
metrics.addCustomChart(new SimplePie("economy_enabled", () -> economyManager.isInitialized() ? "YES" : "NO"));
|
||||||
metrics.addCustomChart(new SimplePie("papi_version", () -> {
|
metrics.addCustomChart(new SimplePie("papi_version", () -> {
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
|
||||||
@@ -113,7 +111,7 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
protected void shutdown() {
|
||||||
if (!isInitialized()) return;
|
if (!isInitialized()) return;
|
||||||
|
|
||||||
log("保存现有用户数据...");
|
log("保存现有用户数据...");
|
||||||
@@ -147,6 +145,11 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
return depositoryManager;
|
return depositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugging() {
|
||||||
|
return PluginConfig.DEBUG.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void outputInfo() {
|
public void outputInfo() {
|
||||||
log(" ",
|
log(" ",
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package cc.carm.plugin.ultradepository.configuration;
|
package cc.carm.plugin.ultradepository.configuration;
|
||||||
|
|
||||||
|
import cc.carm.lib.easyplugin.configuration.cast.ConfigStringCast;
|
||||||
import cc.carm.lib.easyplugin.configuration.impl.ConfigSound;
|
import cc.carm.lib.easyplugin.configuration.impl.ConfigSound;
|
||||||
import cc.carm.lib.easyplugin.configuration.impl.ConfigStringCast;
|
|
||||||
import cc.carm.lib.easyplugin.configuration.message.ConfigMessage;
|
import cc.carm.lib.easyplugin.configuration.message.ConfigMessage;
|
||||||
import cc.carm.lib.easyplugin.configuration.message.ConfigMessageList;
|
import cc.carm.lib.easyplugin.configuration.message.ConfigMessageList;
|
||||||
import cc.carm.lib.easyplugin.configuration.values.ConfigValue;
|
import cc.carm.lib.easyplugin.configuration.values.ConfigValue;
|
||||||
import cc.carm.plugin.ultradepository.manager.ConfigManager;
|
import cc.carm.plugin.ultradepository.manager.ConfigManager;
|
||||||
import cc.carm.plugin.ultradepository.storage.StorageMethod;
|
import cc.carm.plugin.ultradepository.storage.StorageMethod;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
public class PluginConfig {
|
public class PluginConfig {
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ public class PluginConfig {
|
|||||||
|
|
||||||
public static class Sounds {
|
public static class Sounds {
|
||||||
|
|
||||||
public static final ConfigSound COLLECT = new ConfigSound("sounds.collect");
|
public static final ConfigSound COLLECT = new ConfigSound("sounds.collect", Sound.ENTITY_VILLAGER_CELEBRATE);
|
||||||
public static final ConfigSound SELL_SUCCESS = new ConfigSound("sounds.sell-success");
|
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 SELL_FAIL = new ConfigSound("sounds.sell-fail");
|
||||||
public static final ConfigSound GUI_CLICK = new ConfigSound("sounds.gui-click");
|
public static final ConfigSound GUI_CLICK = new ConfigSound("sounds.gui-click");
|
||||||
|
|||||||
+15
-4
@@ -42,10 +42,21 @@ public class DepositoryCapacity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerCapacity(Player player) {
|
public int getPlayerCapacity(Player player) {
|
||||||
return getPermissions().entrySet().stream()
|
if (defaultCapacity == -1) return -1;
|
||||||
.filter(entry -> player.hasPermission(entry.getKey()))
|
|
||||||
.mapToInt(Map.Entry::getValue)
|
int capacity = defaultCapacity;
|
||||||
.max().orElse(defaultCapacity);
|
for (Map.Entry<String, Integer> entry : getPermissions().entrySet()) {
|
||||||
|
if (player.hasPermission(entry.getKey())) {
|
||||||
|
int value = entry.getValue();
|
||||||
|
if (value == -1) {
|
||||||
|
return -1;
|
||||||
|
} else if (value > capacity) {
|
||||||
|
capacity = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class UserData {
|
|||||||
|
|
||||||
|
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return new Date(DateIntUtil.getDateMillis(getDateInt()));
|
return DateIntUtil.getDate(getDateInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDateInt() {
|
public int getDateInt() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||||||
"%UltraDepository_amount_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_amount_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraDepository_sold_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_sold_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraDepository_price_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_price_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraDepository_reUltraDepository_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_remain_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraDepository_capacity_<BackpackID>%",
|
"%UltraDepository_capacity_<BackpackID>%",
|
||||||
"%UltraDepository_used_<BackpackID>%",
|
"%UltraDepository_used_<BackpackID>%",
|
||||||
"%UltraDepository_usable_<BackpackID>%"
|
"%UltraDepository_usable_<BackpackID>%"
|
||||||
@@ -80,7 +80,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||||||
if (sold == null) return "Depository or Item not exists";
|
if (sold == null) return "Depository or Item not exists";
|
||||||
else return sold.toString();
|
else return sold.toString();
|
||||||
}
|
}
|
||||||
case "reUltraDepository": {
|
case "remain": {
|
||||||
if (args.length < 2) return "Error Params";
|
if (args.length < 2) return "Error Params";
|
||||||
Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
|
Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
|
||||||
if (depository == null) return "Depository not exists";
|
if (depository == null) return "Depository not exists";
|
||||||
@@ -106,7 +106,8 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||||||
if (args.length < 2) return "Error Params";
|
if (args.length < 2) return "Error Params";
|
||||||
Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
|
Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
|
||||||
if (depository == null) return "Depository not exists";
|
if (depository == null) return "Depository not exists";
|
||||||
return Integer.toString(depository.getCapacity().getPlayerCapacity(player));
|
int capacity = depository.getCapacity().getPlayerCapacity(player);
|
||||||
|
return capacity < 0 ? "∞" : Integer.toString(capacity);
|
||||||
}
|
}
|
||||||
case "used": {
|
case "used": {
|
||||||
if (args.length < 2) return "Error Params";
|
if (args.length < 2) return "Error Params";
|
||||||
@@ -118,8 +119,9 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||||||
if (args.length < 2) return "Error Params";
|
if (args.length < 2) return "Error Params";
|
||||||
Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
|
Depository depository = UltraDepository.getDepositoryManager().getDepository(args[1]);
|
||||||
if (depository == null) return "Depository not exists";
|
if (depository == null) return "Depository not exists";
|
||||||
|
int max = depository.getCapacity().getPlayerCapacity(player);
|
||||||
int used = data.getDepositoryData(depository).getUsedCapacity();
|
int used = data.getDepositoryData(depository).getUsedCapacity();
|
||||||
return Integer.toString(depository.getCapacity().getPlayerCapacity(player) - used);
|
return max < 0 ? "∞" : Integer.toString(max - used);
|
||||||
}
|
}
|
||||||
case "version": {
|
case "version": {
|
||||||
return getVersion();
|
return getVersion();
|
||||||
|
|||||||
@@ -9,12 +9,17 @@ public class ConfigManager {
|
|||||||
private static FileConfig pluginConfiguration;
|
private static FileConfig pluginConfiguration;
|
||||||
private static FileConfig messageConfiguration;
|
private static FileConfig messageConfiguration;
|
||||||
|
|
||||||
public static void initConfig() {
|
public static boolean initialize() {
|
||||||
pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
|
try {
|
||||||
messageConfiguration = new FileConfig(UltraDepository.getInstance(), "messages.yml");
|
pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
|
||||||
|
messageConfiguration = new FileConfig(UltraDepository.getInstance(), "messages.yml");
|
||||||
|
|
||||||
FileConfig.pluginConfiguration = () -> pluginConfiguration;
|
FileConfig.pluginConfiguration = () -> pluginConfiguration;
|
||||||
FileConfig.messageConfiguration = () -> messageConfiguration;
|
FileConfig.messageConfiguration = () -> messageConfiguration;
|
||||||
|
return true;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfig getPluginConfig() {
|
public static FileConfig getPluginConfig() {
|
||||||
@@ -26,13 +31,21 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
getPluginConfig().reload();
|
try {
|
||||||
getMessageConfig().reload();
|
getPluginConfig().reload();
|
||||||
|
getMessageConfig().reload();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveConfig() {
|
public static void saveConfig() {
|
||||||
getPluginConfig().save();
|
try {
|
||||||
getMessageConfig().save();
|
getPluginConfig().save();
|
||||||
|
getMessageConfig().save();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class DepositoryManager {
|
|||||||
return getItemDepositories(itemStack).stream().filter(configuration -> {
|
return getItemDepositories(itemStack).stream().filter(configuration -> {
|
||||||
int used = UltraDepository.getUserManager().getData(player).getDepositoryData(configuration).getUsedCapacity();
|
int used = UltraDepository.getUserManager().getData(player).getDepositoryData(configuration).getUsedCapacity();
|
||||||
int max = configuration.getCapacity().getPlayerCapacity(player);
|
int max = configuration.getCapacity().getPlayerCapacity(player);
|
||||||
return used + itemStack.getAmount() <= max;
|
return max < 0 || used + itemStack.getAmount() <= max;
|
||||||
}).collect(Collectors.toSet());
|
}).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,11 +165,13 @@ public class DepositoryManager {
|
|||||||
int finalAmount = collectItemEvent.getItemAmount();
|
int finalAmount = collectItemEvent.getItemAmount();
|
||||||
|
|
||||||
collectItemEvent.getUserData().addItemAmount(depository.getIdentifier(), typeID, finalAmount);
|
collectItemEvent.getUserData().addItemAmount(depository.getIdentifier(), typeID, finalAmount);
|
||||||
PluginMessages.COLLECTED.send(player, new Object[]{
|
if (!player.hasPermission("UltraDepository.silent")) {
|
||||||
depository.getItems().get(typeID).getName(),
|
PluginMessages.COLLECTED.send(player, new Object[]{
|
||||||
finalAmount, depository.getName()
|
depository.getItems().get(typeID).getName(),
|
||||||
});
|
finalAmount, depository.getName()
|
||||||
PluginConfig.Sounds.COLLECT.play(player);
|
});
|
||||||
|
PluginConfig.Sounds.COLLECT.play(player);
|
||||||
|
}
|
||||||
UltraDepository.getInstance().debug("Item collected successfully.");
|
UltraDepository.getInstance().debug("Item collected successfully.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import cc.carm.plugin.ultradepository.hooker.VaultHooker;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
public class EconomyManager {
|
public class EconomyManager {
|
||||||
|
|
||||||
VaultHooker hooker;
|
VaultHooker hooker;
|
||||||
@@ -35,9 +38,9 @@ public class EconomyManager {
|
|||||||
|
|
||||||
public double sell(Player player, double price, int amount) {
|
public double sell(Player player, double price, int amount) {
|
||||||
if (!isInitialized()) return 0D;
|
if (!isInitialized()) return 0D;
|
||||||
double money = price * amount;
|
BigDecimal money = BigDecimal.valueOf(price * amount).setScale(2, RoundingMode.DOWN);
|
||||||
getHooker().addMoney(player, money);
|
getHooker().addMoney(player, money.doubleValue());
|
||||||
return money;
|
return money.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sellAllItem(Player player, UserData userData) {
|
public void sellAllItem(Player player, UserData userData) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import cc.carm.lib.easyplugin.database.api.SQLManager;
|
|||||||
import cc.carm.lib.easyplugin.database.api.action.query.PreparedQueryAction;
|
import cc.carm.lib.easyplugin.database.api.action.query.PreparedQueryAction;
|
||||||
import cc.carm.lib.easyplugin.database.api.action.query.SQLQuery;
|
import cc.carm.lib.easyplugin.database.api.action.query.SQLQuery;
|
||||||
import cc.carm.plugin.ultradepository.UltraDepository;
|
import cc.carm.plugin.ultradepository.UltraDepository;
|
||||||
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
|
|
||||||
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
||||||
import cc.carm.plugin.ultradepository.data.DepositoryData;
|
import cc.carm.plugin.ultradepository.data.DepositoryData;
|
||||||
import cc.carm.plugin.ultradepository.data.UserData;
|
import cc.carm.plugin.ultradepository.data.UserData;
|
||||||
@@ -62,7 +61,7 @@ public class MySQLStorage extends JSONStorage {
|
|||||||
try {
|
try {
|
||||||
UltraDepository.getInstance().log(" 尝试连接到数据库...");
|
UltraDepository.getInstance().log(" 尝试连接到数据库...");
|
||||||
this.sqlManager = EasySQL.createManager(DRIVER_NAME.get(), URL.get(), USERNAME.get(), PASSWORD.get());
|
this.sqlManager = EasySQL.createManager(DRIVER_NAME.get(), URL.get(), USERNAME.get(), PASSWORD.get());
|
||||||
this.sqlManager.setDebugMode(PluginConfig.DEBUG.get());
|
this.sqlManager.setDebugMode(UltraDepository.getInstance().isDebugging());
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
UltraDepository.getInstance().error("无法连接到数据库,请检查配置文件。");
|
UltraDepository.getInstance().error("无法连接到数据库,请检查配置文件。");
|
||||||
UltraDepository.getInstance().error("Could not connect to the database, please check the configuration.");
|
UltraDepository.getInstance().error("Could not connect to the database, please check the configuration.");
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ public class DepositoryGUI extends GUI {
|
|||||||
|
|
||||||
private GUIItem createGUIItem(DepositoryItem item) {
|
private GUIItem createGUIItem(DepositoryItem item) {
|
||||||
DepositoryItemData itemData = userData.getItemData(item);
|
DepositoryItemData itemData = userData.getItemData(item);
|
||||||
int remain = item.getLimit() - itemData.getSold();
|
int canSell = item.getLimit() - itemData.getSold();
|
||||||
|
|
||||||
ItemStackFactory factory = new ItemStackFactory(item.getDisplayItem());
|
ItemStackFactory factory = new ItemStackFactory(item.getDisplayItem());
|
||||||
List<String> additionalLore = PluginConfig.General.ADDITIONAL_LORE.get(player, new Object[]{
|
List<String> additionalLore = PluginConfig.General.ADDITIONAL_LORE.get(player, new Object[]{
|
||||||
item.getName(), itemData.getAmount(), item.getPrice(),
|
item.getName(), itemData.getAmount(), item.getPrice(),
|
||||||
itemData.getSold(), remain, item.getLimit()
|
itemData.getSold(), canSell, item.getLimit()
|
||||||
});
|
});
|
||||||
|
|
||||||
additionalLore.forEach(factory::addLore);
|
additionalLore.forEach(factory::addLore);
|
||||||
@@ -65,10 +65,12 @@ public class DepositoryGUI extends GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type == ClickType.LEFT) {
|
if (type == ClickType.LEFT) {
|
||||||
if (remain >= 1) {
|
if (canSell >= 1) {
|
||||||
SellItemGUI.open(player, userData, itemData, depository, item);
|
SellItemGUI.open(player, userData, itemData, depository, item);
|
||||||
} else {
|
} else {
|
||||||
PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{remain, item.getLimit()});
|
PluginConfig.Sounds.SELL_FAIL.play(player);
|
||||||
|
PluginMessages.ITEM_SOLD_LIMIT.send(player, new Object[]{canSell, item.getLimit()});
|
||||||
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
} else if (type == ClickType.RIGHT) {
|
} else if (type == ClickType.RIGHT) {
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
|||||||
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
||||||
import cc.carm.plugin.ultradepository.data.DepositoryItemData;
|
import cc.carm.plugin.ultradepository.data.DepositoryItemData;
|
||||||
import cc.carm.plugin.ultradepository.data.UserData;
|
import cc.carm.plugin.ultradepository.data.UserData;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -73,7 +74,7 @@ public class SellItemGUI extends GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GUIItem getAddItem(int amount) {
|
private GUIItem getAddItem(int amount) {
|
||||||
ItemStackFactory factory = new ItemStackFactory(Add.TYPE.get());
|
ItemStackFactory factory = new ItemStackFactory(Add.TYPE.getOptional().orElse(Material.STONE));
|
||||||
factory.setDurability(Add.DATA.get());
|
factory.setDurability(Add.DATA.get());
|
||||||
factory.setDisplayName(Add.NAME.get(player, new Object[]{
|
factory.setDisplayName(Add.NAME.get(player, new Object[]{
|
||||||
getItemName(), amount
|
getItemName(), amount
|
||||||
@@ -93,7 +94,7 @@ public class SellItemGUI extends GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GUIItem getRemoveItem(int amount) {
|
private GUIItem getRemoveItem(int amount) {
|
||||||
ItemStackFactory factory = new ItemStackFactory(Remove.TYPE.get());
|
ItemStackFactory factory = new ItemStackFactory(Remove.TYPE.getOptional().orElse(Material.STONE));
|
||||||
factory.setDurability(Remove.DATA.get());
|
factory.setDurability(Remove.DATA.get());
|
||||||
factory.setDisplayName(Remove.NAME.get(player, new Object[]{
|
factory.setDisplayName(Remove.NAME.get(player, new Object[]{
|
||||||
getItemName(), amount
|
getItemName(), amount
|
||||||
@@ -112,7 +113,7 @@ public class SellItemGUI extends GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GUIItem getConfirmItem() {
|
private GUIItem getConfirmItem() {
|
||||||
ItemStackFactory factory = new ItemStackFactory(Confirm.TYPE.get());
|
ItemStackFactory factory = new ItemStackFactory(Confirm.TYPE.getOptional().orElse(Material.STONE));
|
||||||
factory.setDurability(Confirm.DATA.get());
|
factory.setDurability(Confirm.DATA.get());
|
||||||
factory.setDisplayName(Confirm.NAME.get(player, new Object[]{
|
factory.setDisplayName(Confirm.NAME.get(player, new Object[]{
|
||||||
getItemName(), getCurrentAmount(), getTotalMoney()
|
getItemName(), getCurrentAmount(), getTotalMoney()
|
||||||
@@ -131,7 +132,7 @@ public class SellItemGUI extends GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GUIItem getCancelItem() {
|
private GUIItem getCancelItem() {
|
||||||
ItemStackFactory factory = new ItemStackFactory(Cancel.TYPE.get());
|
ItemStackFactory factory = new ItemStackFactory(Cancel.TYPE.getOptional().orElse(Material.STONE));
|
||||||
factory.setDurability(Cancel.DATA.get());
|
factory.setDurability(Cancel.DATA.get());
|
||||||
factory.setDisplayName(Cancel.NAME.get());
|
factory.setDisplayName(Cancel.NAME.get());
|
||||||
factory.setLore(Cancel.LORE.get());
|
factory.setLore(Cancel.LORE.get());
|
||||||
|
|||||||
@@ -22,10 +22,14 @@ public class DateIntUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getDateMillis(int dateInt) {
|
public static long getDateMillis(int dateInt) {
|
||||||
|
return getDate(dateInt).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date getDate(int dateInt) {
|
||||||
try {
|
try {
|
||||||
return getFormat().parse(Integer.toString(dateInt)).getTime();
|
return (Date) getFormat().parse(Integer.toString(dateInt));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException | NumberFormatException e) {
|
||||||
return System.currentTimeMillis();
|
return new Date(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ permissions:
|
|||||||
description: "超级仓库的基本使用权限"
|
description: "超级仓库的基本使用权限"
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
|
"UltraDepository.silent":
|
||||||
|
description: "超级仓库的安静模式权限,拥有该权限将不再接收到放入背包的提示。"
|
||||||
|
default: false
|
||||||
|
|
||||||
"UltraDepository.auto":
|
"UltraDepository.auto":
|
||||||
description: "超级仓库的自动收集权限"
|
description: "超级仓库的自动收集权限"
|
||||||
default: op
|
default: op
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
public class MoneyTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
System.out.println(get(1.2, 100));
|
||||||
|
System.out.println(get(0.55, 10));
|
||||||
|
System.out.println(get(0.21, 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double get(double price, int amount) {
|
||||||
|
BigDecimal money = BigDecimal.valueOf(price * amount).setScale(2, RoundingMode.DOWN);
|
||||||
|
return money.doubleValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user