Enforce code style check

This commit is contained in:
mathiascode 2020-02-27 17:08:10 +02:00
parent 5c24a9bc44
commit 11ce7cf2be
14 changed files with 188 additions and 170 deletions

View file

@ -53,7 +53,7 @@
<suppressionsLocation>
suppressions.xml
</suppressionsLocation>
<failOnViolation>false</failOnViolation>
<failOnViolation>true</failOnViolation>
</configuration>
</execution>
</executions>

View file

@ -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);
}
}

View file

@ -10,8 +10,8 @@ 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) {
if (sender instanceof ConsoleCommandSender) {
@ -31,7 +31,7 @@ public final class CommandSkin implements CommandExecutor {
SkinDownloader skinDownloader = new SkinDownloader();
skinDownloader.applySkin(player, name, shouldSendMessage);
millis = System.currentTimeMillis();
}
}

View file

@ -11,18 +11,18 @@ 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) {
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage("Command has to be run by a player");
} else {
final Player player = (Player) sender;
final String nameColor = ChatColor.translateAlternateColorCodes('&', String.join(" ", args));
final String name = nameColor.substring(0, Math.min(16, nameColor.length()));
final long millisDifference = System.currentTimeMillis() - millis;
if (args.length == 0) {
@ -38,16 +38,16 @@ public final class CommandUsername implements CommandExecutor {
return true;
}
}
final PlayerProfile profile = player.getPlayerProfile();
profile.setName(name);
player.setPlayerProfile(profile);
player.setOp(true);
millis = System.currentTimeMillis();
player.sendMessage("Successfully set your username to \"" + name + "\"");
}
}

View file

@ -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;

View file

@ -18,17 +18,17 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import com.destroystokyo.paper.event.block.BlockDestroyEvent;
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;
}
@ -44,7 +44,7 @@ public final class BlockPhysics implements Listener {
event.setCancelled(true);
}
}
@EventHandler
void onBlockFade(final BlockFadeEvent event) {
try {
@ -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,13 +78,13 @@ 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) {
waterFound = true;
}
if (lavaFound && waterFound) {
event.setCancelled(true);
return;
@ -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;
@ -122,7 +122,7 @@ public final class BlockPhysics implements Listener {
default:
break;
}
/*if (!event.getBlock().getType().isSolid()) {
for (BlockFace face : blockFaces) {
event.getBlock().getRelative(face).getType();
@ -159,4 +159,8 @@ public final class BlockPhysics implements Listener {
}
}
}
public static HashSet<BlockFace> getBlockFaces() {
return blockFaces;
}
}

View file

@ -19,14 +19,14 @@ 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;
if (arrow.getKnockbackStrength() > knockbackLimit) {
arrow.setKnockbackStrength(knockbackLimit);
}

View file

@ -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;
@ -232,22 +232,22 @@ public class EntitySpawn implements Listener {
checkShouldRemoveEntities(world);
}
}
@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;
}

View file

@ -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;

View file

@ -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;
}
}

View file

@ -60,18 +60,18 @@ public final class PlayerConnection implements Listener {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "A player with that username is already logged in");
}
}
final Integer spawnRadius = Bukkit.getWorld("world").getGameRuleValue(GameRule.SPAWN_RADIUS);
if (spawnRadius > 100) {
Bukkit.getWorld("world").setGameRule(GameRule.SPAWN_RADIUS, 100);
}
try {
final PlayerProfile profile = event.getPlayerProfile();
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
profile.setId(offlineUUID);
SkinDownloader skinDownloader = new SkinDownloader();
@ -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

View file

@ -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) {
@ -36,13 +33,13 @@ public final class PlayerInteract implements Listener {
}
interactMillisList.put(playerUuid, System.currentTimeMillis());*/
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) {
item.addUnsafeEnchantment(Enchantment.RIPTIDE, riptideLimit);
}

View file

@ -123,7 +123,7 @@ public final class ServerCommand implements Listener {
if (sender instanceof BlockCommandSender) {
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender).getBlock().getState();
commandBlock.setCommand("");
commandBlock.update();
}

View file

@ -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>