mirror of
https://github.com/CarmJos/UserPrefix.git
synced 2024-09-19 20:15:47 +00:00
2.1.7 提供自定义配置文件存储位置的功能
This commit is contained in:
parent
83b9ced6f5
commit
1a2644210b
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<artifactId>userprefix</artifactId>
|
||||
<version>2.1.6</version>
|
||||
<version>2.1.7</version>
|
||||
|
||||
<name>UserPrefix</name>
|
||||
<description>轻便、高效、实时的用户前缀系统。</description>
|
||||
|
@ -11,6 +11,14 @@ public class PrefixConfig {
|
||||
|
||||
public static ConfigValue<Boolean> DEBUG = new ConfigValue<>("debug", Boolean.class, false);
|
||||
|
||||
public static class CustomStorage {
|
||||
|
||||
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
|
||||
|
||||
public static ConfigValue<String> PATH = new ConfigValue<>("custom-storage.path", String.class, "prefixes/");
|
||||
|
||||
}
|
||||
|
||||
public static class Functions {
|
||||
|
||||
public static ConfigValue<Boolean> NAME_PREFIX = new ConfigValue<>("functions.OnNamePrefix", Boolean.class, true);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.carm.plugin.userprefix.manager;
|
||||
|
||||
import cc.carm.plugin.userprefix.Main;
|
||||
import cc.carm.plugin.userprefix.configuration.PrefixConfig;
|
||||
import cc.carm.plugin.userprefix.model.ConfiguredPrefix;
|
||||
import cc.carm.plugin.userprefix.util.ItemStackFactory;
|
||||
import org.bukkit.Material;
|
||||
@ -37,7 +38,7 @@ public class PrefixManager {
|
||||
|
||||
public static void loadConfiguredPrefixes() {
|
||||
|
||||
File prefixDataFolder = new File(Main.getInstance().getDataFolder() + File.separator + FOLDER_NAME);
|
||||
File prefixDataFolder = getStorageFolder();
|
||||
if (!prefixDataFolder.isDirectory() || !prefixDataFolder.exists()) {
|
||||
prefixDataFolder.mkdir();
|
||||
}
|
||||
@ -150,5 +151,18 @@ public class PrefixManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static File getStorageFolder() {
|
||||
if (PrefixConfig.CustomStorage.ENABLE.get()) {
|
||||
String path = PrefixConfig.CustomStorage.PATH.get();
|
||||
if (path.startsWith(File.separator)) {
|
||||
return new File(path);
|
||||
} else {
|
||||
return new File(Main.getInstance().getDataFolder() + File.separator + path);
|
||||
}
|
||||
} else {
|
||||
return new File(Main.getInstance().getDataFolder() + File.separator + FOLDER_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,14 @@ version: ${project.version}
|
||||
|
||||
debug: false
|
||||
|
||||
custom-storage:
|
||||
# 自定义存储位置
|
||||
# 默认存储位置为 “插件文件夹”/prefixes
|
||||
# 可以规定到远程文件夹中去寻找前缀相关的设定
|
||||
# 支持绝对文件路径,如 "/etc/minecraft/configurations/prefixes/"
|
||||
enable: false # 是否启用
|
||||
path: "prefixes/" # 一定要指向一个文件夹!
|
||||
|
||||
functions:
|
||||
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
|
||||
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个
|
||||
|
@ -2,6 +2,13 @@ version: ${project.version} # DO NOT EDIT IT
|
||||
|
||||
debug: false #DEBUG OUT PUT
|
||||
|
||||
custom-storage:
|
||||
# Custom storage location
|
||||
# default location is "./prefixes"
|
||||
# Support absolute file path , such as "/etc/minecraft/configurations/prefixes/"
|
||||
enable: false
|
||||
path: "prefixes/" # Must be a folder!
|
||||
|
||||
GUI:
|
||||
title: "&f&lMy Prefixes List" # Title of the GUI
|
||||
items:
|
||||
|
Loading…
Reference in New Issue
Block a user