Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.nick.npractice;
- import lombok.Setter;
- import me.allen.ziggurat.Ziggurat;
- import me.nick.npractice.arena.Arena;
- import me.nick.npractice.arena.ArenaType;
- import me.nick.npractice.arena.ArenaTypeAdapter;
- import me.nick.npractice.arena.ArenaTypeTypeAdapter;
- import me.nick.npractice.arena.command.*;
- import me.nick.npractice.event.EventCommand;
- import me.nick.npractice.event.impl.juggernaut.JuggernautListener;
- import me.nick.npractice.event.impl.juggernaut.JuggernautManager;
- import me.nick.npractice.event.impl.juggernaut.command.*;
- import me.nick.npractice.event.impl.parkour.ParkourListener;
- import me.nick.npractice.event.impl.parkour.ParkourManager;
- import me.nick.npractice.event.impl.brackets.BracketsListener;
- import me.nick.npractice.event.impl.brackets.BracketsManager;
- import me.nick.npractice.event.impl.brackets.command.*;
- import me.nick.npractice.event.impl.ffa.FFAListener;
- import me.nick.npractice.event.impl.ffa.FFAManager;
- import me.nick.npractice.event.impl.ffa.command.*;
- import me.nick.npractice.event.impl.parkour.command.*;
- import me.nick.npractice.event.impl.skywars.SkyWarsListener;
- import me.nick.npractice.event.impl.skywars.SkyWarsManager;
- import me.nick.npractice.event.impl.skywars.command.*;
- import me.nick.npractice.event.impl.spleef.SpleefListener;
- import me.nick.npractice.event.impl.spleef.SpleefManager;
- import me.nick.npractice.event.impl.spleef.command.*;
- import me.nick.npractice.event.impl.wipeout.WipeoutListener;
- import me.nick.npractice.event.impl.wipeout.WipeoutManager;
- import me.nick.npractice.event.impl.wipeout.command.*;
- import me.nick.npractice.match.kits.utils.ArmorClassManager;
- import me.nick.npractice.match.kits.utils.bard.EffectRestorer;
- import me.nick.npractice.profile.command.*;
- import me.nick.npractice.duel.command.DuelAcceptCommand;
- import me.nick.npractice.duel.command.DuelCommand;
- import me.nick.npractice.duel.command.RematchCommand;
- import me.nick.npractice.profile.command.staff.RemoveProfileCommand;
- import me.nick.npractice.profile.command.staff.SetSpawnCommand;
- import me.nick.npractice.profile.hotbar.HotbarListener;
- import me.nick.npractice.profile.stats.command.LeaderboardsCommand;
- import me.nick.npractice.profile.stats.command.StatsCommand;
- import me.nick.npractice.queue.QueueListener;
- import me.nick.npractice.event.impl.sumo.SumoListener;
- import me.nick.npractice.event.impl.sumo.SumoManager;
- import me.nick.npractice.event.impl.sumo.command.*;
- import me.nick.npractice.kit.Kit;
- import me.nick.npractice.kit.KitEditorListener;
- import me.nick.npractice.kit.KitTypeAdapter;
- import me.nick.npractice.kit.command.KitCreateCommand;
- import me.nick.npractice.kit.command.KitGetLoadoutCommand;
- import me.nick.npractice.kit.command.KitListCommand;
- import me.nick.npractice.kit.command.KitSetLoadoutCommand;
- import me.nick.npractice.match.Match;
- import me.nick.npractice.match.MatchListener;
- import me.nick.npractice.match.command.SpectateCommand;
- import me.nick.npractice.match.command.StopSpectatingCommand;
- import me.nick.npractice.match.command.ViewInventoryCommand;
- import me.nick.npractice.util.events.WorldListener;
- import me.nick.npractice.party.Party;
- import me.nick.npractice.party.PartyListener;
- import me.nick.npractice.party.command.*;
- import me.nick.npractice.profile.Profile;
- import me.nick.npractice.profile.ProfileListener;
- import me.nick.npractice.profile.hotbar.Hotbar;
- import me.nick.npractice.queue.QueueThread;
- import me.nick.npractice.scoreboard.ScoreboardAdapter;
- import me.nick.npractice.event.impl.tournament.command.*;
- import me.nick.npractice.scoreboard.TabAdapter;
- import me.nick.npractice.util.InventoryUtil;
- import me.nick.npractice.util.essentials.Essentials;
- import me.nick.npractice.util.essentials.listener.EssentialsListener;
- import me.nick.npractice.util.events.ArmorListener;
- import me.nick.npractice.util.external.duration.Duration;
- import me.nick.npractice.util.external.duration.DurationTypeAdapter;
- import me.nick.npractice.util.external.menu.MenuListener;
- import com.mongodb.MongoClient;
- import com.mongodb.MongoClientOptions;
- import com.mongodb.MongoCredential;
- import com.mongodb.ServerAddress;
- import com.mongodb.client.MongoDatabase;
- import com.qrakn.honcho.Honcho;
- import com.qrakn.phoenix.lang.file.type.BasicConfigurationFile;
- import lombok.Getter;
- import me.joeleoli.frame.Frame;
- import net.milkbowl.vault.chat.Chat;
- import org.bukkit.Difficulty;
- import org.bukkit.Material;
- import org.bukkit.plugin.RegisteredServiceProvider;
- import org.bukkit.plugin.java.JavaPlugin;
- import java.util.Arrays;
- public class nPractice extends JavaPlugin {
- private static nPractice nPractice;
- @Getter
- private BasicConfigurationFile mainConfig;
- @Getter
- private BasicConfigurationFile arenasConfig;
- @Getter
- private BasicConfigurationFile kitsConfig;
- @Getter
- private BasicConfigurationFile eventsConfig;
- @Getter
- private MongoDatabase mongoDatabase;
- @Getter
- private SumoManager sumoManager;
- @Getter
- private BracketsManager bracketsManager;
- @Getter
- private FFAManager ffaManager;
- @Getter
- private JuggernautManager juggernautManager;
- @Getter
- private ParkourManager parkourManager;
- @Getter
- private WipeoutManager wipeoutManager;
- @Getter
- private SkyWarsManager skyWarsManager;
- @Getter
- private SpleefManager spleefManager;
- @Getter
- private ArmorClassManager armorClassManager;
- @Getter
- private EffectRestorer effectRestorer;
- @Getter
- private Essentials essentials;
- @Getter
- private Chat chat;
- @Getter
- private Honcho honcho;
- @Override
- public void onEnable() {
- nPractice = this;
- honcho = new Honcho(this);
- mainConfig = new BasicConfigurationFile(this, "config");
- arenasConfig = new BasicConfigurationFile(this, "arenas");
- kitsConfig = new BasicConfigurationFile(this, "kits");
- eventsConfig = new BasicConfigurationFile(this, "events");
- loadMongo();
- Profile.init();
- Kit.init();
- Arena.init();
- Hotbar.init();
- Match.init();
- Party.init();
- essentials = new Essentials(this);
- setupChat();
- honcho.registerTypeAdapter(Arena.class, new ArenaTypeAdapter());
- honcho.registerTypeAdapter(ArenaType.class, new ArenaTypeTypeAdapter());
- honcho.registerTypeAdapter(Kit.class, new KitTypeAdapter());
- for (Object command : Arrays.asList(
- //Staff commands
- new SetSpawnCommand(),
- new RemoveProfileCommand(),
- //Player commands
- new TsbCommand(),
- new TduelCommand(),
- new TpmCommand(),
- new StatsCommand(),
- new LeaderboardsCommand(),
- new OptionsCommand(),
- new EventCommand(),
- //Arena commands
- new ArenaAddKitCommand(),
- new ArenaRemoveKitCommand(),
- new ArenaSetSpawnCommand(),
- new ArenaSetPointCommand(),
- new ArenaCreateCommand(),
- new ArenaRemoveCommand(),
- new ArenasCommand(),
- new ArenaTpCommand(),
- //Duel commands
- new DuelCommand(),
- new DuelAcceptCommand(),
- new RematchCommand(),
- new ViewInventoryCommand(),
- new SpectateCommand(),
- new StopSpectatingCommand(),
- //Party commands
- new PartyCloseCommand(),
- new PartyCreateCommand(),
- new PartyDisbandCommand(),
- new PartyHelpCommand(),
- new PartyInfoCommand(),
- new PartyInviteCommand(),
- new PartyJoinCommand(),
- new PartyKickCommand(),
- new PartyLeaveCommand(),
- new PartyOpenCommand(),
- new PartyLeaderCommand(),
- new PartyUnbanCommand(),
- new PartyBanCommand(),
- //Kit commands
- new KitCreateCommand(),
- new KitGetLoadoutCommand(),
- new KitSetLoadoutCommand(),
- new KitListCommand(),
- //Brackets commands
- new BracketsLeaveCommand(),
- new BracketsCancelCommand(),
- new BracketsCooldownCommand(),
- new BracketsJoinCommand(),
- new BracketsSetSpawnCommand(),
- new BracketsHostCommand(),
- new BracketsTpCommand(),
- //Sumo commands
- new SumoCancelCommand(),
- new SumoCooldownCommand(),
- new SumoHostCommand(),
- new SumoJoinCommand(),
- new SumoLeaveCommand(),
- new SumoSetSpawnCommand(),
- new SumoTpCommand(),
- //Spleef commands
- new FFACancelCommand(),
- new FFACooldownCommand(),
- new FFAHostCommand(),
- new FFAJoinCommand(),
- new FFALeaveCommand(),
- new FFASetSpawnCommand(),
- new FFATpCommand(),
- //Juggernaut commands
- new JuggernautCancelCommand(),
- new JuggernautCooldownCommand(),
- new JuggernautHostCommand(),
- new JuggernautJoinCommand(),
- new JuggernautLeaveCommand(),
- new JuggernautSetSpawnCommand(),
- new JuggernautTpCommand(),
- //Parkour commands
- new ParkourCancelCommand(),
- new ParkourCooldownCommand(),
- new ParkourHostCommand(),
- new ParkourJoinCommand(),
- new ParkourLeaveCommand(),
- new ParkourSetSpawnCommand(),
- new ParkourTpCommand(),
- //Wipeout commands
- new WipeoutCancelCommand(),
- new WipeoutCooldownCommand(),
- new WipeoutHostCommand(),
- new WipeoutJoinCommand(),
- new WipeoutLeaveCommand(),
- new WipeoutSetSpawnCommand(),
- new WipeoutTpCommand(),
- //SkyWars commands
- new SkyWarsCancelCommand(),
- new SkyWarsCooldownCommand(),
- new SkyWarsHostCommand(),
- new SkyWarsJoinCommand(),
- new SkyWarsLeaveCommand(),
- new SkyWarsSetSpawnCommand(),
- new SkyWarsTpCommand(),
- //Spleef commands
- new SpleefCancelCommand(),
- new SpleefCooldownCommand(),
- new SpleefHostCommand(),
- new SpleefJoinCommand(),
- new SpleefLeaveCommand(),
- new SpleefSetSpawnCommand(),
- new SpleefTpCommand(),
- //Tournament commands
- new TournamentCommand(),
- new TournamentLeaveCommand(),
- new TournamentJoinCommand(),
- new TournamentHostCommand(),
- new TournamentCancelCommand()
- )) {
- honcho.registerCommand(command);
- }
- honcho.registerTypeAdapter(Duration.class, new DurationTypeAdapter());
- sumoManager = new SumoManager();
- bracketsManager = new BracketsManager();
- ffaManager = new FFAManager();
- juggernautManager = new JuggernautManager();
- parkourManager = new ParkourManager();
- wipeoutManager = new WipeoutManager();
- skyWarsManager = new SkyWarsManager();
- spleefManager = new SpleefManager();
- this.effectRestorer = new EffectRestorer(this);
- this.armorClassManager = new ArmorClassManager(this);
- Arrays.asList(
- Material.WORKBENCH,
- Material.STICK,
- Material.WOOD_PLATE,
- Material.WOOD_BUTTON,
- Material.SNOW_BLOCK
- ).forEach(InventoryUtil::removeCrafting);
- getServer().getWorlds().forEach(world -> {
- world.setDifficulty(Difficulty.HARD);
- essentials.clearEntities(world);
- });
- Arrays.asList(
- new ProfileListener(),
- new MenuListener(this),
- new EssentialsListener(this),
- new SumoListener(),
- new BracketsListener(),
- new FFAListener(),
- new JuggernautListener(),
- new ParkourListener(),
- new WipeoutListener(),
- new SkyWarsListener(),
- new SpleefListener(),
- new KitEditorListener(),
- new PartyListener(),
- new HotbarListener(),
- new MatchListener(),
- new WorldListener(),
- new QueueListener(),
- new ArmorListener()
- ).forEach(listener -> getServer().getPluginManager().registerEvents(listener, this));
- new Ziggurat(this, new TabAdapter());
- new Frame(this, new ScoreboardAdapter(this));
- new QueueThread().start();
- }
- @Override
- public void onDisable() {
- Match.cleanup();
- }
- private void loadMongo() {
- if (mainConfig.getBoolean("MONGO.AUTHENTICATION.ENABLED")) {
- mongoDatabase = new MongoClient(
- new ServerAddress(
- mainConfig.getString("MONGO.HOST"),
- mainConfig.getInteger("MONGO.PORT")
- ),
- MongoCredential.createCredential(
- mainConfig.getString("MONGO.AUTHENTICATION.USERNAME"),
- "admin", mainConfig.getString("MONGO.AUTHENTICATION.PASSWORD").toCharArray()
- ),
- MongoClientOptions.builder().build()
- ).getDatabase(mainConfig.getString("MONGO.DATABASE"));
- } else {
- mongoDatabase = new MongoClient(mainConfig.getString("MONGO.HOST"), mainConfig.getInteger("MONGO.PORT"))
- .getDatabase(mainConfig.getString("MONGO.DATABASE"));
- }
- }
- public static nPractice get() {
- return nPractice;
- }
- public boolean setupChat()
- {
- RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
- this.chat = ((Chat)rsp.getProvider());
- return this.chat != null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement