diff --git a/.examples/depositories/README.md b/.examples/depositories/README.md index d3f9f5d..1f9d4a9 100644 --- a/.examples/depositories/README.md +++ b/.examples/depositories/README.md @@ -6,7 +6,7 @@ ## 使用须知 -预设配置基于 MineCraft 1.16 实现,更低版本可能无法使用。 +预设配置基于 MineCraft 1.16 实现,理论上支持更高版本使用。 ## 如何使用? diff --git a/README.md b/README.md index f5ba0ee..8d819f2 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ [![License](https://img.shields.io/github/license/CarmJos/UltraDepository)](https://opensource.org/licenses/GPL-3.0) [![workflow](https://github.com/CarmJos/UltraDepository/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/CarmJos/UltraDepository/actions/workflows/maven.yml) ![CodeSize](https://img.shields.io/github/languages/code-size/CarmJos/UltraDepository) -![Support](https://img.shields.io/badge/Minecraft-Java%201.13--Latest-green) +![Support](https://img.shields.io/badge/Minecraft-Java%201.16--Latest-green) ![](https://visitor-badge.glitch.me/badge?page_id=UltraDepository.readme) 超级仓库插件,支持设定不同物品的存储仓库。 -本插件基于Spigot实现,**理论上支持全版本**。 +本插件基于 Spigot(1.16.3) 实现,**理论上支持1.16后的全部版本**。 本插件由 [墨豆Mordo](https://www.mordo.cn)、[子墨Zimrs](https://www.zimrs.cn) 资助本人开发,经过授权后开源。 diff --git a/pom.xml b/pom.xml index b09503e..aed95a0 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ org.spigotmc spigot-api - 1.17-R0.1-SNAPSHOT + 1.16.3-R0.1-SNAPSHOT provided 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 4b4c7cb..f9d3d7f 100644 --- a/src/main/java/cc/carm/plugin/ultradepository/manager/ConfigManager.java +++ b/src/main/java/cc/carm/plugin/ultradepository/manager/ConfigManager.java @@ -7,52 +7,63 @@ import cc.carm.lib.easyplugin.configuration.language.MessagesInitializer; import cc.carm.plugin.ultradepository.UltraDepository; import cc.carm.plugin.ultradepository.configuration.PluginMessages; +import java.io.File; + public class ConfigManager { - private static FileConfig pluginConfiguration; - private static MessagesConfig messageConfiguration; + private static FileConfig pluginConfiguration; + private static MessagesConfig messageConfiguration; - public static boolean initialize() { - try { - pluginConfiguration = new FileConfig(UltraDepository.getInstance(), "config.yml"); - messageConfiguration = new MessagesConfig(UltraDepository.getInstance(), "messages.yml"); + public static boolean initialize() { + UltraDepository udPlugin = UltraDepository.getInstance(); + File configFile = new File(udPlugin.getDataFolder(), "config.yml"); + if (!configFile.exists()) { + //没找到配置文件,可能是第一次加载此插件 + //把一些英文版的东西复制出来,方便英文用户使用。 + udPlugin.saveResource("i18n/en_US/config.yml", false); + udPlugin.saveResource("i18n/ko_KR/config.yml", false); + } - FileConfig.pluginConfiguration = () -> pluginConfiguration; - FileConfig.messageConfiguration = () -> messageConfiguration; + try { + pluginConfiguration = new FileConfig(udPlugin, "config.yml"); + messageConfiguration = new MessagesConfig(udPlugin, "messages.yml"); - MessagesInitializer.initialize(messageConfiguration, PluginMessages.class); + FileConfig.pluginConfiguration = () -> pluginConfiguration; + FileConfig.messageConfiguration = () -> messageConfiguration; - return true; - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } + MessagesInitializer.initialize(messageConfiguration, PluginMessages.class); - public static FileConfig getPluginConfig() { - return pluginConfiguration; - } + return true; + } catch (Exception ex) { + ex.printStackTrace(); + return false; + } + } - public static MessagesConfig getMessageConfig() { - return messageConfiguration; - } + public static FileConfig getPluginConfig() { + return pluginConfiguration; + } - public static void reload() { - try { - getPluginConfig().reload(); - getMessageConfig().reload(); - } catch (Exception ex) { - ex.printStackTrace(); - } - } + public static MessagesConfig getMessageConfig() { + return messageConfiguration; + } - public static void saveConfig() { - try { - getPluginConfig().save(); - getMessageConfig().save(); - } catch (Exception ex) { - ex.printStackTrace(); - } - } + 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/resources/config.yml b/src/main/resources/config.yml index 2da410f..7f86ce4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -7,7 +7,7 @@ version: ${project.version} debug: false # 统计数据设定 -# 改选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。 +# 该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。 # 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。 metrics: true diff --git a/src/main/resources/i18n/en_US/config.yml b/src/main/resources/i18n/en_US/config.yml new file mode 100644 index 0000000..f309a69 --- /dev/null +++ b/src/main/resources/i18n/en_US/config.yml @@ -0,0 +1,91 @@ +# ${project.name} - ${project.description} +# Source url: ${project.url} +# Download URL: ${project.distributionManagement.downloadUrl} + +version: ${project.version} + +debug: false + +# bStats Metrics +# This option is used to help developers analysis plugin stats, +# and will never affect performance and user experience. +# You can choose to turn it off here. +metrics: true + +# Storage Configuration +storage: + + # Storage method + # You can choose [ yaml | json | mysql ] + 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) + # **Be aware of permission issues when using absolute paths!** + file-path: data + + # The Database configuration when choosing "mysql" method. + mysql: + driver: "com.mysql.jdbc.Driver" + url: "jdbc:mysql://127.0.0.1:3306/" + table: "ud_data" # Plugin data table name, allowing customization + username: "username" + password: "password" + + +# Player Collect Configuration +# Used to determine when put the player's item into the backpack automatically +collect: + pickup: true # Pickup Items + kill: true # Kill Entities (Animals/Monsters) + break: true # Break Blocks + +sounds: + collect: "ENTITY_EXPERIENCE_ORB_PICKUP:0.5" + sell-success: "ENTITY_VILLAGER_CELEBRATE" + sell-fail: "ENTITY_VILLAGER_NO" + gui-click: "UI_BUTTON_CLICK" + +# General Configuration +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)" + + # 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" + + # Configuration of the SellGUI + sell-gui: + title: "&8Selling %(item_name)" + items: + add: + type: GREEN_STAINED_GLASS_PANE + name: "&aAdd %(amount)" + remove: + type: RED_STAINED_GLASS_PANE + name: "&cReduce %(amount)" + confirm: + type: EMERALD + name: "&a&lConfirm" + lore: + - " " + - "&7You will sell &r%(item_name) &8x &f%(amount)" + - "&7and will get $&e%(money) &7." + - " " + - "&a&lClick to confirm" + cancel: + type: REDSTONE + name: "&c&lCancel" + lore: + - " " + - "&cClick to cancel" \ No newline at end of file diff --git a/src/main/resources/i18n/ko_KR/config.yml b/src/main/resources/i18n/ko_KR/config.yml new file mode 100644 index 0000000..f309a69 --- /dev/null +++ b/src/main/resources/i18n/ko_KR/config.yml @@ -0,0 +1,91 @@ +# ${project.name} - ${project.description} +# Source url: ${project.url} +# Download URL: ${project.distributionManagement.downloadUrl} + +version: ${project.version} + +debug: false + +# bStats Metrics +# This option is used to help developers analysis plugin stats, +# and will never affect performance and user experience. +# You can choose to turn it off here. +metrics: true + +# Storage Configuration +storage: + + # Storage method + # You can choose [ yaml | json | mysql ] + 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) + # **Be aware of permission issues when using absolute paths!** + file-path: data + + # The Database configuration when choosing "mysql" method. + mysql: + driver: "com.mysql.jdbc.Driver" + url: "jdbc:mysql://127.0.0.1:3306/" + table: "ud_data" # Plugin data table name, allowing customization + username: "username" + password: "password" + + +# Player Collect Configuration +# Used to determine when put the player's item into the backpack automatically +collect: + pickup: true # Pickup Items + kill: true # Kill Entities (Animals/Monsters) + break: true # Break Blocks + +sounds: + collect: "ENTITY_EXPERIENCE_ORB_PICKUP:0.5" + sell-success: "ENTITY_VILLAGER_CELEBRATE" + sell-fail: "ENTITY_VILLAGER_NO" + gui-click: "UI_BUTTON_CLICK" + +# General Configuration +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)" + + # 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" + + # Configuration of the SellGUI + sell-gui: + title: "&8Selling %(item_name)" + items: + add: + type: GREEN_STAINED_GLASS_PANE + name: "&aAdd %(amount)" + remove: + type: RED_STAINED_GLASS_PANE + name: "&cReduce %(amount)" + confirm: + type: EMERALD + name: "&a&lConfirm" + lore: + - " " + - "&7You will sell &r%(item_name) &8x &f%(amount)" + - "&7and will get $&e%(money) &7." + - " " + - "&a&lClick to confirm" + cancel: + type: REDSTONE + name: "&c&lCancel" + lore: + - " " + - "&cClick to cancel" \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1233415..838eea3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,7 +9,7 @@ authors: - CarmJos - Zimrs -api-version: 1.13 +api-version: 1.16 softdepend: - PlaceholderAPI