mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2026-11-07 01:42:35 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28ccd9130c | ||
|
|
16976e6347 | ||
|
|
c8f8c38cc8 | ||
|
|
ddbe549900 | ||
|
|
b4608394f7 | ||
|
|
7b7fe63364 | ||
|
|
906390aa78 | ||
|
|
c491a99b1e | ||
|
|
5733338584 | ||
|
|
2fb0e311c9 | ||
|
|
44656962ac | ||
|
|
87703736c3 | ||
|
|
1053b36f75 | ||
|
|
9b26ce4e19 |
No files matched your search
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
repositories {
|
||||
maven("https://jitpack.io/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,10 @@ public abstract class AbstractCNPlayer implements CNPlayer {
|
||||
private volatile boolean tempPreviewing = false;
|
||||
private volatile boolean toggleablePreviewing = false;
|
||||
|
||||
private String equippedNameplate;
|
||||
private String equippedBubble;
|
||||
private String currentNameplate;
|
||||
private String nameplateData;
|
||||
private String currentBubble;
|
||||
private String bubbleData;
|
||||
|
||||
private final TeamView teamView = new TeamView();
|
||||
|
||||
@@ -541,32 +543,57 @@ public abstract class AbstractCNPlayer implements CNPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String equippedBubble() {
|
||||
if (equippedNameplate == null) return "none";
|
||||
return equippedBubble;
|
||||
public String currentBubble() {
|
||||
if (currentNameplate == null) return "none";
|
||||
return currentBubble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equippedBubble(String equippedBubble) {
|
||||
public boolean setCurrentBubble(String bubble) {
|
||||
if (!isLoaded()) return false;
|
||||
if (!equippedBubble.equals(this.equippedBubble)) {
|
||||
this.equippedBubble = equippedBubble;
|
||||
this.currentBubble = bubble;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String bubbleData() {
|
||||
if (bubbleData == null) return "none";
|
||||
return bubbleData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBubbleData(String bubble) {
|
||||
if (!isLoaded()) return false;
|
||||
this.currentBubble = bubble;
|
||||
this.bubbleData = bubble;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currentNameplate() {
|
||||
if (currentNameplate == null) return "none";
|
||||
return currentNameplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setCurrentNameplate(String nameplate) {
|
||||
if (!isLoaded()) return false;
|
||||
if (!nameplate.equals(this.currentNameplate)) {
|
||||
this.currentNameplate = nameplate;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String equippedNameplate() {
|
||||
if (equippedNameplate == null) return "none";
|
||||
return equippedNameplate;
|
||||
public String nameplateData() {
|
||||
return nameplateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equippedNameplate(String equippedNameplate) {
|
||||
public boolean setNameplateData(String nameplate) {
|
||||
if (!isLoaded()) return false;
|
||||
if (!equippedNameplate.equals(this.equippedNameplate)) {
|
||||
this.equippedNameplate = equippedNameplate;
|
||||
}
|
||||
this.nameplateData = nameplate;
|
||||
this.currentNameplate = nameplate;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -574,8 +601,8 @@ public abstract class AbstractCNPlayer implements CNPlayer {
|
||||
public void save() {
|
||||
plugin.getStorageManager().dataSource().updatePlayerData(PlayerData.builder()
|
||||
.uuid(uuid())
|
||||
.nameplate(equippedNameplate())
|
||||
.bubble(equippedBubble())
|
||||
.nameplate(nameplateData())
|
||||
.bubble(bubbleData())
|
||||
.previewTags(isToggleablePreviewing())
|
||||
.build(), plugin.getScheduler().async());
|
||||
}
|
||||
|
||||
@@ -410,36 +410,64 @@ public interface CNPlayer {
|
||||
Tracker getTracker(CNPlayer another);
|
||||
|
||||
/**
|
||||
* Returns the ID of the currently equipped bubble for the player.
|
||||
* Gets the bubble currently in use (Includes temp bubble used in preview)
|
||||
*
|
||||
* @return the ID of the equipped bubble
|
||||
* @return bubble
|
||||
*/
|
||||
String equippedBubble();
|
||||
String currentBubble();
|
||||
|
||||
/**
|
||||
* Sets the equipped bubble for the player.
|
||||
* Operation would fail if player is not loaded.
|
||||
* Sets the bubble currently in use, which would not be saved
|
||||
*
|
||||
* @param equippedBubble the new bubble ID to equip
|
||||
* @return success or not
|
||||
* @param bubble id
|
||||
* @return false if data not loaded
|
||||
*/
|
||||
boolean equippedBubble(String equippedBubble);
|
||||
boolean setCurrentBubble(String bubble);
|
||||
|
||||
/**
|
||||
* Returns the ID of the currently equipped nameplate for the player.
|
||||
* Sets the bubble data
|
||||
*
|
||||
* @return the ID of the equipped nameplate
|
||||
* @param bubble id
|
||||
* @return false if data not loaded
|
||||
*/
|
||||
String equippedNameplate();
|
||||
boolean setBubbleData(String bubble);
|
||||
|
||||
/**
|
||||
* Sets the equipped nameplate for the player.
|
||||
* Operation would fail if player is not loaded.
|
||||
* Gets the bubble data
|
||||
*
|
||||
* @param equippedNameplate the new nameplate ID to equip
|
||||
* @return success or not
|
||||
* @return bubble id
|
||||
*/
|
||||
boolean equippedNameplate(String equippedNameplate);
|
||||
String bubbleData();
|
||||
|
||||
/**
|
||||
* Gets the nameplate currently in use (Includes temp nameplate used in preview)
|
||||
*
|
||||
* @return nameplate
|
||||
*/
|
||||
String currentNameplate();
|
||||
|
||||
/**
|
||||
* Sets the nameplate currently in use, which would not be saved
|
||||
*
|
||||
* @param nameplate id
|
||||
* @return false if data not loaded
|
||||
*/
|
||||
boolean setCurrentNameplate(String nameplate);
|
||||
|
||||
/**
|
||||
* Gets the nameplate data
|
||||
*
|
||||
* @return the nameplate id
|
||||
*/
|
||||
String nameplateData();
|
||||
|
||||
/**
|
||||
* Sets the nameplate data
|
||||
*
|
||||
* @param nameplate id
|
||||
* @return false if data not loaded
|
||||
*/
|
||||
boolean setNameplateData(String nameplate);
|
||||
|
||||
/**
|
||||
* Save the player's current nameplate/bubble to database
|
||||
|
||||
@@ -104,6 +104,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
||||
protected boolean packOraxen;
|
||||
protected boolean packNexo;
|
||||
protected boolean packCreativeCentral;
|
||||
protected boolean packCraftEngine;
|
||||
|
||||
protected boolean chatUnsafe;
|
||||
protected boolean chatTR;
|
||||
@@ -188,6 +189,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
||||
packOraxen = config.getBoolean("integrations.resource-pack.Oraxen", false);
|
||||
packCreativeCentral = config.getBoolean("integrations.resource-pack.Creative-Central");
|
||||
packNexo = config.getBoolean("integrations.resource-pack.Nexo");
|
||||
packCraftEngine = config.getBoolean("integrations.resource-pack.CraftEngine", false);
|
||||
|
||||
chatUnsafe = config.getBoolean("other-settings.unsafe-chat-event", false);
|
||||
chatEss = config.getBoolean("integrations.chat.Essentials", false);
|
||||
@@ -321,6 +323,10 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
||||
return instance.packNexo;
|
||||
}
|
||||
|
||||
public static boolean packCraftEngine() {
|
||||
return instance.packCraftEngine;
|
||||
}
|
||||
|
||||
public static boolean packCreativeCentral() { return instance.packCreativeCentral; }
|
||||
|
||||
public static boolean hideScoreBoardNumber() {
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class CustomNameplates implements NameplatesPlugin {
|
||||
protected MainTask mainTask;
|
||||
protected SchedulerTask scheduledMainTask;
|
||||
protected ConcurrentHashMap<UUID, CNPlayer> onlinePlayerMap = new ConcurrentHashMap<>();
|
||||
protected Int2ObjectOpenHashMap<CNPlayer> entityIDFastLookup = new Int2ObjectOpenHashMap<>();
|
||||
protected ConcurrentHashMap<Integer, CNPlayer> entityIDFastLookup = new ConcurrentHashMap<>();
|
||||
protected AdvanceManager advanceManager;
|
||||
protected BackgroundManager backgroundManager;
|
||||
protected EventManager eventManager;
|
||||
|
||||
+7
@@ -19,7 +19,9 @@ package net.momirealms.customnameplates.api.placeholder.internal;
|
||||
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesAPI;
|
||||
import net.momirealms.customnameplates.api.feature.AdaptiveImage;
|
||||
import net.momirealms.customnameplates.api.feature.OffsetFont;
|
||||
import net.momirealms.customnameplates.api.feature.PreParsedDynamicText;
|
||||
import net.momirealms.customnameplates.api.helper.AdventureHelper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -99,4 +101,9 @@ public class AdaptiveImageText<T extends AdaptiveImage> {
|
||||
public String getText(CNPlayer p1, CNPlayer p2) {
|
||||
return preParsedDynamicText.fastCreate(p1).render(p2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTextOffsetCharacters(CNPlayer p1, CNPlayer p2) {
|
||||
return OffsetFont.createOffsets(CustomNameplatesAPI.getInstance().getTextAdvance(preParsedDynamicText.fastCreate(p1).render(p2)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <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.api.util;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class ZipUtils {
|
||||
|
||||
public static void zipDirectory(Path folderPath, Path zipFilePath) throws IOException {
|
||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath.toFile()))) {
|
||||
try (Stream<Path> paths = Files.walk(folderPath)) {
|
||||
for (Path path : (Iterable<Path>) paths::iterator) {
|
||||
if (Files.isDirectory(path)) {
|
||||
continue;
|
||||
}
|
||||
String zipEntryName = folderPath.relativize(path).toString().replace("\\", "/");
|
||||
ZipEntry zipEntry = new ZipEntry(zipEntryName);
|
||||
try (InputStream is = Files.newInputStream(path)) {
|
||||
addToZip(zipEntry, is, zos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addToZip(ZipEntry zipEntry, InputStream is, ZipOutputStream zos) throws IOException {
|
||||
zos.putNextEntry(zipEntry);
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = is.read(buffer)) != -1) {
|
||||
zos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,10 @@ dependencies {
|
||||
compileOnly("org.lwjgl:lwjgl:${rootProject.properties["lwjgl_version"]}")
|
||||
// Fast util
|
||||
compileOnly("it.unimi.dsi:fastutil:${rootProject.properties["fastutil_version"]}")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(17)
|
||||
dependsOn(tasks.clean)
|
||||
}
|
||||
+1
-1
@@ -296,7 +296,7 @@ public class BubbleManagerImpl implements BubbleManager, ChatListener {
|
||||
// check requirements
|
||||
if (!player.isMet(sendBubbleRequirements())) return;
|
||||
|
||||
String equippedBubble = player.equippedBubble();
|
||||
String equippedBubble = player.currentBubble();
|
||||
if (equippedBubble.equals("none")) equippedBubble = defaultBubbleId;
|
||||
|
||||
BubbleConfig config = bubbleConfigs.get(equippedBubble);
|
||||
|
||||
+17
@@ -35,6 +35,7 @@ import net.momirealms.customnameplates.api.feature.nameplate.Nameplate;
|
||||
import net.momirealms.customnameplates.api.feature.pack.ResourcePackManager;
|
||||
import net.momirealms.customnameplates.api.helper.VersionHelper;
|
||||
import net.momirealms.customnameplates.api.util.CharacterUtils;
|
||||
import net.momirealms.customnameplates.api.util.ZipUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@@ -123,6 +124,12 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
||||
this.setPackFormat();
|
||||
// copy the resource pack to hooked plugins
|
||||
this.copyResourcePackToHookedPlugins(resourcePackFolder);
|
||||
|
||||
try {
|
||||
ZipUtils.zipDirectory(resourcePackFolder.toPath(), plugin.getDataFolder().toPath().resolve("resourcepack.zip"));
|
||||
} catch (IOException e) {
|
||||
plugin.getPluginLogger().warn("Failed to zip resourcepack.zip", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFont(JsonObject fontJson) {
|
||||
@@ -244,6 +251,16 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
||||
plugin.getPluginLogger().warn("Failed to copy files to Nexo", e);
|
||||
}
|
||||
}
|
||||
if (ConfigManager.packCraftEngine()){
|
||||
try {
|
||||
FileUtils.deleteDirectory(new File(pluginsFolder, "CraftEngine" + File.separator + "resources" + File.separator + "nameplates"));
|
||||
FileUtils.copyDirectory(resourcePackFolder, new File(pluginsFolder, "CraftEngine" + File.separator + "resources" + File.separator + "CustomNameplates" + File.separator + "resourcepack"));
|
||||
FileUtils.delete(new File(pluginsFolder, "CraftEngine" + File.separator + "resources" + File.separator + "CustomNameplates" + File.separator + "resourcepack" + File.separator + "pack.mcmeta"));
|
||||
FileUtils.delete(new File(pluginsFolder, "CraftEngine" + File.separator + "resources" + File.separator + "CustomNameplates" + File.separator + "resourcepack" + File.separator + "pack.png"));
|
||||
} catch (IOException e){
|
||||
plugin.getPluginLogger().warn("Failed to copy files to CraftEngine", e);
|
||||
}
|
||||
}
|
||||
if(ConfigManager.packCreativeCentral()) {
|
||||
try {
|
||||
FileUtils.copyDirectory(new File(resourcePackFolder, "assets"), new File(pluginsFolder, "creative-central" + File.separator + "resources" + File.separator + "assets"));
|
||||
|
||||
+14
-8
@@ -125,7 +125,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
}
|
||||
PreParsedDynamicText nameTag = new PreParsedDynamicText(plugin.getNameplateManager().playerNameTag());
|
||||
Placeholder placeholder1 = this.registerPlayerPlaceholder("%np_tag-image%", (player -> {
|
||||
String equippedNameplate = player.equippedNameplate();
|
||||
String equippedNameplate = player.currentNameplate();
|
||||
if (equippedNameplate.equals("none")) equippedNameplate = plugin.getNameplateManager().defaultNameplateId();
|
||||
Nameplate nameplate = plugin.getNameplateManager().nameplateById(equippedNameplate);
|
||||
if (nameplate == null) return "";
|
||||
@@ -134,7 +134,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
return AdventureHelper.surroundWithNameplatesFont(nameplate.createImage(advance, 0, 0));
|
||||
}));
|
||||
Placeholder placeholder2 = this.registerRelationalPlaceholder("%rel_np_tag-image%", (p1, p2) -> {
|
||||
String equippedNameplate = p1.equippedNameplate();
|
||||
String equippedNameplate = p1.currentNameplate();
|
||||
if (equippedNameplate.equals("none")) equippedNameplate = plugin.getNameplateManager().defaultNameplateId();
|
||||
Nameplate nameplate = plugin.getNameplateManager().nameplateById(equippedNameplate);
|
||||
if (nameplate == null) return "";
|
||||
@@ -145,7 +145,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
Placeholder placeholder3 = this.registerPlayerPlaceholder("%np_tag-text%", (player -> nameTag.fastCreate(player).render(player)));
|
||||
Placeholder placeholder4 = this.registerRelationalPlaceholder("%rel_np_tag-text%", (p1, p2) -> nameTag.fastCreate(p1).render(p2));
|
||||
Placeholder placeholder5 = this.registerPlayerPlaceholder("%np_tag%", (player -> {
|
||||
String equippedNameplate = player.equippedNameplate();
|
||||
String equippedNameplate = player.currentNameplate();
|
||||
if (equippedNameplate.equals("none")) equippedNameplate = plugin.getNameplateManager().defaultNameplateId();
|
||||
Nameplate nameplate = plugin.getNameplateManager().nameplateById(equippedNameplate);
|
||||
String tag = nameTag.fastCreate(player).render(player);
|
||||
@@ -155,7 +155,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
+ tag + AdventureHelper.surroundWithNameplatesFont(nameplate.createImageSuffix(advance, 0, 0));
|
||||
}));
|
||||
Placeholder placeholder6 = this.registerRelationalPlaceholder("%rel_np_tag%", (p1, p2) -> {
|
||||
String equippedNameplate = p1.equippedNameplate();
|
||||
String equippedNameplate = p1.currentNameplate();
|
||||
Nameplate nameplate = plugin.getNameplateManager().nameplateById(equippedNameplate);
|
||||
if (nameplate == null) return p1.name();
|
||||
String tag = nameTag.fastCreate(p1).render(p2);
|
||||
@@ -192,16 +192,16 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
this.registerPlayerPlaceholder("%np_offset_" + i + "%", (p) -> AdventureHelper.surroundWithNameplatesFont(characters));
|
||||
}
|
||||
if (ConfigManager.nameplateModule()) {
|
||||
this.registerPlayerPlaceholder("%np_equipped_nameplate%", CNPlayer::equippedNameplate);
|
||||
this.registerPlayerPlaceholder("%np_equipped_nameplate%", CNPlayer::currentNameplate);
|
||||
this.registerPlayerPlaceholder("%np_equipped_nameplate-name%", (player) -> {
|
||||
Nameplate nameplate = plugin.getNameplateManager().nameplateById(player.equippedNameplate());
|
||||
Nameplate nameplate = plugin.getNameplateManager().nameplateById(player.currentNameplate());
|
||||
return Optional.ofNullable(nameplate).map(Nameplate::displayName).orElse("");
|
||||
});
|
||||
}
|
||||
if (ConfigManager.bubbleModule()) {
|
||||
this.registerPlayerPlaceholder("%np_equipped_bubble%", CNPlayer::equippedBubble);
|
||||
this.registerPlayerPlaceholder("%np_equipped_bubble%", CNPlayer::currentBubble);
|
||||
this.registerPlayerPlaceholder("%np_equipped_bubble-name%", (player) -> {
|
||||
BubbleConfig bubble = plugin.getBubbleManager().bubbleConfigById(player.equippedBubble());
|
||||
BubbleConfig bubble = plugin.getBubbleManager().bubbleConfigById(player.currentBubble());
|
||||
return Optional.ofNullable(bubble).map(BubbleConfig::displayName).orElse("");
|
||||
});
|
||||
}
|
||||
@@ -512,6 +512,9 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
Placeholder placeholder7 = this.registerSharedPlaceholder("%shared_np_background-image_" + id + "%", () -> adaptiveImageText.getImage(null, null));
|
||||
Placeholder placeholder8 = this.registerPlayerPlaceholder("%np_background-image_" + id + "%", (p) -> adaptiveImageText.getImage(p, p));
|
||||
Placeholder placeholder9 = this.registerRelationalPlaceholder("%rel_np_background-image_" + id + "%", adaptiveImageText::getImage);
|
||||
Placeholder placeholder40 = this.registerSharedPlaceholder("%shared_np_background-text-offset_" + id + "%", () -> adaptiveImageText.getTextOffsetCharacters(null, null));
|
||||
Placeholder placeholder50 = this.registerPlayerPlaceholder("%np_background-text-offset_" + id + "%", (p) -> adaptiveImageText.getTextOffsetCharacters(p, p));
|
||||
Placeholder placeholder60 = this.registerRelationalPlaceholder("%rel_np_background-text-offset_" + id + "%", adaptiveImageText::getTextOffsetCharacters);
|
||||
childrenText.put(placeholder1, list);
|
||||
childrenText.put(placeholder2, list);
|
||||
childrenText.put(placeholder3, list);
|
||||
@@ -521,6 +524,9 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
childrenText.put(placeholder7, list);
|
||||
childrenText.put(placeholder8, list);
|
||||
childrenText.put(placeholder9, list);
|
||||
childrenText.put(placeholder40, list);
|
||||
childrenText.put(placeholder50, list);
|
||||
childrenText.put(placeholder60, list);
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Background [" + bgID + "] not exists");
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class BubbleRequirement extends AbstractRequirement {
|
||||
@Override
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
if (!ConfigManager.bubbleModule()) return false;
|
||||
String bubble = p1.equippedBubble();
|
||||
String bubble = p1.currentBubble();
|
||||
if (bubble.equals("none")) bubble = CustomNameplates.getInstance().getBubbleManager().defaultBubbleId();
|
||||
return bubbles.contains(bubble);
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class HasBubbleRequirement extends AbstractRequirement {
|
||||
@Override
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
if (!ConfigManager.bubbleModule()) return !has;
|
||||
String bubble = p1.equippedBubble();
|
||||
String bubble = p1.currentBubble();
|
||||
if (bubble.equals("none")) bubble = CustomNameplates.getInstance().getBubbleManager().defaultBubbleId();
|
||||
if (has) {
|
||||
return !bubble.equals("none");
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class HasNameplateRequirement extends AbstractRequirement {
|
||||
@Override
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
if (!ConfigManager.nameplateModule()) return !has;
|
||||
String nameplate = p1.equippedNameplate();
|
||||
String nameplate = p1.currentNameplate();
|
||||
if (nameplate.equals("none")) nameplate = CustomNameplates.getInstance().getNameplateManager().defaultNameplateId();
|
||||
if (has) {
|
||||
return !nameplate.equals("none");
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class NameplateRequirement extends AbstractRequirement {
|
||||
@Override
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
if (!ConfigManager.nameplateModule()) return false;
|
||||
String nameplate = p1.equippedNameplate();
|
||||
String nameplate = p1.currentNameplate();
|
||||
if (nameplate.equals("none")) nameplate = CustomNameplates.getInstance().getNameplateManager().defaultNameplateId();
|
||||
return nameplates.contains(nameplate);
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class NotBubbleRequirement extends AbstractRequirement {
|
||||
@Override
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
if (!ConfigManager.bubbleModule()) return false;
|
||||
String bubble = p1.equippedBubble();
|
||||
String bubble = p1.currentBubble();
|
||||
if (bubble.equals("none")) bubble = CustomNameplates.getInstance().getBubbleManager().defaultBubbleId();
|
||||
return !bubbles.contains(bubble);
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class NotNameplateRequirement extends AbstractRequirement {
|
||||
@Override
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
if (!ConfigManager.nameplateModule()) return false;
|
||||
String nameplate = p1.equippedNameplate();
|
||||
String nameplate = p1.currentNameplate();
|
||||
if (nameplate.equals("none")) nameplate = CustomNameplates.getInstance().getNameplateManager().defaultNameplateId();
|
||||
return !nameplates.contains(nameplate);
|
||||
}
|
||||
|
||||
+2
-2
@@ -93,8 +93,8 @@ public class StorageManagerImpl implements StorageManager, JoinQuitListener {
|
||||
}
|
||||
|
||||
private void handleDataLoad(CNPlayer player, PlayerData data) {
|
||||
player.equippedBubble(data.bubble());
|
||||
player.equippedNameplate(data.nameplate());
|
||||
player.setBubbleData(data.bubble());
|
||||
player.setNameplateData(data.nameplate());
|
||||
plugin.getUnlimitedTagManager().togglePreviewing(player, data.previewTags());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ modules:
|
||||
# Plugin Integrations: Integrate resource packs and chat plugins with other plugins.
|
||||
integrations:
|
||||
resource-pack:
|
||||
CraftEngine: false # Integration with CraftEngine
|
||||
ItemsAdder: false # Integration with ItemsAdder
|
||||
ItemsAdder-old-method: false # Legacy integration with ItemsAdder
|
||||
Oraxen: false # Integration with Oraxen
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=3.0.16
|
||||
config_version=35
|
||||
project_version=3.0.19
|
||||
config_version=36
|
||||
project_group=net.momirealms
|
||||
|
||||
# Supported languages
|
||||
@@ -18,7 +18,7 @@ asm_commons_version=9.7.1
|
||||
jar_relocator_version=1.7
|
||||
h2_driver_version=2.3.232
|
||||
sqlite_driver_version=3.47.0.0
|
||||
adventure_bundle_version=4.18.0-SNAPSHOT
|
||||
adventure_bundle_version=4.18.0
|
||||
adventure_platform_version=4.3.5-SNAPSHOT
|
||||
cloud_core_version=2.0.0
|
||||
cloud_services_version=2.0.0
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -6,7 +6,7 @@ repositories {
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // papi
|
||||
maven("https://libraries.minecraft.net") // brigadier
|
||||
maven("https://jitpack.io/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/") // paper
|
||||
maven("https://repo.papermc.io/repository/maven-public/") // paper
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") // spigot
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/") // paper
|
||||
maven("https://repo.papermc.io/repository/maven-public/") // paper
|
||||
maven("https://repo.william278.net/releases/") // husk
|
||||
maven("https://jitpack.io/")
|
||||
maven("https://repo.oraxen.com/releases/")
|
||||
|
||||
+42
-6
@@ -19,6 +19,8 @@ package net.momirealms.customnameplates.bukkit;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.ConfigManager;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
@@ -49,7 +51,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class BukkitPlatform implements Platform {
|
||||
|
||||
private static final Pattern LANG_PATTERN = Pattern.compile("<lang:[a-zA-Z0-9._/]+>");
|
||||
private static final Pattern LANG_PATTERN = Pattern.compile("<lang:[a-zA-Z0-9._/':-]+/?>");
|
||||
|
||||
private final CustomNameplates plugin;
|
||||
private final boolean placeholderAPI;
|
||||
@@ -103,6 +105,9 @@ public class BukkitPlatform implements Platform {
|
||||
// some plugins would send null to clear the actionbar, what a bad solution
|
||||
Object component = Optional.ofNullable(Reflections.field$ClientboundSetActionBarTextPacket$text.get(packet)).orElse(Reflections.instance$Component$empty);
|
||||
Object contents = Reflections.method$Component$getContents.invoke(component);
|
||||
if (contents == null) {
|
||||
return;
|
||||
}
|
||||
if (Reflections.clazz$ScoreContents.isAssignableFrom(contents.getClass())) {
|
||||
//String name = scoreContentNameFunction.apply(Reflections.field$ScoreContents$name.get(contents));
|
||||
String objective = (String) Reflections.field$ScoreContents$objective.get(contents);
|
||||
@@ -305,15 +310,46 @@ public class BukkitPlatform implements Platform {
|
||||
Object attributeHolder = Reflections.field$ClientboundUpdateAttributesPacket$AttributeSnapshot$attribute.get(attributeSnapshot);
|
||||
Object attribute = Reflections.method$Holder$value.invoke(attributeHolder);
|
||||
String id = (String) Reflections.field$Attribute$id.get(attribute);
|
||||
if (id.equals("attribute.name.generic.scale")) {
|
||||
if (id.endsWith("scale")) {
|
||||
double baseValue = (double) Reflections.field$ClientboundUpdateAttributesPacket$AttributeSnapshot$base.get(attributeSnapshot);
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<Object> modifiers = (Collection<Object>) Reflections.field$ClientboundUpdateAttributesPacket$AttributeSnapshot$modifiers.get(attributeSnapshot);
|
||||
for (Object modifier : modifiers) {
|
||||
double amount = (double) Reflections.field$AttributeModifier$amount.get(modifier);
|
||||
baseValue += amount;
|
||||
int left = modifiers.size();
|
||||
if (left > 0) {
|
||||
for (Object modifier : modifiers) {
|
||||
Object operation = Reflections.field$AttributeModifier$operation.get(modifier);
|
||||
if (operation == Reflections.instance$AttributeModifier$Operation$ADD_VALUE) {
|
||||
double amount = (double) Reflections.field$AttributeModifier$amount.get(modifier);
|
||||
baseValue += amount;
|
||||
left--;
|
||||
if (left == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CustomNameplates.getInstance().getUnlimitedTagManager().onPlayerAttributeSet(another, player, baseValue);
|
||||
double finalValue = baseValue;
|
||||
if (left > 0) {
|
||||
for (Object modifier : modifiers) {
|
||||
Object operation = Reflections.field$AttributeModifier$operation.get(modifier);
|
||||
if (operation == Reflections.instance$AttributeModifier$Operation$ADD_MULTIPLIED_BASE) {
|
||||
double amount = (double) Reflections.field$AttributeModifier$amount.get(modifier);
|
||||
finalValue += amount * baseValue;
|
||||
left--;
|
||||
if (left == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (left > 0) {
|
||||
for (Object modifier : modifiers) {
|
||||
Object operation = Reflections.field$AttributeModifier$operation.get(modifier);
|
||||
if (operation == Reflections.instance$AttributeModifier$Operation$ADD_MULTIPLIED_TOTAL) {
|
||||
double amount = (double) Reflections.field$AttributeModifier$amount.get(modifier);
|
||||
finalValue *= 1.0 + amount;
|
||||
left--;
|
||||
if (left == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CustomNameplates.getInstance().getUnlimitedTagManager().onPlayerAttributeSet(another, player, finalValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -81,11 +81,11 @@ public class BubblesEquipCommand extends BukkitCommandFeature<CommandSender> {
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_EQUIP_FAILURE_PERMISSION);
|
||||
return;
|
||||
}
|
||||
if (player.equippedBubble().equals(bubbleId)) {
|
||||
if (player.currentBubble().equals(bubbleId)) {
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_EQUIP_FAILURE_NO_CHANGE);
|
||||
return;
|
||||
}
|
||||
player.equippedBubble(bubbleId);
|
||||
player.setBubbleData(bubbleId);
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_EQUIP_SUCCESS, Component.text(bubbleId), AdventureHelper.miniMessage(bubble.displayName()));
|
||||
});
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class BubblesForceEquipCommand extends BukkitCommandFeature<CommandSender
|
||||
plugin.getPluginLogger().warn("Player " + player.name() + " tried to equip a bubble when data not loaded");
|
||||
return;
|
||||
}
|
||||
player.equippedBubble(bubbleId);
|
||||
player.setBubbleData(bubbleId);
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_FORCE_EQUIP_SUCCESS, Component.text(bukkitPlayer.getName()), Component.text(bubbleId), AdventureHelper.miniMessage(bubble.displayName()));
|
||||
});
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class BubblesForceUnEquipCommand extends BukkitCommandFeature<CommandSend
|
||||
plugin.getPluginLogger().warn("Player " + player.name() + " tried to equip a bubble when data not loaded");
|
||||
return;
|
||||
}
|
||||
player.equippedBubble("none");
|
||||
player.setBubbleData("none");
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_FORCE_UNEQUIP_SUCCESS, Component.text(bukkitPlayer.getName()));
|
||||
});
|
||||
|
||||
+2
-2
@@ -48,11 +48,11 @@ public class BubblesUnEquipCommand extends BukkitCommandFeature<CommandSender> {
|
||||
plugin.getPluginLogger().warn("Player " + player.name() + " tried to unequip a bubble when data not loaded");
|
||||
return;
|
||||
}
|
||||
if (player.equippedBubble().equals("none")) {
|
||||
if (player.bubbleData().equals("none")) {
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_UNEQUIP_FAILURE_NOT_EQUIP);
|
||||
return;
|
||||
}
|
||||
player.equippedBubble("none");
|
||||
player.setBubbleData("none");
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_BUBBLES_UNEQUIP_SUCCESS);
|
||||
});
|
||||
|
||||
+2
-2
@@ -81,11 +81,11 @@ public class NameplatesEquipCommand extends BukkitCommandFeature<CommandSender>
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_EQUIP_FAILURE_PERMISSION);
|
||||
return;
|
||||
}
|
||||
if (player.equippedNameplate().equals(nameplateId)) {
|
||||
if (player.currentNameplate().equals(nameplateId)) {
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_EQUIP_FAILURE_NO_CHANGE);
|
||||
return;
|
||||
}
|
||||
player.equippedNameplate(nameplateId);
|
||||
player.setNameplateData(nameplateId);
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_EQUIP_SUCCESS, Component.text(nameplateId), AdventureHelper.miniMessage(nameplate.displayName()));
|
||||
});
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class NameplatesForceEquipCommand extends BukkitCommandFeature<CommandSen
|
||||
plugin.getPluginLogger().warn("Player " + player.name() + " tried to equip a nameplate when data not loaded");
|
||||
return;
|
||||
}
|
||||
player.equippedNameplate(nameplateId);
|
||||
player.setNameplateData(nameplateId);
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_FORCE_EQUIP_SUCCESS, Component.text(bukkitPlayer.getName()), Component.text(nameplateId), AdventureHelper.miniMessage(nameplate.displayName()));
|
||||
});
|
||||
|
||||
+3
-3
@@ -74,9 +74,9 @@ public class NameplatesForcePreviewCommand extends BukkitCommandFeature<CommandS
|
||||
|
||||
int time = (int) context.optional("time").orElse(plugin.getUnlimitedTagManager().previewDuration());
|
||||
|
||||
String previousNameplate = player.equippedNameplate();
|
||||
String previousNameplate = player.currentNameplate();
|
||||
if (specified) {
|
||||
player.equippedNameplate(optionalNameplate.get());
|
||||
player.setCurrentNameplate(optionalNameplate.get());
|
||||
}
|
||||
|
||||
if (!player.isTempPreviewing())
|
||||
@@ -92,7 +92,7 @@ public class NameplatesForcePreviewCommand extends BukkitCommandFeature<CommandS
|
||||
}
|
||||
|
||||
if (specified) {
|
||||
player.equippedNameplate(previousNameplate);
|
||||
player.setCurrentNameplate(previousNameplate);
|
||||
}
|
||||
}, time, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class NameplatesForceUnEquipCommand extends BukkitCommandFeature<CommandS
|
||||
plugin.getPluginLogger().warn("Player " + player.name() + " tried to equip a nameplate when data not loaded");
|
||||
return;
|
||||
}
|
||||
player.equippedNameplate("none");
|
||||
player.setNameplateData("none");
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_FORCE_UNEQUIP_SUCCESS, Component.text(bukkitPlayer.getName()));
|
||||
});
|
||||
|
||||
+2
-2
@@ -48,11 +48,11 @@ public class NameplatesUnEquipCommand extends BukkitCommandFeature<CommandSender
|
||||
plugin.getPluginLogger().warn("Player " + player.name() + " tried to unequip a nameplate when data not loaded");
|
||||
return;
|
||||
}
|
||||
if (player.equippedNameplate().equals("none")) {
|
||||
if (player.nameplateData().equals("none")) {
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_UNEQUIP_FAILURE_NOT_EQUIP);
|
||||
return;
|
||||
}
|
||||
player.equippedNameplate("none");
|
||||
player.setNameplateData("none");
|
||||
player.save();
|
||||
handleFeedback(context, MessageConstants.COMMAND_NAMEPLATES_UNEQUIP_SUCCESS);
|
||||
});
|
||||
|
||||
+10
-2
@@ -37,10 +37,18 @@ public class BedrockPlayerRequirement extends AbstractRequirement {
|
||||
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||
BukkitPlatform platform = (BukkitPlatform) CustomNameplates.getInstance().getPlatform();
|
||||
if (platform.hasGeyser()) {
|
||||
if (GeyserUtils.isBedrockPlayer(p1.uuid())) return true;
|
||||
if (is) {
|
||||
return GeyserUtils.isBedrockPlayer(p1.uuid());
|
||||
} else {
|
||||
return !GeyserUtils.isBedrockPlayer(p1.uuid());
|
||||
}
|
||||
}
|
||||
if (platform.hasFloodGate()) {
|
||||
if (FloodGateUtils.isBedrockPlayer(p1.uuid())) return true;
|
||||
if (is) {
|
||||
return FloodGateUtils.isBedrockPlayer(p1.uuid());
|
||||
} else {
|
||||
return !FloodGateUtils.isBedrockPlayer(p1.uuid());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+34
-1
@@ -274,7 +274,7 @@ public class Reflections {
|
||||
try {
|
||||
Field field = ReflectionUtils.getDeclaredField(
|
||||
clazz$ClientboundBossEventPacket,
|
||||
"f", "REMOVE_OPERATION");
|
||||
VersionHelper.isVersionNewerThan1_20_5() ? "g" : "f", "REMOVE_OPERATION");
|
||||
field.setAccessible(true);
|
||||
instance$ClientboundBossEventPacket$REMOVE_OPERATION = requireNonNull(field.get(null));
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -1097,4 +1097,37 @@ public class Reflections {
|
||||
}
|
||||
field$ServerConnectionListener$channels = requireNonNull(f);
|
||||
}
|
||||
|
||||
public static final Class<?> clazz$AttributeModifier$Operation = requireNonNull(
|
||||
ReflectionUtils.getClazz(
|
||||
BukkitReflectionUtils.assembleMCClass("world.entity.ai.attributes.AttributeModifier$Operation")
|
||||
)
|
||||
);
|
||||
|
||||
public static final Method method$AttributeModifier$Operation$values = requireNonNull(
|
||||
ReflectionUtils.getStaticMethod(
|
||||
clazz$AttributeModifier$Operation, clazz$AttributeModifier$Operation.arrayType()
|
||||
)
|
||||
);
|
||||
|
||||
public static final Object instance$AttributeModifier$Operation$ADD_VALUE;
|
||||
public static final Object instance$AttributeModifier$Operation$ADD_MULTIPLIED_BASE;
|
||||
public static final Object instance$AttributeModifier$Operation$ADD_MULTIPLIED_TOTAL;
|
||||
|
||||
static {
|
||||
try {
|
||||
Object[] values = (Object[]) method$AttributeModifier$Operation$values.invoke(null);
|
||||
instance$AttributeModifier$Operation$ADD_VALUE = values[0];
|
||||
instance$AttributeModifier$Operation$ADD_MULTIPLIED_BASE = values[1];
|
||||
instance$AttributeModifier$Operation$ADD_MULTIPLIED_TOTAL = values[2];
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Field field$AttributeModifier$operation = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$AttributeModifier, clazz$AttributeModifier$Operation, 0
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ softdepend:
|
||||
- MagicCosmetics
|
||||
- ItemsAdder
|
||||
- Oraxen
|
||||
- CraftEngine
|
||||
- TrChat
|
||||
- CarbonChat
|
||||
- HuskChat
|
||||
|
||||
Reference in new issue
Block a user