9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-27 02:49:05 +00:00
This commit is contained in:
Xiao-MoMi
2022-08-01 01:24:00 +08:00
parent 55de5f1589
commit 9b6f40d894
8 changed files with 40 additions and 11 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
group = 'net.momirealms'
version = '1.8.0-PRE-2'
version = '1.8.1'
repositories {
mavenCentral()

View File

@@ -72,6 +72,7 @@ public class ConfigManager {
public static char start;
public static String folder_path;
public static String bg_folder_path;
public static String ss_folder_path;
public static String font;
public static String default_nameplate;
public static String player_prefix;
@@ -87,6 +88,7 @@ public class ConfigManager {
public static boolean hideSuffix;
public static boolean anotherFont;
public static boolean tab;
public static boolean oraxen;
public static int fontOffset;
public static void ReloadConfig(){
CustomNameplates.instance.saveDefaultConfig();
@@ -100,6 +102,7 @@ public class ConfigManager {
start = start_char.charAt(0);
folder_path = config.getString("config.nameplate-folder-path","font\\nameplates\\");
bg_folder_path = config.getString("config.background-folder-path","font\\backgrounds\\");
ss_folder_path = config.getString("config.space-split-folder-path","font\\");
default_nameplate = config.getString("config.default-nameplate");
player_prefix = config.getString("config.prefix");
player_suffix = config.getString("config.suffix");
@@ -129,7 +132,12 @@ public class ConfigManager {
if (tab){
if(CustomNameplates.instance.getServer().getPluginManager().getPlugin("TAB") == null){
tab = false;
CustomNameplates.instance.getLogger().warning("Failed to initialize TAB!");
}
}
oraxen = config.getBoolean("config.integrations.Oraxen",false);
if (oraxen){
if(CustomNameplates.instance.getServer().getPluginManager().getPlugin("Oraxen") == null){
oraxen = false;
}
}

View File

@@ -27,7 +27,7 @@ import java.util.HashMap;
public class TimerTaskA {
private final HashMap<Integer, BossBarSenderA> bossbarCache = new HashMap<>();
private HashMap<Integer, BossBarSenderA> bossbarCache = new HashMap<>();
public TimerTaskA(Player player){
ConfigManager.bossbarsA.forEach((key, bossbarConfig) -> {
@@ -43,5 +43,6 @@ public class TimerTaskA {
value.hideBossbar();
Bukkit.getScheduler().cancelTask(key);
});
bossbarCache = null;
}
}

View File

@@ -10,7 +10,7 @@ import java.util.HashMap;
public class TimerTaskP {
private final HashMap<Integer, BossBarSenderP> bossbarCache = new HashMap<>();
private HashMap<Integer, BossBarSenderP> bossbarCache = new HashMap<>();
public TimerTaskP(Player player){
ConfigManager.bossbarsP.forEach((key, bossbarConfig) -> {
@@ -18,6 +18,7 @@ public class TimerTaskP {
bossbar.showBossbar();
BukkitTask task = bossbar.runTaskTimerAsynchronously(CustomNameplates.instance, 1,1);
bossbarCache.put(task.getTaskId(), bossbar);
});
}
@@ -25,5 +26,6 @@ public class TimerTaskP {
bossbarCache.forEach((key,value)-> {
Bukkit.getScheduler().cancelTask(key);
});
bossbarCache = null;
}
}

View File

@@ -9,12 +9,9 @@ public class TABHook {
TAB tab = TAB.getInstance();
TabPlayer tabPlayer = tab.getPlayer(playerName);
String name = tabPlayer.getTeamName();
if (name == null) {
//System.out.println("TAB没有" + playerName);
return playerName;
}
//System.out.println("太好啦有team" + name);
return name;
}
}

View File

@@ -95,6 +95,7 @@ public class ResourceManager {
jsonObject_1.add("providers", jsonArray_1);
if (ConfigManager.MainConfig.anotherFont){
JsonObject jsonObject_2 = new JsonObject();
jsonObject_2.add("type", new JsonPrimitive("bitmap"));
jsonObject_2.add("file", new JsonPrimitive("minecraft:font/ascii.png"));
@@ -119,6 +120,14 @@ public class ResourceManager {
jsonArray_2.add("\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000");
jsonObject_2.add("chars", jsonArray_2);
jsonArray_1.add(jsonObject_2);
JsonObject jsonObject_3 = new JsonObject();
jsonObject_3.add("type", new JsonPrimitive("space"));
JsonObject jsonObject_4 = new JsonObject();
jsonObject_4.add(" ", new JsonPrimitive(4));
jsonObject_4.add("", new JsonPrimitive(0));
jsonObject_3.add("advances", jsonObject_4);
jsonArray_1.add(jsonObject_3);
}
if (ConfigManager.nameplate){
@@ -161,7 +170,7 @@ public class ResourceManager {
CustomNameplates.instance.saveResource("space_split.png", false); //复制space_split.png
try{
FileUtils.copyFile(new File(CustomNameplates.instance.getDataFolder(),"space_split.png"), new File(t_file.getPath() + File.separator + "space_split.png"));
FileUtils.copyFile(new File(CustomNameplates.instance.getDataFolder(),"space_split.png"), new File(t_file.getPath() + File.separator + ConfigManager.MainConfig.ss_folder_path + "space_split.png"));
}catch (IOException e){
e.printStackTrace();
AdventureManager.consoleMessage("<red>[CustomNameplates] Error! Failed to copy space_split.png to resource pack...</red>");
@@ -187,6 +196,15 @@ public class ResourceManager {
AdventureManager.consoleMessage("<red>[CustomNameplates] Error! Failed to copy files to ItemsAdder...</red>");
}
}
if (ConfigManager.MainConfig.oraxen){
try{
FileUtils.copyDirectory(g_file, new File(Bukkit.getPluginManager().getPlugin("Oraxen").getDataFolder() + File.separator + "pack"+ File.separator + "assets"));
AdventureManager.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Detected <color:#90EE90>Oraxen!<color:#baffd1> Automatically sent rp to Oraxen folder!");
}catch (IOException e){
e.printStackTrace();
AdventureManager.consoleMessage("<red>[CustomNameplates] Error! Failed to copy files to Oraxen...</red>");
}
}
}
private void saveDefaultResources() {
@@ -263,7 +281,7 @@ public class ResourceManager {
private JsonObject getNegativeFontChar(int height, char character) {
JsonObject jsonObject = new JsonObject();
jsonObject.add("type", new JsonPrimitive("bitmap"));
jsonObject.add("file", new JsonPrimitive(ConfigManager.MainConfig.namespace + ":space_split.png"));
jsonObject.add("file", new JsonPrimitive(ConfigManager.MainConfig.namespace + ":" + ConfigManager.MainConfig.ss_folder_path.replaceAll("\\\\","/") + "space_split.png"));
jsonObject.add("ascent", new JsonPrimitive(-5000));
jsonObject.add("height", new JsonPrimitive(height));
final JsonArray jsonArray = new JsonArray();

View File

@@ -9,11 +9,12 @@ config:
# Require restart to register papi
PlaceholderAPI: true
# When enabled, the plugin will automatically place the nameplates
# folder into the resource pack generated by ItemsAdder.
# folder into the resource pack generated by ItemsAdder/Oraxen.
ItemsAdder: false
Oraxen: false
# When enabled, the plugin will hook into TAB's team management
# require a restart to apply this
TAB: false
TAB: true
# Your namespace
# If you don't know how font works, don't change this
@@ -33,6 +34,7 @@ config:
# This is useful for those who want to keep their resource pack structure in order.
nameplate-folder-path: 'font\nameplates\'
background-folder-path: 'font\backgrounds\'
space-split-folder-path: 'font\'
# The initial character of all nameplates.
# 뀁 is the first character of Korean \ub001.

View File

@@ -9,6 +9,7 @@ softdepend:
- ItemsAdder
- PlaceholderAPI
- TAB
- Oraxen
commands:
customnameplates:
usage: /customnameplates help