All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.remigio07.chatplugin.bootstrap.SpongeBootstrapper Maven / Gradle / Ivy

Go to download

A complete yet lightweight plugin which handles just too many features!

There is a newer version: 1.9.10
Show newest version
/*
 * 	ChatPlugin - A complete yet lightweight plugin which handles just too many features!
 * 	Copyright 2024  Remigio07
 * 	
 * 	This program is distributed in the hope that it will be useful,
 * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 	GNU Affero General Public License for more details.
 * 	
 * 	You should have received a copy of the GNU Affero General Public License
 * 	along with this program.  If not, see .
 * 	
 * 	
 */

package me.remigio07.chatplugin.bootstrap;

import java.nio.file.Path;

import org.slf4j.Logger;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.event.game.state.GameStoppedServerEvent;
import org.spongepowered.api.plugin.Dependency;
import org.spongepowered.api.plugin.Plugin;

import com.google.inject.Inject;

import me.remigio07.chatplugin.api.ChatPlugin;

/**
 * Represents the Sponge's bootstrapper.
 */
@Plugin(
		id = "chatplugin",
		name = "ChatPlugin",
		version = "${version}",
		url = "https://remigio07.me/chatplugin",
		description = "A lightweight yet complete plugin which handles just too many features!",
		authors = "Remigio07",
		dependencies = {
				@Dependency(
						id = "negativity",
						version = "[1.9.0,)",
						optional = true
						),
				@Dependency(
						id = "viaversion",
						version = "[4.0.0,)",
						optional = true
						)
		})
public class SpongeBootstrapper {
	
	private static SpongeBootstrapper instance;
	@Inject
	private Logger logger;
	@Inject
	@ConfigDir(sharedRoot = false)
	private Path dataFolder;
	
	/**
	 * Event automatically called on server startup.
	 * 
	 * @param event Startup event
	 */
	@Listener
	public void onGameStartedServer(GameStartedServerEvent event) {
		instance = this;
		Environment.currentEnvironment = Environment.SPONGE;
		
		JARLibraryLoader.getInstance().initialize(logger, dataFolder);
	}
	
	/**
	 * Event automatically called on server shutdown.
	 * 
	 * @param event Shutdown event
	 */
	@SuppressWarnings("deprecation")
	@Listener
	public void onGameStoppedServer(GameStoppedServerEvent event) {
		ChatPlugin.getInstance().unload();
	}
	
	/**
	 * Gets this Sponge plugin's instance.
	 * 
	 * @return Plugin's instance
	 */
	public static SpongeBootstrapper getInstance() {
		return instance;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy