forked from kaboomserver/extras
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>
|
<goal>check</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<suppressionsLocation>
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
suppressions.xml
|
<suppressionsLocation>suppressions.xml</suppressionsLocation>
|
||||||
</suppressionsLocation>
|
|
||||||
<failOnViolation>true</failOnViolation>
|
<failOnViolation>true</failOnViolation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -7,11 +7,13 @@ import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public final class CommandBroadcastVanilla implements CommandExecutor {
|
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) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
||||||
} else {
|
} else {
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
Command.broadcastCommandMessage(sender, ChatColor.translateAlternateColorCodes(
|
||||||
|
'&', String.join(" ", args)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class CommandClearChat implements CommandExecutor {
|
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;
|
final int maxMessages = 100;
|
||||||
|
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
|
|
@ -8,13 +8,15 @@ import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public final class CommandConsole implements CommandExecutor {
|
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) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
||||||
} else {
|
} else {
|
||||||
Bukkit.dispatchCommand(
|
Bukkit.dispatchCommand(
|
||||||
Bukkit.getConsoleSender(),
|
Bukkit.getConsoleSender(),
|
||||||
"minecraft:say " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args))
|
"minecraft:say " + ChatColor.translateAlternateColorCodes(
|
||||||
|
'&', String.join(" ", args))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -10,7 +10,8 @@ import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public final class CommandDestroyEntities implements CommandExecutor {
|
public final class CommandDestroyEntities implements CommandExecutor {
|
||||||
@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) {
|
||||||
int entityCount = 0;
|
int entityCount = 0;
|
||||||
int worldCount = 0;
|
int worldCount = 0;
|
||||||
|
|
||||||
|
@ -24,7 +25,8 @@ public final class CommandDestroyEntities implements CommandExecutor {
|
||||||
worldCount++;
|
worldCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("Successfully destroyed " + entityCount + " entities in " + worldCount + " worlds");
|
sender.sendMessage("Successfully destroyed " + entityCount + " entities in "
|
||||||
|
+ worldCount + " worlds");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public final class CommandEnchantAll implements CommandExecutor {
|
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) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} 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) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
|
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,7 +36,8 @@ public final class CommandJumpscare implements CommandExecutor {
|
||||||
final Player target = Bukkit.getPlayer(args[0]);
|
final Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
createJumpscare(target);
|
createJumpscare(target);
|
||||||
sender.sendMessage("Successfully created jumpscare for player \"" + target.getName() + "\"");
|
sender.sendMessage("Successfully created jumpscare for player \""
|
||||||
|
+ target.getName() + "\"");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("Player \"" + args[0] + "\" not found");
|
sender.sendMessage("Player \"" + args[0] + "\" not found");
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public final class CommandKaboom implements CommandExecutor {
|
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;
|
final Player player = (Player) sender;
|
||||||
boolean explode = ThreadLocalRandom.current().nextBoolean();
|
boolean explode = ThreadLocalRandom.current().nextBoolean();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class CommandPing implements CommandExecutor {
|
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;
|
Player target;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
|
|
@ -19,12 +19,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import pw.kaboom.extras.Main;
|
import pw.kaboom.extras.Main;
|
||||||
|
|
||||||
public final class CommandPrefix implements CommandExecutor {
|
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) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
final Player player = (Player) sender;
|
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);
|
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -37,10 +39,13 @@ public final class CommandPrefix implements CommandExecutor {
|
||||||
} else {
|
} else {
|
||||||
prefixConfig.set(player.getUniqueId().toString(), String.join(" ", args));
|
prefixConfig.set(player.getUniqueId().toString(), String.join(" ", args));
|
||||||
prefixConfig.save(configFile);
|
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) {
|
} 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();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ public final class CommandPumpkin implements CommandExecutor {
|
||||||
player.getInventory().setHelmet(new ItemStack(Material.CARVED_PUMPKIN));
|
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) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
|
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <player>");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,14 +13,16 @@ import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public final class CommandServerInfo implements CommandExecutor {
|
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(
|
target.sendMessage(
|
||||||
ChatColor.GRAY + description + ": "
|
ChatColor.GRAY + description + ": "
|
||||||
+ ChatColor.WHITE + value
|
+ 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 {
|
try {
|
||||||
sendInfoMessage(sender, "Hostname",
|
sendInfoMessage(sender, "Hostname",
|
||||||
InetAddress.getLocalHost().getHostName()
|
InetAddress.getLocalHost().getHostName()
|
||||||
|
@ -79,7 +81,8 @@ public final class CommandServerInfo implements CommandExecutor {
|
||||||
);
|
);
|
||||||
|
|
||||||
final long heapUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
|
final long heapUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
|
||||||
final long nonHeapUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed();
|
final long nonHeapUsage = ManagementFactory.getMemoryMXBean()
|
||||||
|
.getNonHeapMemoryUsage().getUsed();
|
||||||
final long memoryMax = (
|
final long memoryMax = (
|
||||||
ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax()
|
ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax()
|
||||||
+ ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getMax()
|
+ ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getMax()
|
||||||
|
|
|
@ -13,7 +13,8 @@ public final class CommandSkin implements CommandExecutor {
|
||||||
private 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) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,7 +15,8 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class CommandSpawn implements CommandExecutor {
|
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) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +26,8 @@ public final class CommandSpawn implements CommandExecutor {
|
||||||
final int maxWorldHeight = 256;
|
final int maxWorldHeight = 256;
|
||||||
|
|
||||||
for (double y = spawnLocation.getY(); y <= maxWorldHeight; y++) {
|
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);
|
final Block coordBlock = world.getBlockAt(yLocation);
|
||||||
|
|
||||||
if (!coordBlock.getType().isSolid()
|
if (!coordBlock.getType().isSolid()
|
||||||
|
|
|
@ -14,7 +14,8 @@ import org.bukkit.util.BlockIterator;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public final class CommandSpidey implements CommandExecutor {
|
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) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,12 +10,14 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class CommandTellraw implements CommandExecutor {
|
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) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message ..>");
|
||||||
} else {
|
} else {
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
onlinePlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
onlinePlayer.sendMessage(ChatColor.translateAlternateColorCodes(
|
||||||
|
'&', String.join(" ", args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -14,13 +14,15 @@ public final class CommandUsername implements CommandExecutor {
|
||||||
private 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) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
final Player player = (Player) sender;
|
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 String name = nameColor.substring(0, Math.min(16, nameColor.length()));
|
||||||
|
|
||||||
final long millisDifference = System.currentTimeMillis() - millis;
|
final long millisDifference = System.currentTimeMillis() - millis;
|
||||||
|
|
|
@ -29,7 +29,8 @@ public final class BlockPhysics implements Listener {
|
||||||
try {
|
try {
|
||||||
if (!event.getBlock().getType().isSolid()) {
|
if (!event.getBlock().getType().isSolid()) {
|
||||||
for (BlockFace face : getBlockFaces()) {
|
for (BlockFace face : getBlockFaces()) {
|
||||||
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
if (event.getBlock().getRelative(face).getType()
|
||||||
|
!= event.getBlock().getType()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!event.getBlock().getType().equals(Material.AIR)) {
|
if (!event.getBlock().getType().equals(Material.AIR)) {
|
||||||
|
@ -84,9 +85,11 @@ public final class BlockPhysics implements Listener {
|
||||||
boolean waterFound = false;
|
boolean waterFound = false;
|
||||||
|
|
||||||
for (BlockFace face : getBlockFaces()) {
|
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) {
|
||||||
waterFound = true;
|
waterFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +118,10 @@ public final class BlockPhysics implements Listener {
|
||||||
case REPEATER:
|
case REPEATER:
|
||||||
case TRIPWIRE:
|
case TRIPWIRE:
|
||||||
if (!event.getBlock().getRelative(BlockFace.DOWN).getType().isSolid()
|
if (!event.getBlock().getRelative(BlockFace.DOWN).getType().isSolid()
|
||||||
&& !Material.AIR.equals(event.getBlock().getRelative(BlockFace.DOWN).getType())
|
&& !Material.AIR.equals(event.getBlock().getRelative(BlockFace.DOWN)
|
||||||
&& !Material.CAVE_AIR.equals(event.getBlock().getRelative(BlockFace.DOWN).getType())) {
|
.getType())
|
||||||
|
&& !Material.CAVE_AIR.equals(event.getBlock()
|
||||||
|
.getRelative(BlockFace.DOWN).getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pw.kaboom.extras.modules.entity;
|
package pw.kaboom.extras.modules.entity;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -16,9 +18,10 @@ public final class EntityExplosion implements Listener {
|
||||||
event.setRadius(maxRadius);
|
event.setRadius(maxRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final World world = event.getEntity().getWorld();
|
||||||
final int maxFireballCount = 30;
|
final int maxFireballCount = 30;
|
||||||
|
|
||||||
if (event.getEntity().getWorld().getEntitiesByClass(Fireball.class).size() > maxFireballCount
|
if (world.getEntitiesByClass(Fireball.class).size() > maxFireballCount
|
||||||
&& event.getRadius() > 1) {
|
&& event.getRadius() > 1) {
|
||||||
event.setRadius(1);
|
event.setRadius(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,8 @@ public final class EntitySpawn implements Listener {
|
||||||
return false;
|
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) {
|
switch (entityType) {
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
final int worldDragonCount = world.getEntitiesByClass(EnderDragon.class).size();
|
final int worldDragonCount = world.getEntitiesByClass(EnderDragon.class).size();
|
||||||
|
@ -169,7 +170,8 @@ public final class EntitySpawn implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onExplosionPrime(final ExplosionPrimeEvent event) {
|
void onExplosionPrime(final ExplosionPrimeEvent 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +257,9 @@ public final class EntitySpawn implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onSpawnerSpawn(final 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)) {
|
final FallingBlock block = (FallingBlock) event.getEntity();
|
||||||
|
|
||||||
|
if (block.getBlockData().getMaterial().equals(Material.SPAWNER)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getSpawner().setSpawnedType(EntityType.FALLING_BLOCK);
|
event.getSpawner().setSpawnedType(EntityType.FALLING_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ public final class PlayerChat implements Listener {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (PlayerCommand.getCommandMillisList().get(playerUuid) != null) {
|
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) {
|
if (millisDifference < 50) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -39,7 +40,8 @@ public final class PlayerChat implements Listener {
|
||||||
return;
|
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 FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||||
final String prefix;
|
final String prefix;
|
||||||
final String name = player.getDisplayName().toString();
|
final String name = player.getDisplayName().toString();
|
||||||
|
|
|
@ -18,7 +18,8 @@ public final class PlayerCommand implements Listener {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (getCommandMillisList().get(playerUuid) != null) {
|
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) {
|
if (millisDifference < 75) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -43,11 +44,6 @@ public final class PlayerCommand implements Listener {
|
||||||
event.setMessage(checkedCommand);
|
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() {
|
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 int FADE_OUT = 5;
|
||||||
|
|
||||||
private static final boolean ENABLE_KICK = CONFIG.getBoolean("enableKick");
|
private static final boolean ENABLE_KICK = CONFIG.getBoolean("enableKick");
|
||||||
private static final boolean ENABLE_JOIN_RESTRICTIONS = CONFIG.getBoolean("enableJoinRestrictions");
|
private static final boolean ENABLE_JOIN_RESTRICTIONS = CONFIG.getBoolean(
|
||||||
private static final boolean ALLOW_JOIN_ON_FULL_SERVER = CONFIG.getBoolean("allowJoinOnFullServer");
|
"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 OP_ON_JOIN = CONFIG.getBoolean("opOnJoin");
|
||||||
private static final boolean RANDOMIZE_SPAWN = CONFIG.getBoolean("randomizeSpawn");
|
private static final boolean RANDOMIZE_SPAWN = CONFIG.getBoolean("randomizeSpawn");
|
||||||
|
|
||||||
|
@ -47,13 +49,15 @@ public final class PlayerConnection implements Listener {
|
||||||
void onAsyncPlayerPreLogin(final AsyncPlayerPreLoginEvent event) {
|
void onAsyncPlayerPreLogin(final AsyncPlayerPreLoginEvent event) {
|
||||||
if (Bukkit.getPlayer(event.getName()) != null
|
if (Bukkit.getPlayer(event.getName()) != null
|
||||||
&& Bukkit.getPlayer(event.getName()).isOnline()) {
|
&& 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 {
|
/*try {
|
||||||
final PlayerProfile profile = event.getPlayerProfile();
|
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);
|
profile.setId(offlineUUID);
|
||||||
|
|
||||||
|
@ -113,7 +117,8 @@ public final class PlayerConnection implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerSpawn(final PlayerSpawnLocationEvent event) {
|
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 World world = event.getPlayer().getWorld();
|
||||||
final double x = ThreadLocalRandom.current().nextInt(-300000000, 30000000) + .5;
|
final double x = ThreadLocalRandom.current().nextInt(-300000000, 30000000) + .5;
|
||||||
final double y = 100;
|
final double y = 100;
|
||||||
|
@ -133,7 +138,8 @@ public final class PlayerConnection implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPreLookupProfile(final PreLookupProfileEvent event) {
|
void onPreLookupProfile(final PreLookupProfileEvent event) {
|
||||||
// Disable Mojang API calls, we don't need them
|
// 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.setUUID(offlineUUID);
|
||||||
|
|
||||||
event.setProfileProperties(new HashSet<ProfileProperty>());
|
event.setProfileProperties(new HashSet<ProfileProperty>());
|
||||||
|
|
|
@ -65,7 +65,8 @@ public final class PlayerDamage implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getDroppedExp() > 0) {
|
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());
|
xp.setExperience(event.getDroppedExp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ public final class PlayerInteract implements Listener {
|
||||||
/*final UUID playerUuid = event.getPlayer().getUniqueId();
|
/*final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (interactMillisList.get(playerUuid) != null) {
|
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) {
|
if (millisDifference < 150) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
|
@ -18,7 +18,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import pw.kaboom.extras.Main;
|
import pw.kaboom.extras.Main;
|
||||||
|
|
||||||
public final class ServerCommand implements Listener {
|
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();
|
private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger();
|
||||||
|
|
||||||
public static boolean checkExecuteCommand(final String cmd) {
|
public static boolean checkExecuteCommand(final String cmd) {
|
||||||
|
@ -46,7 +47,8 @@ public final class ServerCommand implements Listener {
|
||||||
|| "w".equalsIgnoreCase(cmd)
|
|| "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(" ");
|
final String[] arr = command.split(" ");
|
||||||
String commandName = arr[0].toLowerCase();
|
String commandName = arr[0].toLowerCase();
|
||||||
|
|
||||||
|
@ -72,7 +74,6 @@ public final class ServerCommand implements Listener {
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Ignore exception
|
// Ignore exception
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +99,10 @@ public final class ServerCommand implements Listener {
|
||||||
if (checkExecuteCommand(arr[i + 1])) {
|
if (checkExecuteCommand(arr[i + 1])) {
|
||||||
return "cancel";
|
return "cancel";
|
||||||
} else {
|
} else {
|
||||||
final String[] executeCommand = Arrays.copyOfRange(arr, i + 1, arr.length);
|
final String[] executeCommand = Arrays.copyOfRange(
|
||||||
String result = checkCommand(sender, String.join(" ", executeCommand), true);
|
arr, i + 1, arr.length);
|
||||||
|
String result = checkCommand(sender,
|
||||||
|
String.join(" ", executeCommand), true);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +110,8 @@ public final class ServerCommand implements Listener {
|
||||||
case "cancel":
|
case "cancel":
|
||||||
return "cancel";
|
return "cancel";
|
||||||
default:
|
default:
|
||||||
String pureExecute = String.join(" ", Arrays.copyOfRange(arr, 0, i + 1));
|
String pureExecute = String.join(
|
||||||
|
" ", Arrays.copyOfRange(arr, 0, i + 1));
|
||||||
return (pureExecute + " " + result);
|
return (pureExecute + " " + result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +215,8 @@ public final class ServerCommand implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.contains("distance")) {
|
if (command.contains("distance")) {
|
||||||
return command.replace("distance=", "]").replace("\"distance\"=", "]").replace("'distance'=", "]");
|
return command.replace("distance=", "]").replace("\"distance\"=", "]")
|
||||||
|
.replace("'distance'=", "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -222,7 +227,8 @@ public final class ServerCommand implements Listener {
|
||||||
final CommandSender sender = event.getSender();
|
final CommandSender sender = event.getSender();
|
||||||
|
|
||||||
if (sender instanceof BlockCommandSender) {
|
if (sender instanceof BlockCommandSender) {
|
||||||
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender).getBlock().getState();
|
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender)
|
||||||
|
.getBlock().getState();
|
||||||
|
|
||||||
commandBlock.setCommand("");
|
commandBlock.setCommand("");
|
||||||
commandBlock.update();
|
commandBlock.update();
|
||||||
|
|
|
@ -19,7 +19,8 @@ public final class ServerTabComplete implements Listener {
|
||||||
void onAsyncTabComplete(final AsyncTabCompleteEvent event) {
|
void onAsyncTabComplete(final AsyncTabCompleteEvent event) {
|
||||||
final String[] arr = event.getBuffer().split(" ", 2);
|
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) {
|
if (arr.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
<!DOCTYPE suppressions PUBLIC
|
<!DOCTYPE suppressions PUBLIC
|
||||||
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
|
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
||||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||||
|
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<suppress checks="Javadoc" files="."/>
|
<suppress checks="Javadoc" files="."/>
|
||||||
<suppress checks="LineLength" files="."/>
|
|
||||||
<suppress checks="MagicNumber" files="."/>
|
<suppress checks="MagicNumber" files="."/>
|
||||||
<suppress checks="MethodLength" files="."/>
|
<suppress checks="MethodLength" files="."/>
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
|
Loading…
Reference in a new issue