mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-20 07:29:17 +00:00
添加屏蔽部分包的功能
This commit is contained in:
@@ -899,7 +899,12 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onNMSPacketReceive(NetWorkUser user, NMSPacketEvent event, Object packet) {
|
private void onNMSPacketReceive(NetWorkUser user, NMSPacketEvent event, Object packet) {
|
||||||
Debugger.PACKET.debug(() -> "[C->S]" + packet.getClass());
|
Debugger.PACKET.debug(() -> {
|
||||||
|
if (Config.isPacketIgnored(packet.getClass())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return "[C->S]" + packet.getClass();
|
||||||
|
});
|
||||||
handleReceiveNMSPacket(user, event, packet);
|
handleReceiveNMSPacket(user, event, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,7 +915,12 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
|
|||||||
onNMSPacketSend(player, event, p);
|
onNMSPacketSend(player, event, p);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Debugger.PACKET.debug(() -> "[S->C]" + packet.getClass());
|
Debugger.PACKET.debug(() -> {
|
||||||
|
if (Config.isPacketIgnored(packet.getClass())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return "[S->C]" + packet.getClass();
|
||||||
|
});
|
||||||
handleSendNMSPacket(player, event, packet);
|
handleSendNMSPacket(player, event, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -579,9 +579,10 @@ client-optimization:
|
|||||||
# Enables or disables debug mode
|
# Enables or disables debug mode
|
||||||
debug:
|
debug:
|
||||||
common: false
|
common: false
|
||||||
packet: false
|
|
||||||
furniture: false
|
furniture: false
|
||||||
item: false
|
item: false
|
||||||
resource-pack: false
|
resource-pack: false
|
||||||
block: false
|
block: false
|
||||||
entity-culling: false
|
entity-culling: false
|
||||||
|
packet: false
|
||||||
|
ignored-packets: []
|
||||||
@@ -52,8 +52,8 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mcmeta1Pack.has("min_format") || mcmeta2Pack.has("min_format")) {
|
if (mcmeta1Pack.has("min_format") || mcmeta2Pack.has("min_format")) {
|
||||||
int[] minFormat1 = new int[]{Integer.MAX_VALUE, 0};
|
int[] minFormat1 = new int[]{1000, 15};
|
||||||
int[] minFormat2 = new int[]{Integer.MAX_VALUE, 0};
|
int[] minFormat2 = new int[]{1000, 15};
|
||||||
|
|
||||||
if (mcmeta1Pack.has("min_format")) {
|
if (mcmeta1Pack.has("min_format")) {
|
||||||
JsonElement minFormat = mcmeta1Pack.get("min_format");
|
JsonElement minFormat = mcmeta1Pack.get("min_format");
|
||||||
@@ -62,9 +62,13 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
}
|
}
|
||||||
if (minFormat.isJsonArray()) {
|
if (minFormat.isJsonArray()) {
|
||||||
JsonArray minFormatArray = minFormat.getAsJsonArray();
|
JsonArray minFormatArray = minFormat.getAsJsonArray();
|
||||||
minFormat1[0] = minFormatArray.get(0).getAsInt();
|
if (!minFormatArray.isEmpty()) {
|
||||||
if (minFormatArray.size() > 1) {
|
if (minFormatArray.get(0) instanceof JsonPrimitive jp0) {
|
||||||
minFormat1[1] = minFormatArray.get(1).getAsInt();
|
minFormat1[0] = jp0.getAsInt();
|
||||||
|
}
|
||||||
|
if (minFormatArray.size() > 1 && minFormatArray.get(1) instanceof JsonPrimitive jp1) {
|
||||||
|
minFormat1[1] = jp1.getAsInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,11 +78,15 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
if (minFormat.isJsonPrimitive()) {
|
if (minFormat.isJsonPrimitive()) {
|
||||||
minFormat2[0] = minFormat.getAsInt();
|
minFormat2[0] = minFormat.getAsInt();
|
||||||
}
|
}
|
||||||
if (mcmeta2Pack.isJsonArray()) {
|
if (minFormat.isJsonArray()) {
|
||||||
JsonArray minFormatArray = minFormat.getAsJsonArray();
|
JsonArray minFormatArray = minFormat.getAsJsonArray();
|
||||||
minFormat2[0] = minFormatArray.get(0).getAsInt();
|
if (!minFormatArray.isEmpty()) {
|
||||||
if (minFormatArray.size() > 1) {
|
if (minFormatArray.get(0) instanceof JsonPrimitive jp0) {
|
||||||
minFormat2[1] = minFormatArray.get(1).getAsInt();
|
minFormat2[0] = jp0.getAsInt();
|
||||||
|
}
|
||||||
|
if (minFormatArray.size() > 1 && minFormatArray.get(1) instanceof JsonPrimitive jp1) {
|
||||||
|
minFormat2[1] = jp1.getAsInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,9 +108,13 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
}
|
}
|
||||||
if (maxFormat.isJsonArray()) {
|
if (maxFormat.isJsonArray()) {
|
||||||
JsonArray maxFormatArray = maxFormat.getAsJsonArray();
|
JsonArray maxFormatArray = maxFormat.getAsJsonArray();
|
||||||
maxFormat1[0] = maxFormatArray.get(0).getAsInt();
|
if (!maxFormatArray.isEmpty()) {
|
||||||
if (maxFormatArray.size() > 1) {
|
if (maxFormatArray.get(0) instanceof JsonPrimitive jp0) {
|
||||||
maxFormat1[1] = maxFormatArray.get(1).getAsInt();
|
maxFormat1[0] = jp0.getAsInt();
|
||||||
|
}
|
||||||
|
if (maxFormatArray.size() > 1 && maxFormatArray.get(1) instanceof JsonPrimitive jp1) {
|
||||||
|
maxFormat1[1] = jp1.getAsInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,9 +126,13 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
}
|
}
|
||||||
if (maxFormat.isJsonArray()) {
|
if (maxFormat.isJsonArray()) {
|
||||||
JsonArray maxFormatArray = maxFormat.getAsJsonArray();
|
JsonArray maxFormatArray = maxFormat.getAsJsonArray();
|
||||||
maxFormat2[0] = maxFormatArray.get(0).getAsInt();
|
if (!maxFormatArray.isEmpty()) {
|
||||||
if (maxFormatArray.size() > 1) {
|
if (maxFormatArray.get(0) instanceof JsonPrimitive jp0) {
|
||||||
maxFormat2[1] = maxFormatArray.get(1).getAsInt();
|
maxFormat2[0] = jp0.getAsInt();
|
||||||
|
}
|
||||||
|
if (maxFormatArray.size() > 1 && maxFormatArray.get(1) instanceof JsonPrimitive jp1) {
|
||||||
|
maxFormat2[1] = jp1.getAsInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class Config {
|
|||||||
protected boolean debug$resource_pack;
|
protected boolean debug$resource_pack;
|
||||||
protected boolean debug$block;
|
protected boolean debug$block;
|
||||||
protected boolean debug$entity_culling;
|
protected boolean debug$entity_culling;
|
||||||
|
protected Set<String> debug$ignored_packets;
|
||||||
|
|
||||||
protected boolean resource_pack$remove_tinted_leaves_particle;
|
protected boolean resource_pack$remove_tinted_leaves_particle;
|
||||||
protected boolean resource_pack$generate_mod_assets;
|
protected boolean resource_pack$generate_mod_assets;
|
||||||
@@ -323,6 +324,7 @@ public class Config {
|
|||||||
debug$resource_pack = config.getBoolean("debug.resource-pack", false);
|
debug$resource_pack = config.getBoolean("debug.resource-pack", false);
|
||||||
debug$block = config.getBoolean("debug.block", false);
|
debug$block = config.getBoolean("debug.block", false);
|
||||||
debug$entity_culling = config.getBoolean("debug.entity-culling", false);
|
debug$entity_culling = config.getBoolean("debug.entity-culling", false);
|
||||||
|
debug$ignored_packets = new HashSet<>(config.getStringList("debug.ignored-packets"));
|
||||||
|
|
||||||
// resource pack
|
// resource pack
|
||||||
resource_pack$path = resolvePath(config.getString("resource-pack.path", "./generated/resource_pack.zip"));
|
resource_pack$path = resolvePath(config.getString("resource-pack.path", "./generated/resource_pack.zip"));
|
||||||
@@ -1228,6 +1230,10 @@ public class Config {
|
|||||||
return instance.client_optimization$entity_culling$ray_tracing;
|
return instance.client_optimization$entity_culling$ray_tracing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isPacketIgnored(Class<?> clazz) {
|
||||||
|
return instance.debug$ignored_packets.contains(clazz.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean enableBedrockEditionSupport() {
|
public static boolean enableBedrockEditionSupport() {
|
||||||
return instance.bedrock_edition_support$enable;
|
return instance.bedrock_edition_support$enable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,24 @@ public enum Debugger {
|
|||||||
|
|
||||||
public void debug(Supplier<String> message) {
|
public void debug(Supplier<String> message) {
|
||||||
if (this.condition.get()) {
|
if (this.condition.get()) {
|
||||||
CraftEngine.instance().logger().info("[DEBUG] " + message.get());
|
String s = message.get();
|
||||||
|
if (s != null) {
|
||||||
|
CraftEngine.instance().logger().info("[DEBUG] " + s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(Supplier<String> message, Throwable e) {
|
public void warn(Supplier<String> message, Throwable e) {
|
||||||
if (this.condition.get()) {
|
if (this.condition.get()) {
|
||||||
|
String s = message.get();
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
CraftEngine.instance().logger().warn("[DEBUG] " + message.get(), e);
|
if (s != null) {
|
||||||
|
CraftEngine.instance().logger().warn("[DEBUG] " + s, e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
CraftEngine.instance().logger().warn("[DEBUG] " + message.get());
|
if (s != null) {
|
||||||
|
CraftEngine.instance().logger().warn("[DEBUG] " + s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user