mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-04 14:31:19 +01:00
Allow /npc follow to teleport across worlds
This commit is contained in:
parent
7743763d3c
commit
1eddabe8c0
@ -104,6 +104,7 @@ public class Settings {
|
|||||||
DISABLE_MC_NAVIGATION_FALLBACK("npc.pathfinding.disable-mc-fallback-navigation", true),
|
DISABLE_MC_NAVIGATION_FALLBACK("npc.pathfinding.disable-mc-fallback-navigation", true),
|
||||||
DISABLE_TABLIST("npc.tablist.disable", true),
|
DISABLE_TABLIST("npc.tablist.disable", true),
|
||||||
ERROR_COLOUR("general.color-scheme.message-error", "<c>"),
|
ERROR_COLOUR("general.color-scheme.message-error", "<c>"),
|
||||||
|
FOLLOW_ACROSS_WORLDS("npc.follow.teleport-across-worlds", true),
|
||||||
HIGHLIGHT_COLOUR("general.color-scheme.message-highlight", "<e>"),
|
HIGHLIGHT_COLOUR("general.color-scheme.message-highlight", "<e>"),
|
||||||
KEEP_CHUNKS_LOADED("npc.chunks.always-keep-loaded", false),
|
KEEP_CHUNKS_LOADED("npc.chunks.always-keep-loaded", false),
|
||||||
LOCALE("general.translation.locale", ""),
|
LOCALE("general.translation.locale", ""),
|
||||||
|
@ -9,7 +9,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
|
import net.citizensnpcs.Settings.Setting;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
@ -39,7 +41,7 @@ public class FollowTrait extends Trait {
|
|||||||
* Returns whether the trait is actively following a {@link Player}.
|
* Returns whether the trait is actively following a {@link Player}.
|
||||||
*/
|
*/
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return enabled && npc.isSpawned() && player != null && npc.getEntity().getWorld().equals(player.getWorld());
|
return enabled && npc.isSpawned() && player != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
@ -73,6 +75,12 @@ public class FollowTrait extends Trait {
|
|||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!npc.getEntity().getWorld().equals(player.getWorld())) {
|
||||||
|
if (Setting.FOLLOW_ACROSS_WORLDS.asBoolean()) {
|
||||||
|
npc.teleport(player.getLocation(), TeleportCause.PLUGIN);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!npc.getNavigator().isNavigating()) {
|
if (!npc.getNavigator().isNavigating()) {
|
||||||
npc.getNavigator().setTarget(player, false);
|
npc.getNavigator().setTarget(player, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user