9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2026-01-03 06:02:32 +00:00

2.2.0-temp

This commit is contained in:
Xiao-MoMi
2023-03-29 01:37:51 +08:00
parent 3d0e37623c
commit f3c08658bd
260 changed files with 5566 additions and 5576 deletions

View File

@@ -1,75 +1,101 @@
package net.momirealms.customnameplates.manager;
import net.kyori.adventure.key.Key;
import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.objects.Function;
import net.momirealms.customnameplates.utils.ConfigUtil;
import net.momirealms.customnameplates.object.Function;
import net.momirealms.customnameplates.utils.ConfigUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import java.util.List;
public class ConfigManager extends Function {
public static String namespace;
public static String fontName;
public static String start_char;
public static String lang;
public static String np_folder_path;
public static String bg_folder_path;
public static String ss_folder_path;
public static String bb_folder_path;
public static String font;
public static String lang;
public static String nameplates_folder_path;
public static String backgrounds_folder_path;
public static String space_split_folder_path;
public static String bubbles_folder_path;
public static String images_folder_path;
public static boolean itemsAdderHook;
public static boolean thin_font;
public static boolean tab_hook;
public static boolean tab_BC_hook;
public static boolean oraxenHook;
public static boolean extract;
public static boolean trChat_Hook;
public static boolean ventureChat_Hook;
public static List<Integer> offsets;
public static char start;
public static Key key;
public static boolean extract;
public static char start_char;
public static boolean checkUpdate;
public static boolean enableBStats;
public static boolean enableNameplates;
public static boolean enableBossBar;
public static boolean enableActionBar;
public static boolean enableBubbles;
public static boolean enableBackground;
public static boolean enableImages;
public ConfigManager() {
load();
@Override
public void load(){
ConfigUtils.update("config.yml");
YamlConfiguration config = ConfigUtils.getConfig("config.yml");
lang = config.getString("lang");
enableBStats = config.getBoolean("config.metrics", true);
checkUpdate = config.getBoolean("update-checker", true);
loadModules(config);
loadIntegrations(config);
loadResourcePack(config);
}
public void load(){
ConfigUtil.update("config.yml");
YamlConfiguration config = ConfigUtil.getConfig("config.yml");
lang = config.getString("config.lang");
namespace = config.getString("config.namespace");
font = config.getString("config.font");
fontName = namespace + ":" + font;
start_char = config.getString("config.start-char");
assert start_char != null;
start = start_char.charAt(0);
np_folder_path = config.getString("config.nameplate-folder-path","font\\nameplates\\");
bb_folder_path = config.getString("config.bubble-folder-path","font\\bubbles\\");
bg_folder_path = config.getString("config.background-folder-path","font\\backgrounds\\");
ss_folder_path = config.getString("config.space-split-folder-path","font\\");
key = Key.key(fontName);
thin_font = config.getBoolean("config.use-thin-font",false);
itemsAdderHook = config.getBoolean("config.integrations.ItemsAdder",false);
if (itemsAdderHook && Bukkit.getPluginManager().getPlugin("ItemsAdder") == null) itemsAdderHook = false;
tab_hook = config.getBoolean("config.integrations.TAB",false);
tab_BC_hook = config.getBoolean("config.integrations.TAB-BC",false);
oraxenHook = config.getBoolean("config.integrations.Oraxen",false);
if (oraxenHook && Bukkit.getPluginManager().getPlugin("Oraxen") == null) oraxenHook = false;
trChat_Hook = config.getBoolean("config.integrations.TrChat",false);
ventureChat_Hook = config.getBoolean("config.integrations.VentureChat",false);
offsets = config.getIntegerList("config.ascii-y-offset.offset");
extract = config.getBoolean("config.extract-shader",true);
if (tab_hook && Bukkit.getPluginManager().getPlugin("TAB") == null) {
tab_hook = false;
private void loadIntegrations(ConfigurationSection config) {
ConfigurationSection section = config.getConfigurationSection("integrations");
if (section != null) {
tab_hook = section.getBoolean("TAB",false) && Bukkit.getPluginManager().isPluginEnabled("TAB");
tab_BC_hook = section.getBoolean("TAB-BC",false);
trChat_Hook = section.getBoolean("TrChat",false) && Bukkit.getPluginManager().isPluginEnabled("TrChat");
itemsAdderHook = section.getBoolean("ItemsAdder",false) && Bukkit.getPluginManager().isPluginEnabled("ItemsAdder");
oraxenHook = section.getBoolean("Oraxen",false) && Bukkit.getPluginManager().isPluginEnabled("Oraxen");
ventureChat_Hook = section.getBoolean("VentureChat",false) && Bukkit.getPluginManager().isPluginEnabled("VentureChat");
}
}
if (trChat_Hook && CustomNameplates.plugin.getServer().getPluginManager().getPlugin("TrChat") == null){
CustomNameplates.plugin.getLogger().warning("Failed to initialize TrChat!");
trChat_Hook = false;
private void loadResourcePack(ConfigurationSection config) {
ConfigurationSection section = config.getConfigurationSection("resource-pack");
if (section != null) {
namespace = section.getString("namespace", "nameplates");
font = section.getString("font", "default");
start_char = section.getString("config.left-char", "").charAt(0);
nameplates_folder_path = section.getString("image-path.nameplates","font\\nameplates\\");
bubbles_folder_path = section.getString("image-path.bubbles","font\\bubbles\\");
backgrounds_folder_path = section.getString("image-path.backgrounds","font\\backgrounds\\");
space_split_folder_path = section.getString("image-path.space-split","font\\base\\");
images_folder_path = section.getString("image-path.images","font\\images\\");
thin_font = section.getBoolean("use-thin-font",false);
extract = section.getBoolean("extract-shader",true);
}
}
private void loadModules(ConfigurationSection config) {
ConfigurationSection section = config.getConfigurationSection("modules");
if (section != null) {
enableNameplates = section.getBoolean("nameplates");
enableBossBar = section.getBoolean("bossbars");
enableActionBar = section.getBoolean("actionbars");
enableBubbles = section.getBoolean("bubbles");
enableBackground = section.getBoolean("backgrounds");
enableImages = section.getBoolean("images");
}
}
public static String getMiniMessageFontTag() {
return "<font:" + namespace + ":" + font + ">";
}
public static String getFontTagCloser() {
return "</font>";
}
public static String surroundWithFont(String text) {
return getMiniMessageFontTag() + text + getFontTagCloser();
}
}