mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-11 11:40:19 +00:00
Prevent server from half-crashing
This commit is contained in:
parent
92d9e4ad64
commit
6fe4e56a7f
3 changed files with 50 additions and 48 deletions
|
@ -40,7 +40,7 @@ public final class BlockPhysics implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception | StackOverflowError e) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -52,13 +52,14 @@ public final class BlockPhysics implements Listener {
|
|||
event.getBlock().setType(Material.AIR, false);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception | StackOverflowError e) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockForm(final BlockFormEvent event) {
|
||||
try {
|
||||
if (event.getBlock().getType() == Material.LAVA
|
||||
|| event.getBlock().getType() == Material.WATER) {
|
||||
for (BlockFace face : getBlockFaces()) {
|
||||
|
@ -69,10 +70,14 @@ public final class BlockPhysics implements Listener {
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} catch (Exception | StackOverflowError e) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockFromTo(final BlockFromToEvent event) {
|
||||
try {
|
||||
if (event.getBlock().getType() == Material.LAVA
|
||||
|| event.getBlock().getType() == Material.WATER) {
|
||||
boolean lavaFound = false;
|
||||
|
@ -91,6 +96,9 @@ public final class BlockPhysics implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception | StackOverflowError e) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -121,7 +129,7 @@ public final class BlockPhysics implements Listener {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception | StackOverflowError e) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,14 +27,9 @@ import pw.kaboom.extras.Main;
|
|||
public final class PlayerConnection implements Listener {
|
||||
@EventHandler
|
||||
void onAsyncPlayerPreLogin(final AsyncPlayerPreLoginEvent event) {
|
||||
if (event.getName().length() > 16) {
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username can't be longer than 16 characters");
|
||||
} else {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (event.getName().equals(player.getName())) {
|
||||
if (Bukkit.getPlayer(event.getName()) != null) {
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "A player with that username is already logged in");
|
||||
}
|
||||
}
|
||||
|
||||
/*try {
|
||||
final PlayerProfile profile = event.getPlayerProfile();
|
||||
|
@ -48,7 +43,6 @@ public final class PlayerConnection implements Listener {
|
|||
} catch (Exception ignored) {
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package pw.kaboom.extras.modules.player;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -48,11 +49,10 @@ public final class PlayerInteract implements Listener {
|
|||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
final BlockState clickedBlock = event.getClickedBlock().getState();
|
||||
|
||||
if (clickedBlock.getType() == Material.SIGN
|
||||
|| clickedBlock.getType() == Material.WALL_SIGN) {
|
||||
clickedBlock.getState().update();
|
||||
if (clickedBlock instanceof Sign) {
|
||||
clickedBlock.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue