mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 03:25:13 +01:00
Add /npc gamemode command
This commit is contained in:
parent
02e2232cd4
commit
5cbc8b7c15
@ -46,6 +46,7 @@ import net.citizensnpcs.util.StringHelper;
|
|||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -373,6 +374,40 @@ public class NPCCommands {
|
|||||||
Messaging.sendTr(sender, Messages.NPC_DESPAWNED, npc.getName());
|
Messaging.sendTr(sender, Messages.NPC_DESPAWNED, npc.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "gamemode [gamemode]",
|
||||||
|
desc = "Changes the gamemode",
|
||||||
|
modifiers = { "gravity" },
|
||||||
|
min = 1,
|
||||||
|
max = 2,
|
||||||
|
permission = "npc.gravity")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.PLAYER })
|
||||||
|
public void gamemode(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
|
Player player = (Player) npc.getBukkitEntity();
|
||||||
|
if (args.argsLength() == 1) {
|
||||||
|
Messaging.sendTr(sender, Messages.GAMEMODE_DESCRIBE, npc.getName(), player.getGameMode().name()
|
||||||
|
.toLowerCase());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GameMode mode = null;
|
||||||
|
try {
|
||||||
|
int value = args.getInteger(1);
|
||||||
|
mode = GameMode.getByValue(value);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
try {
|
||||||
|
mode = GameMode.valueOf(args.getString(1));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode == null) {
|
||||||
|
Messaging.sendErrorTr(sender, Messages.GAMEMODE_INVALID, args.getString(1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.setGameMode(mode);
|
||||||
|
Messaging.sendTr(sender, Messages.GAMEMODE_SET, mode.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "gravity",
|
usage = "gravity",
|
||||||
|
@ -175,4 +175,7 @@ public class Messages {
|
|||||||
public static final String WAYPOINT_PROVIDER_SET = "citizens.waypoints.set-provider";
|
public static final String WAYPOINT_PROVIDER_SET = "citizens.waypoints.set-provider";
|
||||||
public static final String WRITING_DEFAULT_SETTING = "citizens.settings.writing-default";
|
public static final String WRITING_DEFAULT_SETTING = "citizens.settings.writing-default";
|
||||||
public static final String PATHFINDING_RANGE_SET = "citizens.commands.npc.pathfindingrange.set";
|
public static final String PATHFINDING_RANGE_SET = "citizens.commands.npc.pathfindingrange.set";
|
||||||
|
public static final String GAMEMODE_DESCRIBE = "citizens.commands.npc.gamemode.describe";
|
||||||
|
public static final String GAMEMODE_INVALID = "citizens.commands.npc.gamemode.invalid";
|
||||||
|
public static final String GAMEMODE_SET = "citizens.commands.npc.gamemode.set";
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,9 @@ citizens.commands.npc.age.cannot-be-aged=The mob type {0} cannot be aged.
|
|||||||
citizens.commands.npc.age.help=Can only be used on entities that can become babies. Use the [[-l]] flag to lock age over time (note: relogs may be required to see this).
|
citizens.commands.npc.age.help=Can only be used on entities that can become babies. Use the [[-l]] flag to lock age over time (note: relogs may be required to see this).
|
||||||
citizens.commands.npc.age.invalid-age=Invalid age. Valid ages are adult, baby, number between -24000 and 0
|
citizens.commands.npc.age.invalid-age=Invalid age. Valid ages are adult, baby, number between -24000 and 0
|
||||||
citizens.commands.npc.age.locked=Age locked.
|
citizens.commands.npc.age.locked=Age locked.
|
||||||
|
citizens.commands.npc.gamemode.describe={0}'s gamemode is [[{1}]].
|
||||||
|
citizens.commands.npc.gamemode.invalid={0} is not a valid gamemode.
|
||||||
|
citizens.commands.npc.gamemode.set=Gamemode set to [[{0}]].
|
||||||
citizens.commands.npc.age.set-adult=[[{0}]] is now an adult.
|
citizens.commands.npc.age.set-adult=[[{0}]] is now an adult.
|
||||||
citizens.commands.npc.age.set-baby=[[{0}]] is now a baby.
|
citizens.commands.npc.age.set-baby=[[{0}]] is now a baby.
|
||||||
citizens.commands.npc.age.set-normal=[[{0}]] is now age [[{1}]].
|
citizens.commands.npc.age.set-normal=[[{0}]] is now age [[{1}]].
|
||||||
|
Loading…
Reference in New Issue
Block a user