mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 15:09:23 +00:00
some changes
This commit is contained in:
@@ -28,13 +28,6 @@ public interface VersionManager {
|
|||||||
*/
|
*/
|
||||||
boolean isFolia();
|
boolean isFolia();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get bukkit version
|
|
||||||
*
|
|
||||||
* @return version
|
|
||||||
*/
|
|
||||||
String getServerVersion();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check update
|
* Check update
|
||||||
*
|
*
|
||||||
@@ -66,6 +59,8 @@ public interface VersionManager {
|
|||||||
|
|
||||||
boolean isVersionNewerThan1_19();
|
boolean isVersionNewerThan1_19();
|
||||||
|
|
||||||
|
boolean isMojmap();
|
||||||
|
|
||||||
boolean isVersionNewerThan1_19_R2();
|
boolean isVersionNewerThan1_19_R2();
|
||||||
|
|
||||||
boolean isVersionNewerThan1_19_R3();
|
boolean isVersionNewerThan1_19_R3();
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ plugins {
|
|||||||
id("java")
|
id("java")
|
||||||
id("application")
|
id("application")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
id("io.github.goooler.shadow") version "8.1.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
version = "2.3.3.9"
|
version = "2.4.0"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
apply(plugin = "application")
|
apply(plugin = "application")
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "io.github.goooler.shadow")
|
||||||
apply(plugin = "org.gradle.maven-publish")
|
apply(plugin = "org.gradle.maven-publish")
|
||||||
|
|
||||||
application {
|
application {
|
||||||
@@ -20,8 +20,8 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://maven.aliyun.com/repository/public/")
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven("https://maven.aliyun.com/repository/public/")
|
||||||
maven("https://papermc.io/repo/repository/maven-public/")
|
maven("https://papermc.io/repo/repository/maven-public/")
|
||||||
maven("https://oss.sonatype.org/content/groups/public/")
|
maven("https://oss.sonatype.org/content/groups/public/")
|
||||||
maven("https://repo.dmulloy2.net/repository/public/")
|
maven("https://repo.dmulloy2.net/repository/public/")
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ dependencies {
|
|||||||
compileOnly("commons-io:commons-io:2.15.1")
|
compileOnly("commons-io:commons-io:2.15.1")
|
||||||
compileOnly("org.geysermc.geyser:api:2.2.0-SNAPSHOT")
|
compileOnly("org.geysermc.geyser:api:2.2.0-SNAPSHOT")
|
||||||
compileOnly("LibsDisguises:LibsDisguises:10.0.42")
|
compileOnly("LibsDisguises:LibsDisguises:10.0.42")
|
||||||
implementation("com.github.Xiao-MoMi:BiomeAPI:0.3")
|
|
||||||
|
|
||||||
// chat channels
|
// chat channels
|
||||||
compileOnly(files("libs/VentureChat-3.7.1.jar"))
|
compileOnly(files("libs/VentureChat-3.7.1.jar"))
|
||||||
@@ -49,17 +48,18 @@ dependencies {
|
|||||||
// api module
|
// api module
|
||||||
implementation(project(":api"))
|
implementation(project(":api"))
|
||||||
implementation(project(":common"))
|
implementation(project(":common"))
|
||||||
|
implementation(files("libs/Sparrow-Heart-0.17.jar"))
|
||||||
|
|
||||||
// adventure
|
// adventure
|
||||||
compileOnly("net.kyori:adventure-api:4.16.0")
|
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||||
compileOnly("net.kyori:adventure-platform-bukkit:4.3.2")
|
compileOnly("net.kyori:adventure-platform-bukkit:4.3.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
||||||
relocate ("org.bstats", "net.momirealms.customnameplates.libraries.bstats")
|
relocate ("org.bstats", "net.momirealms.customnameplates.libraries.bstats")
|
||||||
relocate ("net.momirealms.biomeapi", "net.momirealms.customnameplates.libraries.biomeapi")
|
relocate ("net.momirealms.sparrow.heart", "net.momirealms.customnameplates.libraries.sparrow")
|
||||||
relocate ("org.apache.commons.pool2", "net.momirealms.customnameplates.libraries.commonspool2")
|
relocate ("org.apache.commons.pool2", "net.momirealms.customnameplates.libraries.commonspool2")
|
||||||
relocate ("com.mysql", "net.momirealms.customnameplates.libraries.mysql")
|
relocate ("com.mysql", "net.momirealms.customnameplates.libraries.mysql")
|
||||||
relocate ("org.mariadb", "net.momirealms.customnameplates.libraries.mariadb")
|
relocate ("org.mariadb", "net.momirealms.customnameplates.libraries.mariadb")
|
||||||
|
|||||||
BIN
paper/libs/Sparrow-Heart-0.17.jar
Normal file
BIN
paper/libs/Sparrow-Heart-0.17.jar
Normal file
Binary file not shown.
@@ -64,13 +64,14 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
this.versionManager = new VersionManagerImpl(this);
|
||||||
this.dependencyManager = new DependencyManagerImpl(this, new ReflectionClassPathAppender(this.getClassLoader()));
|
this.dependencyManager = new DependencyManagerImpl(this, new ReflectionClassPathAppender(this.getClassLoader()));
|
||||||
this.dependencyManager.loadDependencies(new ArrayList<>(
|
this.dependencyManager.loadDependencies(new ArrayList<>(
|
||||||
List.of(
|
List.of(
|
||||||
Dependency.GSON,
|
Dependency.GSON,
|
||||||
Dependency.SLF4J_API,
|
Dependency.SLF4J_API,
|
||||||
Dependency.SLF4J_SIMPLE,
|
Dependency.SLF4J_SIMPLE,
|
||||||
Dependency.COMMAND_API,
|
versionManager.isMojmap() ? Dependency.COMMAND_API_MOJMAP : Dependency.COMMAND_API,
|
||||||
Dependency.BOOSTED_YAML,
|
Dependency.BOOSTED_YAML,
|
||||||
Dependency.BIOME_API,
|
Dependency.BIOME_API,
|
||||||
Dependency.ADVENTURE_BUNDLE,
|
Dependency.ADVENTURE_BUNDLE,
|
||||||
@@ -99,7 +100,6 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implement
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.adventureManager = new AdventureManagerImpl(this);
|
this.adventureManager = new AdventureManagerImpl(this);
|
||||||
this.versionManager = new VersionManagerImpl(this);
|
|
||||||
this.scheduler = new SchedulerImpl(this);
|
this.scheduler = new SchedulerImpl(this);
|
||||||
this.storageManager = new StorageManagerImpl(this);
|
this.storageManager = new StorageManagerImpl(this);
|
||||||
this.requirementManager = new RequirementManagerImpl(this);
|
this.requirementManager = new RequirementManagerImpl(this);
|
||||||
|
|||||||
@@ -286,6 +286,10 @@ public class AdventureManagerImpl implements AdventureManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Audience audience(Player player) {
|
||||||
|
return adventure.player(player);
|
||||||
|
}
|
||||||
|
|
||||||
public class CacheSystem {
|
public class CacheSystem {
|
||||||
|
|
||||||
private final LoadingCache<String, Object> miniMessageToIChatComponentCache;
|
private final LoadingCache<String, Object> miniMessageToIChatComponentCache;
|
||||||
|
|||||||
@@ -63,11 +63,19 @@ public enum Dependency {
|
|||||||
COMMAND_API(
|
COMMAND_API(
|
||||||
"dev{}jorel",
|
"dev{}jorel",
|
||||||
"commandapi-bukkit-shade",
|
"commandapi-bukkit-shade",
|
||||||
"9.4.0",
|
"9.5.1",
|
||||||
null,
|
null,
|
||||||
"commandapi-bukkit",
|
"commandapi-bukkit",
|
||||||
Relocation.of("commandapi", "dev{}jorel{}commandapi")
|
Relocation.of("commandapi", "dev{}jorel{}commandapi")
|
||||||
),
|
),
|
||||||
|
COMMAND_API_MOJMAP(
|
||||||
|
"dev{}jorel",
|
||||||
|
"commandapi-bukkit-shade-mojang-mapped",
|
||||||
|
"9.5.1",
|
||||||
|
null,
|
||||||
|
"commandapi-bukkit-mojang-mapped",
|
||||||
|
Relocation.of("commandapi", "dev{}jorel{}commandapi")
|
||||||
|
),
|
||||||
MARIADB_DRIVER(
|
MARIADB_DRIVER(
|
||||||
"org{}mariadb{}jdbc",
|
"org{}mariadb{}jdbc",
|
||||||
"mariadb-java-client",
|
"mariadb-java-client",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ 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 net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -40,14 +41,11 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
*/
|
*/
|
||||||
public class VersionManagerImpl implements VersionManager, Listener {
|
public class VersionManagerImpl implements VersionManager, Listener {
|
||||||
|
|
||||||
private final boolean isNewerThan1_19;
|
|
||||||
private final boolean isNewerThan1_19_R2;
|
private final float mcVersion;
|
||||||
private final boolean isNewerThan1_19_R3;
|
|
||||||
private final boolean isNewerThan1_20;
|
|
||||||
private final boolean isNewerThan1_20_R2;
|
|
||||||
private final String serverVersion;
|
|
||||||
private final CustomNameplatesPluginImpl plugin;
|
private final CustomNameplatesPluginImpl plugin;
|
||||||
private boolean isFolia;
|
private boolean isFolia;
|
||||||
|
private boolean isMojmap;
|
||||||
private final String pluginVersion;
|
private final String pluginVersion;
|
||||||
private boolean isLatest = true;
|
private boolean isLatest = true;
|
||||||
|
|
||||||
@@ -55,47 +53,47 @@ public class VersionManagerImpl implements VersionManager, Listener {
|
|||||||
public VersionManagerImpl(CustomNameplatesPluginImpl plugin) {
|
public VersionManagerImpl(CustomNameplatesPluginImpl plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// Get the server version
|
// Get the server version
|
||||||
serverVersion = plugin.getServer().getClass().getPackage().getName().split("\\.")[3];
|
|
||||||
String[] split = serverVersion.split("_");
|
String[] split = Bukkit.getServer().getBukkitVersion().split("-")[0].split("\\.");
|
||||||
int main_ver = Integer.parseInt(split[1]);
|
this.mcVersion = Float.parseFloat(split[1] + "." + split[2]);
|
||||||
// Determine if the server version is newer than 1_19_R2 and 1_20_R1
|
|
||||||
if (main_ver >= 20) {
|
|
||||||
isNewerThan1_20_R2 = Integer.parseInt(split[2].substring(1)) >= 2;
|
|
||||||
isNewerThan1_19_R2 = isNewerThan1_19_R3 = true;
|
|
||||||
isNewerThan1_20 = true;
|
|
||||||
isNewerThan1_19 = true;
|
|
||||||
} else if (main_ver == 19) {
|
|
||||||
isNewerThan1_19_R2 = Integer.parseInt(split[2].substring(1)) >= 2;
|
|
||||||
isNewerThan1_19_R3 = Integer.parseInt(split[2].substring(1)) >= 3;
|
|
||||||
isNewerThan1_20 = isNewerThan1_20_R2 = false;
|
|
||||||
isNewerThan1_19 = true;
|
|
||||||
} else {
|
|
||||||
isNewerThan1_19 = isNewerThan1_19_R2= isNewerThan1_19_R3 = false;
|
|
||||||
isNewerThan1_20 = isNewerThan1_20_R2 = false;
|
|
||||||
}
|
|
||||||
// Check if the server is Folia
|
|
||||||
try {
|
|
||||||
Class.forName("io.papermc.paper.threadedregions.scheduler.AsyncScheduler");
|
|
||||||
this.isFolia = true;
|
|
||||||
} catch (ClassNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
// Get the plugin version
|
// Get the plugin version
|
||||||
this.pluginVersion = plugin.getDescription().getVersion();
|
this.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
// Check if the server is Folia
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||||
|
this.isFolia = true;
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
this.isFolia = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the server is Mojmap
|
||||||
|
try {
|
||||||
|
Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket");
|
||||||
|
this.isMojmap = true;
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMojmap() {
|
||||||
|
return isMojmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVersionNewerThan1_19_R2() {
|
public boolean isVersionNewerThan1_19_R2() {
|
||||||
return isNewerThan1_19_R2;
|
return mcVersion >= 19.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVersionNewerThan1_20() {
|
public boolean isVersionNewerThan1_20() {
|
||||||
return isNewerThan1_20;
|
return mcVersion >= 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVersionNewerThan1_20_R2() {
|
public boolean isVersionNewerThan1_20_R2() {
|
||||||
return isNewerThan1_20_R2;
|
return mcVersion >= 20.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -111,36 +109,42 @@ public class VersionManagerImpl implements VersionManager, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVersionNewerThan1_19() {
|
public boolean isVersionNewerThan1_19() {
|
||||||
return isNewerThan1_19;
|
return mcVersion >= 19;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVersionNewerThan1_19_R3() {
|
public boolean isVersionNewerThan1_19_R3() {
|
||||||
return isNewerThan1_19_R3;
|
return mcVersion >= 19.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPackFormat() {
|
public int getPackFormat() {
|
||||||
switch (serverVersion) {
|
switch (Bukkit.getServer().getBukkitVersion().split("-")[0]) {
|
||||||
case "v1_20_R3" -> {
|
case "1.21" -> {
|
||||||
|
return 34;
|
||||||
|
}
|
||||||
|
case "1.20.5", "1.20.6" -> {
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
case "1.20.3", "1.20.4" -> {
|
||||||
return 22;
|
return 22;
|
||||||
}
|
}
|
||||||
case "v1_20_R2" -> {
|
case "1.20.2" -> {
|
||||||
return 18;
|
return 18;
|
||||||
}
|
}
|
||||||
case "v1_20_R1" -> {
|
case "1.20", "1.20.1" -> {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
case "v1_19_R3" -> {
|
case "1.19.4" -> {
|
||||||
return 13;
|
return 13;
|
||||||
}
|
}
|
||||||
case "v1_19_R2" -> {
|
case "1.19.3" -> {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
case "v1_19_R1" -> {
|
case "1.19", "1.19.1", "1.19.2" -> {
|
||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
case "v1_18_R1", "v1_18_R2" -> {
|
case "1.18", "1.18.1", "1.18.2" -> {
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
@@ -154,11 +158,6 @@ public class VersionManagerImpl implements VersionManager, Listener {
|
|||||||
return isFolia;
|
return isFolia;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServerVersion() {
|
|
||||||
return serverVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to asynchronously check for plugin updates
|
// Method to asynchronously check for plugin updates
|
||||||
public CompletableFuture<Boolean> checkUpdate() {
|
public CompletableFuture<Boolean> checkUpdate() {
|
||||||
CompletableFuture<Boolean> updateFuture = new CompletableFuture<>();
|
CompletableFuture<Boolean> updateFuture = new CompletableFuture<>();
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package net.momirealms.customnameplates.paper.mechanic.requirement;
|
package net.momirealms.customnameplates.paper.mechanic.requirement;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.momirealms.biomeapi.BiomeAPI;
|
|
||||||
import net.momirealms.customnameplates.api.manager.RequirementManager;
|
import net.momirealms.customnameplates.api.manager.RequirementManager;
|
||||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||||
import net.momirealms.customnameplates.api.requirement.RequirementExpansion;
|
import net.momirealms.customnameplates.api.requirement.RequirementExpansion;
|
||||||
@@ -32,6 +31,7 @@ import net.momirealms.customnameplates.paper.util.ClassUtils;
|
|||||||
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
||||||
import net.momirealms.customnameplates.paper.util.DisguiseUtils;
|
import net.momirealms.customnameplates.paper.util.DisguiseUtils;
|
||||||
import net.momirealms.customnameplates.paper.util.GeyserUtils;
|
import net.momirealms.customnameplates.paper.util.GeyserUtils;
|
||||||
|
import net.momirealms.sparrow.heart.SparrowHeart;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -327,14 +327,14 @@ public class RequirementManagerImpl implements RequirementManager {
|
|||||||
registerRequirement("biome", (args) -> {
|
registerRequirement("biome", (args) -> {
|
||||||
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||||
return condition -> {
|
return condition -> {
|
||||||
String currentBiome = BiomeAPI.getBiomeAt(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
|
String currentBiome = SparrowHeart.getInstance().getBiomeResourceLocation(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
|
||||||
return biomes.contains(currentBiome);
|
return biomes.contains(currentBiome);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
registerRequirement("!biome", (args) -> {
|
registerRequirement("!biome", (args) -> {
|
||||||
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||||
return condition -> {
|
return condition -> {
|
||||||
String currentBiome = BiomeAPI.getBiomeAt(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
|
String currentBiome = SparrowHeart.getInstance().getBiomeResourceLocation(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
|
||||||
return !biomes.contains(currentBiome);
|
return !biomes.contains(currentBiome);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,13 +27,15 @@ 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.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.TeamColor;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||||
|
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||||
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.provider.*;
|
import net.momirealms.customnameplates.paper.mechanic.team.provider.*;
|
||||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||||
|
import net.momirealms.sparrow.heart.SparrowHeart;
|
||||||
|
import net.momirealms.sparrow.heart.feature.team.TeamCollisionRule;
|
||||||
|
import net.momirealms.sparrow.heart.feature.team.TeamColor;
|
||||||
|
import net.momirealms.sparrow.heart.feature.team.TeamVisibility;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -50,13 +52,11 @@ import java.util.Optional;
|
|||||||
public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||||
|
|
||||||
private final CustomNameplatesPlugin plugin;
|
private final CustomNameplatesPlugin plugin;
|
||||||
private final TeamPacketAdaptor teamPacketAdaptor;
|
|
||||||
private TeamProvider teamProvider;
|
private TeamProvider teamProvider;
|
||||||
private static final String CHANNEL = "customnameplates:cnp";
|
private static final String CHANNEL = "customnameplates:cnp";
|
||||||
|
|
||||||
public TeamManagerImpl(CustomNameplatesPlugin plugin) {
|
public TeamManagerImpl(CustomNameplatesPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.teamPacketAdaptor = new TeamPacket_1_17();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,35 +78,33 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
}
|
}
|
||||||
playerTeam.addPlayer(player);
|
playerTeam.addPlayer(player);
|
||||||
} else {
|
} else {
|
||||||
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
|
|
||||||
TeamCreate.builder()
|
|
||||||
.teamName(team)
|
|
||||||
.color(TeamColor.WHITE)
|
|
||||||
.display("")
|
|
||||||
.prefix("")
|
|
||||||
.suffix("")
|
|
||||||
.members(Collections.singletonList(player.getName()))
|
|
||||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
|
||||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
PacketManager.getInstance().send(online, createOwner);
|
SparrowHeart.getInstance().addClientSideTeam(online, team,
|
||||||
|
Collections.singletonList(player.getName()),
|
||||||
|
"{\"text\":\"\"}",
|
||||||
|
"{\"text\":\"\"}",
|
||||||
|
"{\"text\":\"\"}",
|
||||||
|
TeamVisibility.ALWAYS,
|
||||||
|
TeamVisibility.ALWAYS,
|
||||||
|
TeamCollisionRule.ALWAYS,
|
||||||
|
TeamColor.WHITE,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
);
|
||||||
if (online == player) continue;
|
if (online == player) continue;
|
||||||
String onlineTeam = teamProvider.getTeam(online, null);
|
String onlineTeam = teamProvider.getTeam(online, null);
|
||||||
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
|
SparrowHeart.getInstance().addClientSideTeam(player, team,
|
||||||
TeamCreate.builder()
|
Collections.singletonList(onlineTeam),
|
||||||
.teamName(onlineTeam)
|
"{\"text\":\"\"}",
|
||||||
.color(TeamColor.WHITE)
|
"{\"text\":\"\"}",
|
||||||
.display("")
|
"{\"text\":\"\"}",
|
||||||
.prefix("")
|
TeamVisibility.ALWAYS,
|
||||||
.suffix("")
|
TeamVisibility.ALWAYS,
|
||||||
.members(Collections.singletonList(online.getName()))
|
TeamCollisionRule.ALWAYS,
|
||||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
TeamColor.WHITE,
|
||||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
true,
|
||||||
.build()
|
true
|
||||||
);
|
);
|
||||||
PacketManager.getInstance().send(player, createOther);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,28 +125,23 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
Optional.ofNullable(scoreboard.getTeam(team)).ifPresent(Team::unregister);
|
Optional.ofNullable(scoreboard.getTeam(team)).ifPresent(Team::unregister);
|
||||||
} else {
|
} else {
|
||||||
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
|
|
||||||
TeamRemove.builder()
|
|
||||||
.teamName(team)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
if (player == online) continue;
|
if (player == online) continue;
|
||||||
PacketManager.getInstance().send(online, packet);
|
SparrowHeart.getInstance().removeClientSideTeam(online, team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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, net.momirealms.customnameplates.common.team.TeamColor color, TeamTagVisibility visibility) {
|
||||||
if (CNConfig.disableTeamManage) return;
|
if (CNConfig.disableTeamManage) return;
|
||||||
String team = teamProvider.getTeam(owner, viewer);
|
String team = teamProvider.getTeam(owner, viewer);
|
||||||
if (team == null) {
|
if (team == null) {
|
||||||
LogUtils.warn("Failed to get player " + owner.getName() + "'s team for viewer " + viewer.getName());
|
LogUtils.warn("Failed to get player " + owner.getName() + "'s team for viewer " + viewer.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
|
if (color == net.momirealms.customnameplates.common.team.TeamColor.NONE || color == net.momirealms.customnameplates.common.team.TeamColor.CUSTOM)
|
||||||
color = TeamColor.WHITE;
|
color = net.momirealms.customnameplates.common.team.TeamColor.WHITE;
|
||||||
if (plugin.getNameplateManager().isProxyMode()) {
|
if (plugin.getNameplateManager().isProxyMode()) {
|
||||||
this.sendPluginMessage(
|
this.sendPluginMessage(
|
||||||
MessageType.UPDATE,
|
MessageType.UPDATE,
|
||||||
@@ -160,18 +153,18 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
visibility.name()
|
visibility.name()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
|
SparrowHeart.getInstance().updateClientSideTeam(
|
||||||
TeamUpdate.builder()
|
viewer, team,
|
||||||
.teamName(team)
|
"{\"text\":\"\"}",
|
||||||
.color(color)
|
AdventureManagerImpl.getInstance().componentToJson(AdventureManagerImpl.getInstance().getComponentFromMiniMessage(prefix)),
|
||||||
.display("")
|
AdventureManagerImpl.getInstance().componentToJson(AdventureManagerImpl.getInstance().getComponentFromMiniMessage(suffix)),
|
||||||
.prefix(prefix)
|
TeamVisibility.ALWAYS,
|
||||||
.suffix(suffix)
|
TeamVisibility.ALWAYS,
|
||||||
.tagVisibility(visibility)
|
TeamCollisionRule.ALWAYS,
|
||||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
TeamColor.valueOf(color.name()),
|
||||||
.build()
|
true,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
PacketManager.getInstance().send(viewer, packet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,166 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.packet;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
|
||||||
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class TeamCreate {
|
|
||||||
|
|
||||||
// String i
|
|
||||||
private String teamName;
|
|
||||||
// Collection<String> j
|
|
||||||
private Collection<String> members;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Optional<b> k
|
|
||||||
*/
|
|
||||||
// IChatBaseComponent a
|
|
||||||
private Object teamDisplay;
|
|
||||||
// IChatBaseComponent b
|
|
||||||
private Object teamPrefix;
|
|
||||||
// IChatBaseComponent c
|
|
||||||
private Object teamSuffix;
|
|
||||||
// String d
|
|
||||||
private TeamTagVisibility tagVisibility;
|
|
||||||
// String e
|
|
||||||
private TeamCollisionRule collisionRule;
|
|
||||||
// Enum f
|
|
||||||
private TeamColor teamColor;
|
|
||||||
|
|
||||||
private TeamCreate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamCreate(
|
|
||||||
String teamName,
|
|
||||||
Collection<String> members,
|
|
||||||
Component teamDisplay,
|
|
||||||
Component teamPrefix,
|
|
||||||
Component teamSuffix,
|
|
||||||
TeamTagVisibility tagVisibility,
|
|
||||||
TeamCollisionRule collisionRule,
|
|
||||||
TeamColor teamColor
|
|
||||||
) {
|
|
||||||
this.teamName = teamName;
|
|
||||||
this.members = members;
|
|
||||||
this.teamDisplay = teamDisplay;
|
|
||||||
this.teamPrefix = teamPrefix;
|
|
||||||
this.teamSuffix = teamSuffix;
|
|
||||||
this.tagVisibility = tagVisibility;
|
|
||||||
this.collisionRule = collisionRule;
|
|
||||||
this.teamColor = teamColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamName() {
|
|
||||||
return teamName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<String> getMembers() {
|
|
||||||
return members;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTeamDisplay() {
|
|
||||||
return teamDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTeamPrefix() {
|
|
||||||
return teamPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTeamSuffix() {
|
|
||||||
return teamSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamTagVisibility getTagVisibility() {
|
|
||||||
return tagVisibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamCollisionRule getCollisionRule() {
|
|
||||||
return collisionRule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamColor getTeamColor() {
|
|
||||||
return teamColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
|
|
||||||
private final TeamCreate packet;
|
|
||||||
|
|
||||||
public Builder() {
|
|
||||||
this.packet = new TeamCreate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder of() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder teamName(String name) {
|
|
||||||
packet.teamName = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder members(Collection<String> members) {
|
|
||||||
packet.members = members;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder display(String display) {
|
|
||||||
packet.teamDisplay = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(display);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder prefix(String prefix) {
|
|
||||||
packet.teamPrefix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(prefix);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder suffix(String suffix) {
|
|
||||||
packet.teamSuffix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(suffix);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder color(TeamColor color) {
|
|
||||||
packet.teamColor = color;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder tagVisibility(TeamTagVisibility visibility) {
|
|
||||||
packet.tagVisibility = visibility;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder collisionRule(TeamCollisionRule rule) {
|
|
||||||
packet.collisionRule = rule;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamCreate build() {
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.packet;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
|
|
||||||
public interface TeamPacketAdaptor {
|
|
||||||
|
|
||||||
PacketContainer getTeamCreatePacket(TeamCreate teamCreate);
|
|
||||||
|
|
||||||
PacketContainer getTeamUpdatePacket(TeamUpdate teamUpdate);
|
|
||||||
|
|
||||||
PacketContainer getTeamRemovePacket(TeamRemove teamRemove);
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.packet;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.InternalStructure;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
|
||||||
public class TeamPacket_1_17 implements TeamPacketAdaptor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketContainer getTeamCreatePacket(TeamCreate teamCreate) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
|
|
||||||
// 0 = create team
|
|
||||||
packet.getModifier().write(0,0);
|
|
||||||
packet.getModifier().write(1, teamCreate.getTeamName());
|
|
||||||
packet.getModifier().write(2, teamCreate.getMembers());
|
|
||||||
Optional<InternalStructure> optionalInternalStructure = packet.getOptionalStructures().read(0);
|
|
||||||
if (optionalInternalStructure.isPresent()) {
|
|
||||||
InternalStructure is = optionalInternalStructure.get();
|
|
||||||
// Team
|
|
||||||
is.getModifier().write(0, teamCreate.getTeamDisplay());
|
|
||||||
is.getModifier().write(1, teamCreate.getTeamPrefix());
|
|
||||||
is.getModifier().write(2, teamCreate.getTeamSuffix());
|
|
||||||
is.getModifier().write(3, teamCreate.getTagVisibility().getId());
|
|
||||||
is.getModifier().write(4, teamCreate.getCollisionRule().getId());
|
|
||||||
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamCreate.getTeamColor());
|
|
||||||
is.getModifier().write(6, teamCreate.getMembers().size());
|
|
||||||
}
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketContainer getTeamRemovePacket(TeamRemove teamRemove) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
|
|
||||||
// 1 = remove team
|
|
||||||
packet.getModifier().write(0,1);
|
|
||||||
packet.getStrings().write(0, teamRemove.getTeamName());
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketContainer getTeamUpdatePacket(TeamUpdate teamUpdate) {
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
|
|
||||||
// 2 = update team
|
|
||||||
packet.getModifier().write(0,2);
|
|
||||||
packet.getModifier().write(1, teamUpdate.getTeamName());
|
|
||||||
Optional<InternalStructure> optionalInternalStructure = packet.getOptionalStructures().read(0);
|
|
||||||
if (optionalInternalStructure.isPresent()) {
|
|
||||||
InternalStructure is = optionalInternalStructure.get();
|
|
||||||
// Team
|
|
||||||
is.getModifier().write(0, teamUpdate.getTeamDisplay());
|
|
||||||
is.getModifier().write(1, teamUpdate.getTeamPrefix());
|
|
||||||
is.getModifier().write(2, teamUpdate.getTeamSuffix());
|
|
||||||
is.getModifier().write(3, teamUpdate.getTagVisibility().getId());
|
|
||||||
is.getModifier().write(4, teamUpdate.getCollisionRule().getId());
|
|
||||||
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamUpdate.getTeamColor());
|
|
||||||
}
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.packet;
|
|
||||||
|
|
||||||
public class TeamRemove {
|
|
||||||
|
|
||||||
private String teamName;
|
|
||||||
|
|
||||||
private TeamRemove() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamRemove(String teamName) {
|
|
||||||
this.teamName = teamName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamName() {
|
|
||||||
return teamName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
|
|
||||||
private final TeamRemove packet;
|
|
||||||
|
|
||||||
public Builder() {
|
|
||||||
this.packet = new TeamRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder teamName(String teamName) {
|
|
||||||
packet.teamName = teamName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamRemove build() {
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.packet;
|
|
||||||
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
|
||||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
|
||||||
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
|
||||||
|
|
||||||
public class TeamUpdate {
|
|
||||||
|
|
||||||
private String teamName;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Optional<b> k
|
|
||||||
*/
|
|
||||||
// IChatBaseComponent a
|
|
||||||
private Object teamDisplay;
|
|
||||||
// IChatBaseComponent b
|
|
||||||
private Object teamPrefix;
|
|
||||||
// IChatBaseComponent c
|
|
||||||
private Object teamSuffix;
|
|
||||||
// String d
|
|
||||||
private TeamTagVisibility tagVisibility;
|
|
||||||
// String e
|
|
||||||
private TeamCollisionRule collisionRule;
|
|
||||||
// Enum f
|
|
||||||
private TeamColor teamColor;
|
|
||||||
|
|
||||||
private TeamUpdate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamUpdate(
|
|
||||||
String teamName,
|
|
||||||
Object teamDisplay,
|
|
||||||
Object teamPrefix,
|
|
||||||
Object teamSuffix,
|
|
||||||
TeamTagVisibility tagVisibility,
|
|
||||||
TeamCollisionRule collisionRule,
|
|
||||||
TeamColor teamColor
|
|
||||||
) {
|
|
||||||
this.teamName = teamName;
|
|
||||||
this.teamDisplay = teamDisplay;
|
|
||||||
this.teamPrefix = teamPrefix;
|
|
||||||
this.teamSuffix = teamSuffix;
|
|
||||||
this.tagVisibility = tagVisibility;
|
|
||||||
this.collisionRule = collisionRule;
|
|
||||||
this.teamColor = teamColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamName() {
|
|
||||||
return teamName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTeamDisplay() {
|
|
||||||
return teamDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTeamPrefix() {
|
|
||||||
return teamPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getTeamSuffix() {
|
|
||||||
return teamSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamTagVisibility getTagVisibility() {
|
|
||||||
return tagVisibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamCollisionRule getCollisionRule() {
|
|
||||||
return collisionRule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamColor getTeamColor() {
|
|
||||||
return teamColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
|
|
||||||
private final TeamUpdate packet;
|
|
||||||
|
|
||||||
public Builder() {
|
|
||||||
this.packet = new TeamUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder of() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder teamName(String name) {
|
|
||||||
packet.teamName = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder display(String display) {
|
|
||||||
packet.teamDisplay = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(display);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder prefix(String prefix) {
|
|
||||||
packet.teamPrefix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(prefix);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder suffix(String suffix) {
|
|
||||||
packet.teamSuffix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(suffix);;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder color(TeamColor color) {
|
|
||||||
packet.teamColor = color;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder tagVisibility(TeamTagVisibility visibility) {
|
|
||||||
packet.tagVisibility = visibility;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder collisionRule(TeamCollisionRule rule) {
|
|
||||||
packet.collisionRule = rule;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TeamUpdate build() {
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
package net.momirealms.customnameplates.paper.util;
|
package net.momirealms.customnameplates.paper.util;
|
||||||
|
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
|
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -42,23 +43,43 @@ public class ReflectionUtils {
|
|||||||
private static boolean isPaper;
|
private static boolean isPaper;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
try {
|
if (CustomNameplatesPlugin.get().getVersionManager().isMojmap()) {
|
||||||
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
|
try {
|
||||||
Field remove = bar.getDeclaredField("f");
|
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket");
|
||||||
remove.setAccessible(true);
|
Field remove = bar.getDeclaredField("REMOVE_OPERATION");
|
||||||
removeBossBarPacket = remove.get(null);
|
remove.setAccessible(true);
|
||||||
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
|
removeBossBarPacket = remove.get(null);
|
||||||
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
|
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket$UpdateProgressOperation");
|
||||||
progressConstructor.setAccessible(true);
|
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
|
||||||
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
|
progressConstructor.setAccessible(true);
|
||||||
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
|
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket$UpdateNameOperation");
|
||||||
updateConstructor.setAccessible(true);
|
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
|
||||||
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
|
updateConstructor.setAccessible(true);
|
||||||
iChatComponentMethod.setAccessible(true);
|
Class<?> craftChatMessageClass = Class.forName("org.bukkit.craftbukkit.util.CraftChatMessage");
|
||||||
emptyComponent = iChatComponentMethod.invoke(null, "{\"text\":\"\"}");
|
iChatComponentMethod = craftChatMessageClass.getDeclaredMethod("fromJSON", String.class);
|
||||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
|
iChatComponentMethod.setAccessible(true);
|
||||||
LogUtils.severe("Error occurred when loading reflections", exception);
|
emptyComponent = iChatComponentMethod.invoke(null, "{\"text\":\"\"}");
|
||||||
exception.printStackTrace();
|
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
|
||||||
|
LogUtils.severe("Error occurred while loading reflections", exception);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
|
||||||
|
Field remove = bar.getDeclaredField("f");
|
||||||
|
remove.setAccessible(true);
|
||||||
|
removeBossBarPacket = remove.get(null);
|
||||||
|
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
|
||||||
|
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
|
||||||
|
progressConstructor.setAccessible(true);
|
||||||
|
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
|
||||||
|
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
|
||||||
|
updateConstructor.setAccessible(true);
|
||||||
|
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
|
||||||
|
iChatComponentMethod.setAccessible(true);
|
||||||
|
emptyComponent = iChatComponentMethod.invoke(null, "{\"text\":\"\"}");
|
||||||
|
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
|
||||||
|
LogUtils.severe("Error occurred while loading reflections", exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class<?> componentClass = Class.forName("net;kyori;adventure;text;Component".replace(";", "."));
|
Class<?> componentClass = Class.forName("net;kyori;adventure;text;Component".replace(";", "."));
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#version 150
|
||||||
|
#moj_import<fog.glsl>
|
||||||
|
|
||||||
|
uniform sampler2D Sampler0;
|
||||||
|
uniform vec4 ColorModulator;
|
||||||
|
uniform float FogStart,FogEnd;
|
||||||
|
uniform vec4 FogColor;
|
||||||
|
uniform float GameTime;
|
||||||
|
|
||||||
|
in float vertexDistance;
|
||||||
|
in vec4 vertexColor;
|
||||||
|
in vec2 texCoord0;
|
||||||
|
in float depthLevel;
|
||||||
|
%SHADER_0%
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 texColor = texture(Sampler0, texCoord0);
|
||||||
|
vec4 color = texColor * vertexColor * ColorModulator;%SHADER_1%
|
||||||
|
if (color.a < 0.1) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
if (texColor.a == 254.0/255.0) {
|
||||||
|
if (depthLevel == 0.00) {
|
||||||
|
discard;
|
||||||
|
} else {
|
||||||
|
color = vec4(texColor.rgb, 1.0) * vertexColor * ColorModulator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"blend": {
|
||||||
|
"func": "add",
|
||||||
|
"srcrgb": "srcalpha",
|
||||||
|
"dstrgb": "1-srcalpha"
|
||||||
|
},
|
||||||
|
"vertex": "rendertype_text",
|
||||||
|
"fragment": "rendertype_text",
|
||||||
|
"attributes": [
|
||||||
|
"Position",
|
||||||
|
"Color",
|
||||||
|
"UV0",
|
||||||
|
"UV2"
|
||||||
|
],
|
||||||
|
"samplers": [
|
||||||
|
{ "name": "Sampler0" },
|
||||||
|
{ "name": "Sampler2" }
|
||||||
|
],
|
||||||
|
"uniforms": [
|
||||||
|
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||||
|
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||||
|
{ "name": "IViewRotMat", "type": "matrix3x3", "count": 9, "values": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||||
|
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
|
||||||
|
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||||
|
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] },
|
||||||
|
{ "name": "GameTime", "type": "float", "count": 1, "values": [ 1.0 ] },
|
||||||
|
{ "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#version 150
|
||||||
|
#moj_import <fog.glsl>
|
||||||
|
|
||||||
|
in vec3 Position;
|
||||||
|
in vec4 Color;
|
||||||
|
in vec2 UV0;
|
||||||
|
in ivec2 UV2;
|
||||||
|
|
||||||
|
uniform sampler2D Sampler2;
|
||||||
|
uniform mat4 ModelViewMat;
|
||||||
|
uniform mat4 ProjMat;
|
||||||
|
uniform mat3 IViewRotMat;
|
||||||
|
uniform float GameTime;
|
||||||
|
uniform int FogShape;
|
||||||
|
uniform vec2 ScreenSize;
|
||||||
|
|
||||||
|
out float vertexDistance;
|
||||||
|
out vec4 vertexColor;
|
||||||
|
out vec2 texCoord0;
|
||||||
|
out float depthLevel;
|
||||||
|
%SHADER_0%
|
||||||
|
void main() {
|
||||||
|
vec4 vertex = vec4(Position, 1.0);
|
||||||
|
vertexDistance = fog_distance(ModelViewMat, IViewRotMat * Position, FogShape);
|
||||||
|
depthLevel = Position.z;
|
||||||
|
texCoord0 = UV0;
|
||||||
|
%SHADER_1%%SHADER_2%%SHADER_3%
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ tasks {
|
|||||||
shadowJar {
|
shadowJar {
|
||||||
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
||||||
relocate ("org.bstats", "net.momirealms.customnameplates.libraries.bstats")
|
relocate ("org.bstats", "net.momirealms.customnameplates.libraries.bstats")
|
||||||
relocate ("net.momirealms.biomeapi", "net.momirealms.customnameplates.libraries.biomeapi")
|
relocate ("net.momirealms.sparrow.heart", "net.momirealms.customnameplates.libraries.sparrow")
|
||||||
relocate ("org.apache.commons.pool2", "net.momirealms.customnameplates.libraries.commonspool2")
|
relocate ("org.apache.commons.pool2", "net.momirealms.customnameplates.libraries.commonspool2")
|
||||||
relocate ("com.mysql", "net.momirealms.customnameplates.libraries.mysql")
|
relocate ("com.mysql", "net.momirealms.customnameplates.libraries.mysql")
|
||||||
relocate ("org.mariadb", "net.momirealms.customnameplates.libraries.mariadb")
|
relocate ("org.mariadb", "net.momirealms.customnameplates.libraries.mariadb")
|
||||||
|
|||||||
Reference in New Issue
Block a user