-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...yExploitFixesFolia/src/main/java/me/xginko/aef/modules/dupepreventions/BookTitleDupe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package me.xginko.aef.modules.dupepreventions; | ||
|
||
import com.github.retrooper.packetevents.event.PacketListenerPriority; | ||
import com.github.retrooper.packetevents.event.PacketReceiveEvent; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEditBook; | ||
import me.xginko.aef.modules.packets.PacketModule; | ||
import me.xginko.aef.utils.PlatformUtil; | ||
|
||
public class BookTitleDupe extends PacketModule { | ||
|
||
private final int maxTitleChars; | ||
|
||
public BookTitleDupe() { | ||
super("dupe-preventions.book-title-dupe", PacketListenerPriority.HIGHEST); | ||
config.addComment(configPath + ".enable", """ | ||
Relevant for 1.20.6 - 1.21: | ||
Will prevent players from sending book packets with a too large title, | ||
to get disconnected and their inventories restored."""); | ||
this.maxTitleChars = config.getInt(configPath + ".max-title-charlength", 20, """ | ||
Normal ascii like charlimit in vanilla is 15, you could need a bit more | ||
if you want to support languages with special characters."""); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
return config.getBoolean(configPath + ".enable", PlatformUtil.getMinecraftPatchVersion() > 19); | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (event.getPacketType() != PacketType.Play.Client.EDIT_BOOK) return; | ||
|
||
WrapperPlayClientEditBook packet = new WrapperPlayClientEditBook(event); | ||
if (packet.getTitle() == null) return; | ||
|
||
if (packet.getTitle().length() > maxTitleChars) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ExploitFixesLegacy/src/main/java/me/xginko/aef/modules/dupepreventions/BookTitleDupe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package me.xginko.aef.modules.dupepreventions; | ||
|
||
import com.github.retrooper.packetevents.event.PacketListenerPriority; | ||
import com.github.retrooper.packetevents.event.PacketReceiveEvent; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEditBook; | ||
import me.xginko.aef.modules.packets.PacketModule; | ||
import me.xginko.aef.utils.PlatformUtil; | ||
|
||
public class BookTitleDupe extends PacketModule { | ||
|
||
private final int maxTitleChars; | ||
|
||
public BookTitleDupe() { | ||
super("dupe-preventions.book-title-dupe", PacketListenerPriority.HIGHEST); | ||
config.addComment(configPath + ".enable", | ||
"Relevant for 1.20.6 - 1.21:\n" + | ||
"Will prevent players from sending book packets with a too large title,\n" + | ||
"to get disconnected and their inventories restored."); | ||
this.maxTitleChars = config.getInt(configPath + ".max-title-charlength", 20, | ||
"Normal ascii like charlimit in vanilla is 15, you could need a bit more\n" + | ||
"if you want to support languages with special characters."); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
return config.getBoolean(configPath + ".enable", PlatformUtil.getMinecraftPatchVersion() > 19); | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (event.getPacketType() != PacketType.Play.Client.EDIT_BOOK) return; | ||
|
||
WrapperPlayClientEditBook packet = new WrapperPlayClientEditBook(event); | ||
if (packet.getTitle() == null) return; | ||
|
||
if (packet.getTitle().length() > maxTitleChars) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} |