42 public static final Logger logger = LogManager.getLogger(
CommandExtension.class);
43 protected static final Set<CommandExtension> extensions =
new HashSet<>();
45 protected final Set<Command> commands =
new HashSet<>();
46 public final Multimap<String, Command> multimap = ArrayListMultimap.create();
49 public void onInit() {
53 for (
Command command : commands) {
54 if (command.getNames().length == 0) {
55 logger.warn(String.format(
"plugin=%s command missing name.",
this.getClass().getSimpleName()));
59 for (String name : command.getNames()) {
60 final String key = name.toLowerCase();
61 if (multimap.containsKey(key)) {
62 logger.warn(String.format(
"plugin=%s duplicate command=%s",
this.getClass().getSimpleName(), key));
66 multimap.put(key, command);
72 protected abstract void register();
74 public abstract boolean canAccess(
Player player);
77 return !player.locking.
locked(
PacketType.COMMANDS) || parser.getCommand().startsWith(
"key");
82 if (!canExecute(player, parser)) {
88 if (!extension.canAccess(player)) {
92 final Collection<Command> collection = extension.multimap.get(parser.getCommand().toLowerCase());
94 if (collection ==
null) {
98 if (collection.isEmpty()) {
106 command.execute(player, parser);
107 }
catch (Exception ex) {