Revert previous change. Fix commandtrait charging for a cost of 0

This commit is contained in:
fullwall 2024-03-05 10:00:42 +08:00
parent 8be9da5f04
commit 8672b4b997
9 changed files with 3 additions and 26 deletions

View File

@ -99,7 +99,7 @@ public class CommandTrait extends Trait {
NPCShopAction action = null; NPCShopAction action = null;
if (player.hasPermission("citizens.npc.command.ignoreerrors.*")) if (player.hasPermission("citizens.npc.command.ignoreerrors.*"))
return Transaction.success(); return Transaction.success();
if (cost > 0 && !player.hasPermission("citizens.npc.command.ignoreerrors.cost")) { if (cost != 0 && !player.hasPermission("citizens.npc.command.ignoreerrors.cost")) {
action = new MoneyAction(cost); action = new MoneyAction(cost);
if (!action.take(player, null, 1).isPossible()) { if (!action.take(player, null, 1).isPossible()) {
sendErrorMessage(player, CommandTraitError.MISSING_MONEY, null, cost); sendErrorMessage(player, CommandTraitError.MISSING_MONEY, null, cost);
@ -119,7 +119,8 @@ public class CommandTrait extends Trait {
stack.getAmount()); stack.getAmount());
} }
} }
if (command.cost != -1 && !player.hasPermission("citizens.npc.command.ignoreerrors.cost")) { if (command.cost != -1 && command.cost != 0
&& !player.hasPermission("citizens.npc.command.ignoreerrors.cost")) {
action = new MoneyAction(command.cost); action = new MoneyAction(command.cost);
if (!action.take(player, null, 1).isPossible()) { if (!action.take(player, null, 1).isPossible()) {
sendErrorMessage(player, CommandTraitError.MISSING_MONEY, null, command.cost); sendErrorMessage(player, CommandTraitError.MISSING_MONEY, null, command.cost);

View File

@ -1135,9 +1135,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.movementTick();
}
player.playerTick(); player.playerTick();
}; };
} }

View File

@ -1152,9 +1152,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.movementTick();
}
player.playerTick(); player.playerTick();
}; };
} }

View File

@ -1176,9 +1176,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.movementTick();
}
player.playerTick(); player.playerTick();
}; };
} }

View File

@ -1182,9 +1182,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.aiStep();
}
player.doTick(); player.doTick();
}; };
} }

View File

@ -1191,9 +1191,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.aiStep();
}
player.doTick(); player.doTick();
}; };
} }

View File

@ -1318,9 +1318,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.aiStep();
}
player.doTick(); player.doTick();
}; };
} }

View File

@ -1290,9 +1290,6 @@ public class NMSImpl implements NMSBridge {
return () -> { return () -> {
if (!entity.isValid()) if (!entity.isValid())
return; return;
if (npc != null && npc.useMinecraftAI()) {
player.aiStep();
}
player.doTick(); player.doTick();
}; };
} }

View File

@ -909,9 +909,6 @@ public class NMSImpl implements NMSBridge {
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist", boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist",
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean()); Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
entity.l(); entity.l();
if (npc != null && npc.useMinecraftAI()) {
entity.m();
}
if (!removeFromPlayerList) if (!removeFromPlayerList)
return; return;
if (!entity.dead) { if (!entity.dead) {