mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
添加队伍包拦截
This commit is contained in:
@@ -25,6 +25,7 @@ dependencies {
|
||||
compileOnly("net.kyori:adventure-text-serializer-gson:${rootProject.properties["adventure_bundle_version"]}") {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
}
|
||||
compileOnly("net.kyori:adventure-text-serializer-json-legacy-impl:${rootProject.properties["adventure_bundle_version"]}")
|
||||
// Command
|
||||
compileOnly("org.incendo:cloud-core:${rootProject.properties["cloud_core_version"]}")
|
||||
compileOnly("org.incendo:cloud-minecraft-extras:${rootProject.properties["cloud_minecraft_extras_version"]}")
|
||||
@@ -46,7 +47,6 @@ dependencies {
|
||||
compileOnly("org.lz4:lz4-java:${rootProject.properties["lz4_version"]}")
|
||||
// Commons IO
|
||||
compileOnly("commons-io:commons-io:${rootProject.properties["commons_io_version"]}")
|
||||
compileOnly("commons-io:commons-io:${rootProject.properties["commons_io_version"]}")
|
||||
// Data Fixer Upper
|
||||
compileOnly("com.mojang:datafixerupper:${rootProject.properties["datafixerupper_version"]}")
|
||||
// Aho-Corasick java implementation
|
||||
|
||||
@@ -282,7 +282,7 @@ public abstract class CraftEngine implements Plugin {
|
||||
Dependencies.SNAKE_YAML,
|
||||
Dependencies.BOOSTED_YAML,
|
||||
Dependencies.MINIMESSAGE,
|
||||
Dependencies.TEXT_SERIALIZER_GSON,
|
||||
Dependencies.TEXT_SERIALIZER_GSON, Dependencies.TEXT_SERIALIZER_GSON_LEGACY,
|
||||
Dependencies.TEXT_SERIALIZER_JSON,
|
||||
Dependencies.AHO_CORASICK,
|
||||
Dependencies.LZ4
|
||||
|
||||
@@ -128,6 +128,7 @@ public class Config {
|
||||
protected boolean image$intercept_packets$title;
|
||||
protected boolean image$intercept_packets$bossbar;
|
||||
protected boolean image$intercept_packets$container;
|
||||
protected boolean image$intercept_packets$team;
|
||||
|
||||
public Config(CraftEngine plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -290,6 +291,7 @@ public class Config {
|
||||
image$intercept_packets$title = config.getBoolean("image.intercept-packets.title", true);
|
||||
image$intercept_packets$bossbar = config.getBoolean("image.intercept-packets.bossbar", true);
|
||||
image$intercept_packets$container = config.getBoolean("image.intercept-packets.container", true);
|
||||
image$intercept_packets$team = config.getBoolean("image.intercept-packets.team", true);
|
||||
|
||||
Class<?> modClazz = ReflectionUtils.getClazz(CraftEngine.MOD_CLASS);
|
||||
if (modClazz != null) {
|
||||
@@ -614,6 +616,10 @@ public class Config {
|
||||
return instance.image$intercept_packets$container;
|
||||
}
|
||||
|
||||
public static boolean interceptTeam() {
|
||||
return instance.image$intercept_packets$team;
|
||||
}
|
||||
|
||||
public YamlDocument loadOrCreateYamlData(String fileName) {
|
||||
File file = new File(this.plugin.dataFolderFile(), fileName);
|
||||
if (!file.exists()) {
|
||||
|
||||
@@ -200,6 +200,13 @@ public class Dependencies {
|
||||
"adventure-text-serializer-gson",
|
||||
List.of(Relocation.of("adventure", "net{}kyori{}adventure"))
|
||||
);
|
||||
public static final Dependency TEXT_SERIALIZER_GSON_LEGACY = new Dependency(
|
||||
"adventure-text-serializer-json-legacy-impl",
|
||||
"net{}kyori",
|
||||
"adventure-text-serializer-json-legacy-impl",
|
||||
"adventure-text-serializer-json-legacy-impl",
|
||||
List.of(Relocation.of("adventure", "net{}kyori{}adventure"))
|
||||
);
|
||||
public static final Dependency TEXT_SERIALIZER_JSON = new Dependency(
|
||||
"adventure-text-serializer-json",
|
||||
"net{}kyori",
|
||||
|
||||
@@ -7,6 +7,10 @@ import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.json.JSONOptions;
|
||||
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
import net.momirealms.sparrow.nbt.serializer.NBTComponentSerializer;
|
||||
|
||||
/**
|
||||
* Helper class for handling Adventure components and related functionalities.
|
||||
@@ -16,11 +20,18 @@ public class AdventureHelper {
|
||||
private final MiniMessage miniMessage;
|
||||
private final MiniMessage miniMessageStrict;
|
||||
private final GsonComponentSerializer gsonComponentSerializer;
|
||||
private final NBTComponentSerializer nbtComponentSerializer;
|
||||
|
||||
private AdventureHelper() {
|
||||
this.miniMessage = MiniMessage.builder().build();
|
||||
this.miniMessageStrict = MiniMessage.builder().strict(true).build();
|
||||
this.gsonComponentSerializer = GsonComponentSerializer.builder().build();
|
||||
GsonComponentSerializer.Builder builder = GsonComponentSerializer.builder();
|
||||
if (!VersionHelper.isVersionNewerThan1_20_5()) {
|
||||
builder.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get());
|
||||
builder.editOptions((b) -> b.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, false));
|
||||
}
|
||||
this.gsonComponentSerializer = builder.build();
|
||||
this.nbtComponentSerializer = NBTComponentSerializer.builder().build();
|
||||
}
|
||||
|
||||
private static class SingletonHolder {
|
||||
@@ -54,6 +65,15 @@ public class AdventureHelper {
|
||||
return getInstance().gsonComponentSerializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the NBTComponentSerializer instance.
|
||||
*
|
||||
* @return the NBTComponentSerializer instance
|
||||
*/
|
||||
public static NBTComponentSerializer getNBT() {
|
||||
return getInstance().nbtComponentSerializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to an audience.
|
||||
*
|
||||
@@ -134,6 +154,14 @@ public class AdventureHelper {
|
||||
return getGson().serializeToTree(component);
|
||||
}
|
||||
|
||||
public static Tag componentToTag(Component component) {
|
||||
return getNBT().serialize(component);
|
||||
}
|
||||
|
||||
public static Component tagToComponent(Tag tag) {
|
||||
return getNBT().deserialize(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a character is a legacy color code.
|
||||
*
|
||||
|
||||
@@ -48,6 +48,22 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
return BlockPos.of(buf.readLong());
|
||||
}
|
||||
|
||||
public List<String> readStringList() {
|
||||
int i = this.readVarInt();
|
||||
List<String> list = new ArrayList<>(i);
|
||||
for (int j = 0; j < i; ++j) {
|
||||
list.add(readUtf());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void writeStringList(List<String> list) {
|
||||
writeVarInt(list.size());
|
||||
for (String s : list) {
|
||||
writeUtf(s);
|
||||
}
|
||||
}
|
||||
|
||||
public FriendlyByteBuf writeBlockPos(BlockPos pos) {
|
||||
this.writeLong(pos.asLong());
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user