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 String countPrompt = "null";
private String display = "null";
private boolean enableCount = true;
private boolean showCount = true;
private int count = 1;
@ -116,15 +115,35 @@ public abstract class CustomObjective implements Listener {
public void setCountPrompt(String countPrompt) {
this.countPrompt = countPrompt;
}
public boolean isCountShown() {
/**
* Check whether to let user set required amount for objective
*
* @param enableCount
*/
public boolean canShowCount() {
return showCount;
}
/**
* Set whether to let user set required amount for objective
*
* @param enableCount
*/
public void setShowCount(boolean 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() {
return display;
}
@ -132,14 +151,6 @@ public abstract class CustomObjective implements Listener {
public void setDisplay(String 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) {
return getDatamap(player, customObj, quest);
@ -246,9 +257,6 @@ public abstract class CustomObjective implements Listener {
if (other.display.equals(display) == false) {
return false;
}
if (other.enableCount != enableCount) {
return false;
}
if (other.showCount != showCount) {
return false;
}

View File

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

View File

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