mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-03 14:02:01 +01:00
Add cursor argument and center flag to /npc tphere
This commit is contained in:
parent
4e3ee63303
commit
d579fcbb53
@ -23,6 +23,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -1839,6 +1840,7 @@ public class NPCCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return;
|
||||
} else if (args.hasFlag('t')) {
|
||||
@ -2148,23 +2150,37 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "tphere",
|
||||
usage = "tphere (cursor) (-c(enter))",
|
||||
desc = "Teleport a NPC to your location",
|
||||
flags = "c",
|
||||
modifiers = { "tphere", "tph", "move" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
max = 2,
|
||||
permission = "citizens.npc.tphere")
|
||||
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.getSenderLocation() == null)
|
||||
Location to = args.getSenderLocation();
|
||||
if (to == null)
|
||||
throw new ServerCommandException();
|
||||
if (args.argsLength() > 1 && args.getString(1).equalsIgnoreCase("cursor")) {
|
||||
if (!(sender instanceof Player))
|
||||
throw new ServerCommandException();
|
||||
Block target = ((Player) sender).getTargetBlock(null, 64);
|
||||
if (target == null)
|
||||
throw new CommandException(Messages.MISSING_TP_CURSOR_BLOCK);
|
||||
to = target.getLocation();
|
||||
}
|
||||
if (!sender.hasPermission("citizens.npc.tphere.multiworld")
|
||||
&& npc.getStoredLocation().getWorld() != args.getSenderLocation().getWorld()) {
|
||||
throw new CommandException(Messages.CANNOT_TELEPORT_ACROSS_WORLDS);
|
||||
}
|
||||
if (args.hasFlag('c')) {
|
||||
to.setX(Math.round(to.getX() * 2) / 2.0);
|
||||
to.setZ(Math.round(to.getZ() * 2) / 2.0);
|
||||
}
|
||||
if (!npc.isSpawned()) {
|
||||
npc.spawn(args.getSenderLocation(), SpawnReason.COMMAND);
|
||||
npc.spawn(to, SpawnReason.COMMAND);
|
||||
} else {
|
||||
npc.teleport(args.getSenderLocation(), TeleportCause.COMMAND);
|
||||
npc.teleport(to, TeleportCause.COMMAND);
|
||||
}
|
||||
Messaging.sendTr(sender, Messages.NPC_TELEPORTED, npc.getName(),
|
||||
Util.prettyPrintLocation(args.getSenderLocation()));
|
||||
|
@ -212,6 +212,7 @@ public class Messages {
|
||||
public static final String METRICS_ERROR_NOTIFICATION = "citizens.notifications.metrics-load-error";
|
||||
public static final String MINECART_SET = "citizens.commands.npc.minecart.set";
|
||||
public static final String MINIMUM_COST_REQUIRED = "citizens.economy.minimum-cost-required";
|
||||
public static final String MISSING_TP_CURSOR_BLOCK = "citizens.commands.npc.tphere.missing-cursor-block";
|
||||
public static final String MISSING_TRANSLATIONS = "citizens.notifications.missing-translations";
|
||||
public static final String MOBTYPE_CANNOT_BE_AGED = "citizens.commands.npc.age.cannot-be-aged";
|
||||
public static final String MONEY_WITHDRAWN = "citizens.economy.money-withdrawn";
|
||||
|
@ -226,6 +226,7 @@ citizens.commands.npc.tp.location-not-found=Couldn''t find the target NPC''s loc
|
||||
citizens.commands.npc.tpto.success=Teleported successfully.
|
||||
citizens.commands.npc.tpto.to-not-found=Destination entity not found.
|
||||
citizens.commands.npc.tpto.from-not-found=Source entity not found.
|
||||
citizens.commands.npc.tphere.missing-cursor-block=Please look at a block to teleport to.
|
||||
citizens.commands.npc.tphere.teleported=[[{0}]] was teleported to {1}.
|
||||
citizens.commands.npc.type.set=[[{0}]]''s type set to [[{1}]].
|
||||
citizens.commands.npc.type.invalid=[[{0}]] is not a valid type.
|
||||
|
Loading…
Reference in New Issue
Block a user