Skip to content

Commit

Permalink
Fixed incorrect UpkeepPropertyType order. Fixed values string. Few ot…
Browse files Browse the repository at this point in the history
…her bits and bobs.
  • Loading branch information
Mthec committed Dec 6, 2015
1 parent 52092c1 commit 94ef885
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ public void sendQuestion3() {
Village k = Villages.getVillage(this.deed.getData2());
if(k.mayChangeName()) {
buf.append("input{maxchars=\"40\";id=\"vname\";text=\"").append(this.villageName).append("\"}");
buf.append("text{type=\"bold\";color=\"255,50,0\";text=\"NOTE: Changing name will").append(Servers.localServer.isFreeDeeds() ? "" : " cost 5 silver,").append(" remove all faith bonuses, and lock the name for 6 months.\"}");
buf.append("text{type=\"bold\";color=\"255,50,0\";text=\"NOTE: Changing name will").append(Servers.localServer.isFreeDeeds() ? "" : " cost " + new Change(NAME_CHANGE_COST).getChangeString() + ",").append(" remove all faith bonuses, and lock the name for 6 months.\"}");
} else {
buf.append("text{text=\"").append(this.villageName).append("\"}");
buf.append("passthrough{id=\"vname\";text=\"").append(this.villageName).append("\"}");
Expand Down
4 changes: 2 additions & 2 deletions src/mod/wurmonline/mods/upkeepcosts/UpkeepCosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ void logValues () {
Villages.GUARD_COST_STRING,
Villages.GUARD_UPKEEP_STRING,
Villages.MINIMUM_UPKEEP_STRING,
VillageFoundationQuestion.MINIMUM_LEFT_UPKEEP,
VillageFoundationQuestion.NAME_CHANGE_COST));
new Change(VillageFoundationQuestion.MINIMUM_LEFT_UPKEEP).getChangeString(),
new Change(VillageFoundationQuestion.NAME_CHANGE_COST).getChangeString()));
}

@Override
Expand Down
26 changes: 4 additions & 22 deletions src/mod/wurmonline/mods/upkeepcosts/UpkeepCostsUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void logValues () {
Villages.GUARD_COST_STRING,
Villages.GUARD_UPKEEP_STRING,
Villages.MINIMUM_UPKEEP_STRING,
VillageFoundationQuestion.MINIMUM_LEFT_UPKEEP,
VillageFoundationQuestion.NAME_CHANGE_COST));
new Change(VillageFoundationQuestion.MINIMUM_LEFT_UPKEEP).getChangeString(),
new Change(VillageFoundationQuestion.NAME_CHANGE_COST).getChangeString()));
}

@Override
Expand All @@ -89,39 +89,21 @@ void lateConfigure () {
ScrollPane container;

@FXML
@Override
void saveUpkeep () {
if (upkeepPropertySheet.haveChanges()) {
File file = getFile();
Properties properties = new Properties();

try {
boolean created = file.createNewFile();
if (!created) {
FileInputStream stream = new FileInputStream(file.toString());
properties.load(stream);
}
} catch (IOException ex) {
logger.warning(messages.getString("load_properties_error"));
ex.printStackTrace();
}
for (Field field : this.getClass().getFields()) {
if (!(field.getType().isAssignableFrom(Long.class))) {
continue;
}
try {
field.set(this, upkeepPropertySheet.list.get(UpkeepPropertySheet.UpkeepPropertyType.valueOf(field.getName().toUpperCase()).ordinal()).getValue());
properties.setProperty(field.getName(), field.get(this).toString());
} catch (IllegalAccessException ex) {
logger.warning(messages.getString("error"));
ex.printStackTrace();
}
}
try (FileOutputStream stream = new FileOutputStream(file.toString())) {
properties.store(stream, "");
} catch (IOException ex) {
logger.warning(messages.getString("save_properties_error"));
ex.printStackTrace();
}
super.saveUpkeep();
upkeepPropertySheet.clearChanges();
if (controller.serverIsRunning()) {
onServerStarted();
Expand Down
4 changes: 2 additions & 2 deletions src/mod/wurmonline/mods/upkeepcosts/UpkeepPropertySheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ enum UpkeepPropertyType {
EPIC_GUARD_COST,
EPIC_GUARD_UPKEEP,
MINIMUM_UPKEEP,
NAME_CHANGE,
INTO_UPKEEP
INTO_UPKEEP,
NAME_CHANGE
}
}

0 comments on commit 94ef885

Please sign in to comment.