mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 09:55:36 -05:00
Cleanups, better optimizations
This commit is contained in:
parent
a08c19f850
commit
2c6e2a8b31
14 changed files with 204 additions and 176 deletions
|
@ -12,16 +12,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
int fallingBlockCount;
|
||||
HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||
HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||
HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
||||
HashSet<BlockFace> faces = new HashSet<>();
|
||||
HashSet<Material> fallingBlockList = new HashSet<>();
|
||||
HashSet<Material> nonSolidBlockList = new HashSet<>();
|
||||
HashSet<Material> nonSolidDoubleBlockList = new HashSet<>();
|
||||
HashSet<Material> nonSolidSingularBlockList = new HashSet<>();
|
||||
HashSet<Material> nonSolidWallMountedBlockList = new HashSet<>();
|
||||
static int fallingBlockCount;
|
||||
static HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||
static HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||
static HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
||||
static HashSet<Material> nonSolidBlockList = new HashSet<>();
|
||||
static HashSet<Material> nonSolidDoubleBlockList = new HashSet<>();
|
||||
static HashSet<Material> nonSolidSingularBlockList = new HashSet<>();
|
||||
static HashSet<Material> nonSolidWallMountedBlockList = new HashSet<>();
|
||||
|
||||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
|
@ -381,23 +379,6 @@ public class Main extends JavaPlugin {
|
|||
"vvbukkit"
|
||||
);
|
||||
|
||||
Collections.addAll(
|
||||
faces,
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
BlockFace.WEST,
|
||||
BlockFace.EAST,
|
||||
BlockFace.UP,
|
||||
BlockFace.DOWN
|
||||
);
|
||||
|
||||
Collections.addAll(
|
||||
fallingBlockList,
|
||||
Material.ANVIL,
|
||||
Material.GRAVEL,
|
||||
Material.SAND
|
||||
);
|
||||
|
||||
Collections.addAll(
|
||||
nonSolidDoubleBlockList,
|
||||
Material.GRASS,
|
||||
|
@ -613,19 +594,19 @@ public class Main extends JavaPlugin {
|
|||
this.getCommand("destroyentities").setExecutor(new CommandDestroyEntities());
|
||||
this.getCommand("enchantall").setExecutor(new CommandEnchantAll());
|
||||
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
|
||||
this.getCommand("prefix").setExecutor(new CommandPrefix(this));
|
||||
this.getCommand("prefix").setExecutor(new CommandPrefix());
|
||||
this.getCommand("pumpkin").setExecutor(new CommandPumpkin());
|
||||
this.getCommand("skin").setExecutor(new CommandSkin(this));
|
||||
this.getCommand("skin").setExecutor(new CommandSkin());
|
||||
this.getCommand("spawn").setExecutor(new CommandSpawn());
|
||||
this.getCommand("spidey").setExecutor(new CommandSpidey());
|
||||
this.getCommand("tellraw").setExecutor(new CommandTellraw());
|
||||
this.getCommand("unloadchunks").setExecutor(new CommandUnloadChunks());
|
||||
this.getCommand("username").setExecutor(new CommandUsername(this));
|
||||
this.getCommand("username").setExecutor(new CommandUsername());
|
||||
|
||||
/* Block-related modules */
|
||||
this.getServer().getPluginManager().registerEvents(new BlockCheck(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new BlockCheck(), this);
|
||||
/*new TileEntityCheck(this).runTaskTimerAsynchronously(this, 0, 400);*/
|
||||
this.getServer().getPluginManager().registerEvents(new BlockPhysics(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new BlockPhysics(), this);
|
||||
|
||||
/* Entity-related modules */
|
||||
this.getServer().getPluginManager().registerEvents(new EntityExplosion(), this);
|
||||
|
@ -633,14 +614,14 @@ public class Main extends JavaPlugin {
|
|||
this.getServer().getPluginManager().registerEvents(new EntitySpawn(), this);
|
||||
|
||||
/* Player-related modules */
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerChat(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerCommand(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerConnection(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerChat(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerCommand(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerConnection(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerDamage(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerInteract(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerInteract(), this);
|
||||
|
||||
/* Server-related modules */
|
||||
this.getServer().getPluginManager().registerEvents(new ServerCommand(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ServerCommand(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ServerPing(), this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,27 +9,25 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class CommandPrefix implements CommandExecutor {
|
||||
private Main main;
|
||||
public CommandPrefix(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
class CommandPrefix implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
final Player player = (Player) sender;
|
||||
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
|
||||
} else if (args[0].equalsIgnoreCase("off")) {
|
||||
main.getConfig().set(player.getUniqueId().toString(), null);
|
||||
main.saveConfig();
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("You no longer have a tag");
|
||||
} else {
|
||||
main.getConfig().set(player.getUniqueId().toString(), String.join(" ", args));
|
||||
main.saveConfig();
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), String.join(" ", args));
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
|
@ -23,11 +25,6 @@ import com.google.gson.JsonObject;
|
|||
import com.google.gson.JsonParser;
|
||||
|
||||
class CommandSkin implements CommandExecutor {
|
||||
private Main main;
|
||||
public CommandSkin(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
|
@ -63,7 +60,7 @@ class CommandSkin implements CommandExecutor {
|
|||
public void run() {
|
||||
player.setPlayerProfile(textureProfile);
|
||||
}
|
||||
}.runTask(main);
|
||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||
} else {
|
||||
player.sendMessage("A player with that username doesn't exist");
|
||||
}
|
||||
|
@ -72,7 +69,7 @@ class CommandSkin implements CommandExecutor {
|
|||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}.runTaskAsynchronously(JavaPlugin.getPlugin(Main.class));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
|
@ -23,11 +25,6 @@ import com.google.gson.JsonObject;
|
|||
import com.google.gson.JsonParser;
|
||||
|
||||
class CommandUsername implements CommandExecutor {
|
||||
private Main main;
|
||||
public CommandUsername(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
|
@ -78,11 +75,11 @@ class CommandUsername implements CommandExecutor {
|
|||
public void run() {
|
||||
player.setPlayerProfile(profile);
|
||||
}
|
||||
}.runTask(main);
|
||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}.runTaskAsynchronously(JavaPlugin.getPlugin(Main.class));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -12,11 +12,6 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
class BlockCheck implements Listener {
|
||||
private Main main;
|
||||
public BlockCheck(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.getItemInHand().toString().length() > 3019) {
|
||||
|
@ -44,7 +39,6 @@ class BlockCheck implements Listener {
|
|||
event.getChunk().getX(),
|
||||
event.getChunk().getZ()
|
||||
);
|
||||
System.out.println("REGEN");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import org.bukkit.block.BlockFace;
|
|||
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
|
@ -17,12 +20,9 @@ import org.bukkit.event.block.BlockFromToEvent;
|
|||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
class BlockPhysics implements Listener {
|
||||
private Main main;
|
||||
public BlockPhysics(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
|
||||
class BlockPhysics implements Listener {
|
||||
@EventHandler
|
||||
void onBlockFromTo(BlockFromToEvent event) {
|
||||
try {
|
||||
|
@ -32,10 +32,40 @@ class BlockPhysics implements Listener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final double tps = Bukkit.getServer().getTPS()[0];
|
||||
|
||||
if (tps < 15) {
|
||||
if (tps < 17) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getBlock();
|
||||
final World world = block.getWorld();
|
||||
final int radius = 5;
|
||||
int blockCount = 0;
|
||||
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
if (blockCount < 500) {
|
||||
final Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z);
|
||||
final Block coordBlock = world.getBlockAt(blockLocation);
|
||||
|
||||
if (coordBlock.getType() == Material.LAVA ||
|
||||
coordBlock.getType() == Material.WATER ||
|
||||
coordBlock.getType() == Material.OBSIDIAN) {
|
||||
blockCount++;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockCount == 500) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -44,55 +74,9 @@ class BlockPhysics implements Listener {
|
|||
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
final Material material = event.getChangedType();
|
||||
|
||||
if (main.fallingBlockList.contains(material)) {
|
||||
main.fallingBlockCount++;
|
||||
|
||||
if (main.fallingBlockCount == 10) {
|
||||
event.setCancelled(true);
|
||||
main.fallingBlockCount = 0;
|
||||
}
|
||||
} else if (material == Material.FARMLAND) {
|
||||
if (material == Material.FARMLAND) {
|
||||
event.setCancelled(true);
|
||||
} else if (material == Material.WATER ||
|
||||
material == Material.LAVA) {
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (block.getBlockData() instanceof Levelled) {
|
||||
final Levelled levelledBlock = (Levelled) block.getBlockData();
|
||||
|
||||
if (levelledBlock.getLevel() <= 7) {
|
||||
if (block.getRelative(BlockFace.UP).getType() != material) {
|
||||
boolean cancel = true;
|
||||
boolean solid = false;
|
||||
|
||||
for (BlockFace face : main.faces) {
|
||||
if (block.getRelative(face).getType() == Material.AIR ||
|
||||
block.getRelative(face).getType() == Material.CAVE_AIR ||
|
||||
block.getRelative(BlockFace.UP).getType() == Material.WATER) {
|
||||
cancel = false;
|
||||
}
|
||||
|
||||
if (block.getRelative(face).getType() != Material.AIR ||
|
||||
block.getRelative(face).getType() != Material.CAVE_AIR ||
|
||||
block.getRelative(face).getType() != Material.LAVA ||
|
||||
block.getRelative(face).getType() != Material.WATER) {
|
||||
solid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (block.getRelative(BlockFace.UP).getType() == Material.WATER &&
|
||||
!solid) {
|
||||
event.setCancelled(true);
|
||||
} else if (cancel) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (block.getRelative(BlockFace.DOWN).getType() == material) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (main.nonSolidWallMountedBlockList.contains(material)) {
|
||||
} else if (Main.nonSolidWallMountedBlockList.contains(material)) {
|
||||
final Block block = event.getBlock();
|
||||
final World world = block.getWorld();
|
||||
final int radius = 5;
|
||||
|
@ -106,7 +90,7 @@ class BlockPhysics implements Listener {
|
|||
final Block coordBlock = world.getBlockAt(blockLocation);
|
||||
|
||||
if (coordBlock.getType() == material ||
|
||||
main.nonSolidWallMountedBlockList.contains(coordBlock.getType())) {
|
||||
Main.nonSolidWallMountedBlockList.contains(coordBlock.getType())) {
|
||||
blockCount++;
|
||||
}
|
||||
|
||||
|
@ -120,19 +104,19 @@ class BlockPhysics implements Listener {
|
|||
if (blockCount == 42) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (main.nonSolidDoubleBlockList.contains(material)) {
|
||||
} else if (Main.nonSolidDoubleBlockList.contains(material)) {
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) {
|
||||
if (Main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) {
|
||||
event.setCancelled(true);
|
||||
} else if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR ||
|
||||
(main.nonSolidBlockList.contains(block.getRelative(BlockFace.DOWN).getType()) &&
|
||||
!main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType()))) {
|
||||
(Main.nonSolidBlockList.contains(block.getRelative(BlockFace.DOWN).getType()) &&
|
||||
!Main.nonSolidDoubleBlockList.contains(block.getRelative(BlockFace.DOWN).getType()))) {
|
||||
for (int y = block.getRelative(BlockFace.UP).getY(); y <= 256; y++) {
|
||||
final World world = event.getBlock().getWorld();
|
||||
final Block coordBlock = world.getBlockAt(new Location(world, block.getX(), y, block.getZ()));
|
||||
|
||||
if (main.nonSolidDoubleBlockList.contains(coordBlock.getType())) {
|
||||
if (Main.nonSolidDoubleBlockList.contains(coordBlock.getType())) {
|
||||
coordBlock.setType(Material.AIR, false);
|
||||
continue;
|
||||
}
|
||||
|
@ -142,11 +126,11 @@ class BlockPhysics implements Listener {
|
|||
|
||||
block.setType(Material.AIR, false);
|
||||
}
|
||||
} else if (main.nonSolidSingularBlockList.contains(material)) {
|
||||
} else if (Main.nonSolidSingularBlockList.contains(material)) {
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR ||
|
||||
main.nonSolidBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) {
|
||||
Main.nonSolidBlockList.contains(block.getRelative(BlockFace.DOWN).getType())) {
|
||||
block.setType(Material.AIR, false);
|
||||
}
|
||||
}
|
||||
|
@ -160,4 +144,17 @@ class BlockPhysics implements Listener {
|
|||
event.setNewCurrent(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (event.getEntityType() == EntityType.FALLING_BLOCK &&
|
||||
event.getTo() == Material.AIR) {
|
||||
Main.fallingBlockCount++;
|
||||
|
||||
if (Main.fallingBlockCount == 10) {
|
||||
event.setCancelled(true);
|
||||
Main.fallingBlockCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import org.bukkit.entity.Fireball;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
|
@ -11,5 +13,11 @@ class EntityExplosion implements Listener {
|
|||
if (event.getRadius() > 20) {
|
||||
event.setRadius(20);
|
||||
}
|
||||
|
||||
if (event.getEntity().getWorld().getEntitiesByClass(Fireball.class).size() > 40) {
|
||||
if (event.getRadius() > 1) {
|
||||
event.setRadius(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package pw.kaboom.extras;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
|
@ -14,6 +15,7 @@ import org.bukkit.block.ShulkerBox;
|
|||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
@ -21,9 +23,11 @@ import org.bukkit.entity.FallingBlock;
|
|||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
|
||||
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
@ -46,6 +50,23 @@ import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
|
|||
import org.bukkit.block.banner.Pattern;
|
||||
|
||||
class EntitySpawn implements Listener {
|
||||
@EventHandler
|
||||
void onAreaEffectCloudApply(AreaEffectCloudApplyEvent event) {
|
||||
final AreaEffectCloud cloud = event.getEntity();
|
||||
|
||||
if (cloud.getRadius() > 40) {
|
||||
cloud.setRadius(40);
|
||||
}
|
||||
|
||||
if (cloud.getRadiusOnUse() > 0.01f) {
|
||||
cloud.setRadiusOnUse(0.1f);
|
||||
}
|
||||
|
||||
if (cloud.getRadiusPerTick() > 0) {
|
||||
cloud.setRadiusPerTick(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockDispense(BlockDispenseEvent event) {
|
||||
try {
|
||||
|
@ -161,14 +182,14 @@ class EntitySpawn implements Listener {
|
|||
} else if (event.getEntityType() == EntityType.MAGMA_CUBE) {
|
||||
final MagmaCube magmacube = (MagmaCube) event.getEntity();
|
||||
|
||||
if (magmacube.getSize() > 100) {
|
||||
magmacube.setSize(100);
|
||||
if (magmacube.getSize() > 50) {
|
||||
magmacube.setSize(50);
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.SLIME) {
|
||||
final Slime slime = (Slime) event.getEntity();
|
||||
|
||||
if (slime.getSize() > 100) {
|
||||
slime.setSize(100);
|
||||
if (slime.getSize() > 50) {
|
||||
slime.setSize(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +197,17 @@ class EntitySpawn implements Listener {
|
|||
@EventHandler
|
||||
void onEntityAddToWorld(EntityAddToWorldEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
final World world = event.getEntity().getWorld();
|
||||
|
||||
if (world.getEntities().size() > 1024) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity.getType() != EntityType.PLAYER) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntity().getLocation().isGenerated() &&
|
||||
event.getEntity().getLocation().isChunkLoaded()) {
|
||||
final Entity entity = event.getEntity();
|
||||
|
@ -183,6 +215,7 @@ class EntitySpawn implements Listener {
|
|||
|
||||
if (count > 50) {
|
||||
entity.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,6 +292,26 @@ class EntitySpawn implements Listener {
|
|||
} catch (Exception exception) {
|
||||
mob.getEquipment().setItemInOffHand(null);
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.AREA_EFFECT_CLOUD) {
|
||||
final AreaEffectCloud cloud = (AreaEffectCloud) event.getEntity();
|
||||
|
||||
if (cloud.getRadius() > 40) {
|
||||
cloud.setRadius(40);
|
||||
}
|
||||
|
||||
if (cloud.getRadiusOnUse() > 0.01f) {
|
||||
cloud.setRadiusOnUse(0.1f);
|
||||
}
|
||||
|
||||
if (cloud.getRadiusPerTick() > 0) {
|
||||
cloud.setRadiusPerTick(0);
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.PRIMED_TNT) {
|
||||
if (world.getEntitiesByClass(TNTPrimed.class).size() > 180) {
|
||||
for (Entity entity : world.getEntitiesByClass(TNTPrimed.class)) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,6 +319,17 @@ class EntitySpawn implements Listener {
|
|||
@EventHandler
|
||||
void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
final World world = event.getLocation().getWorld();
|
||||
|
||||
if (world.getEntities().size() > 1024) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity.getType() != EntityType.PLAYER) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getLocation().isGenerated() &&
|
||||
event.getLocation().isChunkLoaded()) {
|
||||
final int entityCount = event.getLocation().getChunk().getEntities().length;
|
||||
|
@ -289,6 +353,17 @@ class EntitySpawn implements Listener {
|
|||
@EventHandler
|
||||
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
||||
if (event.getType() != EntityType.PLAYER) {
|
||||
final World world = event.getSpawnLocation().getWorld();
|
||||
|
||||
if (world.getEntities().size() > 1024) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity.getType() != EntityType.PLAYER) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getSpawnLocation().isGenerated() &&
|
||||
event.getSpawnLocation().isChunkLoaded()) {
|
||||
final int entityCount = event.getSpawnLocation().getChunk().getEntities().length;
|
||||
|
@ -354,9 +429,9 @@ class EntitySpawn implements Listener {
|
|||
void onTNTPrime(TNTPrimeEvent event) {
|
||||
final double tps = Bukkit.getTPS()[0];
|
||||
|
||||
if (tps < 10) {
|
||||
if (tps < 10 ||
|
||||
event.getBlock().getWorld().getEntitiesByClass(TNTPrimed.class).size() > 140) {
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,35 +11,32 @@ import org.bukkit.event.Listener;
|
|||
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
class PlayerChat implements Listener {
|
||||
private Main main;
|
||||
public PlayerChat(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
class PlayerChat implements Listener {
|
||||
@EventHandler
|
||||
void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (main.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid);
|
||||
if (Main.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - Main.commandMillisList.get(playerUuid);
|
||||
|
||||
if (millisDifference < 5) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
Main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (main.getConfig().getString(player.getUniqueId().toString()) != null) {
|
||||
if (JavaPlugin.getPlugin(Main.class).getConfig().getString(player.getUniqueId().toString()) != null) {
|
||||
final String prefix = ChatColor.translateAlternateColorCodes(
|
||||
'&',
|
||||
main.getConfig().getString(player.getUniqueId().toString())
|
||||
JavaPlugin.getPlugin(Main.class).getConfig().getString(player.getUniqueId().toString())
|
||||
);
|
||||
|
||||
event.setFormat(prefix + ChatColor.RESET + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + "%2$s");
|
||||
|
|
|
@ -15,26 +15,21 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
class PlayerCommand implements Listener {
|
||||
private Main main;
|
||||
public PlayerCommand(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
final String[] arr = event.getMessage().split(" ");
|
||||
final String command = event.getMessage();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (main.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid);
|
||||
if (Main.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - Main.commandMillisList.get(playerUuid);
|
||||
|
||||
if (millisDifference < 75) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
Main.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.bukkit.event.player.PlayerLoginEvent.Result;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent;
|
||||
|
@ -38,11 +40,6 @@ import com.google.gson.JsonObject;
|
|||
import com.google.gson.JsonParser;
|
||||
|
||||
class PlayerConnection implements Listener {
|
||||
private Main main;
|
||||
public PlayerConnection(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
if (event.getName().length() > 16) {
|
||||
|
@ -67,8 +64,8 @@ class PlayerConnection implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
||||
main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||
main.interactMillisList.remove(event.getPlayerUniqueId());
|
||||
Main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||
Main.interactMillisList.remove(event.getPlayerUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -150,13 +147,13 @@ class PlayerConnection implements Listener {
|
|||
public void run() {
|
||||
player.setPlayerProfile(textureProfile);
|
||||
}
|
||||
}.runTask(main);
|
||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||
}
|
||||
|
||||
skinConnection.disconnect();
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}.runTaskAsynchronously(JavaPlugin.getPlugin(Main.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,24 +10,19 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class PlayerInteract implements Listener {
|
||||
private Main main;
|
||||
public PlayerInteract(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (main.interactMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - main.interactMillisList.get(playerUuid);
|
||||
if (Main.interactMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - Main.interactMillisList.get(playerUuid);
|
||||
|
||||
if (millisDifference < 150) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
main.interactMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
Main.interactMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,18 +12,13 @@ import org.bukkit.event.server.RemoteServerCommandEvent;
|
|||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
class ServerCommand implements Listener {
|
||||
private Main main;
|
||||
public ServerCommand(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onServerCommand(ServerCommandEvent event) {
|
||||
final String[] arr = event.getCommand().split(" ");
|
||||
final String command = event.getCommand();
|
||||
|
||||
if (event.getSender() instanceof BlockCommandSender) {
|
||||
if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||
if (Main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ commands:
|
|||
description: Broadcasts a message as the console
|
||||
permission: extras.console
|
||||
destroyentities:
|
||||
aliases: de
|
||||
description: Destroys all entities in every world
|
||||
permission: extras.destroyentities
|
||||
enchantall:
|
||||
|
@ -42,6 +43,7 @@ commands:
|
|||
description: Broadcasts raw text to the server
|
||||
permission: extras.tellraw
|
||||
unloadchunks:
|
||||
aliases: uc
|
||||
description: Unloads all unused chunks
|
||||
permission: extras.unloadchunks
|
||||
username:
|
||||
|
|
Loading…
Reference in a new issue