Clarify region start methods

This commit is contained in:
PikaMug 2019-11-08 15:10:40 -05:00
parent 6eecb62c0c
commit fd04e25976
5 changed files with 25 additions and 11 deletions

View File

@ -55,11 +55,11 @@ public class Quest {
private String name; private String name;
protected String description; protected String description;
protected String finished; protected String finished;
protected String region = null;
protected ItemStack guiDisplay = null; protected ItemStack guiDisplay = null;
private LinkedList<Stage> orderedStages = new LinkedList<Stage>(); private LinkedList<Stage> orderedStages = new LinkedList<Stage>();
protected NPC npcStart; protected NPC npcStart;
protected Location blockStart; protected Location blockStart;
protected String regionStart = null;
protected Action initialAction; protected Action initialAction;
private Requirements reqs = new Requirements(); private Requirements reqs = new Requirements();
private Planner pln = new Planner(); private Planner pln = new Planner();
@ -94,12 +94,26 @@ public class Quest {
this.finished = finished; this.finished = finished;
} }
public String getRegion() { public String getRegionStart() {
return region; return regionStart;
} }
public void setRegionStart(String regionStart) {
this.regionStart = regionStart;
}
/**
* @deprecated Use {@link #getRegionStart()}
*/
public String getRegion() {
return getRegionStart();
}
/**
* @deprecated Use {@link #setRegion(String)}
*/
public void setRegion(String region) { public void setRegion(String region) {
this.region = region; setRegionStart(region);
} }
public ItemStack getGUIDisplay() { public ItemStack getGUIDisplay() {
@ -781,11 +795,11 @@ public class Quest {
* @return true if player is in region * @return true if player is in region
*/ */
private boolean isInRegion(Player player) { private boolean isInRegion(Player player) {
if (region == null) { if (regionStart == null) {
return false; return false;
} }
if (plugin.getDependencies().getWorldGuardApi() if (plugin.getDependencies().getWorldGuardApi()
.getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(region)) { .getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(regionStart)) {
return true; return true;
} }
return false; return false;

View File

@ -528,8 +528,8 @@ public class QuestFactory implements ConversationAbandonedListener {
if (q.initialAction != null) { if (q.initialAction != null) {
cc.setSessionData(CK.Q_INITIAL_EVENT, q.initialAction.getName()); cc.setSessionData(CK.Q_INITIAL_EVENT, q.initialAction.getName());
} }
if (q.region != null) { if (q.regionStart != null) {
cc.setSessionData(CK.Q_REGION, q.region); cc.setSessionData(CK.Q_REGION, q.regionStart);
} }
if (q.guiDisplay != null) { if (q.guiDisplay != null) {
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay); cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);

View File

@ -3508,7 +3508,7 @@ public class Quester {
return false; return false;
} }
if (canAcceptOffer(quest, giveReason)) { if (canAcceptOffer(quest, giveReason)) {
if (quest.getRegion() != null) { if (quest.getRegionStart() != null) {
if (!quest.isInRegion(this)) { if (!quest.isInRegion(this)) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "questInvalidLocation"); String msg = Lang.get(getPlayer(), "questInvalidLocation");

View File

@ -1548,7 +1548,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (World world : getServer().getWorlds()) { for (World world : getServer().getWorlds()) {
if (getDependencies().getWorldGuardApi().getRegionManager(world) != null) { if (getDependencies().getWorldGuardApi().getRegionManager(world) != null) {
if (getDependencies().getWorldGuardApi().getRegionManager(world).hasRegion(region)) { if (getDependencies().getWorldGuardApi().getRegionManager(world).hasRegion(region)) {
quest.region = region; quest.regionStart = region;
exists = true; exists = true;
break; break;
} }

View File

@ -146,7 +146,7 @@ public class PlayerListener implements Listener {
takeable = false; takeable = false;
} }
} }
if (quest.getRegion() != null) { if (quest.getRegionStart() != null) {
if (!quest.isInRegion(quester)) { if (!quest.isInRegion(quester)) {
String invalidLoc = Lang.get(player, "questInvalidLocation"); String invalidLoc = Lang.get(player, "questInvalidLocation");
invalidLoc = invalidLoc.replace("<quest>", ChatColor.AQUA + quest.getName() invalidLoc = invalidLoc.replace("<quest>", ChatColor.AQUA + quest.getName()