fix images
6
.gitignore
vendored
@@ -1,14 +1,12 @@
|
|||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
|
target/
|
||||||
!gradle/wrapper/gradle-wrapper.jar
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
!**/src/main/**/build/
|
!**/src/main/**/build/
|
||||||
!**/src/test/**/build/
|
!**/src/test/**/build/
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
### IntelliJ IDEA ###
|
||||||
.idea/modules.xml
|
.idea
|
||||||
.idea/jarRepositories.xml
|
|
||||||
.idea/compiler.xml
|
|
||||||
.idea/libraries/
|
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ public class BackGround {
|
|||||||
ConfiguredChar offset_128,
|
ConfiguredChar offset_128,
|
||||||
ConfiguredChar right,
|
ConfiguredChar right,
|
||||||
int leftMargin,
|
int leftMargin,
|
||||||
int rightMargin
|
int rightMargin,
|
||||||
|
boolean removeShadow
|
||||||
) {
|
) {
|
||||||
this.left = left;
|
this.left = left;
|
||||||
this.offset_1 = offset_1;
|
this.offset_1 = offset_1;
|
||||||
|
|||||||
@@ -26,13 +26,15 @@ public class BackGroundText {
|
|||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
private BackGround backGround;
|
private BackGround backGround;
|
||||||
|
private boolean removeShadow;
|
||||||
|
|
||||||
private BackGroundText() {
|
private BackGroundText() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackGroundText(String text, BackGround backGround) {
|
public BackGroundText(String text, BackGround backGround, boolean removeShadow) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.backGround = backGround;
|
this.backGround = backGround;
|
||||||
|
this.removeShadow = removeShadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
@@ -46,7 +48,8 @@ public class BackGroundText {
|
|||||||
public String getValue(OfflinePlayer player) {
|
public String getValue(OfflinePlayer player) {
|
||||||
String parsed = PlaceholderAPI.setPlaceholders(player, text);
|
String parsed = PlaceholderAPI.setPlaceholders(player, text);
|
||||||
int parsedWidth = FontUtils.getTextWidth(parsed);
|
int parsedWidth = FontUtils.getTextWidth(parsed);
|
||||||
return FontUtils.surroundNameplateFont(backGround.getBackGroundImage(parsedWidth)) + parsed;
|
String bg = FontUtils.surroundNameplateFont(backGround.getBackGroundImage(parsedWidth));
|
||||||
|
return (removeShadow ? "<#FFFEFD>" + bg + "</#FFFEFD>" : bg)+ parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
@@ -75,6 +78,11 @@ public class BackGroundText {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder removeShadow(boolean remove) {
|
||||||
|
text.removeShadow = remove;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public BackGroundText build() {
|
public BackGroundText build() {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
version = "2.3.0.0-beta-1"
|
version = "2.3.0.0-beta-2"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
systemProp.socks.proxyHost=127.0.0.1
|
||||||
|
systemProp.socks.proxyPort=7890
|
||||||
|
|
||||||
|
systemProp.http.proxyHost=127.0.0.1
|
||||||
|
systemProp.http.proxyPort=7890
|
||||||
|
|
||||||
|
systemProp.https.proxyHost=127.0.0.1
|
||||||
|
systemProp.https.proxyPort=7890
|
||||||
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package net.momirealms.customnameplates.paper;
|
package net.momirealms.customnameplates.paper;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||||
import net.momirealms.customnameplates.api.event.CustomNameplatesReloadEvent;
|
import net.momirealms.customnameplates.api.event.CustomNameplatesReloadEvent;
|
||||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
@@ -43,11 +44,16 @@ import net.momirealms.customnameplates.paper.setting.CNLocale;
|
|||||||
import net.momirealms.customnameplates.paper.storage.StorageManagerImpl;
|
import net.momirealms.customnameplates.paper.storage.StorageManagerImpl;
|
||||||
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
|
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin {
|
public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implements Listener {
|
||||||
|
|
||||||
private CoolDownManager coolDownManager;
|
private CoolDownManager coolDownManager;
|
||||||
private PacketManager packetManager;
|
private PacketManager packetManager;
|
||||||
@@ -83,6 +89,7 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin {
|
|||||||
if (!outDated) this.getAdventure().sendConsoleMessage("[CustomNameplates] You are using the latest version.");
|
if (!outDated) this.getAdventure().sendConsoleMessage("[CustomNameplates] You are using the latest version.");
|
||||||
else this.getAdventure().sendConsoleMessage("[CustomNameplates] Update is available: <u>https://polymart.org/resource/2543<!u>");
|
else this.getAdventure().sendConsoleMessage("[CustomNameplates] Update is available: <u>https://polymart.org/resource/2543<!u>");
|
||||||
});
|
});
|
||||||
|
this.getServer().getPluginManager().registerEvents((VersionManagerImpl) versionManager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,6 +108,7 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin {
|
|||||||
((WidthManagerImpl) this.widthManager).unload();
|
((WidthManagerImpl) this.widthManager).unload();
|
||||||
((StorageManagerImpl) this.storageManager).disable();
|
((StorageManagerImpl) this.storageManager).disable();
|
||||||
((AdventureManagerImpl) this.adventureManager).close();
|
((AdventureManagerImpl) this.adventureManager).close();
|
||||||
|
HandlerList.unregisterAll((VersionManagerImpl) versionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
|||||||
import net.momirealms.customnameplates.api.mechanic.font.FontData;
|
import net.momirealms.customnameplates.api.mechanic.font.FontData;
|
||||||
import net.momirealms.customnameplates.api.mechanic.font.OffsetFont;
|
import net.momirealms.customnameplates.api.mechanic.font.OffsetFont;
|
||||||
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
||||||
|
import net.momirealms.customnameplates.api.mechanic.placeholder.DescentText;
|
||||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
import net.momirealms.customnameplates.common.Key;
|
import net.momirealms.customnameplates.common.Key;
|
||||||
import net.momirealms.customnameplates.common.Tuple;
|
import net.momirealms.customnameplates.common.Tuple;
|
||||||
@@ -126,6 +127,37 @@ public class WidthManagerImpl implements WidthManager {
|
|||||||
registerFontData(
|
registerFontData(
|
||||||
Key.of(CNConfig.namespace, CNConfig.font), fontData
|
Key.of(CNConfig.namespace, CNConfig.font), fontData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ArrayList<Integer> ascentTexts = new ArrayList<>();
|
||||||
|
ArrayList<Integer> ascentUnicodes = new ArrayList<>();
|
||||||
|
for (DescentText descentText : plugin.getPlaceholderManager().getDescentTexts()) {
|
||||||
|
if (descentText.isUnicode()) {
|
||||||
|
ascentUnicodes.add(descentText.getAscent());
|
||||||
|
} else {
|
||||||
|
ascentTexts.add(descentText.getAscent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ascentTexts.removeAll(ascentUnicodes);
|
||||||
|
|
||||||
|
for (int ascent : ascentTexts) {
|
||||||
|
FontData descentFont = new FontData(8);
|
||||||
|
descentFont.overrideWith(NONLATIN_EUROPEAN_DATA);
|
||||||
|
descentFont.overrideWith(ACCENTED_DATA);
|
||||||
|
descentFont.overrideWith(ASCII_DATA);
|
||||||
|
registerFontData(
|
||||||
|
Key.of(CNConfig.namespace, "ascent_" + ascent), descentFont
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (int ascent : ascentUnicodes) {
|
||||||
|
FontData descentFont = new FontData(8);
|
||||||
|
descentFont.overrideWith(UNICODE_DATA);
|
||||||
|
descentFont.overrideWith(NONLATIN_EUROPEAN_DATA);
|
||||||
|
descentFont.overrideWith(ACCENTED_DATA);
|
||||||
|
descentFont.overrideWith(ASCII_DATA);
|
||||||
|
registerFontData(
|
||||||
|
Key.of(CNConfig.namespace, "ascent_" + ascent), descentFont
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadUserConfigs() {
|
private void loadUserConfigs() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import net.momirealms.customnameplates.api.mechanic.character.CharacterArranger;
|
|||||||
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
||||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||||
|
import net.momirealms.customnameplates.paper.util.ImageUtils;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -91,6 +92,11 @@ public class ImageManagerImpl implements ImageManager {
|
|||||||
LogUtils.warn("Found duplicated image: " + key);
|
LogUtils.warn("Found duplicated image: " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File[] pgFiles = imgFolder.listFiles(file -> file.getName().endsWith(".png"));
|
||||||
|
for (File pg : pgFiles) {
|
||||||
|
ImageUtils.removeImageShadow(pg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,9 +17,15 @@
|
|||||||
|
|
||||||
package net.momirealms.customnameplates.paper.mechanic.misc;
|
package net.momirealms.customnameplates.paper.mechanic.misc;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.momirealms.customnameplates.api.manager.VersionManager;
|
import net.momirealms.customnameplates.api.manager.VersionManager;
|
||||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
|
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
|
||||||
|
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -31,7 +37,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
/**
|
/**
|
||||||
* This class implements the VersionManager interface and is responsible for managing version-related information.
|
* This class implements the VersionManager interface and is responsible for managing version-related information.
|
||||||
*/
|
*/
|
||||||
public class VersionManagerImpl implements VersionManager {
|
public class VersionManagerImpl implements VersionManager, Listener {
|
||||||
|
|
||||||
private final boolean isNewerThan1_19;
|
private final boolean isNewerThan1_19;
|
||||||
private final boolean isNewerThan1_19_R2;
|
private final boolean isNewerThan1_19_R2;
|
||||||
@@ -224,4 +230,14 @@ public class VersionManagerImpl implements VersionManager {
|
|||||||
}
|
}
|
||||||
return newVS.length > currentVS.length;
|
return newVS.length > currentVS.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (player.isOp()) {
|
||||||
|
if (!PlaceholderAPI.isRegistered("player")) {
|
||||||
|
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, "You haven't installed Player Expansion yet. Click <b><gold><click:run_command:/papi ecloud download Player>HERE</click></gold><b> to download.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,9 @@ import net.momirealms.customnameplates.api.util.LogUtils;
|
|||||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||||
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -235,6 +238,8 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ascentTexts.removeAll(ascentUnicodes);
|
||||||
|
|
||||||
for (int ascent : ascentTexts) {
|
for (int ascent : ascentTexts) {
|
||||||
String line;
|
String line;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -313,20 +318,41 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void copyResourcePackToHookedPlugins(File resourcePackFolder) {
|
private void copyResourcePackToHookedPlugins(File resourcePackFolder) {
|
||||||
|
Plugin ia = Bukkit.getPluginManager().getPlugin("ItemsAdder");
|
||||||
|
if (ia != null) {
|
||||||
|
File file = new File(ia.getDataFolder(), "config.yml");
|
||||||
|
YamlConfiguration iaConfig = YamlConfiguration.loadConfiguration(file);
|
||||||
|
List<String> folders = iaConfig.getStringList("resource-pack.zip.merge_other_plugins_resourcepacks_folders");
|
||||||
|
boolean changed = false;
|
||||||
if (CNConfig.copyPackIA) {
|
if (CNConfig.copyPackIA) {
|
||||||
|
if (!folders.contains("CustomNameplates/ResourcePack")) {
|
||||||
|
folders.add("CustomNameplates/ResourcePack");
|
||||||
|
iaConfig.set("resource-pack.zip.merge_other_plugins_resourcepacks_folders", folders);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (folders.contains("CustomNameplates/ResourcePack")) {
|
||||||
|
folders.remove("CustomNameplates/ResourcePack");
|
||||||
|
iaConfig.set("resource-pack.zip.merge_other_plugins_resourcepacks_folders", folders);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) {
|
||||||
try {
|
try {
|
||||||
FileUtils.copyDirectory(new File(resourcePackFolder, "assets"), new File(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("ItemsAdder")).getDataFolder() + File.separator + "contents" + File.separator + "nameplates" + File.separator + "resourcepack" + File.separator + "assets") );
|
iaConfig.save(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CNConfig.copyPackOraxen) {
|
|
||||||
try {
|
|
||||||
FileUtils.copyDirectory(new File(resourcePackFolder, "assets"), new File(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("Oraxen")).getDataFolder() + File.separator + "pack" + File.separator + "assets"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (CNConfig.copyPackOraxen) {
|
||||||
|
// try {
|
||||||
|
// FileUtils.copyDirectory(new File(resourcePackFolder, "assets"), new File(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("Oraxen")).getDataFolder() + File.separator + "pack" + File.separator + "assets"));
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<JsonObject> getNameplates(File texturesFolder) {
|
private List<JsonObject> getNameplates(File texturesFolder) {
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
|||||||
BackGroundText.builder()
|
BackGroundText.builder()
|
||||||
.background(Objects.requireNonNull(plugin.getBackGroundManager().getBackGround(innerSection.getString("background"))))
|
.background(Objects.requireNonNull(plugin.getBackGroundManager().getBackGround(innerSection.getString("background"))))
|
||||||
.text(innerSection.getString("text", ""))
|
.text(innerSection.getString("text", ""))
|
||||||
|
.removeShadow(innerSection.getBoolean("remove-shadow"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -228,7 +229,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
|||||||
DescentText.builder()
|
DescentText.builder()
|
||||||
.descent(innerSection.getInt("descent", 0))
|
.descent(innerSection.getInt("descent", 0))
|
||||||
.text(innerSection.getString("text", ""))
|
.text(innerSection.getString("text", ""))
|
||||||
.unicode(unicode)
|
.unicode(unicode || innerSection.getBoolean("is-unicode"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,16 +23,14 @@ import com.google.common.io.ByteArrayDataOutput;
|
|||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||||
import net.momirealms.customnameplates.api.manager.TeamManager;
|
import net.momirealms.customnameplates.api.manager.TeamManager;
|
||||||
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
import net.momirealms.customnameplates.common.message.MessageType;
|
import net.momirealms.customnameplates.common.message.MessageType;
|
||||||
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
||||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||||
import net.momirealms.customnameplates.paper.mechanic.misc.PacketManager;
|
import net.momirealms.customnameplates.paper.mechanic.misc.PacketManager;
|
||||||
import net.momirealms.customnameplates.paper.mechanic.team.packet.*;
|
import net.momirealms.customnameplates.paper.mechanic.team.packet.*;
|
||||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.CMIProvider;
|
import net.momirealms.customnameplates.paper.mechanic.team.provider.*;
|
||||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.DefaultProvider;
|
|
||||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.TABProvider;
|
|
||||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.TeamProvider;
|
|
||||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -57,9 +55,14 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void createTeam(Player player) {
|
public void createTeam(Player player) {
|
||||||
if (CNConfig.disableTeamManage) return;
|
if (CNConfig.disableTeamManage) return;
|
||||||
|
String team = teamProvider.getTeam(player);
|
||||||
|
if (team == null) {
|
||||||
|
LogUtils.warn("Failed to get player " + player.getName() + "'s team.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
|
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
|
||||||
TeamCreate.builder()
|
TeamCreate.builder()
|
||||||
.teamName(teamProvider.getTeam(player))
|
.teamName(team)
|
||||||
.color(TeamColor.WHITE)
|
.color(TeamColor.WHITE)
|
||||||
.display("")
|
.display("")
|
||||||
.prefix("")
|
.prefix("")
|
||||||
@@ -72,9 +75,10 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
PacketManager.getInstance().send(online, createOwner);
|
PacketManager.getInstance().send(online, createOwner);
|
||||||
if (online == player) continue;
|
if (online == player) continue;
|
||||||
|
String onlineTeam = teamProvider.getTeam(online);
|
||||||
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
|
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
|
||||||
TeamCreate.builder()
|
TeamCreate.builder()
|
||||||
.teamName(teamProvider.getTeam(online))
|
.teamName(onlineTeam)
|
||||||
.color(TeamColor.WHITE)
|
.color(TeamColor.WHITE)
|
||||||
.display("")
|
.display("")
|
||||||
.prefix("")
|
.prefix("")
|
||||||
@@ -91,9 +95,10 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void removeTeam(Player player) {
|
public void removeTeam(Player player) {
|
||||||
if (CNConfig.disableTeamManage) return;
|
if (CNConfig.disableTeamManage) return;
|
||||||
|
String team = teamProvider.getTeam(player);
|
||||||
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
|
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
|
||||||
TeamRemove.builder()
|
TeamRemove.builder()
|
||||||
.teamName(teamProvider.getTeam(player))
|
.teamName(team)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
@@ -105,6 +110,7 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void updateTeam(Player owner, Player viewer, String prefix, String suffix, TeamColor color, TeamTagVisibility visibility) {
|
public void updateTeam(Player owner, Player viewer, String prefix, String suffix, TeamColor color, TeamTagVisibility visibility) {
|
||||||
if (CNConfig.disableTeamManage) return;
|
if (CNConfig.disableTeamManage) return;
|
||||||
|
String team = teamProvider.getTeam(owner);
|
||||||
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
|
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
|
||||||
color = TeamColor.WHITE;
|
color = TeamColor.WHITE;
|
||||||
if (plugin.getNameplateManager().isProxyMode()) {
|
if (plugin.getNameplateManager().isProxyMode()) {
|
||||||
@@ -120,7 +126,7 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
} else {
|
} else {
|
||||||
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
|
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
|
||||||
TeamUpdate.builder()
|
TeamUpdate.builder()
|
||||||
.teamName(teamProvider.getTeam(owner))
|
.teamName(team)
|
||||||
.color(color)
|
.color(color)
|
||||||
.display("")
|
.display("")
|
||||||
.prefix(prefix)
|
.prefix(prefix)
|
||||||
@@ -148,6 +154,8 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
teamProvider = new TABProvider();
|
teamProvider = new TABProvider();
|
||||||
} else if (CNConfig.cmiTeam) {
|
} else if (CNConfig.cmiTeam) {
|
||||||
teamProvider = new CMIProvider();
|
teamProvider = new CMIProvider();
|
||||||
|
} else if (CNConfig.unknownTeam) {
|
||||||
|
teamProvider = new UnknownProvider();
|
||||||
} else {
|
} else {
|
||||||
teamProvider = new DefaultProvider();
|
teamProvider = new DefaultProvider();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class CMIProvider implements TeamProvider {
|
|||||||
@Override
|
@Override
|
||||||
public String getTeam(Player player) {
|
public String getTeam(Player player) {
|
||||||
Team team = CMI.getInstance().getSB().getPlayerTeam(player);
|
Team team = CMI.getInstance().getSB().getPlayerTeam(player);
|
||||||
if (team == null) return player.getName();
|
if (team == null) return null;
|
||||||
return team.getName();
|
return team.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.paper.mechanic.team.provider;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
public class UnknownProvider implements TeamProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTeam(Player player) {
|
||||||
|
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
|
Team team = scoreboard.getPlayerTeam(player);
|
||||||
|
if (team == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return team.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -79,6 +79,7 @@ public class CNConfig {
|
|||||||
public static boolean textEffects;
|
public static boolean textEffects;
|
||||||
public static boolean disableTeamManage;
|
public static boolean disableTeamManage;
|
||||||
public static boolean velocitab;
|
public static boolean velocitab;
|
||||||
|
public static boolean unknownTeam;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
try {
|
try {
|
||||||
@@ -128,6 +129,7 @@ public class CNConfig {
|
|||||||
tabTeam = integrationSection.getBoolean("team.TAB", false);
|
tabTeam = integrationSection.getBoolean("team.TAB", false);
|
||||||
cmiTeam = integrationSection.getBoolean("team.CMI", false);
|
cmiTeam = integrationSection.getBoolean("team.CMI", false);
|
||||||
velocitab = integrationSection.getBoolean("team.Velocitab", false);
|
velocitab = integrationSection.getBoolean("team.Velocitab", false);
|
||||||
|
unknownTeam = integrationSection.getBoolean("team.unknown", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationSection packSection = config.getConfigurationSection("resource-pack");
|
ConfigurationSection packSection = config.getConfigurationSection("resource-pack");
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package net.momirealms.customnameplates.paper.util;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ImageUtils {
|
||||||
|
|
||||||
|
public static void removeImageShadow(File file) {
|
||||||
|
try {
|
||||||
|
BufferedImage inputImage = ImageIO.read(file);
|
||||||
|
|
||||||
|
int width = inputImage.getWidth();
|
||||||
|
int height = inputImage.getHeight();
|
||||||
|
BufferedImage outputImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
int[] pixels = new int[width * height];
|
||||||
|
inputImage.getRGB(0, 0, width, height, pixels, 0, width);
|
||||||
|
for (int i = 0; i < pixels.length; i++) {
|
||||||
|
int alpha = (pixels[i] >> 24) & 0xFF;
|
||||||
|
int red = (pixels[i] >> 16) & 0xFF;
|
||||||
|
int green = (pixels[i] >> 8) & 0xFF;
|
||||||
|
int blue = pixels[i] & 0xFF;
|
||||||
|
if (alpha > 0) {
|
||||||
|
alpha = 254;
|
||||||
|
}
|
||||||
|
int newPixel = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||||
|
pixels[i] = newPixel;
|
||||||
|
}
|
||||||
|
outputImage.setRGB(0, 0, width, height, pixels, 0, width);
|
||||||
|
ImageIO.write(outputImage, "png", file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,13 +23,14 @@ modules:
|
|||||||
actionbars: true
|
actionbars: true
|
||||||
images: true
|
images: true
|
||||||
|
|
||||||
# Integrations
|
# Integrations (Please read the wiki)
|
||||||
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/compatibility
|
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/compatibility
|
||||||
integrations:
|
integrations:
|
||||||
resource-pack:
|
resource-pack:
|
||||||
ItemsAdder: false
|
ItemsAdder: false
|
||||||
Oraxen: false
|
Oraxen: false
|
||||||
team:
|
team:
|
||||||
|
unknown: false
|
||||||
TAB: false
|
TAB: false
|
||||||
CMI: false
|
CMI: false
|
||||||
Velocitab: false
|
Velocitab: false
|
||||||
|
|||||||
@@ -136,36 +136,30 @@ static-text:
|
|||||||
# Note: If you want to make an image lower, edit the y position/ascent in that plugin instead of
|
# Note: If you want to make an image lower, edit the y position/ascent in that plugin instead of
|
||||||
# using descent text or descent unicode because they are designed for characters
|
# using descent text or descent unicode because they are designed for characters
|
||||||
descent-text:
|
descent-text:
|
||||||
name:
|
location:
|
||||||
text: "%player_name%"
|
text: "Your Location: [X: %player_x%, Y: %player_y%, Z: %player_z%]"
|
||||||
descent: 0
|
|
||||||
player:
|
|
||||||
text: "%player_name%"
|
|
||||||
descent: 5
|
|
||||||
position:
|
|
||||||
text: "Your Position: %player_x%, %player_y%, %player_z%"
|
|
||||||
descent: 5
|
descent: 5
|
||||||
|
is-unicode: false
|
||||||
time:
|
time:
|
||||||
text: "Time: %nameplates_time%"
|
text: "Time: %nameplates_time%"
|
||||||
descent: 5
|
descent: 5
|
||||||
|
is-unicode: false
|
||||||
weather:
|
weather:
|
||||||
text: "Weather: %nameplates_conditional_weather%"
|
text: "Weather: %nameplates_conditional_weather%"
|
||||||
descent: 5
|
descent: 5
|
||||||
region:
|
is-unicode: false
|
||||||
text: "Region: %worldguard_region%"
|
|
||||||
descent: 5
|
|
||||||
update:
|
update:
|
||||||
text: "A newer version of CustomNameplates is available!"
|
text: "A newer version of CustomNameplates is available!"
|
||||||
descent: 3
|
descent: 3
|
||||||
|
is-unicode: false
|
||||||
money:
|
money:
|
||||||
text: "%vault_eco_balance%"
|
text: "%vault_eco_balance%"
|
||||||
descent: 13
|
descent: 13
|
||||||
|
is-unicode: false
|
||||||
# %nameplates_unicode_{0}%
|
|
||||||
descent-unicode:
|
|
||||||
hello:
|
hello:
|
||||||
text: "Hello 여보세요 你好 こんにちは"
|
text: "Hello 여보세요 你好 こんにちは, Thanks for using CustomNameplates"
|
||||||
descent: 5
|
descent: 5
|
||||||
|
is-unicode: true
|
||||||
|
|
||||||
# %nameplates_switch_{0}%
|
# %nameplates_switch_{0}%
|
||||||
switch-text:
|
switch-text:
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 156 B |
@@ -1,4 +1,4 @@
|
|||||||
image: bell
|
image: bell
|
||||||
height: 10
|
height: 10
|
||||||
ascent: 7
|
ascent: 6
|
||||||
width: 10
|
width: 10
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 118 B |
@@ -1,4 +1,4 @@
|
|||||||
image: bubble
|
image: bubble
|
||||||
height: 10
|
height: 10
|
||||||
ascent: 5
|
ascent: 4
|
||||||
width: 10
|
width: 10
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 954 B After Width: | Height: | Size: 143 B |
@@ -1,4 +1,4 @@
|
|||||||
image: clock
|
image: clock
|
||||||
height: 10
|
height: 10
|
||||||
ascent: 5
|
ascent: 4
|
||||||
width: 10
|
width: 10
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 163 B |
@@ -1,4 +1,4 @@
|
|||||||
image: coin
|
image: coin
|
||||||
height: 10
|
height: 10
|
||||||
ascent: -2
|
ascent: -3
|
||||||
width: 10
|
width: 10
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 175 B |
@@ -1,4 +1,4 @@
|
|||||||
image: compass
|
image: compass
|
||||||
height: 10
|
height: 10
|
||||||
ascent: 5
|
ascent: 4
|
||||||
width: 10
|
width: 10
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 121 B |
@@ -1,4 +1,4 @@
|
|||||||
image: stamina_0
|
image: stamina_0
|
||||||
height: 9
|
height: 9
|
||||||
ascent: -15
|
ascent: -16
|
||||||
width: 9
|
width: 9
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 157 B |
@@ -1,4 +1,4 @@
|
|||||||
image: stamina_1
|
image: stamina_1
|
||||||
height: 9
|
height: 9
|
||||||
ascent: -15
|
ascent: -16
|
||||||
width: 9
|
width: 9
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 207 B |
@@ -1,4 +1,4 @@
|
|||||||
image: stamina_2
|
image: stamina_2
|
||||||
height: 9
|
height: 9
|
||||||
ascent: -15
|
ascent: -16
|
||||||
width: 9
|
width: 9
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 126 B |
@@ -1,4 +1,4 @@
|
|||||||
image: weather
|
image: weather
|
||||||
height: 10
|
height: 10
|
||||||
ascent: 5
|
ascent: 4
|
||||||
width: 10
|
width: 10
|
||||||
|
|||||||