mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-11 11:40:19 +00:00
More style fixes
This commit is contained in:
parent
164f6b5524
commit
b688a2793b
17 changed files with 136 additions and 132 deletions
8
pom.xml
8
pom.xml
|
@ -49,14 +49,6 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>8</source>
|
|
||||||
<target>8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package pw.kaboom.extras;
|
package pw.kaboom.extras;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
@ -36,9 +34,7 @@ import pw.kaboom.extras.modules.player.PlayerTeleport;
|
||||||
import pw.kaboom.extras.modules.server.ServerCommand;
|
import pw.kaboom.extras.modules.server.ServerCommand;
|
||||||
import pw.kaboom.extras.modules.server.ServerPing;
|
import pw.kaboom.extras.modules.server.ServerPing;
|
||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public final class Main extends JavaPlugin {
|
||||||
public static HashSet<UUID> skinInProgress = new HashSet<UUID>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
/* Fill lists */
|
/* Fill lists */
|
||||||
|
|
|
@ -45,8 +45,8 @@ public final class CommandServerInfo implements CommandExecutor {
|
||||||
);
|
);
|
||||||
sendInfoMessage(sender, "Java version",
|
sendInfoMessage(sender, "Java version",
|
||||||
ManagementFactory.getRuntimeMXBean().getSpecVersion()
|
ManagementFactory.getRuntimeMXBean().getSpecVersion()
|
||||||
+ " " +
|
+ " "
|
||||||
ManagementFactory.getRuntimeMXBean().getVmVersion()
|
+ ManagementFactory.getRuntimeMXBean().getVmVersion()
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -103,8 +103,8 @@ public final class CommandServerInfo implements CommandExecutor {
|
||||||
final long seconds = (ManagementFactory.getRuntimeMXBean().getUptime() / 1000) % 60;
|
final long seconds = (ManagementFactory.getRuntimeMXBean().getUptime() / 1000) % 60;
|
||||||
|
|
||||||
sendInfoMessage(sender, "Server uptime",
|
sendInfoMessage(sender, "Server uptime",
|
||||||
minutes + " minute(s) " +
|
minutes + " minute(s) "
|
||||||
seconds + " second(s)"
|
+ seconds + " second(s)"
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package pw.kaboom.extras.helpers;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
@ -18,6 +20,8 @@ import com.google.gson.JsonParser;
|
||||||
import pw.kaboom.extras.Main;
|
import pw.kaboom.extras.Main;
|
||||||
|
|
||||||
public final class SkinDownloader {
|
public final class SkinDownloader {
|
||||||
|
public static HashSet<UUID> skinInProgress = new HashSet<UUID>();
|
||||||
|
|
||||||
private HttpsURLConnection skinConnection;
|
private HttpsURLConnection skinConnection;
|
||||||
private InputStreamReader skinStream;
|
private InputStreamReader skinStream;
|
||||||
|
|
||||||
|
@ -28,7 +32,7 @@ public final class SkinDownloader {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Main.skinInProgress.add(player.getUniqueId());
|
skinInProgress.add(player.getUniqueId());
|
||||||
|
|
||||||
final PlayerProfile profile = player.getPlayerProfile();
|
final PlayerProfile profile = player.getPlayerProfile();
|
||||||
|
|
||||||
|
@ -48,14 +52,14 @@ public final class SkinDownloader {
|
||||||
try {
|
try {
|
||||||
skinStream.close();
|
skinStream.close();
|
||||||
skinConnection.disconnect();
|
skinConnection.disconnect();
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldChangeName && shouldSendMessage) {
|
if (!shouldChangeName && shouldSendMessage) {
|
||||||
player.sendMessage("A player with that username doesn't exist");
|
player.sendMessage("A player with that username doesn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.skinInProgress.remove(player.getUniqueId());
|
skinInProgress.remove(player.getUniqueId());
|
||||||
|
|
||||||
if (!shouldChangeName) {
|
if (!shouldChangeName) {
|
||||||
return;
|
return;
|
||||||
|
@ -75,7 +79,7 @@ public final class SkinDownloader {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.skinInProgress.remove(player.getUniqueId());
|
skinInProgress.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,12 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
|
||||||
public class BlockCheck implements Listener {
|
public final class BlockCheck implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockPlace(BlockPlaceEvent event) {
|
void onBlockPlace(final BlockPlaceEvent event) {
|
||||||
if (event.getItemInHand().toString().length() > 3019) {
|
final int maxItemStringLength = 3019;
|
||||||
|
|
||||||
|
if (event.getItemInHand().toString().length() > maxItemStringLength) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +23,7 @@ public class BlockCheck implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onSignChange(SignChangeEvent event) {
|
void onSignChange(final SignChangeEvent event) {
|
||||||
try {
|
try {
|
||||||
event.getLines();
|
event.getLines();
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
|
|
@ -16,16 +16,16 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.block.BlockDestroyEvent;
|
import com.destroystokyo.paper.event.block.BlockDestroyEvent;
|
||||||
|
|
||||||
public class BlockPhysics implements Listener {
|
public final class BlockPhysics implements Listener {
|
||||||
public static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
public static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockForm(BlockFormEvent event) {
|
void onBlockForm(final BlockFormEvent event) {
|
||||||
if (event.getBlock().getType() == Material.LAVA ||
|
if (event.getBlock().getType() == Material.LAVA
|
||||||
event.getBlock().getType() == Material.WATER) {
|
|| event.getBlock().getType() == Material.WATER) {
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : blockFaces) {
|
||||||
if (event.getBlock().getRelative(face).getType() != Material.LAVA &&
|
if (event.getBlock().getRelative(face).getType() != Material.LAVA
|
||||||
event.getBlock().getRelative(face).getType() != Material.WATER) {
|
&& event.getBlock().getRelative(face).getType() != Material.WATER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -34,9 +34,9 @@ public class BlockPhysics implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockFromTo(BlockFromToEvent event) {
|
void onBlockFromTo(final BlockFromToEvent event) {
|
||||||
if (event.getBlock().getType() == Material.LAVA ||
|
if (event.getBlock().getType() == Material.LAVA
|
||||||
event.getBlock().getType() == Material.WATER) {
|
|| event.getBlock().getType() == Material.WATER) {
|
||||||
boolean lavaFound = false;
|
boolean lavaFound = false;
|
||||||
boolean waterFound = false;
|
boolean waterFound = false;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class BlockPhysics implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockDestroy(BlockDestroyEvent event) {
|
void onBlockDestroy(final BlockDestroyEvent event) {
|
||||||
if (!event.getBlock().getType().isSolid()) {
|
if (!event.getBlock().getType().isSolid()) {
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : blockFaces) {
|
||||||
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
||||||
|
@ -68,7 +68,7 @@ public class BlockPhysics implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
void onBlockPhysics(final BlockPhysicsEvent event) {
|
||||||
switch (event.getChangedType()) {
|
switch (event.getChangedType()) {
|
||||||
case COMPARATOR:
|
case COMPARATOR:
|
||||||
case REDSTONE_TORCH:
|
case REDSTONE_TORCH:
|
||||||
|
@ -99,23 +99,26 @@ public class BlockPhysics implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockRedstone(BlockRedstoneEvent event) {
|
void onBlockRedstone(final BlockRedstoneEvent event) {
|
||||||
final double tps = Bukkit.getServer().getTPS()[0];
|
final double tps = Bukkit.getServer().getTPS()[0];
|
||||||
|
final int maxTps = 10;
|
||||||
|
|
||||||
if (tps < 10) {
|
if (tps < maxTps) {
|
||||||
event.setNewCurrent(0);
|
event.setNewCurrent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int fallingBlockCount;
|
private int fallingBlockCount;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
void onEntityChangeBlock(final EntityChangeBlockEvent event) {
|
||||||
if (event.getEntityType() == EntityType.FALLING_BLOCK &&
|
if (event.getEntityType() == EntityType.FALLING_BLOCK
|
||||||
event.getTo() == Material.AIR) {
|
&& event.getTo() == Material.AIR) {
|
||||||
fallingBlockCount++;
|
fallingBlockCount++;
|
||||||
|
|
||||||
if (fallingBlockCount == 10) {
|
final int maxFallingBlockCount = 10;
|
||||||
|
|
||||||
|
if (fallingBlockCount == maxFallingBlockCount) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
fallingBlockCount = 0;
|
fallingBlockCount = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,19 @@ import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
|
|
||||||
public class EntityExplosion implements Listener {
|
public final class EntityExplosion implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onExplosionPrime(ExplosionPrimeEvent event) {
|
void onExplosionPrime(final ExplosionPrimeEvent event) {
|
||||||
if (event.getRadius() > 20) {
|
final int maxRadius = 20;
|
||||||
event.setRadius(20);
|
|
||||||
|
if (event.getRadius() > maxRadius) {
|
||||||
|
event.setRadius(maxRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEntity().getWorld().getEntitiesByClass(Fireball.class).size() > 30 &&
|
final int maxFireballCount = 30;
|
||||||
event.getRadius() > 1) {
|
|
||||||
|
if (event.getEntity().getWorld().getEntitiesByClass(Fireball.class).size() > maxFireballCount
|
||||||
|
&& event.getRadius() > 1) {
|
||||||
event.setRadius(1);
|
event.setRadius(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
|
import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
|
||||||
|
|
||||||
public class EntityKnockback implements Listener {
|
public final class EntityKnockback implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityKnockbackByEntity(EntityKnockbackByEntityEvent event) {
|
void onEntityKnockbackByEntity(final EntityKnockbackByEntityEvent event) {
|
||||||
final int knockbackLimit = 60;
|
final int knockbackLimit = 60;
|
||||||
|
|
||||||
if (event.getKnockbackStrength() > knockbackLimit) {
|
if (event.getKnockbackStrength() > knockbackLimit) {
|
||||||
|
|
|
@ -5,9 +5,9 @@ import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import org.bukkit.event.entity.EntityTeleportEvent;
|
import org.bukkit.event.entity.EntityTeleportEvent;
|
||||||
|
|
||||||
public class EntityTeleport implements Listener {
|
public final class EntityTeleport implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityTeleport(EntityTeleportEvent event) {
|
void onEntityTeleport(final EntityTeleportEvent event) {
|
||||||
event.setTo(EntitySpawn.limitLocation(event.getTo()));
|
event.setTo(EntitySpawn.limitLocation(event.getTo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import pw.kaboom.extras.Main;
|
import pw.kaboom.extras.Main;
|
||||||
|
|
||||||
public class PlayerChat implements Listener {
|
public final class PlayerChat implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
void onAsyncPlayerChat(final AsyncPlayerChatEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,11 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
import pw.kaboom.extras.modules.server.ServerCommand;
|
import pw.kaboom.extras.modules.server.ServerCommand;
|
||||||
|
|
||||||
public class PlayerCommand implements Listener {
|
public final class PlayerCommand implements Listener {
|
||||||
static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (commandMillisList.get(playerUuid) != null) {
|
if (commandMillisList.get(playerUuid) != null) {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package pw.kaboom.extras.modules.player;
|
package pw.kaboom.extras.modules.player;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
@ -19,17 +17,16 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import pw.kaboom.extras.Main;
|
import pw.kaboom.extras.Main;
|
||||||
import pw.kaboom.extras.helpers.SkinDownloader;
|
import pw.kaboom.extras.helpers.SkinDownloader;
|
||||||
|
|
||||||
public class PlayerConnection implements Listener {
|
public final class PlayerConnection implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) throws IOException {
|
void onAsyncPlayerPreLogin(final AsyncPlayerPreLoginEvent event) {
|
||||||
if (event.getName().length() > 16) {
|
if (event.getName().length() > 16) {
|
||||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username can't be longer than 16 characters");
|
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username can't be longer than 16 characters");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerJoin(PlayerJoinEvent event) {
|
void onPlayerJoin(final PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String title = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinTitle");
|
final String title = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinTitle");
|
||||||
final String subtitle = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinSubtitle");
|
final String subtitle = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinSubtitle");
|
||||||
|
@ -37,8 +34,8 @@ public class PlayerConnection implements Listener {
|
||||||
final int stay = 160;
|
final int stay = 160;
|
||||||
final int fadeOut = 5;
|
final int fadeOut = 5;
|
||||||
|
|
||||||
if (title != null ||
|
if (title != null
|
||||||
subtitle != null) {
|
|| subtitle != null) {
|
||||||
player.sendTitle(
|
player.sendTitle(
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
|
@ -50,16 +47,16 @@ public class PlayerConnection implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerKick(PlayerKickEvent event) {
|
void onPlayerKick(final PlayerKickEvent event) {
|
||||||
if (!JavaPlugin.getPlugin(Main.class).getConfig().getBoolean("enableKick")) {
|
if (!JavaPlugin.getPlugin(Main.class).getConfig().getBoolean("enableKick")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerLogin(PlayerLoginEvent event) {
|
void onPlayerLogin(final PlayerLoginEvent event) {
|
||||||
if (event.getHostname().startsWith("play.flame.ga") &&
|
if (event.getHostname().startsWith("play.flame.ga")
|
||||||
event.getHostname().endsWith(":25565")) {
|
&& event.getHostname().endsWith(":25565")) {
|
||||||
event.disallow(Result.KICK_OTHER, "You connected to the server using an outdated server address/IP.\nPlease use the following address/IP:\n\nkaboom.pw");
|
event.disallow(Result.KICK_OTHER, "You connected to the server using an outdated server address/IP.\nPlease use the following address/IP:\n\nkaboom.pw");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,8 +67,8 @@ public class PlayerConnection implements Listener {
|
||||||
event.allow();
|
event.allow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getResult() == Result.KICK_FULL &&
|
if (event.getResult() == Result.KICK_FULL
|
||||||
JavaPlugin.getPlugin(Main.class).getConfig().getBoolean("allowJoinOnFullServer")) {
|
&& JavaPlugin.getPlugin(Main.class).getConfig().getBoolean("allowJoinOnFullServer")) {
|
||||||
event.allow();
|
event.allow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +89,7 @@ public class PlayerConnection implements Listener {
|
||||||
void onPlayerQuit(PlayerQuitEvent event) {
|
void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
PlayerCommand.commandMillisList.remove(event.getPlayer().getUniqueId());
|
PlayerCommand.commandMillisList.remove(event.getPlayer().getUniqueId());
|
||||||
PlayerInteract.interactMillisList.remove(event.getPlayer().getUniqueId());
|
PlayerInteract.interactMillisList.remove(event.getPlayer().getUniqueId());
|
||||||
Main.skinInProgress.remove(event.getPlayer().getUniqueId());
|
SkinDownloader.skinInProgress.remove(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
final World world = event.getPlayer().getWorld();
|
final World world = event.getPlayer().getWorld();
|
||||||
|
|
||||||
|
|
|
@ -23,19 +23,19 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class PlayerDamage implements Listener {
|
public final class PlayerDamage implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntityDamage(EntityDamageEvent event) {
|
void onEntityDamage(final EntityDamageEvent event) {
|
||||||
if (event.getEntityType() == EntityType.PLAYER) {
|
if (event.getEntityType() == EntityType.PLAYER) {
|
||||||
if (event.getCause() == DamageCause.VOID &&
|
if (event.getCause() == DamageCause.VOID
|
||||||
event.getDamage() == Float.MAX_VALUE) {
|
&& event.getDamage() == Float.MAX_VALUE) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerDeath(PlayerDeathEvent event) {
|
void onPlayerDeath(final PlayerDeathEvent event) {
|
||||||
final Player player = event.getEntity();
|
final Player player = event.getEntity();
|
||||||
final AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
final AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ public class PlayerDamage implements Listener {
|
||||||
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()
|
||||||
!coordBlock.getRelative(BlockFace.UP).getType().isSolid()) {
|
&& !coordBlock.getRelative(BlockFace.UP).getType().isSolid()) {
|
||||||
player.teleportAsync(yLocation);
|
player.teleportAsync(yLocation);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class PlayerInteract implements Listener {
|
public final class PlayerInteract implements Listener {
|
||||||
static HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
|
static HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerInteract(PlayerInteractEvent event) {
|
void onPlayerInteract(final PlayerInteractEvent event) {
|
||||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||||
|
|
||||||
if (interactMillisList.get(playerUuid) != null) {
|
if (interactMillisList.get(playerUuid) != null) {
|
||||||
|
|
|
@ -7,9 +7,9 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
import pw.kaboom.extras.modules.entity.EntitySpawn;
|
import pw.kaboom.extras.modules.entity.EntitySpawn;
|
||||||
|
|
||||||
public class PlayerTeleport implements Listener {
|
public final class PlayerTeleport implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerTeleport(PlayerTeleportEvent event) {
|
void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||||
event.setTo(EntitySpawn.limitLocation(event.getTo()));
|
event.setTo(EntitySpawn.limitLocation(event.getTo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
public class ServerCommand implements Listener {
|
public final class ServerCommand implements Listener {
|
||||||
public static HashSet<String> consoleCommandBlacklist = new HashSet<String>();
|
public static HashSet<String> consoleCommandBlacklist = new HashSet<String>();
|
||||||
|
|
||||||
public static String checkCommand(CommandSender sender, String command, 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();
|
||||||
|
|
||||||
|
@ -31,20 +31,20 @@ public class ServerCommand implements Listener {
|
||||||
for (int i = 1; i < arr.length; i++) {
|
for (int i = 1; i < arr.length; i++) {
|
||||||
if ("run".equalsIgnoreCase(arr[i])) {
|
if ("run".equalsIgnoreCase(arr[i])) {
|
||||||
if (i + 1 < arr.length) {
|
if (i + 1 < arr.length) {
|
||||||
if ("execute".equalsIgnoreCase(arr[i+1]) ||
|
if ("execute".equalsIgnoreCase(arr[i + 1])
|
||||||
"particle".equalsIgnoreCase(arr[i+1]) ||
|
|| "particle".equalsIgnoreCase(arr[i + 1])
|
||||||
"save-off".equalsIgnoreCase(arr[i+1]) ||
|
|| "save-off".equalsIgnoreCase(arr[i + 1])
|
||||||
"spreadplayers".equalsIgnoreCase(arr[i+1]) ||
|
|| "spreadplayers".equalsIgnoreCase(arr[i + 1])
|
||||||
"stop".equalsIgnoreCase(arr[i+1])) {
|
|| "stop".equalsIgnoreCase(arr[i + 1])) {
|
||||||
Command.broadcastCommandMessage(sender, "Forbidden execute command detected");
|
Command.broadcastCommandMessage(sender, "Forbidden execute command detected");
|
||||||
return "cancel";
|
return "cancel";
|
||||||
} else if (i+3 < arr.length &&
|
} else if (i + 3 < arr.length
|
||||||
"gamerule".equalsIgnoreCase(arr[i+1])) {
|
&& "gamerule".equalsIgnoreCase(arr[i + 1])) {
|
||||||
if ("randomTickSpeed".equalsIgnoreCase(arr[i+2]) &&
|
if ("randomTickSpeed".equalsIgnoreCase(arr[i + 2])
|
||||||
Double.parseDouble(arr[i+3]) > 6) {
|
&& Double.parseDouble(arr[i + 3]) > 6) {
|
||||||
return command.replaceFirst("(?i)" + "randomTickSpeed " + arr[i + 3], "randomTickSpeed 6");
|
return command.replaceFirst("(?i)" + "randomTickSpeed " + arr[i + 3], "randomTickSpeed 6");
|
||||||
} else if ("spawnRadius".equalsIgnoreCase(arr[i+2]) &&
|
} else if ("spawnRadius".equalsIgnoreCase(arr[i + 2])
|
||||||
Double.parseDouble(arr[i+3]) > 100) {
|
&& Double.parseDouble(arr[i + 3]) > 100) {
|
||||||
return command.replaceFirst("(?i)" + "spawnRadius " + arr[i + 3], "spawnRadius 100");
|
return command.replaceFirst("(?i)" + "spawnRadius " + arr[i + 3], "spawnRadius 100");
|
||||||
}
|
}
|
||||||
} else if ("give".equalsIgnoreCase(arr[i + 1])) {
|
} else if ("give".equalsIgnoreCase(arr[i + 1])) {
|
||||||
|
@ -57,8 +57,8 @@ public class ServerCommand implements Listener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("as".equalsIgnoreCase(arr[i]) ||
|
if ("as".equalsIgnoreCase(arr[i])
|
||||||
"at".equalsIgnoreCase(arr[i])) {
|
|| "at".equalsIgnoreCase(arr[i])) {
|
||||||
asAtCount++;
|
asAtCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ public class ServerCommand implements Listener {
|
||||||
case "/minecraft:gamerule":
|
case "/minecraft:gamerule":
|
||||||
case "/gamerule":
|
case "/gamerule":
|
||||||
if (arr.length >= 3) {
|
if (arr.length >= 3) {
|
||||||
if ("randomTickSpeed".equalsIgnoreCase(arr[1]) &&
|
if ("randomTickSpeed".equalsIgnoreCase(arr[1])
|
||||||
Double.parseDouble(arr[2]) > 6) {
|
&& Double.parseDouble(arr[2]) > 6) {
|
||||||
return command.replaceFirst(arr[2], "6");
|
return command.replaceFirst(arr[2], "6");
|
||||||
} else if ("spawnRadius".equalsIgnoreCase(arr[1]) &&
|
} else if ("spawnRadius".equalsIgnoreCase(arr[1])
|
||||||
Double.parseDouble(arr[2]) > 100) {
|
&& Double.parseDouble(arr[2]) > 100) {
|
||||||
return command.replaceFirst(arr[2], "100");
|
return command.replaceFirst(arr[2], "100");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,8 @@ public class ServerCommand implements Listener {
|
||||||
break;
|
break;
|
||||||
case "/minecraft:particle":
|
case "/minecraft:particle":
|
||||||
case "/particle":
|
case "/particle":
|
||||||
if (arr.length >= 10 &&
|
if (arr.length >= 10
|
||||||
Double.parseDouble(arr[9]) > 10) {
|
&& Double.parseDouble(arr[9]) > 10) {
|
||||||
arr[9] = "10";
|
arr[9] = "10";
|
||||||
return String.join(" ", arr);
|
return String.join(" ", arr);
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,9 @@ public class ServerCommand implements Listener {
|
||||||
case "/bukkit:rl":
|
case "/bukkit:rl":
|
||||||
case "/reload":
|
case "/reload":
|
||||||
case "/rl":
|
case "/rl":
|
||||||
if (sender.hasPermission("bukkit.command.reload") &&
|
if (sender.hasPermission("bukkit.command.reload")
|
||||||
arr.length >= 2 &&
|
&& arr.length >= 2
|
||||||
"confirm".equalsIgnoreCase(arr[1])) {
|
&& "confirm".equalsIgnoreCase(arr[1])) {
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
||||||
|
@ -125,12 +125,15 @@ public class ServerCommand implements Listener {
|
||||||
case "/minecraft:spreadplayers":
|
case "/minecraft:spreadplayers":
|
||||||
case "/spreadplayers":
|
case "/spreadplayers":
|
||||||
if (arr.length >= 5) {
|
if (arr.length >= 5) {
|
||||||
if (Double.parseDouble(arr[3]) > 0)
|
if (Double.parseDouble(arr[3]) > 0) {
|
||||||
arr[3] = "0";
|
arr[3] = "0";
|
||||||
if (Double.parseDouble(arr[4]) < 8)
|
}
|
||||||
|
if (Double.parseDouble(arr[4]) < 8) {
|
||||||
arr[4] = "8";
|
arr[4] = "8";
|
||||||
if (Double.parseDouble(arr[4]) > 50)
|
}
|
||||||
|
if (Double.parseDouble(arr[4]) > 50) {
|
||||||
arr[4] = "50";
|
arr[4] = "50";
|
||||||
|
}
|
||||||
|
|
||||||
return String.join(" ", arr);
|
return String.join(" ", arr);
|
||||||
}
|
}
|
||||||
|
@ -141,6 +144,8 @@ public class ServerCommand implements Listener {
|
||||||
Command.broadcastCommandMessage(sender, "Stopping the server");
|
Command.broadcastCommandMessage(sender, "Stopping the server");
|
||||||
return "cancel";
|
return "cancel";
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException exception) {
|
} catch (NumberFormatException exception) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
@ -149,7 +154,7 @@ public class ServerCommand implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onServerCommand(ServerCommandEvent event) {
|
void onServerCommand(final ServerCommandEvent event) {
|
||||||
final CommandSender sender = event.getSender();
|
final CommandSender sender = event.getSender();
|
||||||
final String[] arr = event.getCommand().split(" ");
|
final String[] arr = event.getCommand().split(" ");
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@ import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||||
|
|
||||||
public class ServerPing implements Listener {
|
public final class ServerPing implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onServerListPing(PaperServerListPingEvent event) {
|
void onServerListPing(final PaperServerListPingEvent event) {
|
||||||
if (event.getClient().getProtocolVersion() == -1) {
|
if (event.getClient().getProtocolVersion() == -1) {
|
||||||
event.setProtocolVersion(573);
|
final int protocol = 573;
|
||||||
|
event.setProtocolVersion(protocol);
|
||||||
} else {
|
} else {
|
||||||
event.setProtocolVersion(event.getClient().getProtocolVersion());
|
event.setProtocolVersion(event.getClient().getProtocolVersion());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue