mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-30 03:15:41 -05:00
Set maximum line length to 100 characters
This commit is contained in:
parent
78067effe2
commit
67220510b1
29 changed files with 130 additions and 69 deletions
10
checkstyle.xml
Normal file
10
checkstyle.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<module name="LineLength">
|
||||
<property name="max" value="100"/>
|
||||
</module>
|
||||
</module>
|
5
pom.xml
5
pom.xml
|
@ -41,9 +41,8 @@
|
|||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<suppressionsLocation>
|
||||
suppressions.xml
|
||||
</suppressionsLocation>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<suppressionsLocation>suppressions.xml</suppressionsLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -7,11 +7,13 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public final class CommandBroadcastVanilla implements CommandExecutor {
|
||||
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) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||
Command.broadcastCommandMessage(sender, ChatColor.translateAlternateColorCodes(
|
||||
'&', String.join(" ", args)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class CommandClearChat implements CommandExecutor {
|
||||
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) {
|
||||
final int maxMessages = 100;
|
||||
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
|
|
|
@ -8,13 +8,15 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public final class CommandConsole implements CommandExecutor {
|
||||
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) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
||||
} else {
|
||||
Bukkit.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"minecraft:say " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args))
|
||||
"minecraft:say " + ChatColor.translateAlternateColorCodes(
|
||||
'&', String.join(" ", args))
|
||||
);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -10,7 +10,8 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
public final class CommandDestroyEntities implements CommandExecutor {
|
||||
@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) {
|
||||
int entityCount = 0;
|
||||
int worldCount = 0;
|
||||
|
||||
|
@ -24,7 +25,8 @@ public final class CommandDestroyEntities implements CommandExecutor {
|
|||
worldCount++;
|
||||
}
|
||||
|
||||
sender.sendMessage("Successfully destroyed " + entityCount + " entities in " + worldCount + " worlds");
|
||||
sender.sendMessage("Successfully destroyed " + entityCount + " entities in "
|
||||
+ worldCount + " worlds");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public final class CommandEnchantAll implements CommandExecutor {
|
||||
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) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,8 @@ public final class CommandJumpscare implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
|
||||
} else {
|
||||
|
@ -35,7 +36,8 @@ public final class CommandJumpscare implements CommandExecutor {
|
|||
final Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target != null) {
|
||||
createJumpscare(target);
|
||||
sender.sendMessage("Successfully created jumpscare for player \"" + target.getName() + "\"");
|
||||
sender.sendMessage("Successfully created jumpscare for player \""
|
||||
+ target.getName() + "\"");
|
||||
} else {
|
||||
sender.sendMessage("Player \"" + args[0] + "\" not found");
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
public final class CommandKaboom implements CommandExecutor {
|
||||
|
||||
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) {
|
||||
final Player player = (Player) sender;
|
||||
boolean explode = ThreadLocalRandom.current().nextBoolean();
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ import org.bukkit.entity.Player;
|
|||
|
||||
public final class CommandPing implements CommandExecutor {
|
||||
|
||||
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) {
|
||||
Player target;
|
||||
|
||||
if (args.length == 0) {
|
||||
|
|
|
@ -19,12 +19,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import pw.kaboom.extras.Main;
|
||||
|
||||
public final class CommandPrefix implements CommandExecutor {
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, 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 File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(), "prefixes.yml");
|
||||
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(),
|
||||
"prefixes.yml");
|
||||
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
try {
|
||||
|
@ -37,10 +39,13 @@ public final class CommandPrefix implements CommandExecutor {
|
|||
} else {
|
||||
prefixConfig.set(player.getUniqueId().toString(), String.join(" ", args));
|
||||
prefixConfig.save(configFile);
|
||||
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||
player.sendMessage("You now have the tag: "
|
||||
+ ChatColor.translateAlternateColorCodes(
|
||||
'&', String.join(" ", args)));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
player.sendMessage("Something went wrong while saving the prefix. Please check console.");
|
||||
player.sendMessage("Something went wrong while saving the prefix. "
|
||||
+ "Please check console.");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ public final class CommandPumpkin implements CommandExecutor {
|
|||
player.getInventory().setHelmet(new ItemStack(Material.CARVED_PUMPKIN));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
|
||||
} else {
|
||||
|
|
|
@ -13,14 +13,16 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public final class CommandServerInfo implements CommandExecutor {
|
||||
private void sendInfoMessage(final CommandSender target, final String description, final String value) {
|
||||
private void sendInfoMessage(final CommandSender target, final String description,
|
||||
final String value) {
|
||||
target.sendMessage(
|
||||
ChatColor.GRAY + description + ": "
|
||||
+ ChatColor.WHITE + value
|
||||
);
|
||||
}
|
||||
|
||||
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) {
|
||||
try {
|
||||
sendInfoMessage(sender, "Hostname",
|
||||
InetAddress.getLocalHost().getHostName()
|
||||
|
@ -79,7 +81,8 @@ public final class CommandServerInfo implements CommandExecutor {
|
|||
);
|
||||
|
||||
final long heapUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
|
||||
final long nonHeapUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed();
|
||||
final long nonHeapUsage = ManagementFactory.getMemoryMXBean()
|
||||
.getNonHeapMemoryUsage().getUsed();
|
||||
final long memoryMax = (
|
||||
ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax()
|
||||
+ ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getMax()
|
||||
|
|
|
@ -13,7 +13,8 @@ public final class CommandSkin implements CommandExecutor {
|
|||
private long millis;
|
||||
|
||||
@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) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,8 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class CommandSpawn implements CommandExecutor {
|
||||
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) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
|
@ -25,7 +26,8 @@ public final class CommandSpawn implements CommandExecutor {
|
|||
final int maxWorldHeight = 256;
|
||||
|
||||
for (double y = spawnLocation.getY(); y <= maxWorldHeight; y++) {
|
||||
final Location yLocation = new Location(world, spawnLocation.getX(), y, spawnLocation.getZ());
|
||||
final Location yLocation = new Location(world, spawnLocation.getX(), y,
|
||||
spawnLocation.getZ());
|
||||
final Block coordBlock = world.getBlockAt(yLocation);
|
||||
|
||||
if (!coordBlock.getType().isSolid()
|
||||
|
|
|
@ -14,7 +14,8 @@ import org.bukkit.util.BlockIterator;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class CommandSpidey implements CommandExecutor {
|
||||
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) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
|
|
|
@ -10,12 +10,14 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class CommandTellraw implements CommandExecutor {
|
||||
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) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
||||
} else {
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||
onlinePlayer.sendMessage(ChatColor.translateAlternateColorCodes(
|
||||
'&', String.join(" ", args)));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -14,13 +14,15 @@ public final class CommandUsername implements CommandExecutor {
|
|||
private long millis;
|
||||
|
||||
@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) {
|
||||
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 nameColor = ChatColor.translateAlternateColorCodes(
|
||||
'&', String.join(" ", args));
|
||||
final String name = nameColor.substring(0, Math.min(16, nameColor.length()));
|
||||
|
||||
final long millisDifference = System.currentTimeMillis() - millis;
|
||||
|
|
|
@ -29,7 +29,8 @@ public final class BlockPhysics implements Listener {
|
|||
try {
|
||||
if (!event.getBlock().getType().isSolid()) {
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
||||
if (event.getBlock().getRelative(face).getType()
|
||||
!= event.getBlock().getType()) {
|
||||
return;
|
||||
}
|
||||
if (!event.getBlock().getType().equals(Material.AIR)) {
|
||||
|
@ -84,9 +85,11 @@ public final class BlockPhysics implements Listener {
|
|||
boolean waterFound = false;
|
||||
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
if (event.getBlock().getRelative(face).getType() == Material.LAVA && !lavaFound) {
|
||||
if (event.getBlock().getRelative(face).getType() == Material.LAVA
|
||||
&& !lavaFound) {
|
||||
lavaFound = true;
|
||||
} else if (event.getBlock().getRelative(face).getType() == Material.WATER && !waterFound) {
|
||||
} else if (event.getBlock().getRelative(face).getType() == Material.WATER
|
||||
&& !waterFound) {
|
||||
waterFound = true;
|
||||
}
|
||||
|
||||
|
@ -115,8 +118,10 @@ public final class BlockPhysics implements Listener {
|
|||
case REPEATER:
|
||||
case TRIPWIRE:
|
||||
if (!event.getBlock().getRelative(BlockFace.DOWN).getType().isSolid()
|
||||
&& !Material.AIR.equals(event.getBlock().getRelative(BlockFace.DOWN).getType())
|
||||
&& !Material.CAVE_AIR.equals(event.getBlock().getRelative(BlockFace.DOWN).getType())) {
|
||||
&& !Material.AIR.equals(event.getBlock().getRelative(BlockFace.DOWN)
|
||||
.getType())
|
||||
&& !Material.CAVE_AIR.equals(event.getBlock()
|
||||
.getRelative(BlockFace.DOWN).getType())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pw.kaboom.extras.modules.entity;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Fireball;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -16,9 +18,10 @@ public final class EntityExplosion implements Listener {
|
|||
event.setRadius(maxRadius);
|
||||
}
|
||||
|
||||
final World world = event.getEntity().getWorld();
|
||||
final int maxFireballCount = 30;
|
||||
|
||||
if (event.getEntity().getWorld().getEntitiesByClass(Fireball.class).size() > maxFireballCount
|
||||
if (world.getEntitiesByClass(Fireball.class).size() > maxFireballCount
|
||||
&& event.getRadius() > 1) {
|
||||
event.setRadius(1);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ public final class EntitySpawn implements Listener {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean isEntityLimitReached(final EntityType entityType, final Chunk chunk, final World world) {
|
||||
private boolean isEntityLimitReached(final EntityType entityType, final Chunk chunk,
|
||||
final World world) {
|
||||
switch (entityType) {
|
||||
case ENDER_DRAGON:
|
||||
final int worldDragonCount = world.getEntitiesByClass(EnderDragon.class).size();
|
||||
|
@ -169,7 +170,8 @@ public final class EntitySpawn implements Listener {
|
|||
@EventHandler
|
||||
void onExplosionPrime(final ExplosionPrimeEvent event) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +257,9 @@ public final class EntitySpawn implements Listener {
|
|||
@EventHandler
|
||||
void onSpawnerSpawn(final SpawnerSpawnEvent event) {
|
||||
if (EntityType.FALLING_BLOCK.equals(event.getEntityType())) {
|
||||
if (((FallingBlock) event.getEntity()).getBlockData().getMaterial().equals(Material.SPAWNER)) {
|
||||
final FallingBlock block = (FallingBlock) event.getEntity();
|
||||
|
||||
if (block.getBlockData().getMaterial().equals(Material.SPAWNER)) {
|
||||
event.setCancelled(true);
|
||||
event.getSpawner().setSpawnedType(EntityType.FALLING_BLOCK);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ public final class PlayerChat implements Listener {
|
|||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (PlayerCommand.getCommandMillisList().get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - PlayerCommand.getCommandMillisList().get(playerUuid);
|
||||
final long lastCommandTime = PlayerCommand.getCommandMillisList().get(playerUuid);
|
||||
final long millisDifference = System.currentTimeMillis() - lastCommandTime;
|
||||
|
||||
if (millisDifference < 50) {
|
||||
event.setCancelled(true);
|
||||
|
@ -39,7 +40,8 @@ public final class PlayerChat implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(), "prefixes.yml");
|
||||
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(),
|
||||
"prefixes.yml");
|
||||
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
final String prefix;
|
||||
final String name = player.getDisplayName().toString();
|
||||
|
|
|
@ -18,7 +18,8 @@ public final class PlayerCommand implements Listener {
|
|||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (getCommandMillisList().get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - getCommandMillisList().get(playerUuid);
|
||||
final long lastCommandTime = getCommandMillisList().get(playerUuid);
|
||||
final long millisDifference = System.currentTimeMillis() - lastCommandTime;
|
||||
|
||||
if (millisDifference < 75) {
|
||||
event.setCancelled(true);
|
||||
|
@ -43,11 +44,6 @@ public final class PlayerCommand implements Listener {
|
|||
event.setMessage(checkedCommand);
|
||||
}
|
||||
}
|
||||
|
||||
/*final MessageInterceptingCommandRunner cmdRunner = new MessageInterceptingCommandRunner(Bukkit.getConsoleSender());
|
||||
Bukkit.dispatchCommand(cmdRunner, event.getMessage().substring(1));
|
||||
|
||||
event.setCancelled(true);*/
|
||||
}
|
||||
|
||||
public static HashMap<UUID, Long> getCommandMillisList() {
|
||||
|
|
|
@ -38,8 +38,10 @@ public final class PlayerConnection implements Listener {
|
|||
private static final int FADE_OUT = 5;
|
||||
|
||||
private static final boolean ENABLE_KICK = CONFIG.getBoolean("enableKick");
|
||||
private static final boolean ENABLE_JOIN_RESTRICTIONS = CONFIG.getBoolean("enableJoinRestrictions");
|
||||
private static final boolean ALLOW_JOIN_ON_FULL_SERVER = CONFIG.getBoolean("allowJoinOnFullServer");
|
||||
private static final boolean ENABLE_JOIN_RESTRICTIONS = CONFIG.getBoolean(
|
||||
"enableJoinRestrictions");
|
||||
private static final boolean ALLOW_JOIN_ON_FULL_SERVER = CONFIG.getBoolean(
|
||||
"allowJoinOnFullServer");
|
||||
private static final boolean OP_ON_JOIN = CONFIG.getBoolean("opOnJoin");
|
||||
private static final boolean RANDOMIZE_SPAWN = CONFIG.getBoolean("randomizeSpawn");
|
||||
|
||||
|
@ -47,13 +49,15 @@ public final class PlayerConnection implements Listener {
|
|||
void onAsyncPlayerPreLogin(final AsyncPlayerPreLoginEvent event) {
|
||||
if (Bukkit.getPlayer(event.getName()) != null
|
||||
&& Bukkit.getPlayer(event.getName()).isOnline()) {
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "A player with that username is already logged in");
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER,
|
||||
"A player with that username is already logged in");
|
||||
}
|
||||
|
||||
/*try {
|
||||
final PlayerProfile profile = event.getPlayerProfile();
|
||||
|
||||
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
|
||||
UUID offlineUUID = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
|
||||
|
||||
profile.setId(offlineUUID);
|
||||
|
||||
|
@ -113,7 +117,8 @@ public final class PlayerConnection implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onPlayerSpawn(final PlayerSpawnLocationEvent event) {
|
||||
if (RANDOMIZE_SPAWN && event.getPlayer().getBedSpawnLocation() != event.getSpawnLocation()) {
|
||||
if (RANDOMIZE_SPAWN
|
||||
&& event.getPlayer().getBedSpawnLocation() != event.getSpawnLocation()) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
final double x = ThreadLocalRandom.current().nextInt(-300000000, 30000000) + .5;
|
||||
final double y = 100;
|
||||
|
@ -133,7 +138,8 @@ public final class PlayerConnection implements Listener {
|
|||
@EventHandler
|
||||
void onPreLookupProfile(final PreLookupProfileEvent event) {
|
||||
// Disable Mojang API calls, we don't need them
|
||||
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
|
||||
UUID offlineUUID = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
|
||||
event.setUUID(offlineUUID);
|
||||
|
||||
event.setProfileProperties(new HashSet<ProfileProperty>());
|
||||
|
|
|
@ -65,7 +65,8 @@ public final class PlayerDamage implements Listener {
|
|||
}
|
||||
|
||||
if (event.getDroppedExp() > 0) {
|
||||
ExperienceOrb xp = player.getWorld().spawn(player.getLocation(), ExperienceOrb.class);
|
||||
ExperienceOrb xp = player.getWorld().spawn(player.getLocation(),
|
||||
ExperienceOrb.class);
|
||||
xp.setExperience(event.getDroppedExp());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ public final class PlayerInteract implements Listener {
|
|||
/*final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
if (interactMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - interactMillisList.get(playerUuid);
|
||||
final long lastInteractionTime = interactMillisList.get(playerUuid);
|
||||
final long millisDifference = System.currentTimeMillis() - lastInteractionTime;
|
||||
|
||||
if (millisDifference < 150) {
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -18,7 +18,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import pw.kaboom.extras.Main;
|
||||
|
||||
public final class ServerCommand implements Listener {
|
||||
private static final Pattern AS_AT_PATTERN = Pattern.compile("\\b(as|at|facing entity) @[ae]\\b");
|
||||
private static final Pattern AS_AT_PATTERN = Pattern.compile(
|
||||
"\\b(as|at|facing entity) @[ae]\\b");
|
||||
private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger();
|
||||
|
||||
public static boolean checkExecuteCommand(final String cmd) {
|
||||
|
@ -46,7 +47,8 @@ public final class ServerCommand implements Listener {
|
|||
|| "w".equalsIgnoreCase(cmd)
|
||||
);
|
||||
}
|
||||
public static String checkCommand(final CommandSender sender, final String command, final boolean isConsoleCommand) {
|
||||
public static String checkCommand(final CommandSender sender, final String command,
|
||||
final boolean isConsoleCommand) {
|
||||
final String[] arr = command.split(" ");
|
||||
String commandName = arr[0].toLowerCase();
|
||||
|
||||
|
@ -72,7 +74,6 @@ public final class ServerCommand implements Listener {
|
|||
} catch (NumberFormatException e) {
|
||||
// Ignore exception
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,8 +99,10 @@ public final class ServerCommand implements Listener {
|
|||
if (checkExecuteCommand(arr[i + 1])) {
|
||||
return "cancel";
|
||||
} else {
|
||||
final String[] executeCommand = Arrays.copyOfRange(arr, i + 1, arr.length);
|
||||
String result = checkCommand(sender, String.join(" ", executeCommand), true);
|
||||
final String[] executeCommand = Arrays.copyOfRange(
|
||||
arr, i + 1, arr.length);
|
||||
String result = checkCommand(sender,
|
||||
String.join(" ", executeCommand), true);
|
||||
if (result == null) {
|
||||
break;
|
||||
}
|
||||
|
@ -107,7 +110,8 @@ public final class ServerCommand implements Listener {
|
|||
case "cancel":
|
||||
return "cancel";
|
||||
default:
|
||||
String pureExecute = String.join(" ", Arrays.copyOfRange(arr, 0, i + 1));
|
||||
String pureExecute = String.join(
|
||||
" ", Arrays.copyOfRange(arr, 0, i + 1));
|
||||
return (pureExecute + " " + result);
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +215,8 @@ public final class ServerCommand implements Listener {
|
|||
}
|
||||
|
||||
if (command.contains("distance")) {
|
||||
return command.replace("distance=", "]").replace("\"distance\"=", "]").replace("'distance'=", "]");
|
||||
return command.replace("distance=", "]").replace("\"distance\"=", "]")
|
||||
.replace("'distance'=", "]");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -222,7 +227,8 @@ public final class ServerCommand implements Listener {
|
|||
final CommandSender sender = event.getSender();
|
||||
|
||||
if (sender instanceof BlockCommandSender) {
|
||||
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender).getBlock().getState();
|
||||
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender)
|
||||
.getBlock().getState();
|
||||
|
||||
commandBlock.setCommand("");
|
||||
commandBlock.update();
|
||||
|
|
|
@ -19,7 +19,8 @@ public final class ServerTabComplete implements Listener {
|
|||
void onAsyncTabComplete(final AsyncTabCompleteEvent event) {
|
||||
final String[] arr = event.getBuffer().split(" ", 2);
|
||||
|
||||
// Vanilla clients will not send tab complete requests on the first word, but modified or bot clients may
|
||||
// Vanilla clients will not send tab complete requests on the first word,
|
||||
// but modified or bot clients may
|
||||
if (arr.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
||||
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||
|
||||
<suppressions>
|
||||
<suppress checks="Javadoc" files="."/>
|
||||
<suppress checks="LineLength" files="."/>
|
||||
<suppress checks="MagicNumber" files="."/>
|
||||
<suppress checks="MethodLength" files="."/>
|
||||
</suppressions>
|
||||
|
|
Loading…
Reference in a new issue