Unit control null checks

This commit is contained in:
Anuken 2020-08-19 11:03:04 -04:00
parent e81385a8e6
commit 9470f1f99f

View File

@ -156,6 +156,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(targets = Loc.client, called = Loc.server)
public static void dropItem(Player player, float angle){
if(player == null) return;
if(net.server() && player.unit().stack.amount <= 0){
throw new ValidateException(player, "Player cannot drop an item.");
}
@ -208,7 +210,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void tileConfig(Player player, Building tile, @Nullable Object value){
if(tile == null) return;
if(tile == null || player == null) return;
if(net.server() && (!Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.configure, tile.tile(), action -> action.config = value))) throw new ValidateException(player, "Player cannot configure a tile.");
tile.configured(player, value);
@ -217,6 +219,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void unitControl(Player player, @Nullable Unit unit){
if(player == null) return;
//clear player unit when they possess a core
if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreBuild)){
Fx.spawn.at(player);