Skip to content

Commit ff273a8

Browse files
committed
Update to 26.1
1 parent 13650a6 commit ff273a8

11 files changed

Lines changed: 120 additions & 20 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "java"
3-
id "io.github.goooler.shadow" version "${shadowVer}"
3+
id "com.gradleup.shadow" version "${shadowVer}"
44
id "org.jetbrains.gradle.plugin.idea-ext" version "1.0.1"
55
}
66

@@ -20,7 +20,7 @@ tasks {
2020

2121
allprojects {
2222
group = "com.github.kaspiandev.antipopup"
23-
version = "12.4"
23+
version = "13"
2424

2525
repositories {
2626
mavenCentral()

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
userdevVer=2.0.0-beta.17
2-
shadowVer=8.1.7
1+
userdevVer=2.0.0-beta.21
2+
shadowVer=9.4.1
33
tinyRemapperVer=0.10.3
4-
packetEventsVer=2.11.1
4+
packetEventsVer=2.12.0

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ rootProject.name = "AntiPopup"
99
include "spigot", "shared", "nms", "v1.19.2", "v1.19.3", "v1.19.4",
1010
"v1.20.1", "v1.20.2", "v1.20.4", "v1.20.6", "v1.21",
1111
"v1.21.2", "v1.21.4", "v1.21.5", "v1.21.6", "v1.21.9", "v1.21.11",
12-
"velocity"
12+
"v26.1", "velocity"
1313

spigot/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "java"
3-
id "io.github.goooler.shadow" version "${shadowVer}"
3+
id "com.gradleup.shadow" version "${shadowVer}"
44
}
55

66
repositories {
@@ -27,6 +27,7 @@ dependencies {
2727
implementation project(path: ":v1.21.6", configuration: "reobf")
2828
implementation project(path: ":v1.21.9", configuration: "reobf")
2929
implementation project(path: ":v1.21.11", configuration: "reobf")
30+
implementation project(path: ":v26.1", configuration: "default")
3031

3132
compileOnly "org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT"
3233
compileOnly "com.viaversion:viaversion:5.4.0"

spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/AntiPopup.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.github.kaspiandev.antipopup.nms.v1_21_6.PlayerInjector_v1_21_6;
1919
import com.github.kaspiandev.antipopup.nms.v1_21_9.PlayerInjector_v1_21_9;
2020
import com.github.kaspiandev.antipopup.nms.v1_21_11.PlayerInjector_v1_21_11;
21+
import com.github.kaspiandev.antipopup.nms.v26_1.PlayerInjector_v26_1;
2122
import com.github.kaspiandev.antipopup.spigot.api.Api;
2223
import com.github.kaspiandev.antipopup.spigot.hook.HookManager;
2324
import com.github.kaspiandev.antipopup.spigot.hook.viaversion.ViaVersionHook;
@@ -125,6 +126,7 @@ public void onEnable() {
125126
if (config.isBlockChatReports()) {
126127
if (!config.isExperimentalMode()) {
127128
PlayerListener playerListener = switch (serverManager.getVersion()) {
129+
case V_26_1, V_26_1_1 -> new PlayerListener(new PlayerInjector_v26_1());
128130
case V_1_21_11 -> new PlayerListener(new PlayerInjector_v1_21_11());
129131
case V_1_21_9, V_1_21_10 -> new PlayerListener(new PlayerInjector_v1_21_9());
130132
case V_1_21_6, V_1_21_7, V_1_21_8 -> new PlayerListener(new PlayerInjector_v1_21_6());

spigot/src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ softdepend:
1111
- ViaRewind
1212
- Geyser-Spigot
1313
authors: [ Kaspian ]
14-
description: A plugin that removed annoying unsafe server popup.
14+
description: A plugin that removes annoying unsafe server popup.
1515
commands:
1616
antipopup:
1717
description: Main antipopup command.

v1.21.11/build.gradle

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,3 @@ java {
1818
sourceCompatibility = JavaVersion.VERSION_17
1919
targetCompatibility = JavaVersion.VERSION_17
2020
}
21-
22-
// Configure jar manifest to indicate Mojang mappings
23-
// This tells Paper that the plugin is already Mojang-mapped and doesn't need reobf
24-
//tasks.named("jar") {
25-
// manifest {
26-
// attributes([
27-
// "paperweight-mappings-namespace": "mojang"
28-
// ])
29-
// }
30-
//}

v26.1/build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
plugins {
2+
id "java"
3+
id "io.papermc.paperweight.userdev" version "${userdevVer}"
4+
}
5+
6+
dependencies {
7+
compileOnly project(path: ":shared")
8+
compileOnly project(path: ":nms")
9+
10+
paperweightDevelopmentBundle "io.papermc.paper:dev-bundle:26.1.1.build.28-alpha"
11+
}
12+
13+
java {
14+
disableAutoTargetJvm()
15+
toolchain {
16+
languageVersion.set(JavaLanguageVersion.of(25))
17+
}
18+
sourceCompatibility = JavaVersion.VERSION_17
19+
targetCompatibility = JavaVersion.VERSION_17
20+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.github.kaspiandev.antipopup.nms.v26_1;
2+
3+
import com.github.kaspiandev.antipopup.spigot.nms.PacketInjector;
4+
import io.netty.channel.*;
5+
import net.minecraft.network.Connection;
6+
import net.minecraft.network.chat.ChatType;
7+
import net.minecraft.network.chat.Component;
8+
import net.minecraft.network.protocol.game.ClientboundPlayerChatPacket;
9+
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket;
10+
import net.minecraft.server.network.ServerCommonPacketListenerImpl;
11+
import net.minecraft.server.network.ServerGamePacketListenerImpl;
12+
import org.bukkit.craftbukkit.entity.CraftPlayer;
13+
import org.bukkit.entity.Player;
14+
15+
import java.lang.reflect.Field;
16+
import java.lang.reflect.InaccessibleObjectException;
17+
18+
@SuppressWarnings("unused")
19+
public class PlayerInjector_v26_1 implements PacketInjector {
20+
21+
private static final String HANDLER_NAME = "antipopup_handler";
22+
private static Field connectionField;
23+
24+
static {
25+
try {
26+
for (Field field : ServerCommonPacketListenerImpl.class.getDeclaredFields()) {
27+
if (field.getType().equals(Connection.class)) {
28+
field.setAccessible(true);
29+
connectionField = field;
30+
break;
31+
}
32+
}
33+
} catch (SecurityException | InaccessibleObjectException e) {
34+
throw new RuntimeException(e);
35+
}
36+
}
37+
38+
public void inject(Player player) {
39+
ChannelDuplexHandler duplexHandler = new ChannelDuplexHandler() {
40+
@Override
41+
public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception {
42+
if (packet instanceof ClientboundPlayerChatPacket chatPacket) {
43+
Component content = chatPacket.unsignedContent();
44+
if (content == null) {
45+
content = Component.literal(chatPacket.body().content());
46+
}
47+
ChatType.Bound chatType = chatPacket.chatType();
48+
49+
((CraftPlayer) player).getHandle().connection.send(
50+
new ClientboundSystemChatPacket(chatType.decorate(content), false));
51+
return;
52+
}
53+
super.write(ctx, packet, promise);
54+
}
55+
};
56+
57+
ServerGamePacketListenerImpl listener = ((CraftPlayer) player).getHandle().connection;
58+
Channel channel = getConnection(listener).channel;
59+
ChannelPipeline pipeline = channel.pipeline();
60+
61+
if (pipeline.get(HANDLER_NAME) != null) {
62+
pipeline.remove(HANDLER_NAME);
63+
}
64+
65+
channel.eventLoop().submit(() -> {
66+
channel.pipeline().addBefore("packet_handler", HANDLER_NAME, duplexHandler);
67+
});
68+
}
69+
70+
public void uninject(Player player) {
71+
ServerGamePacketListenerImpl listener = ((CraftPlayer) player).getHandle().connection;
72+
Channel channel = getConnection(listener).channel;
73+
channel.eventLoop().submit(() -> {
74+
channel.pipeline().remove(HANDLER_NAME);
75+
});
76+
}
77+
78+
private Connection getConnection(ServerGamePacketListenerImpl listener) {
79+
try {
80+
return (Connection) connectionField.get(listener);
81+
} catch (IllegalAccessException e) {
82+
throw new RuntimeException(e);
83+
}
84+
}
85+
86+
}
87+

0 commit comments

Comments
 (0)