mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-28 18:21:19 +01:00
Fix /npc scoreboard
This commit is contained in:
parent
8366b977ed
commit
683ffc08f7
@ -270,7 +270,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
|
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
|
||||||
: new CommandSenderCreateNPCEvent(sender, copy);
|
: new CommandSenderCreateNPCEvent(sender, copy);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.getNPC().destroy();
|
event.getNPC().destroy();
|
||||||
@ -346,7 +346,7 @@ public class NPCCommands {
|
|||||||
spawnLoc = args.getSenderLocation();
|
spawnLoc = args.getSenderLocation();
|
||||||
}
|
}
|
||||||
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
|
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
|
||||||
: new CommandSenderCreateNPCEvent(sender, npc);
|
: new CommandSenderCreateNPCEvent(sender, npc);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
npc.destroy();
|
npc.destroy();
|
||||||
@ -1021,7 +1021,7 @@ public class NPCCommands {
|
|||||||
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
||||||
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging
|
Messaging
|
||||||
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -1043,13 +1043,8 @@ public class NPCCommands {
|
|||||||
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
|
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove",
|
||||||
aliases = { "npc" },
|
"rem" }, min = 1, max = 2)
|
||||||
usage = "remove|rem (all|id|name)",
|
|
||||||
desc = "Remove a NPC",
|
|
||||||
modifiers = { "remove", "rem" },
|
|
||||||
min = 1,
|
|
||||||
max = 2)
|
|
||||||
@Requirements
|
@Requirements
|
||||||
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (args.argsLength() == 2) {
|
if (args.argsLength() == 2) {
|
||||||
@ -1060,7 +1055,7 @@ public class NPCCommands {
|
|||||||
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
|
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
NPCCommandSelector.Callback callback = new NPCCommandSelector.Callback() {
|
NPCCommandSelector.Callback callback = new NPCCommandSelector.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run(NPC npc) throws CommandException {
|
public void run(NPC npc) throws CommandException {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -1141,11 +1136,11 @@ public class NPCCommands {
|
|||||||
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
||||||
public void scoreboard(CommandContext args, CommandSender sender, NPC npc) {
|
public void scoreboard(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Scoreboard main = Bukkit.getScoreboardManager().getMainScoreboard();
|
Scoreboard main = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
String objective = args.getString(0);
|
String objective = args.getString(1);
|
||||||
String criteria = args.getString(1);
|
String criteria = args.getString(2);
|
||||||
Objective obj = main.getObjective(objective);
|
Objective obj = main.getObjective(objective);
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective(objective, criteria);
|
obj = Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective(objective, criteria);
|
||||||
}
|
}
|
||||||
Player entity = (Player) npc.getEntity();
|
Player entity = (Player) npc.getEntity();
|
||||||
if (args.hasValueFlag("team")) {
|
if (args.hasValueFlag("team")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user