From fdfe46d9bf707be5d299650810617a95c76b3f54 Mon Sep 17 00:00:00 2001 From: mathiascode Date: Sat, 9 Nov 2019 15:14:49 +0200 Subject: [PATCH] Add null check --- .../extras/modules/player/PlayerConnection.java | 4 +++- .../extras/modules/server/ServerCommand.java | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java index b74a3e6..5f4335c 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java @@ -137,7 +137,9 @@ class PlayerConnection implements Listener { new BukkitRunnable() { public void run() { - player.setPlayerProfile(profile); + if (player != null) { + player.setPlayerProfile(profile); + } } }.runTask(JavaPlugin.getPlugin(Main.class)); } diff --git a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java index df6db5b..cb22fd1 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -5,6 +5,9 @@ import org.bukkit.ChatColor; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.Command; +import org.bukkit.block.Block; +import org.bukkit.block.CommandBlock; + import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -14,10 +17,21 @@ import org.bukkit.event.server.ServerCommandEvent; class ServerCommand implements Listener { @EventHandler void onServerCommand(ServerCommandEvent event) { + event.setCancelled(true); final String[] arr = event.getCommand().split(" "); final String command = event.getCommand(); if (event.getSender() instanceof BlockCommandSender) { + /*Block block = ((BlockCommandSender)event.getSender()).getBlock(); + CommandBlock state = (CommandBlock)block.getState(); + + System.out.println(state.getName()); + state.setName("@"); + + if (state.getName() == null) { + state.setName(""); + } + */ if (Main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) { event.setCancelled(true); }