org.bukkit.command.defaults.BukkitCommand Java Examples

The following examples show how to use org.bukkit.command.defaults.BukkitCommand. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BukkitCommands.java    From BlueMap with MIT License 5 votes vote down vote up
public Collection<BukkitCommand> getRootCommands(){
	Collection<BukkitCommand> rootCommands = new ArrayList<>();
	
	for (CommandNode<CommandSender> node : this.dispatcher.getRoot().getChildren()) {
		rootCommands.add(new CommandProxy(node.getName()));
	}
	
	return rootCommands;
}
 
Example #2
Source File: SimpleHelpMap.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private String getCommandPluginName(Command command) {
    if (command instanceof VanillaCommandWrapper) {
        return "Minecraft";
    }
    if (command instanceof BukkitCommand) {
        return "Bukkit";
    }
    if (command instanceof PluginIdentifiableCommand) {
        return ((PluginIdentifiableCommand) command).getPlugin().getName();
    }
    return null;
}
 
Example #3
Source File: SimpleHelpMap.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private boolean commandInIgnoredPlugin(Command command, Set<String> ignoredPlugins) {
    if ((command instanceof BukkitCommand) && ignoredPlugins.contains("Bukkit")) {
        return true;
    }
    if (command instanceof PluginIdentifiableCommand && ignoredPlugins.contains(((PluginIdentifiableCommand) command).getPlugin().getName())) {
        return true;
    }
    return false;
}
 
Example #4
Source File: SimpleHelpMap.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
private String getCommandPluginName(Command command) {
    if (command instanceof VanillaCommandWrapper) {
        return "Minecraft";
    }
    if (command instanceof BukkitCommand || command instanceof VanillaCommand) {
        return "Bukkit";
    }
    if (command instanceof PluginIdentifiableCommand) {
        return ((PluginIdentifiableCommand)command).getPlugin().getName();
    }
    return null;
}
 
Example #5
Source File: SimpleHelpMap.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
private boolean commandInIgnoredPlugin(Command command, Set<String> ignoredPlugins) {
    if ((command instanceof BukkitCommand || command instanceof VanillaCommand) && ignoredPlugins.contains("Bukkit")) {
        return true;
    }
    if (command instanceof PluginIdentifiableCommand && ignoredPlugins.contains(((PluginIdentifiableCommand)command).getPlugin().getName())) {
        return true;
    }
    return false;
}
 
Example #6
Source File: BukkitPlugin.java    From BlueMap with MIT License 4 votes vote down vote up
@Override
public void onEnable() {
	new MetricsLite(this);
	
	//save world so the level.dat is present on new worlds
	Logger.global.logInfo("Saving all worlds once, to make sure the level.dat is present...");
	for (World world : getServer().getWorlds()) {
		world.save();
	}
	
	//register events
	getServer().getPluginManager().registerEvents(eventForwarder, this);
	
	//register commands
	try {
		final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");

		bukkitCommandMap.setAccessible(true);
		CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());

		for (BukkitCommand command : commands.getRootCommands()) {
			commandMap.register(command.getLabel(), command);
		}
	} catch(NoSuchFieldException | SecurityException | IllegalAccessException e) {
		Logger.global.logError("Failed to register commands!", e);
	}
	
	//tab completions
	getServer().getPluginManager().registerEvents(commands, this);
	
	//load bluemap
	getServer().getScheduler().runTaskAsynchronously(this, () -> {
		try {
			Logger.global.logInfo("Loading...");
			this.bluemap.load();
			if (bluemap.isLoaded()) Logger.global.logInfo("Loaded!");
		} catch (Throwable t) {
			Logger.global.logError("Failed to load!", t);
		}
	});
}