mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-25 18:09:20 +00:00
1.8.9
This commit is contained in:
@@ -17,19 +17,12 @@
|
||||
|
||||
package net.momirealms.customnameplates;
|
||||
|
||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning;
|
||||
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.momirealms.customnameplates.background.BackGround;
|
||||
import net.momirealms.customnameplates.bossbar.adventure.BossBarConfigA;
|
||||
import net.momirealms.customnameplates.bossbar.protocollib.BossBarConfigP;
|
||||
import net.momirealms.customnameplates.bossbar.protocollib.Overlay;
|
||||
import net.momirealms.customnameplates.helper.Log;
|
||||
import net.momirealms.customnameplates.hook.Placeholders;
|
||||
import net.momirealms.customnameplates.utils.BGInfo;
|
||||
import net.momirealms.customnameplates.utils.NPInfo;
|
||||
@@ -39,7 +32,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -51,7 +43,6 @@ public class ConfigManager {
|
||||
public static HashMap<String, BGInfo> papiBG = new HashMap<>();
|
||||
public static HashMap<String, NPInfo> papiNP = new HashMap<>();
|
||||
public static HashMap<Character, Integer> fontWidth = new HashMap<>();
|
||||
private static Placeholders placeholders;
|
||||
|
||||
public static YamlConfiguration getConfig(String configName) {
|
||||
File file = new File(CustomNameplates.instance.getDataFolder(), configName);
|
||||
@@ -112,14 +103,9 @@ public class ConfigManager {
|
||||
public static boolean tab;
|
||||
public static boolean oraxen;
|
||||
public static int fontOffset;
|
||||
public static int version;
|
||||
public static void ReloadConfig(){
|
||||
|
||||
try {
|
||||
YamlDocument.create(new File(CustomNameplates.instance.getDataFolder(), "config.yml"), CustomNameplates.instance.getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build());
|
||||
}catch (IOException e){
|
||||
Log.warn(e.getMessage());
|
||||
}
|
||||
|
||||
CustomNameplates.instance.saveDefaultConfig();
|
||||
CustomNameplates.instance.reloadConfig();
|
||||
FileConfiguration config = CustomNameplates.instance.getConfig();
|
||||
@@ -142,6 +128,7 @@ public class ConfigManager {
|
||||
|
||||
itemsAdder = config.getBoolean("config.integrations.ItemsAdder",false);
|
||||
fontOffset = config.getInt("config.another-ascii-font.y-offset",3);
|
||||
version = config.getInt("config-version",1);
|
||||
if (itemsAdder){
|
||||
if(CustomNameplates.instance.getServer().getPluginManager().getPlugin("ItemsAdder") == null){
|
||||
CustomNameplates.instance.getLogger().warning("Failed to initialize ItemsAdder!");
|
||||
@@ -152,12 +139,7 @@ public class ConfigManager {
|
||||
if (placeholderAPI){
|
||||
if(CustomNameplates.instance.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null){
|
||||
loadPapi();
|
||||
if (placeholders != null){
|
||||
placeholders.unregister();
|
||||
}
|
||||
placeholders = new Placeholders();
|
||||
placeholders.register();
|
||||
AdventureManager.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>PlaceholderAPI Hooked!");
|
||||
|
||||
}else {
|
||||
CustomNameplates.instance.getLogger().warning("Failed to initialize PlaceholderAPI!");
|
||||
placeholderAPI = false;
|
||||
|
||||
@@ -30,9 +30,11 @@ import net.momirealms.customnameplates.data.SqlHandler;
|
||||
import net.momirealms.customnameplates.helper.LibraryLoader;
|
||||
import net.momirealms.customnameplates.hook.Placeholders;
|
||||
import net.momirealms.customnameplates.listener.PacketsListener;
|
||||
import net.momirealms.customnameplates.listener.PapiReload;
|
||||
import net.momirealms.customnameplates.listener.PlayerListener;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import net.momirealms.customnameplates.scoreboard.ScoreBoardManager;
|
||||
import net.momirealms.customnameplates.utils.UpdateConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -44,11 +46,11 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
public static JavaPlugin instance;
|
||||
public static BukkitAudiences adventure;
|
||||
public static ProtocolManager protocolManager;
|
||||
public static Placeholders placeholders;
|
||||
|
||||
private ResourceManager resourceManager;
|
||||
private DataManager dataManager;
|
||||
private ScoreBoardManager scoreBoardManager;
|
||||
private Placeholders placeholders;
|
||||
private Timer timer;
|
||||
private PacketsListener packetsListener;
|
||||
|
||||
@@ -97,6 +99,12 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
if (ConfigManager.MainConfig.tab){
|
||||
AdventureManager.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>TAB Hooked!");
|
||||
}
|
||||
if (ConfigManager.MainConfig.placeholderAPI){
|
||||
placeholders = new Placeholders();
|
||||
placeholders.register();
|
||||
Bukkit.getPluginManager().registerEvents(new PapiReload(), this);
|
||||
AdventureManager.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>PlaceholderAPI Hooked!");
|
||||
}
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("customnameplates")).setExecutor(new Execute(this));
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("customnameplates")).setTabCompleter(new TabComplete());
|
||||
this.resourceManager = new ResourceManager(this);
|
||||
@@ -108,6 +116,9 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
instance.getPluginLoader().disablePlugin(instance);
|
||||
return;
|
||||
}
|
||||
if (ConfigManager.MainConfig.version != 1){
|
||||
UpdateConfig.update();
|
||||
}
|
||||
AdventureManager.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Plugin Enabled!");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@ import java.util.Optional;
|
||||
|
||||
public class PacketsListener extends PacketAdapter {
|
||||
|
||||
private final CustomNameplates plugin;
|
||||
|
||||
public PacketsListener(CustomNameplates plugin) {
|
||||
super(plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.SCOREBOARD_TEAM);
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.momirealms.customnameplates.listener;
|
||||
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class PapiReload implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onReload(me.clip.placeholderapi.events.ExpansionUnregisterEvent event){
|
||||
if (CustomNameplates.placeholders != null){
|
||||
if (event.getExpansion().equals(CustomNameplates.placeholders)){
|
||||
CustomNameplates.placeholders.register();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.momirealms.customnameplates.utils;
|
||||
|
||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning;
|
||||
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.helper.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class UpdateConfig {
|
||||
|
||||
public static void update(){
|
||||
try {
|
||||
YamlDocument.create(new File(CustomNameplates.instance.getDataFolder(), "config.yml"), CustomNameplates.instance.getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build());
|
||||
}catch (IOException e){
|
||||
Log.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ config:
|
||||
|
||||
# Customize the folder where png files should be generated.
|
||||
# This is useful for those who want to keep their resource pack structure in order.
|
||||
# if you are using Linux, use / instead
|
||||
nameplate-folder-path: 'font\nameplates\'
|
||||
background-folder-path: 'font\backgrounds\'
|
||||
space-split-folder-path: 'font\'
|
||||
|
||||
Reference in New Issue
Block a user