mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-26 17:21:29 +01:00
Move @Requirements to API, move command.command to commands
This commit is contained in:
parent
0fb3757c8d
commit
43c02b72a1
@ -26,15 +26,14 @@ import net.citizensnpcs.api.trait.Trait;
|
|||||||
import net.citizensnpcs.api.trait.TraitFactory;
|
import net.citizensnpcs.api.trait.TraitFactory;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
import net.citizensnpcs.api.util.Translator;
|
import net.citizensnpcs.api.util.Translator;
|
||||||
import net.citizensnpcs.command.command.AdminCommands;
|
import net.citizensnpcs.commands.AdminCommands;
|
||||||
import net.citizensnpcs.command.command.EditorCommands;
|
import net.citizensnpcs.commands.EditorCommands;
|
||||||
import net.citizensnpcs.command.command.HelpCommands;
|
import net.citizensnpcs.commands.HelpCommands;
|
||||||
import net.citizensnpcs.command.command.NPCCommands;
|
import net.citizensnpcs.commands.NPCCommands;
|
||||||
import net.citizensnpcs.command.command.RequirementsProcessor;
|
import net.citizensnpcs.commands.ScriptCommands;
|
||||||
import net.citizensnpcs.command.command.ScriptCommands;
|
import net.citizensnpcs.commands.TemplateCommands;
|
||||||
import net.citizensnpcs.command.command.TemplateCommands;
|
import net.citizensnpcs.commands.TraitCommands;
|
||||||
import net.citizensnpcs.command.command.TraitCommands;
|
import net.citizensnpcs.commands.WaypointCommands;
|
||||||
import net.citizensnpcs.command.command.WaypointCommands;
|
|
||||||
import net.citizensnpcs.editor.Editor;
|
import net.citizensnpcs.editor.Editor;
|
||||||
import net.citizensnpcs.npc.CitizensNPCRegistry;
|
import net.citizensnpcs.npc.CitizensNPCRegistry;
|
||||||
import net.citizensnpcs.npc.CitizensTraitFactory;
|
import net.citizensnpcs.npc.CitizensTraitFactory;
|
||||||
@ -242,8 +241,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
|
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
commands.setInjector(new Injector(this));
|
commands.setInjector(new Injector(this));
|
||||||
commands.registerAnnotationProcessor(new RequirementsProcessor());
|
|
||||||
|
|
||||||
// Register command classes
|
// Register command classes
|
||||||
commands.register(AdminCommands.class);
|
commands.register(AdminCommands.class);
|
||||||
commands.register(EditorCommands.class);
|
commands.register(EditorCommands.class);
|
||||||
|
@ -163,6 +163,11 @@ public class EventListen implements Listener {
|
|||||||
Bukkit.getPluginManager().callEvent(new EntityTargetNPCEvent(event, npc));
|
Bukkit.getPluginManager().callEvent(new EntityTargetNPCEvent(event, npc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onNeedsRespawn(NPCNeedsRespawnEvent event) {
|
||||||
|
toRespawn.put(toCoord(event.getSpawnLocation()), event.getNPC().getId());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
||||||
if (!(event.getPlayer() instanceof NPCHolder))
|
if (!(event.getPlayer() instanceof NPCHolder))
|
||||||
@ -329,9 +334,4 @@ public class EventListen implements Listener {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onNeedsRespawn(NPCNeedsRespawnEvent event) {
|
|
||||||
toRespawn.put(toCoord(event.getSpawnLocation()), event.getNPC().getId());
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -14,15 +14,15 @@ public class NPCNeedsRespawnEvent extends NPCEvent {
|
|||||||
this.spawn = at;
|
this.spawn = at;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getSpawnLocation() {
|
|
||||||
return spawn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getSpawnLocation() {
|
||||||
|
return spawn;
|
||||||
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package net.citizensnpcs.command.command;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
|
||||||
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface Requirements {
|
|
||||||
EntityType[] excludedTypes() default { EntityType.UNKNOWN };
|
|
||||||
|
|
||||||
boolean ownership() default false;
|
|
||||||
|
|
||||||
boolean selected() default false;
|
|
||||||
|
|
||||||
Class<? extends Trait>[] traits() default {};
|
|
||||||
|
|
||||||
EntityType[] types() default { EntityType.UNKNOWN };
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package net.citizensnpcs.command.command;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
|
||||||
import net.citizensnpcs.api.command.CommandAnnotationProcessor;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.RequirementMissingException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
|
||||||
import net.citizensnpcs.api.trait.trait.MobType;
|
|
||||||
import net.citizensnpcs.api.trait.trait.Owner;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
public class RequirementsProcessor implements CommandAnnotationProcessor {
|
|
||||||
@Override
|
|
||||||
public Class<? extends Annotation> getAnnotationClass() {
|
|
||||||
return Requirements.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(CommandSender sender, CommandContext context, Annotation instance, Object[] methodArgs)
|
|
||||||
throws CommandException {
|
|
||||||
Requirements requirements = (Requirements) instance;
|
|
||||||
NPC npc = (methodArgs.length >= 3 && methodArgs[2] instanceof NPC) ? (NPC) methodArgs[2] : null;
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
if (requirements.selected()) {
|
|
||||||
boolean canRedefineSelected = context.hasValueFlag("id") && sender.hasPermission("npc.select");
|
|
||||||
String error = Messaging.tr(Messages.COMMAND_MUST_HAVE_SELECTED);
|
|
||||||
if (canRedefineSelected) {
|
|
||||||
npc = CitizensAPI.getNPCRegistry().getById(context.getFlagInteger("id"));
|
|
||||||
if (npc == null)
|
|
||||||
error += ' ' + Messaging.tr(Messages.COMMAND_ID_NOT_FOUND, context.getFlagInteger("id"));
|
|
||||||
}
|
|
||||||
if (npc == null)
|
|
||||||
throw new RequirementMissingException(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requirements.ownership() && npc != null && !sender.hasPermission("citizens.admin")
|
|
||||||
&& !npc.getTrait(Owner.class).isOwnedBy(sender))
|
|
||||||
throw new RequirementMissingException(Messaging.tr(Messages.COMMAND_MUST_BE_OWNER));
|
|
||||||
|
|
||||||
if (npc == null)
|
|
||||||
return;
|
|
||||||
for (Class<? extends Trait> clazz : requirements.traits()) {
|
|
||||||
if (!npc.hasTrait(clazz))
|
|
||||||
throw new RequirementMissingException(Messaging.tr(Messages.COMMAND_MISSING_TRAIT,
|
|
||||||
clazz.getSimpleName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<EntityType> types = Sets.newEnumSet(Arrays.asList(requirements.types()), EntityType.class);
|
|
||||||
if (types.contains(EntityType.UNKNOWN))
|
|
||||||
types = EnumSet.allOf(EntityType.class);
|
|
||||||
types.removeAll(Sets.newHashSet(requirements.excludedTypes()));
|
|
||||||
|
|
||||||
EntityType type = npc.getTrait(MobType.class).getType();
|
|
||||||
if (!types.contains(type)) {
|
|
||||||
throw new RequirementMissingException(Messaging.tr(Messages.COMMAND_REQUIREMENTS_INVALID_MOB_TYPE,
|
|
||||||
type.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,9 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import net.citizensnpcs.Citizens;
|
import net.citizensnpcs.Citizens;
|
||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
@ -20,7 +21,7 @@ public class AdminCommands {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "admin")
|
@Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "citizens.admin")
|
||||||
public void citizens(CommandContext args, CommandSender sender, NPC npc) {
|
public void citizens(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging.send(sender,
|
Messaging.send(sender,
|
||||||
" " + StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
" " + StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
||||||
@ -36,7 +37,7 @@ public class AdminCommands {
|
|||||||
modifiers = { "reload" },
|
modifiers = { "reload" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "admin")
|
permission = "citizens.admin")
|
||||||
public void reload(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void reload(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Messaging.sendTr(sender, Messages.CITIZENS_RELOADING);
|
Messaging.sendTr(sender, Messages.CITIZENS_RELOADING);
|
||||||
try {
|
try {
|
||||||
@ -57,7 +58,7 @@ public class AdminCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
flags = "a",
|
flags = "a",
|
||||||
permission = "admin")
|
permission = "citizens.admin")
|
||||||
public void save(CommandContext args, CommandSender sender, NPC npc) {
|
public void save(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging.sendTr(sender, Messages.CITIZENS_SAVING);
|
Messaging.sendTr(sender, Messages.CITIZENS_SAVING);
|
||||||
plugin.storeNPCs(args);
|
plugin.storeNPCs(args);
|
@ -1,7 +1,8 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.editor.Editor;
|
import net.citizensnpcs.editor.Editor;
|
||||||
import net.citizensnpcs.editor.EquipmentEditor;
|
import net.citizensnpcs.editor.EquipmentEditor;
|
||||||
@ -21,7 +22,7 @@ public class EditorCommands {
|
|||||||
modifiers = { "equip" },
|
modifiers = { "equip" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.edit.equip")
|
permission = "citizens.npc.edit.equip")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.ENDERMAN, EntityType.PLAYER, EntityType.PIG,
|
@Requirements(selected = true, ownership = true, types = { EntityType.ENDERMAN, EntityType.PLAYER, EntityType.PIG,
|
||||||
EntityType.SHEEP })
|
EntityType.SHEEP })
|
||||||
public void equip(CommandContext args, Player player, NPC npc) {
|
public void equip(CommandContext args, Player player, NPC npc) {
|
||||||
@ -35,7 +36,7 @@ public class EditorCommands {
|
|||||||
modifiers = { "path" },
|
modifiers = { "path" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.edit.path")
|
permission = "citizens.npc.edit.path")
|
||||||
@Requirements(selected = true, ownership = true, excludedTypes = { EntityType.BLAZE, EntityType.ENDER_DRAGON,
|
@Requirements(selected = true, ownership = true, excludedTypes = { EntityType.BLAZE, EntityType.ENDER_DRAGON,
|
||||||
EntityType.GHAST, EntityType.BAT, EntityType.WITHER, EntityType.SQUID })
|
EntityType.GHAST, EntityType.BAT, EntityType.WITHER, EntityType.SQUID })
|
||||||
public void path(CommandContext args, Player player, NPC npc) {
|
public void path(CommandContext args, Player player, NPC npc) {
|
||||||
@ -49,7 +50,7 @@ public class EditorCommands {
|
|||||||
modifiers = { "text" },
|
modifiers = { "text" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.edit.text")
|
permission = "citizens.npc.edit.text")
|
||||||
public void text(CommandContext args, Player player, NPC npc) {
|
public void text(CommandContext args, Player player, NPC npc) {
|
||||||
Editor.enterOrLeave(player, npc.getTrait(Text.class).getEditor(player));
|
Editor.enterOrLeave(player, npc.getTrait(Text.class).getEditor(player));
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -8,6 +8,7 @@ import net.citizensnpcs.Citizens;
|
|||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
import net.citizensnpcs.api.command.CommandManager.CommandInfo;
|
import net.citizensnpcs.api.command.CommandManager.CommandInfo;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -35,7 +36,7 @@ public class HelpCommands {
|
|||||||
modifiers = { "help" },
|
modifiers = { "help" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "help")
|
permission = "citizens.help")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void citizensHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void citizensHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
@ -71,7 +72,7 @@ public class HelpCommands {
|
|||||||
modifiers = { "help" },
|
modifiers = { "help" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.help")
|
permission = "citizens.npc.help")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void npcHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void npcHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
@ -90,7 +91,7 @@ public class HelpCommands {
|
|||||||
modifiers = { "help" },
|
modifiers = { "help" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "script.help")
|
permission = "citizens.script.help")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void scriptHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void scriptHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
@ -129,7 +130,7 @@ public class HelpCommands {
|
|||||||
modifiers = { "help" },
|
modifiers = { "help" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "templates.help")
|
permission = "citizens.templates.help")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void templatesHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void templatesHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
@ -148,7 +149,7 @@ public class HelpCommands {
|
|||||||
modifiers = { "help" },
|
modifiers = { "help" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "waypoints.help")
|
permission = "citizens.waypoints.help")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void waypointsHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void waypointsHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
int page = 1;
|
int page = 1;
|
@ -1,4 +1,4 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -11,6 +11,7 @@ import net.citizensnpcs.api.CitizensAPI;
|
|||||||
import net.citizensnpcs.api.ai.speech.SpeechContext;
|
import net.citizensnpcs.api.ai.speech.SpeechContext;
|
||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
import net.citizensnpcs.api.command.exception.NoPermissionsException;
|
import net.citizensnpcs.api.command.exception.NoPermissionsException;
|
||||||
import net.citizensnpcs.api.command.exception.ServerCommandException;
|
import net.citizensnpcs.api.command.exception.ServerCommandException;
|
||||||
@ -89,7 +90,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "age" },
|
modifiers = { "age" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.age")
|
permission = "citizens.npc.age")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.CHICKEN, EntityType.COW, EntityType.OCELOT,
|
@Requirements(selected = true, ownership = true, types = { EntityType.CHICKEN, EntityType.COW, EntityType.OCELOT,
|
||||||
EntityType.PIG, EntityType.SHEEP, EntityType.VILLAGER, EntityType.WOLF })
|
EntityType.PIG, EntityType.SHEEP, EntityType.VILLAGER, EntityType.WOLF })
|
||||||
public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
@ -132,7 +133,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "anchor" },
|
modifiers = { "anchor" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 3,
|
max = 3,
|
||||||
permission = "npc.anchor")
|
permission = "citizens.npc.anchor")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
||||||
public void anchor(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void anchor(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Anchors trait = npc.getTrait(Anchors.class);
|
Anchors trait = npc.getTrait(Anchors.class);
|
||||||
@ -202,7 +203,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "behaviour", "behavior", "ai" },
|
modifiers = { "behaviour", "behavior", "ai" },
|
||||||
flags = "r",
|
flags = "r",
|
||||||
min = 2,
|
min = 2,
|
||||||
permission = "npc.behaviour")
|
permission = "citizens.npc.behaviour")
|
||||||
public void behaviour(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void behaviour(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Iterable<String> files = Splitter.on(',').split(args.getJoinedStrings(1, ','));
|
Iterable<String> files = Splitter.on(',').split(args.getJoinedStrings(1, ','));
|
||||||
if (args.hasFlag('r')) {
|
if (args.hasFlag('r')) {
|
||||||
@ -240,7 +241,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "copy" },
|
modifiers = { "copy" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.copy")
|
permission = "citizens.npc.copy")
|
||||||
public void copy(CommandContext args, CommandSender sender, NPC npc) {
|
public void copy(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
EntityType type = npc.getTrait(MobType.class).getType();
|
EntityType type = npc.getTrait(MobType.class).getType();
|
||||||
String name = args.getFlag("name", npc.getFullName());
|
String name = args.getFlag("name", npc.getFullName());
|
||||||
@ -271,7 +272,7 @@ public class NPCCommands {
|
|||||||
flags = "bu",
|
flags = "bu",
|
||||||
modifiers = { "create" },
|
modifiers = { "create" },
|
||||||
min = 2,
|
min = 2,
|
||||||
permission = "npc.create")
|
permission = "citizens.npc.create")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String name = Colorizer.parseColors(args.getJoinedStrings(1));
|
String name = Colorizer.parseColors(args.getJoinedStrings(1));
|
||||||
@ -423,7 +424,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "despawn" },
|
modifiers = { "despawn" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.despawn")
|
permission = "citizens.npc.despawn")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void despawn(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void despawn(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (npc == null || args.argsLength() == 2) {
|
if (npc == null || args.argsLength() == 2) {
|
||||||
@ -446,7 +447,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "gravity" },
|
modifiers = { "gravity" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.gravity")
|
permission = "citizens.npc.gravity")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.PLAYER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.PLAYER })
|
||||||
public void gamemode(CommandContext args, CommandSender sender, NPC npc) {
|
public void gamemode(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Player player = (Player) npc.getBukkitEntity();
|
Player player = (Player) npc.getBukkitEntity();
|
||||||
@ -480,7 +481,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "gravity" },
|
modifiers = { "gravity" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.gravity")
|
permission = "citizens.npc.gravity")
|
||||||
public void gravity(CommandContext args, CommandSender sender, NPC npc) {
|
public void gravity(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
boolean enabled = npc.getTrait(Gravity.class).toggle();
|
boolean enabled = npc.getTrait(Gravity.class).toggle();
|
||||||
String key = enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED;
|
String key = enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED;
|
||||||
@ -494,7 +495,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "id" },
|
modifiers = { "id" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.id")
|
permission = "citizens.npc.id")
|
||||||
public void id(CommandContext args, CommandSender sender, NPC npc) {
|
public void id(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging.send(sender, npc.getId());
|
Messaging.send(sender, npc.getId());
|
||||||
}
|
}
|
||||||
@ -507,7 +508,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "list" },
|
modifiers = { "list" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.list")
|
permission = "citizens.npc.list")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void list(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void list(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
List<NPC> npcs = new ArrayList<NPC>();
|
List<NPC> npcs = new ArrayList<NPC>();
|
||||||
@ -563,7 +564,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "lookclose", "look", "rotate" },
|
modifiers = { "lookclose", "look", "rotate" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.lookclose")
|
permission = "citizens.npc.lookclose")
|
||||||
public void lookClose(CommandContext args, CommandSender sender, NPC npc) {
|
public void lookClose(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging.sendTr(sender, npc.getTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET
|
Messaging.sendTr(sender, npc.getTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET
|
||||||
: Messages.LOOKCLOSE_STOPPED, npc.getName());
|
: Messages.LOOKCLOSE_STOPPED, npc.getName());
|
||||||
@ -576,7 +577,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "mount" },
|
modifiers = { "mount" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.controllable")
|
permission = "citizens.npc.controllable")
|
||||||
public void mount(CommandContext args, Player player, NPC npc) {
|
public void mount(CommandContext args, Player player, NPC npc) {
|
||||||
boolean enabled = npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled();
|
boolean enabled = npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled();
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
@ -594,7 +595,7 @@ public class NPCCommands {
|
|||||||
desc = "Teleports a NPC to a given location",
|
desc = "Teleports a NPC to a given location",
|
||||||
modifiers = "moveto",
|
modifiers = "moveto",
|
||||||
min = 1,
|
min = 1,
|
||||||
permission = "npc.moveto")
|
permission = "citizens.npc.moveto")
|
||||||
public void moveto(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void moveto(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
// Spawn the NPC if it isn't spawned to prevent NPEs
|
// Spawn the NPC if it isn't spawned to prevent NPEs
|
||||||
if (!npc.isSpawned())
|
if (!npc.isSpawned())
|
||||||
@ -637,7 +638,7 @@ public class NPCCommands {
|
|||||||
Messaging.sendTr(sender, Messages.MOVETO_TELEPORTED, npc.getName(), to);
|
Messaging.sendTr(sender, Messages.MOVETO_TELEPORTED, npc.getName(), to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, desc = "Show basic NPC information", max = 0, permission = "npc.info")
|
@Command(aliases = { "npc" }, desc = "Show basic NPC information", max = 0, permission = "citizens.npc.info")
|
||||||
public void npc(CommandContext args, CommandSender sender, NPC npc) {
|
public void npc(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
||||||
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
||||||
@ -664,7 +665,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "owner" },
|
modifiers = { "owner" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.owner")
|
permission = "citizens.npc.owner")
|
||||||
public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Owner ownerTrait = npc.getTrait(Owner.class);
|
Owner ownerTrait = npc.getTrait(Owner.class);
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
@ -680,7 +681,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "pathrange [range]", desc = "Sets an NPC's pathfinding range", modifiers = {
|
@Command(aliases = { "npc" }, usage = "pathrange [range]", desc = "Sets an NPC's pathfinding range", modifiers = {
|
||||||
"pathrange", "pathfindingrange", "prange" }, min = 2, max = 2, permission = "npc.pathfindingrange")
|
"pathrange", "pathfindingrange", "prange" }, min = 2, max = 2, permission = "citizens.npc.pathfindingrange")
|
||||||
public void pathfindingRange(CommandContext args, CommandSender sender, NPC npc) {
|
public void pathfindingRange(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
double range = Math.max(1, args.getDouble(1));
|
double range = Math.max(1, args.getDouble(1));
|
||||||
npc.getNavigator().getDefaultParameters().range((float) range);
|
npc.getNavigator().getDefaultParameters().range((float) range);
|
||||||
@ -695,7 +696,7 @@ public class NPCCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
flags = "ar",
|
flags = "ar",
|
||||||
permission = "npc.playerlist")
|
permission = "citizens.npc.playerlist")
|
||||||
@Requirements(types = EntityType.PLAYER)
|
@Requirements(types = EntityType.PLAYER)
|
||||||
public void playerlist(CommandContext args, CommandSender sender, NPC npc) {
|
public void playerlist(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
@ -718,7 +719,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "pose" },
|
modifiers = { "pose" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.pose")
|
permission = "citizens.npc.pose")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
|
||||||
public void pose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void pose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Poses trait = npc.getTrait(Poses.class);
|
Poses trait = npc.getTrait(Poses.class);
|
||||||
@ -768,7 +769,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "power" },
|
modifiers = { "power" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.power")
|
permission = "citizens.npc.power")
|
||||||
@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
|
||||||
@ -782,7 +783,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "profession", "prof" },
|
modifiers = { "profession", "prof" },
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.profession")
|
permission = "citizens.npc.profession")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.VILLAGER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.VILLAGER })
|
||||||
public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String profession = args.getString(1);
|
String profession = args.getString(1);
|
||||||
@ -833,7 +834,7 @@ public class NPCCommands {
|
|||||||
desc = "Rename a NPC",
|
desc = "Rename a NPC",
|
||||||
modifiers = { "rename" },
|
modifiers = { "rename" },
|
||||||
min = 2,
|
min = 2,
|
||||||
permission = "npc.rename")
|
permission = "citizens.npc.rename")
|
||||||
public void rename(CommandContext args, CommandSender sender, NPC npc) {
|
public void rename(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
String oldName = npc.getName();
|
String oldName = npc.getName();
|
||||||
String newName = args.getJoinedStrings(1);
|
String newName = args.getJoinedStrings(1);
|
||||||
@ -857,7 +858,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "select", "sel" },
|
modifiers = { "select", "sel" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.select")
|
permission = "citizens.npc.select")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void select(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void select(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
NPC toSelect = null;
|
NPC toSelect = null;
|
||||||
@ -910,7 +911,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "skeletontype [type]", desc = "Sets the NPC's skeleton type", modifiers = {
|
@Command(aliases = { "npc" }, usage = "skeletontype [type]", desc = "Sets the NPC's skeleton type", modifiers = {
|
||||||
"skeletontype", "sktype" }, min = 2, max = 2, permission = "npc.skeletontype")
|
"skeletontype", "sktype" }, min = 2, max = 2, permission = "citizens.npc.skeletontype")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
|
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
|
||||||
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SkeletonType type = (type = SkeletonType.getType(args.getInteger(1))) == null ? SkeletonType.valueOf(args
|
SkeletonType type = (type = SkeletonType.getType(args.getInteger(1))) == null ? SkeletonType.valueOf(args
|
||||||
@ -928,7 +929,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "size" },
|
modifiers = { "size" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.size")
|
permission = "citizens.npc.size")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MAGMA_CUBE, EntityType.SLIME })
|
@Requirements(selected = true, ownership = true, types = { EntityType.MAGMA_CUBE, EntityType.SLIME })
|
||||||
public void slimeSize(CommandContext args, CommandSender sender, NPC npc) {
|
public void slimeSize(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
SlimeSize trait = npc.getTrait(SlimeSize.class);
|
SlimeSize trait = npc.getTrait(SlimeSize.class);
|
||||||
@ -948,7 +949,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "spawn" },
|
modifiers = { "spawn" },
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.spawn")
|
permission = "citizens.npc.spawn")
|
||||||
@Requirements(ownership = true)
|
@Requirements(ownership = true)
|
||||||
public void spawn(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void spawn(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
NPC respawn = npcRegistry.getById(args.getInteger(1));
|
NPC respawn = npcRegistry.getById(args.getInteger(1));
|
||||||
@ -976,7 +977,7 @@ public class NPCCommands {
|
|||||||
desc = "Uses the NPCs SpeechController to talk",
|
desc = "Uses the NPCs SpeechController to talk",
|
||||||
modifiers = { "speak" },
|
modifiers = { "speak" },
|
||||||
min = 2,
|
min = 2,
|
||||||
permission = "npc.speak")
|
permission = "citizens.npc.speak")
|
||||||
public void speak(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void speak(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String type = npc.getTrait(Speech.class).getDefaultVocalChord();
|
String type = npc.getTrait(Speech.class).getDefaultVocalChord();
|
||||||
String message = Colorizer.parseColors(args.getJoinedStrings(1));
|
String message = Colorizer.parseColors(args.getJoinedStrings(1));
|
||||||
@ -1016,7 +1017,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "speed" },
|
modifiers = { "speed" },
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.speed")
|
permission = "citizens.npc.speed")
|
||||||
public void speed(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void speed(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
float newSpeed = (float) Math.abs(args.getDouble(1));
|
float newSpeed = (float) Math.abs(args.getDouble(1));
|
||||||
if (newSpeed >= Setting.MAX_SPEED.asDouble())
|
if (newSpeed >= Setting.MAX_SPEED.asDouble())
|
||||||
@ -1033,7 +1034,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "tp", "teleport" },
|
modifiers = { "tp", "teleport" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.tp")
|
permission = "citizens.npc.tp")
|
||||||
public void tp(CommandContext args, Player player, NPC npc) {
|
public void tp(CommandContext args, Player player, NPC npc) {
|
||||||
Location to = npc.getTrait(CurrentLocation.class).getLocation();
|
Location to = npc.getTrait(CurrentLocation.class).getLocation();
|
||||||
player.teleport(to, TeleportCause.COMMAND);
|
player.teleport(to, TeleportCause.COMMAND);
|
||||||
@ -1041,7 +1042,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport a NPC to your location", modifiers = { "tphere",
|
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport a NPC to your location", modifiers = { "tphere",
|
||||||
"tph", "move" }, min = 1, max = 1, permission = "npc.tphere")
|
"tph", "move" }, min = 1, max = 1, permission = "citizens.npc.tphere")
|
||||||
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (args.getSenderLocation() == null)
|
if (args.getSenderLocation() == null)
|
||||||
throw new ServerCommandException();
|
throw new ServerCommandException();
|
||||||
@ -1060,7 +1061,7 @@ public class NPCCommands {
|
|||||||
modifiers = { "type" },
|
modifiers = { "type" },
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "npc.type")
|
permission = "citizens.npc.type")
|
||||||
public void type(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void type(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
EntityType type = Util.matchEntityType(args.getString(1));
|
EntityType type = Util.matchEntityType(args.getString(1));
|
||||||
if (type == null)
|
if (type == null)
|
||||||
@ -1077,7 +1078,7 @@ public class NPCCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
flags = "t",
|
flags = "t",
|
||||||
permission = "npc.vulnerable")
|
permission = "citizens.npc.vulnerable")
|
||||||
public void vulnerable(CommandContext args, CommandSender sender, NPC npc) {
|
public void vulnerable(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
boolean vulnerable = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
boolean vulnerable = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||||
if (args.hasFlag('t')) {
|
if (args.hasFlag('t')) {
|
||||||
@ -1097,7 +1098,7 @@ public class NPCCommands {
|
|||||||
flags = "bv",
|
flags = "bv",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "npc.zombiemodifier")
|
permission = "citizens.npc.zombiemodifier")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.ZOMBIE)
|
@Requirements(selected = true, ownership = true, types = EntityType.ZOMBIE)
|
||||||
public void zombieModifier(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void zombieModifier(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ZombieModifier trait = npc.getTrait(ZombieModifier.class);
|
ZombieModifier trait = npc.getTrait(ZombieModifier.class);
|
@ -1,4 +1,4 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ public class ScriptCommands {
|
|||||||
desc = "compile and run a script",
|
desc = "compile and run a script",
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2,
|
max = 2,
|
||||||
permission = "script.compile")
|
permission = "citizens.script.compile")
|
||||||
public void runScript(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
public void runScript(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
||||||
File file = new File(CitizensAPI.getScriptFolder(), args.getString(1));
|
File file = new File(CitizensAPI.getScriptFolder(), args.getString(1));
|
||||||
if (!file.exists())
|
if (!file.exists())
|
@ -1,4 +1,4 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -8,6 +8,7 @@ import net.citizensnpcs.Citizens;
|
|||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -33,7 +34,7 @@ public class TemplateCommands {
|
|||||||
desc = "Applies a template to the selected NPC",
|
desc = "Applies a template to the selected NPC",
|
||||||
modifiers = { "apply" },
|
modifiers = { "apply" },
|
||||||
min = 2,
|
min = 2,
|
||||||
permission = "templates.apply")
|
permission = "citizens.templates.apply")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void apply(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void apply(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Template template = Template.byName(args.getString(1));
|
Template template = Template.byName(args.getString(1));
|
||||||
@ -76,7 +77,7 @@ public class TemplateCommands {
|
|||||||
min = 2,
|
min = 2,
|
||||||
max = 2,
|
max = 2,
|
||||||
flags = "o",
|
flags = "o",
|
||||||
permission = "templates.create")
|
permission = "citizens.templates.create")
|
||||||
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String name = args.getString(1);
|
String name = args.getString(1);
|
||||||
if (Template.byName(name) != null)
|
if (Template.byName(name) != null)
|
@ -1,4 +1,4 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -6,6 +6,7 @@ import net.citizensnpcs.api.CitizensAPI;
|
|||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandConfigurable;
|
import net.citizensnpcs.api.command.CommandConfigurable;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
import net.citizensnpcs.api.command.exception.NoPermissionsException;
|
import net.citizensnpcs.api.command.exception.NoPermissionsException;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
@ -22,7 +23,6 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
@Requirements(selected = true, ownership = true)
|
@Requirements(selected = true, ownership = true)
|
||||||
public class TraitCommands {
|
public class TraitCommands {
|
||||||
|
|
||||||
@Command(aliases = { "trait", "tr" }, usage = "add [trait name]...", desc = "Adds traits to the NPC", modifiers = {
|
@Command(aliases = { "trait", "tr" }, usage = "add [trait name]...", desc = "Adds traits to the NPC", modifiers = {
|
||||||
"add", "a" }, min = 1, permission = "npc.trait")
|
"add", "a" }, min = 1, permission = "npc.trait")
|
||||||
public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
@ -1,8 +1,9 @@
|
|||||||
package net.citizensnpcs.command.command;
|
package net.citizensnpcs.commands;
|
||||||
|
|
||||||
import net.citizensnpcs.Citizens;
|
import net.citizensnpcs.Citizens;
|
||||||
import net.citizensnpcs.api.command.Command;
|
import net.citizensnpcs.api.command.Command;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -24,7 +25,7 @@ public class WaypointCommands {
|
|||||||
modifiers = { "disableteleport" },
|
modifiers = { "disableteleport" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "waypoints.disableteleport")
|
permission = "citizens.waypoints.disableteleport")
|
||||||
public void disableTeleporting(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void disableTeleporting(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
npc.getNavigator().getDefaultParameters().stuckAction(null);
|
npc.getNavigator().getDefaultParameters().stuckAction(null);
|
||||||
Messaging.sendTr(sender, Messages.WAYPOINT_TELEPORTING_DISABLED);
|
Messaging.sendTr(sender, Messages.WAYPOINT_TELEPORTING_DISABLED);
|
||||||
@ -38,7 +39,7 @@ public class WaypointCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 2,
|
max = 2,
|
||||||
flags = "a",
|
flags = "a",
|
||||||
permission = "waypoints.provider")
|
permission = "citizens.waypoints.provider")
|
||||||
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Waypoints waypoints = npc.getTrait(Waypoints.class);
|
Waypoints waypoints = npc.getTrait(Waypoints.class);
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
@ -30,15 +30,11 @@ public class Messages {
|
|||||||
public static final String CITIZENS_SAVING = "citizens.notifications.saving";
|
public static final String CITIZENS_SAVING = "citizens.notifications.saving";
|
||||||
public static final String COMMAND_AGE_HELP = "citizens.commands.npc.age.help";
|
public static final String COMMAND_AGE_HELP = "citizens.commands.npc.age.help";
|
||||||
public static final String COMMAND_HELP_HEADER = "citizens.commands.help.header";
|
public static final String COMMAND_HELP_HEADER = "citizens.commands.help.header";
|
||||||
public static final String COMMAND_ID_NOT_FOUND = "citizens.commands.id-not-found";
|
|
||||||
public static final String COMMAND_INVALID_MOBTYPE = "citizens.commands.invalid-mobtype";
|
public static final String COMMAND_INVALID_MOBTYPE = "citizens.commands.invalid-mobtype";
|
||||||
public static final String COMMAND_INVALID_NUMBER = "citizens.commands.invalid-number";
|
|
||||||
public static final String COMMAND_MISSING = "citizens.commands.help.command-missing";
|
public static final String COMMAND_MISSING = "citizens.commands.help.command-missing";
|
||||||
public static final String COMMAND_MISSING_TRAIT = "citizens.commands.requirements.missing-required-trait";
|
|
||||||
public static final String COMMAND_MUST_BE_INGAME = "citizens.commands.requirements.must-be-ingame";
|
public static final String COMMAND_MUST_BE_INGAME = "citizens.commands.requirements.must-be-ingame";
|
||||||
public static final String COMMAND_MUST_BE_OWNER = "citizens.commands.requirements.must-be-owner";
|
public static final String COMMAND_MUST_BE_OWNER = "citizens.commands.requirements.must-be-owner";
|
||||||
public static final String COMMAND_MUST_HAVE_SELECTED = "citizens.commands.requirements.must-have-selected";
|
public static final String COMMAND_MUST_HAVE_SELECTED = "citizens.commands.requirements.must-have-selected";
|
||||||
public static final String COMMAND_NO_PERMISSION = "citizens.commands.requirements.missing-permission";
|
|
||||||
public static final String COMMAND_PAGE_MISSING = "citizens.commands.page-missing";
|
public static final String COMMAND_PAGE_MISSING = "citizens.commands.page-missing";
|
||||||
public static final String COMMAND_REPORT_ERROR = "citizens.commands.console-error";
|
public static final String COMMAND_REPORT_ERROR = "citizens.commands.console-error";
|
||||||
public static final String COMMAND_REQUIREMENTS_INVALID_MOB_TYPE = "citizens.commands.requirements.disallowed-mobtype";
|
public static final String COMMAND_REQUIREMENTS_INVALID_MOB_TYPE = "citizens.commands.requirements.disallowed-mobtype";
|
||||||
|
@ -212,6 +212,11 @@ public class NMS {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass");
|
throw new IllegalArgumentException("unable to find valid entity superclass");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeFromServerPlayerList(Player player) {
|
||||||
|
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||||
|
((CraftServer) Bukkit.getServer()).getHandle().players.remove(handle);
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendPacket(Player player, Packet packet) {
|
public static void sendPacket(Player player, Packet packet) {
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
@ -381,9 +386,4 @@ public class NMS {
|
|||||||
STAIR_MATERIALS.add(material.getId());
|
STAIR_MATERIALS.add(material.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeFromServerPlayerList(Player player) {
|
|
||||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
|
||||||
((CraftServer) Bukkit.getServer()).getHandle().players.remove(handle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user