Browse Source

Fixed simpleslime with magmacubes + temp patch for redstone lever spam

pull/2/head
Stefatorus 4 years ago
parent
commit
8c5939ec1c
  1. 2
      plugin.yml
  2. 13
      server.yml
  3. 52
      src/cx/sfy/LagAssist/microfeatures/MicroManager.java
  4. 4
      src/cx/sfy/LagAssist/mobs/SmartMob.java

2
plugin.yml

@ -1,6 +1,6 @@
name: LagAssist
author: Stefatorus
version: 2.23.2
version: 2.23.3
api-version: 1.13
description: LagAssist is an advanced anti-lag solution that allows server owners find and remove lag using multiple advanced and efficient methods.
main: cx.sfy.LagAssist.Main

13
server.yml

@ -154,6 +154,19 @@ microfeatures:
# Two versions (flattening and pre)
- "MELON_BLOCK"
- "MELON"
# Fixes issue with redstone item spam causing lag on the server.
# https://rz.al/u/5591.png
click-spam-fix:
enable: false
# Blocks that will increase the counter/
blocks:
- "LEVER"
counter:
message: "&cStop interacting with this block so fast."
# How much to increment each interact?
increment: 20
# Max value before showing the message
max: 80
# Laggy Chunk detection. You can fiddle around and find the best settings for your

52
src/cx/sfy/LagAssist/microfeatures/MicroManager.java

@ -3,16 +3,21 @@ package cx.sfy.LagAssist.microfeatures;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.material.MaterialData;
import org.bukkit.material.PistonBaseMaterial;
@ -36,9 +41,13 @@ public class MicroManager implements Listener {
for (BlockState b : breakables) {
b.getBlock().breakNaturally();
}
breakables.clear();
for(Player p : intervals.keySet()) {
intervals.compute(p, (key, value) -> value - 5 < 0 ? null : value-5);
}
}, 5, 5);
}
@ -89,4 +98,45 @@ public class MicroManager implements Listener {
}
private static Map<Player, Integer> intervals = new WeakHashMap<>();
@EventHandler(priority = EventPriority.HIGHEST)
public void onRightClick(PlayerInteractEvent e) {
if (!Main.config.getBoolean("microfeatures.click-spam-fix.enable")) {
return;
}
if (e.isCancelled()) {
return;
}
Block b = e.getClickedBlock();
if (b == null) {
return;
}
Material mat = b.getType();
if (!Main.config.getStringList("microfeatures.click-spam-fix.blocks").contains(mat.toString())) {
return;
}
Player p = e.getPlayer();
int increment = Main.config.getInt("microfeatures.click-spam-fix.counter.increment");
int result = intervals.getOrDefault(p, 0);
if (result > Main.config.getInt("microfeatures.click-spam-fix.counter.max")) {
e.setCancelled(true);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.config.getString("microfeatures.click-spam-fix.counter.message")));
return;
}
intervals.compute(p, (key, counter) -> (counter == null ? increment : counter+increment));
//
// System.out.println(increment + " " + result);
}
}

4
src/cx/sfy/LagAssist/mobs/SmartMob.java

@ -91,7 +91,7 @@ public class SmartMob implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void DeathListener(EntityDeathEvent e) {
Entity ent = e.getEntity();
if (simpleslime && ent instanceof Slime) {
if (simpleslime && ent.getType() == EntityType.SLIME) {
Slime slm = (Slime) ent;
e.getDrops().clear();
@ -127,7 +127,7 @@ public class SmartMob implements Listener {
}, 40L);
}
if (simpleslime && (reason == SpawnReason.SLIME_SPLIT)) {
if (simpleslime && (reason == SpawnReason.SLIME_SPLIT) && ent.getType() == EntityType.SLIME) {
e.setCancelled(true);
}

Loading…
Cancel
Save