mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-31 04:36:29 +00:00
1.8.0-SNAPSHOT
This commit is contained in:
@@ -1,7 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.hook;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.background.BackGround;
|
||||
import net.momirealms.customnameplates.font.FontCache;
|
||||
import net.momirealms.customnameplates.font.FontWidth;
|
||||
import net.momirealms.customnameplates.font.FontWidthThin;
|
||||
import net.momirealms.customnameplates.nameplates.NameplateUtil;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import net.momirealms.customnameplates.scoreboard.ScoreBoardManager;
|
||||
import net.momirealms.customnameplates.utils.BGInfo;
|
||||
import net.momirealms.customnameplates.utils.NPInfo;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -34,6 +61,54 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
return ScoreBoardManager.teams.get(player.getName()).getSuffixText();
|
||||
}
|
||||
}
|
||||
if (params.startsWith("bg_")){
|
||||
String bg = params.substring(3);
|
||||
BGInfo bgInfo = ConfigManager.papiBG.get(bg);
|
||||
if (bgInfo != null){
|
||||
BackGround backGround = ConfigManager.backgrounds.get(bgInfo.getBackground());
|
||||
if (backGround != null){
|
||||
String text;
|
||||
if (ConfigManager.MainConfig.placeholderAPI){
|
||||
text = PlaceholderAPI.setPlaceholders(player, bgInfo.getText());
|
||||
}else {
|
||||
text = bgInfo.getText();
|
||||
}
|
||||
if (ConfigManager.MainConfig.thin_font){
|
||||
return backGround.getBackGround(FontWidthThin.getTotalWidth(text));
|
||||
}else {
|
||||
return backGround.getBackGround(FontWidth.getTotalWidth(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.startsWith("npp_")){
|
||||
String np = params.substring(4);
|
||||
NPInfo npInfo = ConfigManager.papiNP.get(np);
|
||||
if (npInfo != null){
|
||||
FontCache fontCache = ResourceManager.caches.get(npInfo.getNameplate());
|
||||
if (fontCache != null){
|
||||
if (ConfigManager.MainConfig.placeholderAPI){
|
||||
return new NameplateUtil(fontCache).makeCustomNameplate("", PlaceholderAPI.setPlaceholders(player, npInfo.getText()),"");
|
||||
}else {
|
||||
return new NameplateUtil(fontCache).makeCustomNameplate("", npInfo.getText(),"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.startsWith("nps_")){
|
||||
String np = params.substring(4);
|
||||
NPInfo npInfo = ConfigManager.papiNP.get(np);
|
||||
if (npInfo != null){
|
||||
FontCache fontCache = ResourceManager.caches.get(npInfo.getNameplate());
|
||||
if (fontCache != null){
|
||||
if (ConfigManager.MainConfig.placeholderAPI){
|
||||
return new NameplateUtil(fontCache).getSuffixLength(PlaceholderAPI.setPlaceholders(player, npInfo.getText()));
|
||||
}else {
|
||||
return new NameplateUtil(fontCache).getSuffixLength(npInfo.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user