1package com.runehive.game.plugin.extension;
3import com.google.common.collect.ArrayListMultimap;
4import com.google.common.collect.Multimap;
5import com.runehive.game.plugin.PluginContext;
6import com.runehive.game.world.entity.mob.data.PacketType;
7import com.runehive.game.world.entity.mob.player.command.CommandParser;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.game.world.entity.mob.player.command.Command;
10import org.apache.logging.log4j.LogManager;
11import org.apache.logging.log4j.Logger;
13import java.util.Collection;
14import java.util.HashSet;
20 protected static final Set<CommandExtension>
extensions =
new HashSet<>();
22 protected final Set<Command>
commands =
new HashSet<>();
23 public final Multimap<String, Command>
multimap = ArrayListMultimap.create();
31 if (command.getNames().length == 0) {
32 logger.warn(String.format(
"plugin=%s command missing name.",
this.getClass().getSimpleName()));
36 for (String name : command.getNames()) {
37 final String key = name.toLowerCase();
39 logger.warn(String.format(
"plugin=%s duplicate command=%s",
this.getClass().getSimpleName(), key));
69 final Collection<Command> collection =
extension.multimap.get(parser.
getCommand().toLowerCase());
71 if (collection ==
null) {
75 if (collection.isEmpty()) {
83 command.
execute(player, parser);
84 }
catch (Exception ex) {
The base class that all plugins should extend.
final Multimap< String, Command > multimap
static boolean canExecute(Player player, CommandParser parser)
static final Set< CommandExtension > extensions
abstract boolean canAccess(Player player)
boolean handleCommand(Player player, CommandParser parser)
final Set< Command > commands
static final Logger logger
boolean locked()
Checks if the mob is locked.
This class represents a character controlled by a player.
abstract void execute(Player player, CommandParser parser)