mirror of
https://github.com/kaboomserver/extras.git
synced 2025-08-07 04:53:14 +00:00
Enforce code style check
This commit is contained in:
parent
5c24a9bc44
commit
11ce7cf2be
14 changed files with 188 additions and 170 deletions
2
pom.xml
2
pom.xml
|
@ -53,7 +53,7 @@
|
||||||
<suppressionsLocation>
|
<suppressionsLocation>
|
||||||
suppressions.xml
|
suppressions.xml
|
||||||
</suppressionsLocation>
|
</suppressionsLocation>
|
||||||
<failOnViolation>false</failOnViolation>
|
<failOnViolation>true</failOnViolation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -2,15 +2,31 @@ package pw.kaboom.extras;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import pw.kaboom.extras.commands.*;
|
import pw.kaboom.extras.commands.CommandBroadcastVanilla;
|
||||||
|
import pw.kaboom.extras.commands.CommandClearChat;
|
||||||
|
import pw.kaboom.extras.commands.CommandConsole;
|
||||||
|
import pw.kaboom.extras.commands.CommandDestroyEntities;
|
||||||
|
import pw.kaboom.extras.commands.CommandEnchantAll;
|
||||||
|
import pw.kaboom.extras.commands.CommandJumpscare;
|
||||||
|
import pw.kaboom.extras.commands.CommandKaboom;
|
||||||
|
import pw.kaboom.extras.commands.CommandPrefix;
|
||||||
|
import pw.kaboom.extras.commands.CommandPumpkin;
|
||||||
|
import pw.kaboom.extras.commands.CommandServerInfo;
|
||||||
|
import pw.kaboom.extras.commands.CommandSkin;
|
||||||
|
import pw.kaboom.extras.commands.CommandSpawn;
|
||||||
|
import pw.kaboom.extras.commands.CommandSpidey;
|
||||||
|
import pw.kaboom.extras.commands.CommandTellraw;
|
||||||
|
import pw.kaboom.extras.commands.CommandUnloadChunks;
|
||||||
|
import pw.kaboom.extras.commands.CommandUsername;
|
||||||
import pw.kaboom.extras.modules.block.BlockCheck;
|
import pw.kaboom.extras.modules.block.BlockCheck;
|
||||||
import pw.kaboom.extras.modules.block.BlockPhysics;
|
import pw.kaboom.extras.modules.block.BlockPhysics;
|
||||||
import pw.kaboom.extras.modules.entity.EntityExplosion;
|
import pw.kaboom.extras.modules.entity.EntityExplosion;
|
||||||
|
@ -31,7 +47,7 @@ public final class Main extends JavaPlugin {
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
/* Fill lists */
|
/* Fill lists */
|
||||||
Collections.addAll(
|
Collections.addAll(
|
||||||
BlockPhysics.blockFaces,
|
BlockPhysics.getBlockFaces(),
|
||||||
BlockFace.NORTH,
|
BlockFace.NORTH,
|
||||||
BlockFace.SOUTH,
|
BlockFace.SOUTH,
|
||||||
BlockFace.WEST,
|
BlockFace.WEST,
|
||||||
|
@ -66,10 +82,10 @@ public final class Main extends JavaPlugin {
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(final PacketEvent event) {
|
||||||
final int maxInventorySize = 46;
|
final int maxInventorySize = 46;
|
||||||
if (event.getPacket().getIntegers().read(1) > maxInventorySize ||
|
if (event.getPacket().getIntegers().read(1) > maxInventorySize
|
||||||
event.getPacket().getIntegers().read(1) < 0) {
|
|| event.getPacket().getIntegers().read(1) < 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||||
import pw.kaboom.extras.helpers.SkinDownloader;
|
import pw.kaboom.extras.helpers.SkinDownloader;
|
||||||
|
|
||||||
public final class CommandSkin implements CommandExecutor {
|
public final class CommandSkin implements CommandExecutor {
|
||||||
public static long millis;
|
private long millis;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
|
|
||||||
public final class CommandUsername implements CommandExecutor {
|
public final class CommandUsername implements CommandExecutor {
|
||||||
public static long millis;
|
private long millis;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
@ -15,14 +14,13 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import pw.kaboom.extras.Main;
|
import pw.kaboom.extras.Main;
|
||||||
|
|
||||||
public final class SkinDownloader {
|
public final class SkinDownloader {
|
||||||
public static HashMap<UUID, PlayerProfile> skinProfiles = new HashMap<UUID, PlayerProfile>();
|
private static HashMap<UUID, PlayerProfile> skinProfiles = new HashMap<UUID, PlayerProfile>();
|
||||||
|
|
||||||
private HttpsURLConnection skinConnection;
|
private HttpsURLConnection skinConnection;
|
||||||
private InputStreamReader skinStream;
|
private InputStreamReader skinStream;
|
||||||
|
|
|
@ -22,13 +22,13 @@ public final class BlockPhysics implements Listener {
|
||||||
// This class contains code to prevent large areas of non-solid blocks
|
// This class contains code to prevent large areas of non-solid blocks
|
||||||
// from crashing the server
|
// from crashing the server
|
||||||
|
|
||||||
public static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
private static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockDestroy(final BlockDestroyEvent event) {
|
void onBlockDestroy(final BlockDestroyEvent event) {
|
||||||
try {
|
try {
|
||||||
if (!event.getBlock().getType().isSolid()) {
|
if (!event.getBlock().getType().isSolid()) {
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : getBlockFaces()) {
|
||||||
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public final class BlockPhysics implements Listener {
|
||||||
void onBlockForm(final BlockFormEvent event) {
|
void onBlockForm(final BlockFormEvent event) {
|
||||||
if (event.getBlock().getType() == Material.LAVA
|
if (event.getBlock().getType() == Material.LAVA
|
||||||
|| event.getBlock().getType() == Material.WATER) {
|
|| event.getBlock().getType() == Material.WATER) {
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : getBlockFaces()) {
|
||||||
if (event.getBlock().getRelative(face).getType() != Material.LAVA
|
if (event.getBlock().getRelative(face).getType() != Material.LAVA
|
||||||
&& event.getBlock().getRelative(face).getType() != Material.WATER) {
|
&& event.getBlock().getRelative(face).getType() != Material.WATER) {
|
||||||
return;
|
return;
|
||||||
|
@ -78,7 +78,7 @@ public final class BlockPhysics implements Listener {
|
||||||
boolean lavaFound = false;
|
boolean lavaFound = false;
|
||||||
boolean waterFound = false;
|
boolean waterFound = false;
|
||||||
|
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : getBlockFaces()) {
|
||||||
if (event.getBlock().getRelative(face).getType() == Material.LAVA && !lavaFound) {
|
if (event.getBlock().getRelative(face).getType() == Material.LAVA && !lavaFound) {
|
||||||
lavaFound = true;
|
lavaFound = true;
|
||||||
} else if (event.getBlock().getRelative(face).getType() == Material.WATER && !waterFound) {
|
} else if (event.getBlock().getRelative(face).getType() == Material.WATER && !waterFound) {
|
||||||
|
@ -112,7 +112,7 @@ public final class BlockPhysics implements Listener {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case TNT:
|
case TNT:
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : getBlockFaces()) {
|
||||||
if (event.getBlock().getRelative(face).getType() != Material.REDSTONE_BLOCK
|
if (event.getBlock().getRelative(face).getType() != Material.REDSTONE_BLOCK
|
||||||
&& event.getBlock().getRelative(face).getType() != Material.REDSTONE_TORCH) {
|
&& event.getBlock().getRelative(face).getType() != Material.REDSTONE_TORCH) {
|
||||||
return;
|
return;
|
||||||
|
@ -159,4 +159,8 @@ public final class BlockPhysics implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashSet<BlockFace> getBlockFaces() {
|
||||||
|
return blockFaces;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ public final class EntityKnockback implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onProjectileHit(final ProjectileHitEvent event) {
|
void onProjectileHit(final ProjectileHitEvent event) {
|
||||||
if (event.getHitEntity() != null &&
|
if (event.getHitEntity() != null
|
||||||
EntityType.ARROW.equals(event.getEntityType())) {
|
&& EntityType.ARROW.equals(event.getEntityType())) {
|
||||||
final Arrow arrow = (Arrow) event.getEntity();
|
final Arrow arrow = (Arrow) event.getEntity();
|
||||||
final int knockbackLimit = 60;
|
final int knockbackLimit = 60;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
|
||||||
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
||||||
import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
|
import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
|
||||||
|
|
||||||
public class EntitySpawn implements Listener {
|
public final class EntitySpawn implements Listener {
|
||||||
private void applyEntityChanges(Entity entity) {
|
private void applyEntityChanges(final Entity entity) {
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
final LivingEntity mob = (LivingEntity) entity;
|
final LivingEntity mob = (LivingEntity) entity;
|
||||||
|
|
||||||
|
@ -57,24 +57,7 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkEntityLimits(EntityType entityType, Chunk chunk, World world, boolean isAddToWorldEvent) {
|
private boolean checkShouldRemoveEntities(final World world) {
|
||||||
final int chunkEntityCount = chunk.getEntities().length;
|
|
||||||
final int chunkEntityCountLimit = 30;
|
|
||||||
|
|
||||||
final int worldDragonCount = world.getEntitiesByClass(EnderDragon.class).size();
|
|
||||||
final int worldDragonCountLimit = 24;
|
|
||||||
|
|
||||||
if ((!EntityType.PLAYER.equals(entityType) &&
|
|
||||||
isEntityLimitReached(chunkEntityCount, chunkEntityCountLimit, isAddToWorldEvent)) ||
|
|
||||||
|
|
||||||
(EntityType.ENDER_DRAGON.equals(entityType) &&
|
|
||||||
isEntityLimitReached(worldDragonCount, worldDragonCountLimit, isAddToWorldEvent))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkShouldRemoveEntities(World world) {
|
|
||||||
final int worldEntityCount = world.getEntities().size();
|
final int worldEntityCount = world.getEntities().size();
|
||||||
|
|
||||||
if (worldEntityCount > 1024) {
|
if (worldEntityCount > 1024) {
|
||||||
|
@ -88,39 +71,50 @@ public class EntitySpawn implements Listener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEntityLimitReached(int count, int countLimit, boolean isAddToWorldEvent) {
|
private boolean isEntityLimitReached(final EntityType entityType, final Chunk chunk, final World world, final boolean isAddToWorldEvent) {
|
||||||
/*
|
/*
|
||||||
Add 1 if EntitySpawnEvent triggered the method, due to the entity count being
|
Add 1 if EntitySpawnEvent triggered the method, due to the entity count being
|
||||||
one larger in EntityAddToWorldEvent compared to EntitySpawnEvent
|
one larger in EntityAddToWorldEvent compared to EntitySpawnEvent
|
||||||
This prevents EntityAddToWorldEvent from triggering an entity removal before
|
This prevents EntityAddToWorldEvent from triggering an entity removal before
|
||||||
EntitySpawnEvent's event cancel
|
EntitySpawnEvent's event cancel
|
||||||
*/
|
*/
|
||||||
if (!isAddToWorldEvent) {
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count >= countLimit) {
|
final int chunkEntityCount =
|
||||||
|
!isAddToWorldEvent ? chunk.getEntities().length + 1
|
||||||
|
: chunk.getEntities().length;
|
||||||
|
final int chunkEntityCountLimit = 30;
|
||||||
|
|
||||||
|
final int worldDragonCount =
|
||||||
|
!isAddToWorldEvent ? world.getEntitiesByClass(EnderDragon.class).size() + 1
|
||||||
|
: world.getEntitiesByClass(EnderDragon.class).size();
|
||||||
|
final int worldDragonCountLimit = 24;
|
||||||
|
|
||||||
|
if ((!EntityType.PLAYER.equals(entityType)
|
||||||
|
&& chunkEntityCount >= chunkEntityCountLimit)
|
||||||
|
|
||||||
|
|| (EntityType.ENDER_DRAGON.equals(entityType)
|
||||||
|
&& worldDragonCount >= worldDragonCountLimit)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOutsideBoundaries(double X, double Y, double Z) {
|
private boolean isOutsideBoundaries(final double x, final double y, final double z) {
|
||||||
int maxValue = 30000000;
|
int maxValue = 30000000;
|
||||||
int minValue = -30000000;
|
int minValue = -30000000;
|
||||||
|
|
||||||
if (X > maxValue ||
|
if (x > maxValue
|
||||||
X < minValue ||
|
|| x < minValue
|
||||||
Y > maxValue ||
|
|| y > maxValue
|
||||||
Y < minValue ||
|
|| y < minValue
|
||||||
Z > maxValue ||
|
|| z > maxValue
|
||||||
Z < minValue) {
|
|| z < minValue) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void limitAreaEffectCloudRadius(AreaEffectCloud cloud) {
|
private void limitAreaEffectCloudRadius(final AreaEffectCloud cloud) {
|
||||||
if (cloud.getRadius() > 40) {
|
if (cloud.getRadius() > 40) {
|
||||||
cloud.setRadius(40);
|
cloud.setRadius(40);
|
||||||
}
|
}
|
||||||
|
@ -134,46 +128,52 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void limitFollowAttribute(LivingEntity mob) {
|
private void limitFollowAttribute(final LivingEntity mob) {
|
||||||
final AttributeInstance followAttribute = mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
|
final AttributeInstance followAttribute = mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
|
||||||
|
|
||||||
if (followAttribute != null &&
|
if (followAttribute != null
|
||||||
followAttribute.getBaseValue() > 40) {
|
&& followAttribute.getBaseValue() > 40) {
|
||||||
followAttribute.setBaseValue(40);
|
followAttribute.setBaseValue(40);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location limitLocation(Location location) {
|
public static Location limitLocation(final Location location) {
|
||||||
double X = location.getX();
|
double x = location.getX();
|
||||||
double Y = location.getY();
|
double y = location.getY();
|
||||||
double Z = location.getZ();
|
double z = location.getZ();
|
||||||
|
|
||||||
int maxValue = 30000000;
|
int maxValue = 30000000;
|
||||||
int minValue = -30000000;
|
int minValue = -30000000;
|
||||||
|
|
||||||
if (X > maxValue)
|
if (x > maxValue) {
|
||||||
X = maxValue;
|
x = maxValue;
|
||||||
if (X < minValue)
|
}
|
||||||
X = minValue;
|
if (x < minValue) {
|
||||||
if (Y > maxValue)
|
x = minValue;
|
||||||
Y = maxValue;
|
}
|
||||||
if (Y < minValue)
|
if (y > maxValue) {
|
||||||
Y = minValue;
|
y = maxValue;
|
||||||
if (Z > maxValue)
|
}
|
||||||
Z = maxValue;
|
if (y < minValue) {
|
||||||
if (Z < minValue)
|
y = minValue;
|
||||||
Z = minValue;
|
}
|
||||||
|
if (z > maxValue) {
|
||||||
|
z = maxValue;
|
||||||
|
}
|
||||||
|
if (z < minValue) {
|
||||||
|
z = minValue;
|
||||||
|
}
|
||||||
|
|
||||||
return new Location(location.getWorld(), X, Y, Z);
|
return new Location(location.getWorld(), x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void limitSlimeSize(Slime slime) {
|
private void limitSlimeSize(final Slime slime) {
|
||||||
if (slime.getSize() > 50) {
|
if (slime.getSize() > 50) {
|
||||||
slime.setSize(50);
|
slime.setSize(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void limitSpawner(CreatureSpawner spawner) {
|
private void limitSpawner(final CreatureSpawner spawner) {
|
||||||
if (EntityType.MINECART_MOB_SPAWNER.equals(spawner.getSpawnedType())) {
|
if (EntityType.MINECART_MOB_SPAWNER.equals(spawner.getSpawnedType())) {
|
||||||
spawner.setSpawnedType(EntityType.MINECART);
|
spawner.setSpawnedType(EntityType.MINECART);
|
||||||
}
|
}
|
||||||
|
@ -196,18 +196,18 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onAreaEffectCloudApply(AreaEffectCloudApplyEvent event) {
|
void onAreaEffectCloudApply(final AreaEffectCloudApplyEvent event) {
|
||||||
limitAreaEffectCloudRadius(event.getEntity());
|
limitAreaEffectCloudRadius(event.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityAddToWorld(EntityAddToWorldEvent event) {
|
void onEntityAddToWorld(final EntityAddToWorldEvent event) {
|
||||||
final Entity entity = event.getEntity();
|
final Entity entity = event.getEntity();
|
||||||
final double X = entity.getLocation().getX();
|
final double x = entity.getLocation().getX();
|
||||||
final double Y = entity.getLocation().getY();
|
final double y = entity.getLocation().getY();
|
||||||
final double Z = entity.getLocation().getZ();
|
final double z = entity.getLocation().getZ();
|
||||||
|
|
||||||
if (isOutsideBoundaries(X, Y, Z)) {
|
if (isOutsideBoundaries(x, y, z)) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ public class EntitySpawn implements Listener {
|
||||||
final EntityType entityType = entity.getType();
|
final EntityType entityType = entity.getType();
|
||||||
final boolean isAddToWorldEvent = true;
|
final boolean isAddToWorldEvent = true;
|
||||||
|
|
||||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)
|
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)
|
||||||
&& !EntityType.PLAYER.equals(entity.getType())) {
|
&& !EntityType.PLAYER.equals(entity.getType())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return;
|
return;
|
||||||
|
@ -234,20 +234,20 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityExplode(EntityExplodeEvent event) {
|
void onEntityExplode(final EntityExplodeEvent event) {
|
||||||
if (EntityType.MINECART_TNT.equals(event.getEntityType()) &&
|
if (EntityType.MINECART_TNT.equals(event.getEntityType())
|
||||||
event.getEntity().getWorld().getEntitiesByClass(ExplosiveMinecart.class).size() > 80) {
|
&& event.getEntity().getWorld().getEntitiesByClass(ExplosiveMinecart.class).size() > 80) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntitySpawn(EntitySpawnEvent event) {
|
void onEntitySpawn(final EntitySpawnEvent event) {
|
||||||
final double X = event.getLocation().getX();
|
final double x = event.getLocation().getX();
|
||||||
final double Y = event.getLocation().getY();
|
final double y = event.getLocation().getY();
|
||||||
final double Z = event.getLocation().getZ();
|
final double z = event.getLocation().getZ();
|
||||||
|
|
||||||
if (isOutsideBoundaries(X, Y, Z)) {
|
if (isOutsideBoundaries(x, y, z)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ public class EntitySpawn implements Listener {
|
||||||
final World world = entity.getWorld();
|
final World world = entity.getWorld();
|
||||||
final boolean isAddToWorldEvent = false;
|
final boolean isAddToWorldEvent = false;
|
||||||
|
|
||||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
|
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -267,13 +267,13 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onLightningStrike(LightningStrikeEvent event) {
|
void onLightningStrike(final LightningStrikeEvent event) {
|
||||||
final LightningStrike lightning = event.getLightning();
|
final LightningStrike lightning = event.getLightning();
|
||||||
final double X = lightning.getLocation().getX();
|
final double x = lightning.getLocation().getX();
|
||||||
final double Y = lightning.getLocation().getY();
|
final double y = lightning.getLocation().getY();
|
||||||
final double Z = lightning.getLocation().getZ();
|
final double z = lightning.getLocation().getZ();
|
||||||
|
|
||||||
if (isOutsideBoundaries(X, Y, Z)) {
|
if (isOutsideBoundaries(x, y, z)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -283,25 +283,25 @@ public class EntitySpawn implements Listener {
|
||||||
final World world = lightning.getWorld();
|
final World world = lightning.getWorld();
|
||||||
final boolean isAddToWorldEvent = false;
|
final boolean isAddToWorldEvent = false;
|
||||||
|
|
||||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
|
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
void onPreCreatureSpawn(final PreCreatureSpawnEvent event) {
|
||||||
final EntityType mobType = event.getType();
|
final EntityType mobType = event.getType();
|
||||||
final Chunk chunk = event.getSpawnLocation().getChunk();
|
final Chunk chunk = event.getSpawnLocation().getChunk();
|
||||||
final World world = event.getSpawnLocation().getWorld();
|
final World world = event.getSpawnLocation().getWorld();
|
||||||
final boolean isAddToWorldEvent = false;
|
final boolean isAddToWorldEvent = false;
|
||||||
|
|
||||||
if (checkEntityLimits(mobType, chunk, world, isAddToWorldEvent)) {
|
if (isEntityLimitReached(mobType, chunk, world, isAddToWorldEvent)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPreSpawnerSpawn(PreSpawnerSpawnEvent event) {
|
void onPreSpawnerSpawn(final PreSpawnerSpawnEvent event) {
|
||||||
try {
|
try {
|
||||||
limitSpawner((CreatureSpawner) event.getSpawnerLocation().getBlock().getState());
|
limitSpawner((CreatureSpawner) event.getSpawnerLocation().getBlock().getState());
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
@ -310,7 +310,7 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onSpawnerSpawn(SpawnerSpawnEvent event) {
|
void onSpawnerSpawn(final SpawnerSpawnEvent event) {
|
||||||
if (EntityType.FALLING_BLOCK.equals(event.getEntityType())) {
|
if (EntityType.FALLING_BLOCK.equals(event.getEntityType())) {
|
||||||
if (((FallingBlock) event.getEntity()).getBlockData().getMaterial().equals(Material.SPAWNER)) {
|
if (((FallingBlock) event.getEntity()).getBlockData().getMaterial().equals(Material.SPAWNER)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -320,7 +320,7 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onTNTPrime(TNTPrimeEvent event) {
|
void onTNTPrime(final TNTPrimeEvent event) {
|
||||||
if (event.getBlock().getWorld().getEntitiesByClass(TNTPrimed.class).size() > 120) {
|
if (event.getBlock().getWorld().getEntitiesByClass(TNTPrimed.class).size() > 120) {
|
||||||
if (PrimeReason.EXPLOSION.equals(event.getReason())) {
|
if (PrimeReason.EXPLOSION.equals(event.getReason())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -329,13 +329,13 @@ public class EntitySpawn implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onVehicleCreate(VehicleCreateEvent event) {
|
void onVehicleCreate(final VehicleCreateEvent event) {
|
||||||
final Vehicle vehicle = event.getVehicle();
|
final Vehicle vehicle = event.getVehicle();
|
||||||
final double X = vehicle.getLocation().getX();
|
final double x = vehicle.getLocation().getX();
|
||||||
final double Y = vehicle.getLocation().getY();
|
final double y = vehicle.getLocation().getY();
|
||||||
final double Z = vehicle.getLocation().getZ();
|
final double z = vehicle.getLocation().getZ();
|
||||||
|
|
||||||
if (isOutsideBoundaries(X, Y, Z)) {
|
if (isOutsideBoundaries(x, y, z)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ public class EntitySpawn implements Listener {
|
||||||
final World world = vehicle.getWorld();
|
final World world = vehicle.getWorld();
|
||||||
final boolean isAddToWorldEvent = false;
|
final boolean isAddToWorldEvent = false;
|
||||||
|
|
||||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
|
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,15 +25,15 @@ public final class PlayerChat implements Listener {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (PlayerCommand.commandMillisList.get(playerUuid) != null) {
|
if (PlayerCommand.getCommandMillisList().get(playerUuid) != null) {
|
||||||
final long millisDifference = System.currentTimeMillis() - PlayerCommand.commandMillisList.get(playerUuid);
|
final long millisDifference = System.currentTimeMillis() - PlayerCommand.getCommandMillisList().get(playerUuid);
|
||||||
|
|
||||||
if (millisDifference < 5) {
|
if (millisDifference < 5) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerCommand.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
PlayerCommand.getCommandMillisList().put(playerUuid, System.currentTimeMillis());
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,21 +11,21 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import pw.kaboom.extras.modules.server.ServerCommand;
|
import pw.kaboom.extras.modules.server.ServerCommand;
|
||||||
|
|
||||||
public final class PlayerCommand implements Listener {
|
public final class PlayerCommand implements Listener {
|
||||||
static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
private static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (commandMillisList.get(playerUuid) != null) {
|
if (getCommandMillisList().get(playerUuid) != null) {
|
||||||
final long millisDifference = System.currentTimeMillis() - commandMillisList.get(playerUuid);
|
final long millisDifference = System.currentTimeMillis() - getCommandMillisList().get(playerUuid);
|
||||||
|
|
||||||
if (millisDifference < 75) {
|
if (millisDifference < 75) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commandMillisList.put(playerUuid, System.currentTimeMillis());
|
getCommandMillisList().put(playerUuid, System.currentTimeMillis());
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
@ -44,4 +44,8 @@ public final class PlayerCommand implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<UUID, Long> getCommandMillisList() {
|
||||||
|
return commandMillisList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,24 +97,6 @@ public final class PlayerConnection implements Listener {
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
void onPlayerCommandSend2(final PlayerStatisticIncrementEvent event) {
|
|
||||||
final World world = event.getPlayer().getWorld();
|
|
||||||
final Integer randomTickSpeed = world.getGameRuleValue(GameRule.RANDOM_TICK_SPEED);
|
|
||||||
|
|
||||||
if (randomTickSpeed > 6) {
|
|
||||||
world.setGameRule(GameRule.RANDOM_TICK_SPEED, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!world.isAutoSave()) {
|
|
||||||
world.setAutoSave(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (event.getPlayer().isOnline()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerJoin(final PlayerJoinEvent event) {
|
void onPlayerJoin(final PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
@ -195,9 +177,25 @@ public final class PlayerConnection implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerQuit(PlayerQuitEvent event) {
|
void onPlayerQuit(final PlayerQuitEvent event) {
|
||||||
PlayerCommand.commandMillisList.remove(event.getPlayer().getUniqueId());
|
PlayerCommand.getCommandMillisList().remove(event.getPlayer().getUniqueId());
|
||||||
PlayerInteract.interactMillisList.remove(event.getPlayer().getUniqueId());
|
//PlayerInteract.interactMillisList.remove(event.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent event) {
|
||||||
|
final World world = event.getPlayer().getWorld();
|
||||||
|
final Integer randomTickSpeed = world.getGameRuleValue(GameRule.RANDOM_TICK_SPEED);
|
||||||
|
|
||||||
|
if (randomTickSpeed > 6) {
|
||||||
|
world.setGameRule(GameRule.RANDOM_TICK_SPEED, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!world.isAutoSave()) {
|
||||||
|
world.setAutoSave(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package pw.kaboom.extras.modules.player;
|
package pw.kaboom.extras.modules.player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -12,7 +9,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public final class PlayerInteract implements Listener {
|
public final class PlayerInteract implements Listener {
|
||||||
static HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
|
//static HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onInventoryClick(final InventoryClickEvent event) {
|
void onInventoryClick(final InventoryClickEvent event) {
|
||||||
|
@ -39,8 +36,8 @@ public final class PlayerInteract implements Listener {
|
||||||
|
|
||||||
final ItemStack item = event.getItem();
|
final ItemStack item = event.getItem();
|
||||||
|
|
||||||
if (item != null &&
|
if (item != null
|
||||||
Material.TRIDENT.equals(item.getType())) {
|
&& Material.TRIDENT.equals(item.getType())) {
|
||||||
final int riptideLimit = 20;
|
final int riptideLimit = 20;
|
||||||
|
|
||||||
if (item.getEnchantmentLevel(Enchantment.RIPTIDE) > riptideLimit) {
|
if (item.getEnchantmentLevel(Enchantment.RIPTIDE) > riptideLimit) {
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
<suppress checks="FileTabCharacter" files="."/>
|
<suppress checks="FileTabCharacter" files="."/>
|
||||||
<suppress checks="Javadoc" files="."/>
|
<suppress checks="Javadoc" files="."/>
|
||||||
<suppress checks="LineLength" files="."/>
|
<suppress checks="LineLength" files="."/>
|
||||||
|
<suppress checks="MagicNumber" files="."/>
|
||||||
<suppress checks="NewlineAtEndOfFile" files="."/>
|
<suppress checks="NewlineAtEndOfFile" files="."/>
|
||||||
</suppressions>
|
</suppressions>
|
Loading…
Add table
Add a link
Reference in a new issue