mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 03:55:30 +01:00
Another attempt to avoid charging costs inappropriately
This commit is contained in:
parent
4bfededf7a
commit
e757344d41
@ -271,6 +271,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
return shops;
|
return shops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TemplateRegistry getTemplateRegistry() {
|
public TemplateRegistry getTemplateRegistry() {
|
||||||
return templateRegistry;
|
return templateRegistry;
|
||||||
}
|
}
|
||||||
|
@ -472,8 +472,8 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.command")
|
permission = "citizens.npc.command")
|
||||||
public void command(CommandContext args, CommandSender sender, NPC npc,
|
public void command(CommandContext args, CommandSender sender, NPC npc,
|
||||||
@Flag(value = { "permissions", "permission" }) String permissions,
|
@Flag(value = { "permissions", "permission" }) String permissions,
|
||||||
@Flag(value = "cost", defValue = "0") Double cost,
|
@Flag(value = "cost", defValue = "-1") Double cost,
|
||||||
@Flag(value = "expcost", defValue = "0") Integer experienceCost,
|
@Flag(value = "expcost", defValue = "-1") Integer experienceCost,
|
||||||
@Flag(value = "cooldown", defValue = "0") Duration cooldown,
|
@Flag(value = "cooldown", defValue = "0") Duration cooldown,
|
||||||
@Flag(value = "gcooldown", defValue = "0") Duration gcooldown, @Flag(value = "n", defValue = "-1") int n,
|
@Flag(value = "gcooldown", defValue = "0") Duration gcooldown, @Flag(value = "n", defValue = "-1") int n,
|
||||||
@Flag(value = "delay", defValue = "0") Duration delay,
|
@Flag(value = "delay", defValue = "0") Duration delay,
|
||||||
|
@ -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 (nonZeroOrNegativeOne(cost) && !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,8 +119,7 @@ public class CommandTrait extends Trait {
|
|||||||
stack.getAmount());
|
stack.getAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (command.cost != -1 && command.cost != 0
|
if (nonZeroOrNegativeOne(command.cost) && !player.hasPermission("citizens.npc.command.ignoreerrors.cost")) {
|
||||||
&& !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);
|
||||||
@ -388,6 +387,10 @@ public class CommandTrait extends Trait {
|
|||||||
return hideErrorMessages;
|
return hideErrorMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean nonZeroOrNegativeOne(double value) {
|
||||||
|
return Math.abs(value) > 0.0001 && Math.abs(-1 - value) > 0.0001;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean persistSequence() {
|
public boolean persistSequence() {
|
||||||
return persistSequence;
|
return persistSequence;
|
||||||
}
|
}
|
||||||
@ -552,9 +555,9 @@ public class CommandTrait extends Trait {
|
|||||||
private static class NPCCommand {
|
private static class NPCCommand {
|
||||||
String command;
|
String command;
|
||||||
int cooldown;
|
int cooldown;
|
||||||
double cost;
|
double cost = -1;
|
||||||
int delay;
|
int delay;
|
||||||
int experienceCost;
|
int experienceCost = -1;
|
||||||
int globalCooldown;
|
int globalCooldown;
|
||||||
Hand hand;
|
Hand hand;
|
||||||
int id;
|
int id;
|
||||||
|
@ -490,6 +490,8 @@
|
|||||||
"citizens.commands.template.list.description" : "사용 가능한 템플릿 목록",
|
"citizens.commands.template.list.description" : "사용 가능한 템플릿 목록",
|
||||||
"citizens.commands.template.list.header" : "사용 가능한 템플릿입니다:",
|
"citizens.commands.template.list.header" : "사용 가능한 템플릿입니다:",
|
||||||
"citizens.commands.template.missing" : "템플릿을 찾을 수 없습니다.",
|
"citizens.commands.template.missing" : "템플릿을 찾을 수 없습니다.",
|
||||||
|
"citizens.commands.template.namespace-already-exists" : "네임스페이스 [[{0}]]가 이미 존재합니다",
|
||||||
|
"citizens.commands.template.qualified-template-required" : "중복된 템플릿 이름 [[{0}]]. 다음 옵션 중에서 선택하세요: [[{1}]]",
|
||||||
"citizens.commands.trait.add.description" : "NPC에 특성을 추가합니다.",
|
"citizens.commands.trait.add.description" : "NPC에 특성을 추가합니다.",
|
||||||
"citizens.commands.trait.added" : "{0}이(가) 성공적으로 추가되었습니다.",
|
"citizens.commands.trait.added" : "{0}이(가) 성공적으로 추가되었습니다.",
|
||||||
"citizens.commands.traitc.*.description" : "특성을 구성합니다.",
|
"citizens.commands.traitc.*.description" : "특성을 구성합니다.",
|
||||||
|
Loading…
Reference in New Issue
Block a user