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

View File

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

View File

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

View File

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

View File

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