mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-26 09:11:30 +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;
|
File diff suppressed because it is too large
Load Diff
@ -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