Fixed #3078 + action listeners for player control events

This commit is contained in:
Anuken
2020-10-23 15:59:52 -04:00
parent 5512c1817d
commit c8ef7ebafb
7 changed files with 39 additions and 9 deletions
@@ -336,6 +336,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public static void unitControl(Player player, @Nullable Unit unit){
if(player == null) return;
//make sure player is allowed to control the unit
if(net.server() && !netServer.admins.allowAction(player, ActionType.control, action -> action.unit = unit)){
throw new ValidateException(player, "Player cannot control a unit.");
}
//clear player unit when they possess a core
if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreBuild)){
Fx.spawn.at(player);
@@ -376,6 +381,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public static void unitCommand(Player player){
if(player == null || player.dead() || !(player.unit() instanceof Commanderc commander)) return;
//make sure player is allowed to make the command
if(net.server() && !netServer.admins.allowAction(player, ActionType.command, action -> {})){
throw new ValidateException(player, "Player cannot command a unit.");
}
if(commander.isCommanding()){
commander.clearCommand();
}else if(player.unit().type.commandLimit > 0){