org.bukkit.command.TabExecutor Java Examples

The following examples show how to use org.bukkit.command.TabExecutor. 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: MineTinker.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onEnable() {
	plugin = this;
	is16compatible = Bukkit.getVersion().split("MC: ")[1].startsWith("1.16");
	ChatWriter.log(false, "Setting up internals...");

	loadConfig(); //load Main config
	LanguageManager.reload(); //Load Language system

	ConfigurationManager.reload();

	ModManager.instance();
	addCoreMods();

	BuildersWandListener.init();

	ChatWriter.reload();

	if (getConfig().getBoolean("PluginIncompatibility.Check")) {
		incompatibilityCheck();
	}

	TabExecutor cmd = new CommandManager();
	this.getCommand("minetinker").setExecutor(cmd); // must be after internals as it would throw a NullPointerException
	this.getCommand("minetinker").setTabCompleter(cmd);

	ChatWriter.logInfo(LanguageManager.getString("StartUp.Commands"));

	if (getConfig().getBoolean("AllowCrafting")) {
		Bukkit.getPluginManager().registerEvents(new CreateToolListener(), this);
	}

	if (getConfig().getBoolean("AllowConverting")) {
		Bukkit.getPluginManager().registerEvents(new ConvertToolListener(), this);
	}

	Bukkit.getPluginManager().registerEvents(new AnvilListener(), this);
	Bukkit.getPluginManager().registerEvents(new ArmorListener(), this);
	Bukkit.getPluginManager().registerEvents(new BlockListener(), this);
	Bukkit.getPluginManager().registerEvents(new CraftItemListener(), this);
	Bukkit.getPluginManager().registerEvents(new EntityListener(), this);
	Bukkit.getPluginManager().registerEvents(new ItemListener(), this);
	Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
	Bukkit.getPluginManager().registerEvents(new TinkerListener(), this);
	Bukkit.getPluginManager().registerEvents(new TridentListener(), this);
	Bukkit.getPluginManager().registerEvents(new PlayerInfo(), this);
	Bukkit.getPluginManager().registerEvents(new EnchantingListener(), this);
	Bukkit.getPluginManager().registerEvents(new GrindstoneListener(), this);

	FileConfiguration elytraConf = ConfigurationManager.getConfig("Elytra.yml");
	elytraConf.options().copyDefaults(true);
	elytraConf.addDefault("ExpChanceWhileFlying", 10);
	ConfigurationManager.saveConfig(elytraConf);

	if (ConfigurationManager.getConfig("BuildersWand.yml").getBoolean("enabled")) {
		Bukkit.getPluginManager().registerEvents(new BuildersWandListener(), this);
		BuildersWandListener.reload();
		ChatWriter.log(false, LanguageManager.getString("StartUp.BuildersWands"));
	}

	if (getConfig().getBoolean("EasyHarvest.enabled")) {
		Bukkit.getPluginManager().registerEvents(new EasyHarvestListener(), this);
		ChatWriter.log(false, LanguageManager.getString("StartUp.EasyHarvest"));
	}

	if (getConfig().getBoolean("actionbar-on-exp-gain", false)) {
		Bukkit.getPluginManager().registerEvents(new ActionBarListener(), this);
	}

	if (getConfig().getBoolean("ItemBehaviour.TrackStatistics", true)) {
		Bukkit.getPluginManager().registerEvents(new ItemStatisticsHandler(), this);
	}

	ChatWriter.log(false, LanguageManager.getString("StartUp.Events"));

	if (getConfig().getBoolean("logging.metrics", true)) {
		Metrics met = new Metrics(this, 	2833);
		met.addCustomChart(new Metrics.SimplePie("used_language", () -> getConfig().getString("Language", "en_US")));
	}

	ChatWriter.log(false, LanguageManager.getString("StartUp.GUIs"));
	GUIs.reload();

	ChatWriter.log(false, LanguageManager.getString("StartUp.StdLogging"));
	ChatWriter.log(true, LanguageManager.getString("StartUp.DebugLogging"));

	for (Player current : Bukkit.getServer().getOnlinePlayers()) {
		Power.HAS_POWER.computeIfAbsent(current, player -> new AtomicBoolean(false));
		Drilling.HAS_DRILLING.computeIfAbsent(current, player -> new AtomicBoolean(false));
		Lists.BLOCKFACE.put(current, null);
	}

	if (getConfig().getBoolean("CheckForUpdates")) {
		Bukkit.getScheduler().runTaskLaterAsynchronously(this, (@NotNull Runnable) Updater::checkForUpdate, 20);
	}
}