mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-29 11:41:39 +01:00
Attempt to track movement not triggered by PlayerMoveEvent, fixes #947
This commit is contained in:
parent
7d90b19171
commit
6dc01de62c
@ -54,7 +54,7 @@ import de.erethon.dungeonsxl.player.DGroup;
|
||||
import me.blackvein.quests.events.quest.QuestTakeEvent;
|
||||
import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent;
|
||||
import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
|
||||
import me.blackvein.quests.timers.StageTimer;
|
||||
import me.blackvein.quests.tasks.StageTimer;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.InventoryUtil;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
|
@ -83,6 +83,8 @@ import me.blackvein.quests.listeners.NpcListener;
|
||||
import me.blackvein.quests.listeners.PartiesListener;
|
||||
import me.blackvein.quests.listeners.PlayerListener;
|
||||
import me.blackvein.quests.prompts.QuestOfferPrompt;
|
||||
import me.blackvein.quests.tasks.NpcEffectThread;
|
||||
import me.blackvein.quests.tasks.PlayerMoveThread;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.InventoryUtil;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
@ -114,6 +116,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
private PlayerListener playerListener;
|
||||
private NpcListener npcListener;
|
||||
private NpcEffectThread effThread;
|
||||
private PlayerMoveThread moveThread;
|
||||
private DungeonsListener dungeonsListener;
|
||||
private PartiesListener partiesListener;
|
||||
private DenizenTrigger trigger;
|
||||
@ -138,6 +141,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
localeQuery.setBukkitVersion(bukkitVersion);
|
||||
playerListener = new PlayerListener(this);
|
||||
effThread = new NpcEffectThread(this);
|
||||
moveThread = new PlayerMoveThread(this);
|
||||
npcListener = new NpcListener(this);
|
||||
dungeonsListener = new DungeonsListener();
|
||||
partiesListener = new PartiesListener();
|
||||
@ -194,6 +198,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, effThread, 20, 20);
|
||||
}
|
||||
}
|
||||
if (settings.getStrictPlayerMovement() > 0) {
|
||||
long ticks = settings.getStrictPlayerMovement() * 20;
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, moveThread, ticks, ticks);
|
||||
}
|
||||
if (depends.getDungeonsApi() != null) {
|
||||
getServer().getPluginManager().registerEvents(dungeonsListener, this);
|
||||
}
|
||||
@ -323,6 +331,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
return eventFactory;
|
||||
}
|
||||
|
||||
public PlayerListener getPlayerListener() {
|
||||
return playerListener;
|
||||
}
|
||||
|
||||
public DenizenTrigger getDenizenTrigger() {
|
||||
return trigger;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class Settings {
|
||||
private String redoEffect = "angry_villager";
|
||||
private boolean showQuestReqs = true;
|
||||
private boolean showQuestTitles = true;
|
||||
private int strictPlayerMovement = 0;
|
||||
private boolean translateNames = false;
|
||||
private boolean translateSubCommands = false;
|
||||
private boolean useCompass = true;
|
||||
@ -120,6 +121,12 @@ public class Settings {
|
||||
public void setShowQuestTitles(boolean showQuestTitles) {
|
||||
this.showQuestTitles = showQuestTitles;
|
||||
}
|
||||
public int getStrictPlayerMovement() {
|
||||
return strictPlayerMovement;
|
||||
}
|
||||
public void setStrictPlayerMovement(int strictPlayerMovement) {
|
||||
this.strictPlayerMovement = strictPlayerMovement;
|
||||
}
|
||||
/**
|
||||
* @deprecated As of release 2.6.4, use {@link #canTranslateNames()}
|
||||
*/
|
||||
@ -178,6 +185,7 @@ public class Settings {
|
||||
redoEffect = config.getString("npc-effects.redo-quest", "angry_villager");
|
||||
showQuestReqs = config.getBoolean("show-requirements", true);
|
||||
showQuestTitles = config.getBoolean("show-titles", true);
|
||||
strictPlayerMovement = config.getInt("strict-player-movement", 0);
|
||||
translateNames = config.getBoolean("translate-names", true);
|
||||
translateSubCommands = config.getBoolean("translate-subcommands", false);
|
||||
useCompass = config.getBoolean("use-compass", true);
|
||||
|
@ -37,7 +37,7 @@ import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.QuestMob;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.timers.ActionTimer;
|
||||
import me.blackvein.quests.tasks.ActionTimer;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.InventoryUtil;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
|
@ -1023,17 +1023,28 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plugin.getQuester(evt.getPlayer().getUniqueId()) != null) {
|
||||
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
playerMove(evt.getPlayer().getUniqueId(), evt.getTo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if uuid is blacklisted. Updates reach-location objectives
|
||||
*
|
||||
* @param uuid The UUID of the Player
|
||||
* @param location The current location of the Player
|
||||
* @since 3.8.2
|
||||
*/
|
||||
public void playerMove(UUID uuid, Location location) {
|
||||
if (plugin.getQuester(uuid) != null) {
|
||||
if (plugin.canUseQuests(uuid)) {
|
||||
Quester quester = plugin.getQuester(uuid);
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest)
|
||||
&& quester.containsObjective(quest, "reachLocation")) {
|
||||
quester.reachLocation(quest, evt.getTo());
|
||||
quester.reachLocation(quest, location);
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "reachLocation", (Quester q) -> {
|
||||
q.reachLocation(quest, evt.getTo());
|
||||
q.reachLocation(quest, location);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.timers;
|
||||
package me.blackvein.quests.tasks;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests;
|
||||
package me.blackvein.quests.tasks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -18,6 +18,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.particle.ParticleProvider;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
@ -0,0 +1,27 @@
|
||||
package me.blackvein.quests.tasks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
|
||||
public class PlayerMoveThread implements Runnable {
|
||||
|
||||
final Quests plugin;
|
||||
|
||||
public PlayerMoveThread(Quests quests) {
|
||||
plugin = quests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
plugin.getPlayerListener().playerMove(player.getUniqueId(), player.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.timers;
|
||||
package me.blackvein.quests.tasks;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
@ -15,6 +15,7 @@ npc-effects:
|
||||
redo-quest: angry_villager
|
||||
show-requirements: true
|
||||
show-titles: true
|
||||
strict-player-movement: 0
|
||||
translate-names: true
|
||||
translate-subcommands: false
|
||||
use-compass: true
|
Loading…
Reference in New Issue
Block a user