Support GPS for location objectives, fixes #295

This commit is contained in:
BuildTools 2018-12-28 00:58:25 -05:00
parent c07e361ec7
commit e5e673be7c
5 changed files with 28 additions and 50 deletions

BIN
lib/GPSAPI.jar Normal file

Binary file not shown.

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>3.5.7</version>
<version>3.5.8</version>
<name>quests</name>
<url>https://github.com/FlyingPikachu/Quests/</url>
<packaging>jar</packaging>
@ -186,6 +186,13 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/CitizensBooks-2.4.7.jar</systemPath>
</dependency>
<dependency>
<groupId>com.live.bemmamin</groupId>
<artifactId>GPS</artifactId>
<version>2.2.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/GPSAPI.jar</systemPath>
</dependency>
</dependencies>
<build>

View File

@ -182,37 +182,7 @@ public class Quest {
quester.updateJournal();
}
/*protected boolean updateGPS(Quester quester, Stage nextStage) {
if (Quests.gpsapi == null) {
return false;
}
if (!plugin.useCompass) {
return false;
}
if (nextStage == null) {
return false;
}
Location targetLocation = null;
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0) {
targetLocation = plugin.getNPCLocation(nextStage.citizensToInteract.getFirst());
} else if (nextStage.citizensToKill != null && nextStage.citizensToKill.size() > 0) {
targetLocation = plugin.getNPCLocation(nextStage.citizensToKill.getFirst());
} else if (nextStage.locationsToReach != null && nextStage.locationsToReach.size() > 0) {
targetLocation = nextStage.locationsToReach.getFirst();
}
if (targetLocation != null) {
if (targetLocation.getWorld().getName().equals(quester.getPlayer().getWorld().getName())) {
Quests.gpsapi.addPoint("questsObjective-" + System.currentTimeMillis(), targetLocation);
if (!Quests.gpsapi.gpsIsActive(quester.getPlayer())) {
Quests.gpsapi.startGPS(quester.getPlayer(), "questsObjective-" + System.currentTimeMillis());
}
}
}
return targetLocation != null;
}*/
/*protected boolean startGPS(Quester quester) {
protected boolean updateGPS(Quester quester) {
if (Quests.gpsapi == null) {
return false;
}
@ -230,30 +200,30 @@ public class Quest {
targetLocations.add(plugin.getNPCLocation(i));
}
} else if (stage.locationsToReach != null && stage.locationsToReach.size() > 0) {
targetLocations = stage.locationsToReach;
targetLocations.addAll(stage.locationsToReach);
}
if (targetLocations != null && !targetLocations.isEmpty()) {
int index = 1;
String pointName = "quests-" + quester.getPlayer().getUniqueId().toString();
for (Location l : targetLocations) {
if (l.getWorld().getName().equals(quester.getPlayer().getWorld().getName())) {
if (!Quests.gpsapi.gpsIsActive(quester.getPlayer())) {
System.out.println("adding point " + index);
Quests.gpsapi.addPoint("target" + index, l);
Quests.gpsapi.addPoint(pointName + index, l);
index++;
}
}
}
for (int i = 1 ; i < targetLocations.size(); i++) {
if (!Quests.gpsapi.gpsIsActive(quester.getPlayer())) {
System.out.println("connecting point " + i + " and point " + (i + 1));
Quests.gpsapi.connect("target" + i, "target" + (i + 1), true);
Quests.gpsapi.connect(pointName + i, pointName + (i + 1), true);
}
}
System.out.println("destination set to " + "point " + (index - 1));
Quests.gpsapi.startGPS(quester.getPlayer(), "target1", "target" + (index - 1));
if (!Quests.gpsapi.gpsIsActive(quester.getPlayer())) {
Quests.gpsapi.startGPS(quester.getPlayer(), pointName + (index - 1));
}
}
return targetLocations != null && !targetLocations.isEmpty();
}*/
}
public boolean updateCompass(Quester quester, Stage nextStage) {
if (!plugin.useCompass) {
@ -616,11 +586,11 @@ public class Quest {
q.saveData();
player.updateInventory();
q.updateJournal();
/*if (Quests.gpsapi != null) {
if (Quests.gpsapi != null) {
if (Quests.gpsapi.gpsIsActive(player)) {
Quests.gpsapi.stopGPS(player);
}
}*/
}
q.findCompassTarget();
}

View File

@ -437,7 +437,7 @@ public class Quester {
stage.startEvent.fire(this, q);
}
q.updateCompass(this, stage);
//q.updateGPS(this, stage);
q.updateGPS(this);
saveData();
} else {
player.sendMessage(q.failRequirements);
@ -2701,11 +2701,11 @@ public class Quester {
}
}
}
/*if (Quests.gpsapi != null) {
if (Quests.gpsapi != null) {
if (Quests.gpsapi.gpsIsActive(this.getPlayer())) {
Quests.gpsapi.stopGPS(this.getPlayer());
}
}*/
}
} catch (Exception ex) {
ex.printStackTrace();
}

View File

@ -88,6 +88,7 @@ import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import com.live.bemmamin.gps.api.GPSAPI;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
@ -119,7 +120,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public static Permission permission = null;
public static WorldGuardPlugin worldGuard = null;
public static mcMMO mcmmo = null;
//public static GPSAPI gpsapi = null;
public static GPSAPI gpsapi = null;
public static Heroes heroes = null;
public static PhatLoots phatLoots = null;
public static PlaceholderAPIPlugin placeholder = null;
@ -429,9 +430,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (isPluginReady("mcMMO")) {
mcmmo = (mcMMO) getServer().getPluginManager().getPlugin("mcMMO");
}
/*if (isPluginReady("GPS")) {
if (isPluginReady("GPS")) {
gpsapi = new GPSAPI(this);
}*/
}
if (isPluginReady("Heroes")) {
heroes = (Heroes) getServer().getPluginManager().getPlugin("Heroes");
}
@ -459,11 +460,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public void onDisable() {
getLogger().info("Saving Quester data.");
for (Player p : getServer().getOnlinePlayers()) {
/*if (gpsapi != null) {
if (gpsapi != null) {
if (gpsapi.gpsIsActive(p)) {
gpsapi.stopGPS(p);
}
}*/
}
Quester quester = getQuester(p.getUniqueId());
quester.saveData();
}