Changes the way quest updates are made
Removes the per-trait update-rate Adds a task timer to update the marker for any NPC moving around Sets the marker update delay to 5 minutes Skips all quest marker updates, unless a quest has changed
This commit is contained in:
@ -3,6 +3,7 @@ package net.knarcraft.dynmapcitizens.handler.trait;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.DynmapAPI;
|
||||
@ -70,11 +71,20 @@ public abstract class AbstractTraitHandler implements CitizensTraitHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Marker marker = markerSet.createMarker(null, markerName + npc.getName(), npcLocation.getWorld().getName(),
|
||||
npcLocation.getX(), npcLocation.getY(), npcLocation.getZ(), icon, false);
|
||||
Marker marker = markerSet.createMarker(npcId.toString(), markerName + npc.getName(),
|
||||
npcLocation.getWorld().getName(), npcLocation.getX(), npcLocation.getY(), npcLocation.getZ(), icon,
|
||||
false);
|
||||
if (marker != null) {
|
||||
marker.setDescription(markerDescription);
|
||||
}
|
||||
|
||||
//For NPCs that move around, update their marker's location every n seconds
|
||||
if (marker != null && isMoving(npc)) {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(DynmapCitizens.getInstance(),
|
||||
() -> marker.setLocation(npcLocation.getWorld().getName(), npc.getStoredLocation().getX(),
|
||||
npc.getStoredLocation().getY(), npc.getStoredLocation().getZ()), 20, 10 * 20);
|
||||
//TODO: Make the update rate configurable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,6 @@ import net.knarcraft.blacksmith.config.NPCSettings;
|
||||
import net.knarcraft.blacksmith.trait.BlacksmithTrait;
|
||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||
import net.knarcraft.dynmapcitizens.property.UpdateRate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.dynmap.DynmapAPI;
|
||||
@ -42,11 +41,6 @@ public class BlacksmithHandler extends AbstractTraitHandler {
|
||||
isEnabled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateRate getUpdateRate() {
|
||||
return UpdateRate.VERY_SLOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMarkers() {
|
||||
//Remove existing markers
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.knarcraft.dynmapcitizens.handler.trait;
|
||||
|
||||
import net.knarcraft.dynmapcitizens.property.UpdateRate;
|
||||
|
||||
/**
|
||||
* A handler which takes care of everything for one citizen trait
|
||||
*/
|
||||
@ -12,13 +10,6 @@ public interface CitizensTraitHandler {
|
||||
*/
|
||||
void initialize();
|
||||
|
||||
/**
|
||||
* Gets the update rate used for this handler
|
||||
*
|
||||
* @return <p>The update rate for this handler</p>
|
||||
*/
|
||||
UpdateRate getUpdateRate();
|
||||
|
||||
/**
|
||||
* Gets whether this handler was properly initialized and enabled
|
||||
*
|
||||
|
@ -5,7 +5,6 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||
import net.knarcraft.dynmapcitizens.property.UpdateRate;
|
||||
import net.knarcraft.minstrel.MinstrelPlugin;
|
||||
import net.knarcraft.minstrel.music.Song;
|
||||
import net.knarcraft.minstrel.trait.MinstrelTrait;
|
||||
@ -39,11 +38,6 @@ public class MinstrelHandler extends AbstractTraitHandler {
|
||||
isEnabled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateRate getUpdateRate() {
|
||||
return UpdateRate.VERY_SLOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMarkers() {
|
||||
//Remove existing markers
|
||||
|
@ -5,7 +5,6 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||
import net.knarcraft.dynmapcitizens.property.UpdateRate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
@ -36,11 +35,6 @@ public class SentinelHandler extends AbstractTraitHandler {
|
||||
isEnabled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateRate getUpdateRate() {
|
||||
return UpdateRate.FAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMarkers() {
|
||||
sentinelSet.getMarkers().forEach(GenericMarker::deleteMarker);
|
||||
|
@ -8,7 +8,6 @@ import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||
import net.knarcraft.dynmapcitizens.handler.trait.AbstractTraitHandler;
|
||||
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||
import net.knarcraft.dynmapcitizens.property.UpdateRate;
|
||||
import net.knarcraft.dynmapcitizens.util.QuestsHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -59,11 +58,6 @@ public class QuestsHandler extends AbstractTraitHandler {
|
||||
isEnabled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateRate getUpdateRate() {
|
||||
return UpdateRate.VERY_SLOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMarkers() {
|
||||
if (questsAPI.isLoading()) {
|
||||
@ -79,14 +73,15 @@ public class QuestsHandler extends AbstractTraitHandler {
|
||||
|
||||
//Updates all quest area markers
|
||||
if (questsChanged) {
|
||||
//Update all area markers for quests
|
||||
updateQuestAreas();
|
||||
|
||||
//Generate information about all NPCs involved in quests
|
||||
generateQuestNPCInfo();
|
||||
|
||||
//Generate markers based on the generated info
|
||||
generateAllMarkers();
|
||||
}
|
||||
|
||||
//Generate information about all NPCs involved in quests
|
||||
generateQuestNPCInfo();
|
||||
|
||||
//Generate markers based on the generated info
|
||||
generateAllMarkers();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user