mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-05 00:58:22 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52df1863f4 | |||
| 4c46af55d0 | |||
| 123ae0b039 | |||
| dd5793427a |
@@ -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.8</version>
|
<version>1.2.1</version>
|
||||||
|
|
||||||
<name>UltraDepository</name>
|
<name>UltraDepository</name>
|
||||||
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||||
@@ -261,9 +261,6 @@
|
|||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
<includes>
|
|
||||||
<include>LICENSE</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -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("保存现有用户数据...");
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
try {
|
||||||
pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
|
pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml");
|
||||||
messageConfiguration = new FileConfig(UltraDepository.getInstance(), "messages.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() {
|
||||||
|
try {
|
||||||
getPluginConfig().reload();
|
getPluginConfig().reload();
|
||||||
getMessageConfig().reload();
|
getMessageConfig().reload();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveConfig() {
|
public static void saveConfig() {
|
||||||
|
try {
|
||||||
getPluginConfig().save();
|
getPluginConfig().save();
|
||||||
getMessageConfig().save();
|
getMessageConfig().save();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ permissions:
|
|||||||
|
|
||||||
"UltraDepository.silent":
|
"UltraDepository.silent":
|
||||||
description: "超级仓库的安静模式权限,拥有该权限将不再接收到放入背包的提示。"
|
description: "超级仓库的安静模式权限,拥有该权限将不再接收到放入背包的提示。"
|
||||||
|
default: false
|
||||||
|
|
||||||
"UltraDepository.auto":
|
"UltraDepository.auto":
|
||||||
description: "超级仓库的自动收集权限"
|
description: "超级仓库的自动收集权限"
|
||||||
|
|||||||
Reference in New Issue
Block a user