Skip to content

Commit

Permalink
Packetfly patch
Browse files Browse the repository at this point in the history
  • Loading branch information
moom0o committed Feb 14, 2021
1 parent 30fae7f commit fd0a8f2
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 24 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ DisableWithers: false
DisableExplosions: false
FixChatcoIgnoreBug: true
FixWorldStatsCommandBug: true
PreventGodMode: true
# Attempt to prevent chunk bans/fps lag.
PreventChunkBan: true
MaxEnchantmentTablePerChunk: 16
MaxEnderchestPerChunk: 64
MaxContainerPerChunk: 1000
MaxSignPerChunk: 100
# Antispam time in seconds
AntiSpamTime: 3
AntiSpamTime: 1
AntiSpamWordTime: 60
AntiSpamLinkTime: 300
PreventUnicodeDot: true
Expand Down Expand Up @@ -130,6 +129,12 @@ PatchPacketElytraFly: false
# Recommended to not go lower as there could be false positives.
MaxElytraOpensPer10Seconds: 25 # Will only allow players to go about 85km/h on kami blue, and won't even work on rusherhack.

# Patch future/rusher packet fly
PatchPacketFly: true
# Max teleport packets per 10 seconds, this is how the packet fly works, 25 is usually fine, if you go lower players may get stuck.
MaxTeleportPacketsPer10Seconds: 25
LogPacketFlyEvents: true

# Patch futureclient boat fly exploit
# Note: this also prevents boats on land. Boats in water are fine
BoatflyPatch: true
Expand Down Expand Up @@ -190,6 +195,4 @@ FallingBlocks: 19
</details>
## Missing features
* Modified god mode patch - Was removed because the original code was so shit that when reloaded with plugman all the players will get kicked, aswell as breaking support for anything other than 1.12.2. Please use my standalone plugin for this (1.12.2 only): https://github.com/moom0o/AntiGodMode
## Probably won't fix
* Packet fly - It's so slow it would be useless to patch. Might as well allow your players to go the same or less speed than walking :^)
* Modified god mode patch - Was removed because the original code was so shit that when reloaded with plugman all the players will get kicked, aswell as breaking support for anything other than 1.12.2. Please use my standalone plugin for this (1.12.2 only): https://github.com/moom0o/AntiGodMode
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.moomoo</groupId>
<artifactId>anarchyexploitfixes</artifactId>
<version>16.0</version>
<version>17.0</version>
<packaging>jar</packaging>

<name>AnarchyExploitFixes</name>
Expand Down
34 changes: 30 additions & 4 deletions src/main/java/me/moomoo/anarchyexploitfixes/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import me.moomoo.anarchyexploitfixes.misc.*;
import me.moomoo.anarchyexploitfixes.patches.*;
import me.moomoo.anarchyexploitfixes.prevention.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Player;
Expand All @@ -30,6 +27,7 @@ public class Main extends JavaPlugin implements Listener {
static HashSet<String> crafting = new HashSet<>();
public final HashMap<Player, Integer> newChunks = new HashMap<>();
public final HashMap<Player, Integer> oldChunks = new HashMap<>();
public HashMap<Player, Integer> levels = new HashMap<>();
public FileConfiguration config = getConfig();
private Logger log;

Expand Down Expand Up @@ -78,6 +76,34 @@ public void onPacketReceiving(PacketEvent event) {
}
});
}
if (config.getBoolean("PreventPacketFly")) {
protocolManager.addPacketListener(
new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Client.TELEPORT_ACCEPT) {
@Override
public void onPacketReceiving(PacketEvent event) {
Player e = event.getPlayer();
Location l = event.getPlayer().getLocation();
if (event.getPlayer().getWorld().getBlockAt(l.getBlockX(), l.getBlockY() - 1, l.getBlockZ()).getType() == Material.AIR && !e.isGliding() && !e.isInsideVehicle()) {
if (event.getPacketType() == PacketType.Play.Client.TELEPORT_ACCEPT) {
if (levels.get(e) != null) {
if (levels.get(e) > config.getInt("MaxTeleportPacketsPer10Seconds")) {
event.setCancelled(true);
if (getConfig().getBoolean("LogPacketFlyEvents")) {
plugin.getLogger().warning(e.getName() + " prevented from packetflying");
}
} else {
levels.merge(e, 1, Integer::sum);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> levels.put(e, levels.get(e) - 1), 200L);
}
} else {
levels.put(e, 1);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> levels.put(e, levels.get(e) - 1), 200L);
}
}
}
}
});
}
} else {
getLogger().warning("Did not detect ProtocolLib, disabling packet patches");
}
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/me/moomoo/anarchyexploitfixes/patches/Elytra.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,20 @@ public void onOpen(EntityToggleGlideEvent evt) {
PlayerInventory i = ((Player) evt.getEntity()).getInventory();
if (evt.getEntity() instanceof Player) {
Player e = (Player) evt.getEntity();
if (evt.getEntity().getName().equals("moom0o")) {
if (levels.get(e) != null) {
if (levels.get(e) > plugin.config.getInt("MaxElytraOpensPer10Seconds")) {
if (i.getChestplate() != null && i.getChestplate().getType().equals(Material.ELYTRA)) {
ItemStack elytra = i.getChestplate();
i.setChestplate(null);
evt.getEntity().getWorld().dropItemNaturally(i.getLocation(), elytra);
}
} else {
levels.merge(e, 1, Integer::sum);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> levels.put(e, levels.get(e) - 1), 200L);
if (levels.get(e) != null) {
if (levels.get(e) > plugin.config.getInt("MaxElytraOpensPer10Seconds")) {
if (i.getChestplate() != null && i.getChestplate().getType().equals(Material.ELYTRA)) {
ItemStack elytra = i.getChestplate();
i.setChestplate(null);
evt.getEntity().getWorld().dropItemNaturally(i.getLocation(), elytra);
}
} else {
levels.put(e, 1);
levels.merge(e, 1, Integer::sum);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> levels.put(e, levels.get(e) - 1), 200L);
}
} else {
levels.put(e, 1);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> levels.put(e, levels.get(e) - 1), 200L);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ DisableWithers: false
DisableExplosions: false
FixChatcoIgnoreBug: true
FixWorldStatsCommandBug: true
PreventGodMode: true
# Attempt to prevent chunk bans/fps lag.
PreventChunkBan: true
MaxEnchantmentTablePerChunk: 16
MaxEnderchestPerChunk: 64
MaxContainerPerChunk: 1000
MaxSignPerChunk: 100
# Antispam time in seconds
AntiSpamTime: 3
AntiSpamTime: 1
AntiSpamWordTime: 60
AntiSpamLinkTime: 300
PreventUnicodeDot: true
Expand Down Expand Up @@ -108,6 +107,12 @@ PatchPacketElytraFly: false
# Recommended to not go lower as there could be false positives.
MaxElytraOpensPer10Seconds: 25 # Will only allow players to go about 85km/h on kami blue, and won't even work on rusherhack.

# Patch future/rusher packet fly
PatchPacketFly: true
# Max teleport packets per 10 seconds, this is how the packet fly works, 25 is usually fine, if you go lower players may get stuck.
MaxTeleportPacketsPer10Seconds: 25
LogPacketFlyEvents: true

# Patch futureclient boat fly exploit
# Note: this also prevents boats on land. Boats in water are fine
BoatflyPatch: true
Expand Down

0 comments on commit fd0a8f2

Please sign in to comment.