mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
Use new API
This commit is contained in:
parent
c880ef8bc5
commit
47dbd881f5
@ -28,6 +28,7 @@ import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Damageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -1017,6 +1018,18 @@ public class NPCCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "hurt [damage]",
|
||||
desc = "Damages the NPC",
|
||||
modifiers = { "hurt" },
|
||||
min = 2,
|
||||
max = 2,
|
||||
permission = "citizens.npc.hurt")
|
||||
public void hurt(CommandContext args, Player sender, NPC npc) {
|
||||
((Damageable) npc.getEntity()).damage(args.getInteger(1));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "id",
|
||||
@ -1621,17 +1634,27 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "pathto [x] [y] [z]",
|
||||
usage = "pathto me | here | cursor | [x] [y] [z]",
|
||||
desc = "Starts pathfinding to a certain location",
|
||||
modifiers = { "pathto" },
|
||||
min = 4,
|
||||
min = 2,
|
||||
max = 4,
|
||||
permission = "citizens.npc.pathto")
|
||||
public void pathto(CommandContext args, CommandSender sender, NPC npc) {
|
||||
public void pathto(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
Location loc = npc.getStoredLocation();
|
||||
loc.setX(args.getDouble(1));
|
||||
loc.setY(args.getDouble(2));
|
||||
loc.setZ(args.getDouble(3));
|
||||
if (args.argsLength() == 2) {
|
||||
if ((args.getString(1).equalsIgnoreCase("me") || args.getString(1).equalsIgnoreCase("here"))) {
|
||||
loc = args.getSenderLocation();
|
||||
} else if (args.getString(1).equalsIgnoreCase("cursor")) {
|
||||
loc = ((Player) sender).getTargetBlockExact(32).getLocation();
|
||||
} else {
|
||||
throw new CommandUsageException();
|
||||
}
|
||||
} else {
|
||||
loc.setX(args.getDouble(1));
|
||||
loc.setY(args.getDouble(2));
|
||||
loc.setZ(args.getDouble(3));
|
||||
}
|
||||
npc.getNavigator().setTarget(loc);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.NeighbourGeneratorBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.PathPoint;
|
||||
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
|
||||
public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
|
||||
private final Map<PathPoint, Integer> fallen = Maps.newHashMap();
|
||||
@ -31,7 +32,7 @@ public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
|
||||
public List<PathPoint> getNeighbours(BlockSource source, PathPoint point) {
|
||||
Vector pos = point.getVector();
|
||||
List<PathPoint> neighbours = ((VectorNode) point).getNeighbours(source, point);
|
||||
if (pos.getBlockY() <= 1)
|
||||
if (pos.getBlockY() <= SpigotUtil.getMinBlockY() + 1)
|
||||
return neighbours;
|
||||
|
||||
Material above = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() + 1, pos.getBlockZ());
|
||||
|
Loading…
Reference in New Issue
Block a user