Skip to content

Commit

Permalink
3.1.4
Browse files Browse the repository at this point in the history
Improved the lag machine patch
  • Loading branch information
Leeewith3Es authored Jun 24, 2022
1 parent 4df72a3 commit 2f1a64b
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 26 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/l2x9/l2x9core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void onEnable() {
getLogger().info("by Nate Legault enabled");
pluginManager.registerEvents(new BlockPlace(this), this);
pluginManager.registerEvents(new Offhand(this), this);
pluginManager.registerEvents(new GateWay(), this);
pluginManager.registerEvents(new GateWay(), this);
try {
commandHandler.registerCommands();
} catch (NotInPluginYMLException e) {
Expand All @@ -78,7 +79,7 @@ public void onEnable() {
pluginManager.registerEvents(new BucketEvent(this), this);
pluginManager.registerEvents(new MinecartLag(this), this);
//pluginManager.registerEvents(new PlayerChat(this), this);
pluginManager.registerEvents(new ChestLagFix(this), this);
//pluginManager.registerEvents(new ChestLagFix(this), this);
pluginManager.registerEvents(new dispensor(this), this);
pluginManager.registerEvents(new PacketElytraFly(this), this);
//pluginManager.registerEvents(connectionMessages, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.l2x9.l2x9core.Main;
Expand Down Expand Up @@ -58,6 +60,64 @@ public void onRedstoneTick(BlockRedstoneEvent event) {
}
}

@EventHandler
public void PistonExtendEvent(BlockPistonExtendEvent event) {
try {
if (Utils.getTps() <= plugin.getConfig().getInt("Redstone.Disable-TPS")
&& !(event.getBlock().getType() == Material.TRAPPED_CHEST)) {
Block block = event.getBlock();
String fagMachine = "Deleted a taco machine at " + block.getLocation().getBlockX() + " "
+ block.getLocation().getBlockY() + " " + block.getLocation().getBlockZ() + " in world "
+ block.getLocation().getWorld().getName() + "";
event.getBlock().setType(Material.AIR);
sendOpMessage("&6&l[&b&lLEF&6&l] &6Removed a lag machine at &r&1" + block.getLocation().getBlockX() + " " + block.getLocation().getBlockY() + " " + block.getLocation().getBlockZ() + "&r&6 owned by &r&1 " + Utils.getNearbyPlayer(50, block.getLocation()).getName(), "&aClick to telepot to the player", "/tp " + Utils.getNearbyPlayer(50, block.getLocation()).getName(), ClickEvent.Action.RUN_COMMAND);
//event.getBlock().getLocation().getWorld().strikeLightning(block.getLocation());
System.out.println(ChatColor.translateAlternateColorCodes('&', "&a" + fagMachine));
boolean alreadySent = false;
for (Entity entity : block.getChunk().getEntities()) {
if (!(entity instanceof Player)) {
entity.remove();
if (!alreadySent) {
System.out.println(ChatColor.GREEN + "Removed " + block.getChunk().getEntities().length + " " + entity.getType().toString().toLowerCase().concat("s") + " from a laggy chunk");
Utils.sendOpMessage("&6&l[&b&lLEF&6&l] &6Removed &r&1" + block.getChunk().getEntities().length + " " + entity.getType().toString().toLowerCase().concat("s") + "&r&6 from a laggy chunk");
alreadySent = true;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@EventHandler
public void PistonRetractEvent(BlockPistonRetractEvent event) {
try {
if (Utils.getTps() <= plugin.getConfig().getInt("Redstone.Disable-TPS")
&& !(event.getBlock().getType() == Material.TRAPPED_CHEST)) {
Block block = event.getBlock();
String fagMachine = "Deleted a taco machine at " + block.getLocation().getBlockX() + " "
+ block.getLocation().getBlockY() + " " + block.getLocation().getBlockZ() + " in world "
+ block.getLocation().getWorld().getName() + "";
event.getBlock().setType(Material.AIR);
sendOpMessage("&6&l[&b&lLEF&6&l] &6Removed a lag machine at &r&1" + block.getLocation().getBlockX() + " " + block.getLocation().getBlockY() + " " + block.getLocation().getBlockZ() + "&r&6 owned by &r&1 " + Utils.getNearbyPlayer(50, block.getLocation()).getName(), "&aClick to telepot to the player", "/tp " + Utils.getNearbyPlayer(50, block.getLocation()).getName(), ClickEvent.Action.RUN_COMMAND);
//event.getBlock().getLocation().getWorld().strikeLightning(block.getLocation());
System.out.println(ChatColor.translateAlternateColorCodes('&', "&a" + fagMachine));
boolean alreadySent = false;
for (Entity entity : block.getChunk().getEntities()) {
if (!(entity instanceof Player)) {
entity.remove();
if (!alreadySent) {
System.out.println(ChatColor.GREEN + "Removed " + block.getChunk().getEntities().length + " " + entity.getType().toString().toLowerCase().concat("s") + " from a laggy chunk");
Utils.sendOpMessage("&6&l[&b&lLEF&6&l] &6Removed &r&1" + block.getChunk().getEntities().length + " " + entity.getType().toString().toLowerCase().concat("s") + "&r&6 from a laggy chunk");
alreadySent = true;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@EventHandler
public void onPull(PlayerInteractEvent event) {
try {
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/org/l2x9/l2x9core/listeners/patches/ChestLagFix.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.l2x9.l2x9core.listeners.patches;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.ShulkerBox;
import org.bukkit.entity.Player;
Expand All @@ -11,6 +12,8 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.l2x9.l2x9core.Main;
import org.l2x9.l2x9core.util.SecondPassEvent;
import org.l2x9.l2x9core.util.Utils;
Expand All @@ -20,11 +23,12 @@
import java.util.regex.Pattern;

public class ChestLagFix implements Listener {
HashMap<Player, Integer> chestHashMap = new HashMap<>();
public HashMap<Player, Integer> chestHashMap = new HashMap<>();
Main plugin;

public ChestLagFix(Main plugin) {
this.plugin = plugin;

}

@EventHandler
Expand All @@ -45,13 +49,19 @@ public void onInventoryOpen(InventoryOpenEvent event) {
deleteNBTBooks(event.getInventory());
}
if (chestHashMap.get(player) > maxSpam) {
chestHashMap.clear();
Utils.kickPlayer(player, kickMessage);
chestHashMap.remove(player);
}
}
} catch (Error | Exception throwable) {
chestHashMap.clear();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer((Plugin) this, () -> {
if (Utils.getTps() <= 15) {
chestHashMap.clear();
}
}, 20L * 1L /*<-- the initial delay */, 20L * 30L /*<-- the interval */);
}

@EventHandler
Expand Down
39 changes: 20 additions & 19 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# LeeesExploitFixer 3.1.3 RELEASE
# LeeesExploitFixer 3.1.4 RELEASE
# There is no support for this plugin
# other than what is provided on the github

#Messages to send the player when they try to place illegal blocks
IllegalBlock-Place:
Enabled: true
Bedrock: '&6&l[&18b&98t&6&l]&6 &6That block is not allowed'
Barrier: '&6&l[&18b&98t&6&l]&6 &6That block is not allowed'
End_Portal_Frame: '&6&l[&18b&98t&6&l]&6 &6That block is not allowed'
Mob_Spawner: '&6&l[&18b&98t&6&l]&6 &6That block is not allowed'
Bedrock: '&6[&18b&98t&6]&6 &6That block is not allowed'
Barrier: '&6[&18b&98t&6]&6 &6That block is not allowed'
End_Portal_Frame: '&6[&18b&98t&6]&6 &6That block is not allowed'
Mob_Spawner: '&6[&18b&98t&6]&6 &6That block is not allowed'


#ChunkBan skull limit tile entity limit and prevent message
ChunkBan:
Enabled: true
Prevent-Message: '&6&l[&18b&98t&6&l]&6 &6ChunkBan has been disabled due to an exploit (^:'
Prevent-Message: '&6[&18b&98t&6]&6 &6ChunkBan has been disabled due to an exploit (^:'
TileEntity-Max: 500
Skull-Max: 100

Expand All @@ -23,9 +23,9 @@ ChunkBan:
Nether:
Enabled: true
Top-Layer: 127
Top-message: '&6&l[&18b&98t&6&l]&6 &6The nether top has been disabled due to lag'
Top-message: '&6[&18b&98t&6]&6 &6The nether top has been disabled due to lag'
Bottom-Layer: 0
Bottom-message: '&6&l[&18b&98t&6&l]&6 &6The nether bottom has been disabled due to lag'
Bottom-message: '&6[&18b&98t&6]&6 &6The nether bottom has been disabled due to lag'
top-bottom-do-damage: true


Expand Down Expand Up @@ -53,16 +53,16 @@ Elytra:
#enable taking off elytras when people go over the speed limit set to false to disable
EnableTakingOffElytra: false
#the message it sends to a player when they reach the elytra speed limit
SpeedLimitReached-message: "&6&l[&18b&98t&6&l]&6 You are going to fast slow down"
SpeedLimitReached-message: "&6[&18b&98t&6]&6 You are going to fast slow down"
#the message it sends to opped players when a player reaches the elytra speed limit
#you can turn this on or off by setting it to true or false
EnableOpMessages: true
SpeeedLimitReached-ops: "&6&l[&18b&98t&6&l]&6 Player {name} is going to fast with an elytra"
SpeeedLimitReached-ops: "&6[&18b&98t&6]&6 Player {name} is going to fast with an elytra"
#This will patch future clients packet elytra fly witch can be used to bypass most elytra speed limit plugins and make the elytra not lose any durability
PacketElytraFly-Enabled: true
#Sends a message to the player when they try to use PacketElytraFly
SendMessage: true
Message: "&6&l[&18b&98t&6&l]&6&6 PacketElytraFly is currently disabled due to it causing tons of lag"
Message: "&6[&18b&98t&6]&6&6 PacketElytraFly is currently disabled due to it causing tons of lag"


#TPS to disable redstone at
Expand All @@ -73,21 +73,21 @@ Redstone:
#Misc config shit
#Message to send when a player tries to use a 32k or strength 255
IllegalDamage:
Message: "&6&l[&18b&98t&6&l]&6&6 How did you even get a 32k out to begin with"
Message: "&6[&18b&98t&6]&6&6 How did you even get a 32k out to begin with"


#Player attempts to use or drink an illegal potion or use an illegal tipped arrow
IllegalPotion:
Message: "&6&l[&18b&98t&6&l]&6&6 Sorry those are patched"
Message: "&6[&18b&98t&6]&6&6 Sorry those are patched"


#Message to send the player when they use an elytra in low tps use {tps} to get the elytra disable tps
ElytraLowTPS:
Message: "&6&l[&18b&98t&6&l]&6 &6Elytras are disabled if the tps is below&r&c {tps}"
Message: "&6[&18b&98t&6]&6 &6Elytras are disabled if the tps is below&r&c {tps}"


UnbookBan:
Message: "&6&l[&18b&98t&6&l]&6&6 You have been unbookbanned"
Message: "&6[&18b&98t&6]&6&6 You have been unbookbanned"


#Message for /discord use & for colors
Expand All @@ -102,7 +102,7 @@ Minecart-per-chunk:

#TP on an entity exploit prevent message
tp.prevent:
message: "&6&l[&18b&98t&6&l]&6 &6Patched"
message: "&6[&18b&98t&6]&6 &6Patched"


#World name for the /world command and the fortress dat deleter
Expand Down Expand Up @@ -161,11 +161,12 @@ Help:
- '&c/changepass &6To change your password'
- '&c/worldstats &6view the servers size'
- '&6Visit &chttps://donate.8b8t.me &6to donate'
- '&1--------------------------------------'


#Formatting for the say command use {message} as a place holder for the message use & for colours
#Colour codes also work in the message
SayCommandFormat: "&6&l[&18b&98t&6&l]&6 {message}"
SayCommandFormat: "&6[&18b&98t&6]&6 {message}"


#water / lava flowing disable tps this is useful on new servers with lots of block physics updates that cause lag
Expand All @@ -175,8 +176,8 @@ BlockPhysics-disable-tps: -1

#This is to prevent people from crashing / lagging the server by spam opening chest and other containers
ChestLagFix:
MaxOpensPerSecond: 8
KickMessage: "&6&l[&18b&98t&6&l]&6&c [AntiChestLag]&r&6 You have lost connection to the server"
MaxOpensPerSecond: 5
KickMessage: "&6[&18b&98t&6]&6&c [AntiChestLag]&r&6 You have lost connection to the server"
RemoveUnicodeBooks: true


Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: LeeesExploitFixer
version: 3.1.3
version: 3.1.4
main: org.l2x9.l2x9core.Main
authors: [ 254n_m, Leeewith3Es ]
description: ${project.description}
Expand Down

0 comments on commit 2f1a64b

Please sign in to comment.