Fixes various bugs in commands
This commit is contained in:
@ -38,7 +38,7 @@ public final class PaidSignManager {
|
||||
*/
|
||||
public void addPaidSign(PaidSign paidSign) throws IOException {
|
||||
this.paidSigns.put(paidSign.getName(), paidSign);
|
||||
saveSigns(this.paidSigns);
|
||||
saveSigns();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ public final class PaidSignManager {
|
||||
if (!removed) {
|
||||
return false;
|
||||
} else {
|
||||
saveSigns(this.paidSigns);
|
||||
saveSigns();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -103,6 +103,44 @@ public final class PaidSignManager {
|
||||
return paidSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all signs registered to this paid sign manager
|
||||
*
|
||||
* @throws IOException <p>If unable to write to the signs file</p>
|
||||
*/
|
||||
public void saveSigns() throws IOException {
|
||||
saveSigns(this.paidSigns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the given paid signs to the signs file
|
||||
*
|
||||
* @param signs <p>The signs to save</p>
|
||||
* @throws IOException <p>If unable to write to the signs file</p>
|
||||
*/
|
||||
public static void saveSigns(Map<String, PaidSign> signs) throws IOException {
|
||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(signsFile);
|
||||
ConfigurationSection signSection = configuration.createSection("paidSigns");
|
||||
|
||||
for (PaidSign sign : signs.values()) {
|
||||
String name = sign.getName();
|
||||
signSection.set(name + ".cost", sign.getCost());
|
||||
signSection.set(name + ".permission", sign.getPermission());
|
||||
signSection.set(name + ".ignoreCase", sign.getIgnoreCase());
|
||||
signSection.set(name + ".ignoreColor", sign.getIgnoreColor());
|
||||
ConfigurationSection conditionsSection = signSection.createSection(name + ".conditions");
|
||||
Map<Short, PaidSignCondition> signConditions = sign.getConditions();
|
||||
for (short lineIndex : signConditions.keySet()) {
|
||||
PaidSignCondition condition = signConditions.get(lineIndex);
|
||||
conditionsSection.set(lineIndex + ".stringToMatch", condition.getStringToMatch());
|
||||
conditionsSection.set(lineIndex + ".executeRegEx", condition.executeRegex());
|
||||
conditionsSection.set(lineIndex + ".ignoreCase", condition.ignoreCase());
|
||||
conditionsSection.set(lineIndex + ".ignoreColor", condition.ignoreColor());
|
||||
}
|
||||
}
|
||||
configuration.save(signsFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads any saved paid sign conditions and applies them to the given sign
|
||||
*
|
||||
@ -125,33 +163,4 @@ public final class PaidSignManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the given paid signs to the signs file
|
||||
*
|
||||
* @param signs <p>The signs to save</p>
|
||||
* @throws IOException <p>If unable to write to the signs file</p>
|
||||
*/
|
||||
public static void saveSigns(Map<String, PaidSign> signs) throws IOException {
|
||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(signsFile);
|
||||
ConfigurationSection signSection = configuration.createSection("paidSigns");
|
||||
|
||||
for (PaidSign sign : signs.values()) {
|
||||
String name = signSection.getName();
|
||||
signSection.set(name + ".cost", sign.getCost());
|
||||
signSection.set(name + ".permission", sign.getPermission());
|
||||
signSection.set(name + ".ignoreCase", sign.getIgnoreCase());
|
||||
signSection.set(name + ".ignoreColor", sign.getIgnoreColor());
|
||||
ConfigurationSection conditionsSection = signSection.createSection(name + ".conditions");
|
||||
Map<Short, PaidSignCondition> signConditions = sign.getConditions();
|
||||
for (short lineIndex : signConditions.keySet()) {
|
||||
PaidSignCondition condition = signConditions.get(lineIndex);
|
||||
conditionsSection.set(lineIndex + ".stringToMatch", condition.getStringToMatch());
|
||||
conditionsSection.set(lineIndex + ".executeRegEx", condition.executeRegex());
|
||||
conditionsSection.set(lineIndex + ".ignoreCase", condition.ignoreCase());
|
||||
conditionsSection.set(lineIndex + ".ignoreColor", condition.ignoreColor());
|
||||
}
|
||||
}
|
||||
configuration.save(signsFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user