Phase out duplicate custom objective boolean

This commit is contained in:
BuildTools 2019-01-18 01:31:29 -05:00
parent 6c07f6dcfe
commit 69caf13bcd
3 changed files with 26 additions and 18 deletions

View File

@ -27,7 +27,6 @@ public abstract class CustomObjective implements Listener {
private Map<String, String> descriptions = new HashMap<String, String>(); private Map<String, String> descriptions = new HashMap<String, String>();
private String countPrompt = "null"; private String countPrompt = "null";
private String display = "null"; private String display = "null";
private boolean enableCount = true;
private boolean showCount = true; private boolean showCount = true;
private int count = 1; private int count = 1;
@ -117,14 +116,34 @@ public abstract class CustomObjective implements Listener {
this.countPrompt = countPrompt; this.countPrompt = countPrompt;
} }
public boolean isCountShown() { /**
* Check whether to let user set required amount for objective
*
* @param enableCount
*/
public boolean canShowCount() {
return showCount; return showCount;
} }
/**
* Set whether to let user set required amount for objective
*
* @param enableCount
*/
public void setShowCount(boolean showCount) { public void setShowCount(boolean showCount) {
this.showCount = showCount; this.showCount = showCount;
} }
/**
* Check whether to let user set required amount for objective
*
* @param enableCount
* @deprecated use setShowCount(boolean)
*/
public void setEnableCount(boolean enableCount) {
setShowCount(enableCount);
}
public String getDisplay() { public String getDisplay() {
return display; return display;
} }
@ -133,14 +152,6 @@ public abstract class CustomObjective implements Listener {
this.display = display; this.display = display;
} }
public boolean isEnableCount() {
return enableCount;
}
public void setEnableCount(boolean enableCount) {
this.enableCount = enableCount;
}
public Map<String, Object> getDataForPlayer(Player player, CustomObjective customObj, Quest quest) { public Map<String, Object> getDataForPlayer(Player player, CustomObjective customObj, Quest quest) {
return getDatamap(player, customObj, quest); return getDatamap(player, customObj, quest);
} }
@ -246,9 +257,6 @@ public abstract class CustomObjective implements Listener {
if (other.display.equals(display) == false) { if (other.display.equals(display) == false) {
return false; return false;
} }
if (other.enableCount != enableCount) {
return false;
}
if (other.showCount != showCount) { if (other.showCount != showCount) {
return false; return false;
} }

View File

@ -796,12 +796,12 @@ public class Quester {
} }
} }
if (entry.getValue() < getCurrentStage(quest).customObjectiveCounts.get(index)) { if (entry.getValue() < getCurrentStage(quest).customObjectiveCounts.get(index)) {
if (co.isCountShown() && co.isEnableCount()) { if (co.canShowCount()) {
display = display.replace("%count%", entry.getValue() + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); display = display.replace("%count%", entry.getValue() + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
} }
unfinishedObjectives.add(ChatColor.GREEN + display); unfinishedObjectives.add(ChatColor.GREEN + display);
} else { } else {
if (co.isCountShown() && co.isEnableCount()) { if (co.canShowCount()) {
display = display.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); display = display.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
} }
finishedObjectives.add(ChatColor.GRAY + display); finishedObjectives.add(ChatColor.GRAY + display);
@ -1554,7 +1554,7 @@ public class Quester {
for (String key : co.getData().keySet()) { for (String key : co.getData().keySet()) {
message = message.replace("%" + ((String) key) + "%", (String) datamap.get(key)); message = message.replace("%" + ((String) key) + "%", (String) datamap.get(key));
} }
if (co.isCountShown() && co.isEnableCount()) { if (co.canShowCount()) {
message = message.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); message = message.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
} }
p.sendMessage(message); p.sendMessage(message);

View File

@ -3895,7 +3895,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList); context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList);
} }
// Send user to the count prompt / custom data prompt if there is any needed // Send user to the count prompt / custom data prompt if there is any needed
if (found.isEnableCount()) { if (found.canShowCount()) {
return new CustomObjectiveCountPrompt(); return new CustomObjectiveCountPrompt();
} }
if (found.getData().isEmpty() == false) { if (found.getData().isEmpty() == false) {