mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-11 11:40:19 +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>
|
||||
suppressions.xml
|
||||
</suppressionsLocation>
|
||||
<failOnViolation>false</failOnViolation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -2,15 +2,31 @@ package pw.kaboom.extras;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
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.BlockPhysics;
|
||||
import pw.kaboom.extras.modules.entity.EntityExplosion;
|
||||
|
@ -31,7 +47,7 @@ public final class Main extends JavaPlugin {
|
|||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
BlockPhysics.blockFaces,
|
||||
BlockPhysics.getBlockFaces(),
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
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) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
public void onPacketReceiving(final PacketEvent event) {
|
||||
final int maxInventorySize = 46;
|
||||
if (event.getPacket().getIntegers().read(1) > maxInventorySize ||
|
||||
event.getPacket().getIntegers().read(1) < 0) {
|
||||
if (event.getPacket().getIntegers().read(1) > maxInventorySize
|
||||
|| event.getPacket().getIntegers().read(1) < 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||
import pw.kaboom.extras.helpers.SkinDownloader;
|
||||
|
||||
public final class CommandSkin implements CommandExecutor {
|
||||
public static long millis;
|
||||
private long millis;
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
public final class CommandUsername implements CommandExecutor {
|
||||
public static long millis;
|
||||
private long millis;
|
||||
|
||||
@Override
|
||||
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.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
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.ProfileProperty;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
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 InputStreamReader skinStream;
|
||||
|
|
|
@ -22,13 +22,13 @@ public final class BlockPhysics implements Listener {
|
|||
// This class contains code to prevent large areas of non-solid blocks
|
||||
// from crashing the server
|
||||
|
||||
public static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||
private static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||
|
||||
@EventHandler
|
||||
void onBlockDestroy(final BlockDestroyEvent event) {
|
||||
try {
|
||||
if (!event.getBlock().getType().isSolid()) {
|
||||
for (BlockFace face : blockFaces) {
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
||||
return;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public final class BlockPhysics implements Listener {
|
|||
void onBlockForm(final BlockFormEvent event) {
|
||||
if (event.getBlock().getType() == Material.LAVA
|
||||
|| event.getBlock().getType() == Material.WATER) {
|
||||
for (BlockFace face : blockFaces) {
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
if (event.getBlock().getRelative(face).getType() != Material.LAVA
|
||||
&& event.getBlock().getRelative(face).getType() != Material.WATER) {
|
||||
return;
|
||||
|
@ -78,7 +78,7 @@ public final class BlockPhysics implements Listener {
|
|||
boolean lavaFound = false;
|
||||
boolean waterFound = false;
|
||||
|
||||
for (BlockFace face : blockFaces) {
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
if (event.getBlock().getRelative(face).getType() == Material.LAVA && !lavaFound) {
|
||||
lavaFound = true;
|
||||
} else if (event.getBlock().getRelative(face).getType() == Material.WATER && !waterFound) {
|
||||
|
@ -112,7 +112,7 @@ public final class BlockPhysics implements Listener {
|
|||
}
|
||||
return;
|
||||
case TNT:
|
||||
for (BlockFace face : blockFaces) {
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
if (event.getBlock().getRelative(face).getType() != Material.REDSTONE_BLOCK
|
||||
&& event.getBlock().getRelative(face).getType() != Material.REDSTONE_TORCH) {
|
||||
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
|
||||
void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getHitEntity() != null &&
|
||||
EntityType.ARROW.equals(event.getEntityType())) {
|
||||
if (event.getHitEntity() != null
|
||||
&& EntityType.ARROW.equals(event.getEntityType())) {
|
||||
final Arrow arrow = (Arrow) event.getEntity();
|
||||
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.PreSpawnerSpawnEvent;
|
||||
|
||||
public class EntitySpawn implements Listener {
|
||||
private void applyEntityChanges(Entity entity) {
|
||||
public final class EntitySpawn implements Listener {
|
||||
private void applyEntityChanges(final Entity entity) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
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) {
|
||||
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) {
|
||||
private boolean checkShouldRemoveEntities(final World world) {
|
||||
final int worldEntityCount = world.getEntities().size();
|
||||
|
||||
if (worldEntityCount > 1024) {
|
||||
|
@ -88,39 +71,50 @@ public class EntitySpawn implements Listener {
|
|||
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
|
||||
one larger in EntityAddToWorldEvent compared to EntitySpawnEvent
|
||||
This prevents EntityAddToWorldEvent from triggering an entity removal before
|
||||
EntitySpawnEvent's event cancel
|
||||
Add 1 if EntitySpawnEvent triggered the method, due to the entity count being
|
||||
one larger in EntityAddToWorldEvent compared to EntitySpawnEvent
|
||||
This prevents EntityAddToWorldEvent from triggering an entity removal before
|
||||
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 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 minValue = -30000000;
|
||||
|
||||
if (X > maxValue ||
|
||||
X < minValue ||
|
||||
Y > maxValue ||
|
||||
Y < minValue ||
|
||||
Z > maxValue ||
|
||||
Z < minValue) {
|
||||
if (x > maxValue
|
||||
|| x < minValue
|
||||
|| y > maxValue
|
||||
|| y < minValue
|
||||
|| z > maxValue
|
||||
|| z < minValue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void limitAreaEffectCloudRadius(AreaEffectCloud cloud) {
|
||||
private void limitAreaEffectCloudRadius(final AreaEffectCloud cloud) {
|
||||
if (cloud.getRadius() > 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);
|
||||
|
||||
if (followAttribute != null &&
|
||||
followAttribute.getBaseValue() > 40) {
|
||||
if (followAttribute != null
|
||||
&& followAttribute.getBaseValue() > 40) {
|
||||
followAttribute.setBaseValue(40);
|
||||
}
|
||||
}
|
||||
|
||||
public static Location limitLocation(Location location) {
|
||||
double X = location.getX();
|
||||
double Y = location.getY();
|
||||
double Z = location.getZ();
|
||||
public static Location limitLocation(final Location location) {
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
|
||||
int maxValue = 30000000;
|
||||
int minValue = -30000000;
|
||||
|
||||
if (X > maxValue)
|
||||
X = maxValue;
|
||||
if (X < minValue)
|
||||
X = minValue;
|
||||
if (Y > maxValue)
|
||||
Y = maxValue;
|
||||
if (Y < minValue)
|
||||
Y = minValue;
|
||||
if (Z > maxValue)
|
||||
Z = maxValue;
|
||||
if (Z < minValue)
|
||||
Z = minValue;
|
||||
if (x > maxValue) {
|
||||
x = maxValue;
|
||||
}
|
||||
if (x < minValue) {
|
||||
x = minValue;
|
||||
}
|
||||
if (y > maxValue) {
|
||||
y = maxValue;
|
||||
}
|
||||
if (y < minValue) {
|
||||
y = 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) {
|
||||
slime.setSize(50);
|
||||
}
|
||||
}
|
||||
|
||||
private void limitSpawner(CreatureSpawner spawner) {
|
||||
private void limitSpawner(final CreatureSpawner spawner) {
|
||||
if (EntityType.MINECART_MOB_SPAWNER.equals(spawner.getSpawnedType())) {
|
||||
spawner.setSpawnedType(EntityType.MINECART);
|
||||
}
|
||||
|
@ -196,18 +196,18 @@ public class EntitySpawn implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onAreaEffectCloudApply(AreaEffectCloudApplyEvent event) {
|
||||
void onAreaEffectCloudApply(final AreaEffectCloudApplyEvent event) {
|
||||
limitAreaEffectCloudRadius(event.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onEntityAddToWorld(EntityAddToWorldEvent event) {
|
||||
void onEntityAddToWorld(final EntityAddToWorldEvent event) {
|
||||
final Entity entity = event.getEntity();
|
||||
final double X = entity.getLocation().getX();
|
||||
final double Y = entity.getLocation().getY();
|
||||
final double Z = entity.getLocation().getZ();
|
||||
final double x = entity.getLocation().getX();
|
||||
final double y = entity.getLocation().getY();
|
||||
final double z = entity.getLocation().getZ();
|
||||
|
||||
if (isOutsideBoundaries(X, Y, Z)) {
|
||||
if (isOutsideBoundaries(x, y, z)) {
|
||||
entity.remove();
|
||||
return;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ public class EntitySpawn implements Listener {
|
|||
final EntityType entityType = entity.getType();
|
||||
final boolean isAddToWorldEvent = true;
|
||||
|
||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)
|
||||
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)
|
||||
&& !EntityType.PLAYER.equals(entity.getType())) {
|
||||
entity.remove();
|
||||
return;
|
||||
|
@ -234,20 +234,20 @@ public class EntitySpawn implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (EntityType.MINECART_TNT.equals(event.getEntityType()) &&
|
||||
event.getEntity().getWorld().getEntitiesByClass(ExplosiveMinecart.class).size() > 80) {
|
||||
void onEntityExplode(final EntityExplodeEvent event) {
|
||||
if (EntityType.MINECART_TNT.equals(event.getEntityType())
|
||||
&& event.getEntity().getWorld().getEntitiesByClass(ExplosiveMinecart.class).size() > 80) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onEntitySpawn(EntitySpawnEvent event) {
|
||||
final double X = event.getLocation().getX();
|
||||
final double Y = event.getLocation().getY();
|
||||
final double Z = event.getLocation().getZ();
|
||||
void onEntitySpawn(final EntitySpawnEvent event) {
|
||||
final double x = event.getLocation().getX();
|
||||
final double y = event.getLocation().getY();
|
||||
final double z = event.getLocation().getZ();
|
||||
|
||||
if (isOutsideBoundaries(X, Y, Z)) {
|
||||
if (isOutsideBoundaries(x, y, z)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ public class EntitySpawn implements Listener {
|
|||
final World world = entity.getWorld();
|
||||
final boolean isAddToWorldEvent = false;
|
||||
|
||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
|
||||
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -267,13 +267,13 @@ public class EntitySpawn implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onLightningStrike(LightningStrikeEvent event) {
|
||||
void onLightningStrike(final LightningStrikeEvent event) {
|
||||
final LightningStrike lightning = event.getLightning();
|
||||
final double X = lightning.getLocation().getX();
|
||||
final double Y = lightning.getLocation().getY();
|
||||
final double Z = lightning.getLocation().getZ();
|
||||
final double x = lightning.getLocation().getX();
|
||||
final double y = lightning.getLocation().getY();
|
||||
final double z = lightning.getLocation().getZ();
|
||||
|
||||
if (isOutsideBoundaries(X, Y, Z)) {
|
||||
if (isOutsideBoundaries(x, y, z)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -283,25 +283,25 @@ public class EntitySpawn implements Listener {
|
|||
final World world = lightning.getWorld();
|
||||
final boolean isAddToWorldEvent = false;
|
||||
|
||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
|
||||
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
||||
void onPreCreatureSpawn(final PreCreatureSpawnEvent event) {
|
||||
final EntityType mobType = event.getType();
|
||||
final Chunk chunk = event.getSpawnLocation().getChunk();
|
||||
final World world = event.getSpawnLocation().getWorld();
|
||||
final boolean isAddToWorldEvent = false;
|
||||
|
||||
if (checkEntityLimits(mobType, chunk, world, isAddToWorldEvent)) {
|
||||
if (isEntityLimitReached(mobType, chunk, world, isAddToWorldEvent)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPreSpawnerSpawn(PreSpawnerSpawnEvent event) {
|
||||
void onPreSpawnerSpawn(final PreSpawnerSpawnEvent event) {
|
||||
try {
|
||||
limitSpawner((CreatureSpawner) event.getSpawnerLocation().getBlock().getState());
|
||||
} catch (Exception exception) {
|
||||
|
@ -310,7 +310,7 @@ public class EntitySpawn implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onSpawnerSpawn(SpawnerSpawnEvent event) {
|
||||
void onSpawnerSpawn(final SpawnerSpawnEvent event) {
|
||||
if (EntityType.FALLING_BLOCK.equals(event.getEntityType())) {
|
||||
if (((FallingBlock) event.getEntity()).getBlockData().getMaterial().equals(Material.SPAWNER)) {
|
||||
event.setCancelled(true);
|
||||
|
@ -320,7 +320,7 @@ public class EntitySpawn implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onTNTPrime(TNTPrimeEvent event) {
|
||||
void onTNTPrime(final TNTPrimeEvent event) {
|
||||
if (event.getBlock().getWorld().getEntitiesByClass(TNTPrimed.class).size() > 120) {
|
||||
if (PrimeReason.EXPLOSION.equals(event.getReason())) {
|
||||
event.setCancelled(true);
|
||||
|
@ -329,13 +329,13 @@ public class EntitySpawn implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onVehicleCreate(VehicleCreateEvent event) {
|
||||
void onVehicleCreate(final VehicleCreateEvent event) {
|
||||
final Vehicle vehicle = event.getVehicle();
|
||||
final double X = vehicle.getLocation().getX();
|
||||
final double Y = vehicle.getLocation().getY();
|
||||
final double Z = vehicle.getLocation().getZ();
|
||||
final double x = vehicle.getLocation().getX();
|
||||
final double y = vehicle.getLocation().getY();
|
||||
final double z = vehicle.getLocation().getZ();
|
||||
|
||||
if (isOutsideBoundaries(X, Y, Z)) {
|
||||
if (isOutsideBoundaries(x, y, z)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ public class EntitySpawn implements Listener {
|
|||
final World world = vehicle.getWorld();
|
||||
final boolean isAddToWorldEvent = false;
|
||||
|
||||
if (checkEntityLimits(entityType, chunk, world, isAddToWorldEvent)) {
|
||||
if (isEntityLimitReached(entityType, chunk, world, isAddToWorldEvent)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -25,15 +25,15 @@ public final class PlayerChat implements Listener {
|
|||
final Player player = event.getPlayer();
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (PlayerCommand.commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - PlayerCommand.commandMillisList.get(playerUuid);
|
||||
if (PlayerCommand.getCommandMillisList().get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - PlayerCommand.getCommandMillisList().get(playerUuid);
|
||||
|
||||
if (millisDifference < 5) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerCommand.commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
PlayerCommand.getCommandMillisList().put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
|
|
|
@ -11,21 +11,21 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||
import pw.kaboom.extras.modules.server.ServerCommand;
|
||||
|
||||
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
|
||||
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - commandMillisList.get(playerUuid);
|
||||
if (getCommandMillisList().get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - getCommandMillisList().get(playerUuid);
|
||||
|
||||
if (millisDifference < 75) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
getCommandMillisList().put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
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
|
||||
void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
@ -195,9 +177,25 @@ public final class PlayerConnection implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerQuit(PlayerQuitEvent event) {
|
||||
PlayerCommand.commandMillisList.remove(event.getPlayer().getUniqueId());
|
||||
PlayerInteract.interactMillisList.remove(event.getPlayer().getUniqueId());
|
||||
void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
PlayerCommand.getCommandMillisList().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
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package pw.kaboom.extras.modules.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -12,7 +9,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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
|
||||
void onInventoryClick(final InventoryClickEvent event) {
|
||||
|
@ -39,8 +36,8 @@ public final class PlayerInteract implements Listener {
|
|||
|
||||
final ItemStack item = event.getItem();
|
||||
|
||||
if (item != null &&
|
||||
Material.TRIDENT.equals(item.getType())) {
|
||||
if (item != null
|
||||
&& Material.TRIDENT.equals(item.getType())) {
|
||||
final int riptideLimit = 20;
|
||||
|
||||
if (item.getEnchantmentLevel(Enchantment.RIPTIDE) > riptideLimit) {
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
<suppress checks="FileTabCharacter" files="."/>
|
||||
<suppress checks="Javadoc" files="."/>
|
||||
<suppress checks="LineLength" files="."/>
|
||||
<suppress checks="MagicNumber" files="."/>
|
||||
<suppress checks="NewlineAtEndOfFile" files="."/>
|
||||
</suppressions>
|
Loading…
Reference in a new issue