Add null check

This commit is contained in:
mathiascode 2019-11-09 15:14:49 +02:00
parent 41b16d11d6
commit fdfe46d9bf
2 changed files with 17 additions and 1 deletions

View file

@ -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));
}

View file

@ -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);
}