Fixes some bugs in the edit command
Adds missing super call to EditTabCompleter Adds missing super call to EditCommand Fixes the index of an argument during tab completion Fixes a bug that caused conditions to be lost when a paid sign is changed
This commit is contained in:
@ -14,6 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A representation of the command for editing a new paid sign
|
||||
@ -23,6 +24,7 @@ public class EditCommand extends TokenizedCommand {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args) {
|
||||
super.onCommand(sender, command, label, args);
|
||||
if (argumentSize < 3) {
|
||||
return false;
|
||||
}
|
||||
@ -122,9 +124,16 @@ public class EditCommand extends TokenizedCommand {
|
||||
sign.matchAnyCondition();
|
||||
double cost = property == PaidSignProperty.COST ? Double.parseDouble(newValue) : sign.getCost();
|
||||
String permission = property == PaidSignProperty.PERMISSION ? newValue : sign.getPermission();
|
||||
Map<Short, PaidSignCondition> conditions = sign.getConditions();
|
||||
|
||||
PaidSignManager manager = PaidSigns.getInstance().getSignManager();
|
||||
PaidSign updatedSign = new PaidSign(signName, cost, permission, ignoreCase, ignoreColor, matchAnyCondition);
|
||||
for (short line : conditions.keySet()) {
|
||||
PaidSignCondition condition = conditions.get(line);
|
||||
updatedSign.addCondition(line, condition.getStringToMatch(), condition.executeRegex(),
|
||||
OptionState.getFromBoolean(condition.ignoreCase()),
|
||||
OptionState.getFromBoolean(condition.ignoreColor()));
|
||||
}
|
||||
manager.removePaidSign(sign.getName());
|
||||
manager.addPaidSign(updatedSign);
|
||||
|
||||
|
Reference in New Issue
Block a user