mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-27 06:42:57 +02:00
Fix /npc follow <NPC ID>
This commit is contained in:
parent
e3e2d16eb2
commit
e0a66ff67b
@ -960,8 +960,7 @@ public class NPCCommands {
|
||||
if (!(sender instanceof ConsoleCommandSender)
|
||||
&& !followingNPC.getOrAddTrait(Owner.class).isOwnedBy(sender))
|
||||
throw new CommandException(CommandMessages.MUST_BE_OWNER);
|
||||
boolean following = followingNPC.getOrAddTrait(FollowTrait.class).toggle(followingNPC.getEntity(),
|
||||
protect);
|
||||
boolean following = npc.getOrAddTrait(FollowTrait.class).toggle(followingNPC.getEntity(), protect);
|
||||
Messaging.sendTr(sender, following ? Messages.FOLLOW_SET : Messages.FOLLOW_UNSET, npc.getName(),
|
||||
followingNPC.getName());
|
||||
};
|
||||
|
@ -283,7 +283,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
cancelNavigation();
|
||||
return;
|
||||
}
|
||||
setTarget((params) -> {
|
||||
setTarget(params -> {
|
||||
params.straightLineTargetingDistance(100000);
|
||||
return new MCTargetStrategy(npc, target, aggressive, params);
|
||||
});
|
||||
@ -297,7 +297,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
cancelNavigation();
|
||||
return;
|
||||
}
|
||||
setTarget((params) -> new StraightLineNavigationStrategy(npc, target.clone(), params));
|
||||
setTarget(params -> new StraightLineNavigationStrategy(npc, target.clone(), params));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -308,12 +308,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
cancelNavigation();
|
||||
return;
|
||||
}
|
||||
setTarget(new Function<NavigatorParameters, PathStrategy>() {
|
||||
@Override
|
||||
public PathStrategy apply(NavigatorParameters params) {
|
||||
return new MCTargetStrategy(npc, target, aggressive, params);
|
||||
}
|
||||
});
|
||||
setTarget(params -> new MCTargetStrategy(npc, target, aggressive, params));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -332,17 +327,14 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
cancelNavigation();
|
||||
return;
|
||||
}
|
||||
setTarget(new Function<NavigatorParameters, PathStrategy>() {
|
||||
@Override
|
||||
public PathStrategy apply(NavigatorParameters params) {
|
||||
if (npc.isFlyable()) {
|
||||
return new FlyingAStarNavigationStrategy(npc, path, params);
|
||||
} else if (params.useNewPathfinder() || !(npc.getEntity() instanceof LivingEntity)
|
||||
|| npc.getEntity() instanceof ArmorStand) {
|
||||
return new AStarNavigationStrategy(npc, path, params);
|
||||
} else {
|
||||
return new MCNavigationStrategy(npc, path, params);
|
||||
}
|
||||
setTarget(params -> {
|
||||
if (npc.isFlyable()) {
|
||||
return new FlyingAStarNavigationStrategy(npc, path, params);
|
||||
} else if (params.useNewPathfinder()
|
||||
|| (!(npc.getEntity() instanceof LivingEntity) && !(npc.getEntity() instanceof ArmorStand))) {
|
||||
return new AStarNavigationStrategy(npc, path, params);
|
||||
} else {
|
||||
return new MCNavigationStrategy(npc, path, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -356,17 +348,14 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
return;
|
||||
}
|
||||
final Location target = targetIn.clone();
|
||||
setTarget(new Function<NavigatorParameters, PathStrategy>() {
|
||||
@Override
|
||||
public PathStrategy apply(NavigatorParameters params) {
|
||||
if (npc.isFlyable()) {
|
||||
return new FlyingAStarNavigationStrategy(npc, target, params);
|
||||
} else if (params.useNewPathfinder() || !(npc.getEntity() instanceof LivingEntity)
|
||||
|| npc.getEntity() instanceof ArmorStand) {
|
||||
return new AStarNavigationStrategy(npc, target, params);
|
||||
} else {
|
||||
return new MCNavigationStrategy(npc, target, params);
|
||||
}
|
||||
setTarget(params -> {
|
||||
if (npc.isFlyable()) {
|
||||
return new FlyingAStarNavigationStrategy(npc, target, params);
|
||||
} else if (params.useNewPathfinder()
|
||||
|| (!(npc.getEntity() instanceof LivingEntity) && !(npc.getEntity() instanceof ArmorStand))) {
|
||||
return new AStarNavigationStrategy(npc, target, params);
|
||||
} else {
|
||||
return new MCNavigationStrategy(npc, target, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -80,16 +80,15 @@ public class FollowTrait extends Trait {
|
||||
return;
|
||||
entity = Bukkit.getPlayer(followingUUID);
|
||||
if (entity == null) {
|
||||
return;
|
||||
entity = Bukkit.getEntity(followingUUID);
|
||||
}
|
||||
entity = Bukkit.getEntity(followingUUID);
|
||||
if (entity == null) {
|
||||
if (entity == null)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isActive()) {
|
||||
|
||||
if (!isActive())
|
||||
return;
|
||||
}
|
||||
|
||||
if (!npc.getEntity().getWorld().equals(entity.getWorld())) {
|
||||
if (Setting.FOLLOW_ACROSS_WORLDS.asBoolean()) {
|
||||
npc.teleport(entity.getLocation(), TeleportCause.PLUGIN);
|
||||
|
Loading…
Reference in New Issue
Block a user