Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Commit 770a71c

Browse files
committed
added files
0 parents  commit 770a71c

File tree

7 files changed

+507
-0
lines changed

7 files changed

+507
-0
lines changed

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# LecternCrashFix
2+
This fixes the new [lectern crash/exploit](https://github.com/Coderx-Gamer/lectern-crash). This bug is fixed on Paper build 276 and above.
3+
4+
This fix is jank but it works. The client isn't going to "click" on the lectern inventory normally, so this just detects any clicks sent and cancels them.
5+
6+
Requires [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/).

pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>lol.hyper</groupId>
8+
<artifactId>lecterncrashfix</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>LecternCrashFix</name>
13+
14+
<properties>
15+
<java.version>1.8</java.version>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<groupId>org.apache.maven.plugins</groupId>
23+
<artifactId>maven-compiler-plugin</artifactId>
24+
<version>3.8.1</version>
25+
<configuration>
26+
<source>${java.version}</source>
27+
<target>${java.version}</target>
28+
</configuration>
29+
</plugin>
30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-shade-plugin</artifactId>
33+
<version>3.2.4</version>
34+
<executions>
35+
<execution>
36+
<phase>package</phase>
37+
<goals>
38+
<goal>shade</goal>
39+
</goals>
40+
<configuration>
41+
<createDependencyReducedPom>false</createDependencyReducedPom>
42+
</configuration>
43+
</execution>
44+
</executions>
45+
</plugin>
46+
</plugins>
47+
<resources>
48+
<resource>
49+
<directory>src/main/resources</directory>
50+
<filtering>true</filtering>
51+
</resource>
52+
</resources>
53+
</build>
54+
55+
<repositories>
56+
<repository>
57+
<id>spigotmc-repo</id>
58+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
59+
</repository>
60+
<repository>
61+
<id>dmulloy2-repo</id>
62+
<url>https://repo.dmulloy2.net/repository/public/</url>
63+
</repository>
64+
</repositories>
65+
66+
<dependencies>
67+
<dependency>
68+
<groupId>org.spigotmc</groupId>
69+
<artifactId>spigot-api</artifactId>
70+
<version>1.18.1-R0.1-SNAPSHOT</version>
71+
<scope>provided</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>com.comphenix.protocol</groupId>
75+
<artifactId>ProtocolLib</artifactId>
76+
<version>4.7.0</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
</dependencies>
80+
</project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package lol.hyper.lecterncrashfix;
2+
3+
import com.comphenix.protocol.PacketType;
4+
import com.comphenix.protocol.ProtocolLibrary;
5+
import com.comphenix.protocol.events.ListenerPriority;
6+
import com.comphenix.protocol.events.PacketAdapter;
7+
import com.comphenix.protocol.events.PacketEvent;
8+
import lol.hyper.lecterncrashfix.wrapper.WrapperPlayClientWindowClick;
9+
import org.bukkit.entity.Player;
10+
import org.bukkit.event.inventory.InventoryType;
11+
import org.bukkit.inventory.InventoryView;
12+
import org.bukkit.plugin.java.JavaPlugin;
13+
14+
import java.util.logging.Logger;
15+
16+
public final class LecternCrashFix extends JavaPlugin {
17+
18+
private Logger logger = this.getLogger();
19+
20+
@Override
21+
public void onEnable() {
22+
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Client.WINDOW_CLICK) {
23+
@Override
24+
public void onPacketReceiving(PacketEvent event) {
25+
if (event.getPlayer() == null) {
26+
return;
27+
}
28+
29+
WrapperPlayClientWindowClick packet = new WrapperPlayClientWindowClick(event.getPacket());
30+
Player player = event.getPlayer();
31+
InventoryView inv = player.getOpenInventory();
32+
if (inv.getType() == InventoryType.LECTERN) {
33+
if (packet.getSlot() == 1) {
34+
event.setCancelled(true);
35+
logger.warning(player.getName() + " tried to illegally click a slot in a lectern!");
36+
}
37+
}
38+
}
39+
});
40+
}
41+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
3+
* Copyright (C) dmulloy2 <http://dmulloy2.net>
4+
* Copyright (C) Kristian S. Strangeland
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
package lol.hyper.lecterncrashfix.wrapper;
20+
21+
import java.lang.reflect.InvocationTargetException;
22+
23+
import org.bukkit.entity.Player;
24+
25+
import com.comphenix.protocol.PacketType;
26+
import com.comphenix.protocol.ProtocolLibrary;
27+
import com.comphenix.protocol.events.PacketContainer;
28+
import com.google.common.base.Objects;
29+
30+
public abstract class AbstractPacket {
31+
// The packet we will be modifying
32+
protected PacketContainer handle;
33+
34+
/**
35+
* Constructs a new strongly typed wrapper for the given packet.
36+
*
37+
* @param handle - handle to the raw packet data.
38+
* @param type - the packet type.
39+
*/
40+
protected AbstractPacket(PacketContainer handle, PacketType type) {
41+
// Make sure we're given a valid packet
42+
if (handle == null)
43+
throw new IllegalArgumentException("Packet handle cannot be NULL.");
44+
if (!Objects.equal(handle.getType(), type))
45+
throw new IllegalArgumentException(handle.getHandle()
46+
+ " is not a packet of type " + type);
47+
48+
this.handle = handle;
49+
}
50+
51+
/**
52+
* Retrieve a handle to the raw packet data.
53+
*
54+
* @return Raw packet data.
55+
*/
56+
public PacketContainer getHandle() {
57+
return handle;
58+
}
59+
60+
/**
61+
* Send the current packet to the given receiver.
62+
*
63+
* @param receiver - the receiver.
64+
* @throws RuntimeException If the packet cannot be sent.
65+
*/
66+
public void sendPacket(Player receiver) {
67+
try {
68+
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
69+
getHandle());
70+
} catch (InvocationTargetException e) {
71+
throw new RuntimeException("Cannot send packet.", e);
72+
}
73+
}
74+
75+
/**
76+
* Send the current packet to all online players.
77+
*/
78+
public void broadcastPacket() {
79+
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle());
80+
}
81+
82+
/**
83+
* Simulate receiving the current packet from the given sender.
84+
*
85+
* @param sender - the sender.
86+
* @throws RuntimeException If the packet cannot be received.
87+
* @deprecated Misspelled. recieve to receive
88+
* @see #receivePacket(Player)
89+
*/
90+
@Deprecated
91+
public void recievePacket(Player sender) {
92+
try {
93+
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
94+
getHandle());
95+
} catch (Exception e) {
96+
throw new RuntimeException("Cannot recieve packet.", e);
97+
}
98+
}
99+
100+
/**
101+
* Simulate receiving the current packet from the given sender.
102+
*
103+
* @param sender - the sender.
104+
* @throws RuntimeException if the packet cannot be received.
105+
*/
106+
public void receivePacket(Player sender) {
107+
try {
108+
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
109+
getHandle());
110+
} catch (Exception e) {
111+
throw new RuntimeException("Cannot receive packet.", e);
112+
}
113+
}
114+
}

0 commit comments

Comments
 (0)