Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.58 KB | None | 0 0
  1. package me.nick.npractice;
  2.  
  3. import lombok.Setter;
  4. import me.allen.ziggurat.Ziggurat;
  5. import me.nick.npractice.arena.Arena;
  6. import me.nick.npractice.arena.ArenaType;
  7. import me.nick.npractice.arena.ArenaTypeAdapter;
  8. import me.nick.npractice.arena.ArenaTypeTypeAdapter;
  9. import me.nick.npractice.arena.command.*;
  10. import me.nick.npractice.event.EventCommand;
  11. import me.nick.npractice.event.impl.juggernaut.JuggernautListener;
  12. import me.nick.npractice.event.impl.juggernaut.JuggernautManager;
  13. import me.nick.npractice.event.impl.juggernaut.command.*;
  14. import me.nick.npractice.event.impl.parkour.ParkourListener;
  15. import me.nick.npractice.event.impl.parkour.ParkourManager;
  16. import me.nick.npractice.event.impl.brackets.BracketsListener;
  17. import me.nick.npractice.event.impl.brackets.BracketsManager;
  18. import me.nick.npractice.event.impl.brackets.command.*;
  19. import me.nick.npractice.event.impl.ffa.FFAListener;
  20. import me.nick.npractice.event.impl.ffa.FFAManager;
  21. import me.nick.npractice.event.impl.ffa.command.*;
  22. import me.nick.npractice.event.impl.parkour.command.*;
  23. import me.nick.npractice.event.impl.skywars.SkyWarsListener;
  24. import me.nick.npractice.event.impl.skywars.SkyWarsManager;
  25. import me.nick.npractice.event.impl.skywars.command.*;
  26. import me.nick.npractice.event.impl.spleef.SpleefListener;
  27. import me.nick.npractice.event.impl.spleef.SpleefManager;
  28. import me.nick.npractice.event.impl.spleef.command.*;
  29. import me.nick.npractice.event.impl.wipeout.WipeoutListener;
  30. import me.nick.npractice.event.impl.wipeout.WipeoutManager;
  31. import me.nick.npractice.event.impl.wipeout.command.*;
  32. import me.nick.npractice.match.kits.utils.ArmorClassManager;
  33. import me.nick.npractice.match.kits.utils.bard.EffectRestorer;
  34. import me.nick.npractice.profile.command.*;
  35. import me.nick.npractice.duel.command.DuelAcceptCommand;
  36. import me.nick.npractice.duel.command.DuelCommand;
  37. import me.nick.npractice.duel.command.RematchCommand;
  38. import me.nick.npractice.profile.command.staff.RemoveProfileCommand;
  39. import me.nick.npractice.profile.command.staff.SetSpawnCommand;
  40. import me.nick.npractice.profile.hotbar.HotbarListener;
  41. import me.nick.npractice.profile.stats.command.LeaderboardsCommand;
  42. import me.nick.npractice.profile.stats.command.StatsCommand;
  43. import me.nick.npractice.queue.QueueListener;
  44. import me.nick.npractice.event.impl.sumo.SumoListener;
  45. import me.nick.npractice.event.impl.sumo.SumoManager;
  46. import me.nick.npractice.event.impl.sumo.command.*;
  47. import me.nick.npractice.kit.Kit;
  48. import me.nick.npractice.kit.KitEditorListener;
  49. import me.nick.npractice.kit.KitTypeAdapter;
  50. import me.nick.npractice.kit.command.KitCreateCommand;
  51. import me.nick.npractice.kit.command.KitGetLoadoutCommand;
  52. import me.nick.npractice.kit.command.KitListCommand;
  53. import me.nick.npractice.kit.command.KitSetLoadoutCommand;
  54. import me.nick.npractice.match.Match;
  55. import me.nick.npractice.match.MatchListener;
  56. import me.nick.npractice.match.command.SpectateCommand;
  57. import me.nick.npractice.match.command.StopSpectatingCommand;
  58. import me.nick.npractice.match.command.ViewInventoryCommand;
  59. import me.nick.npractice.util.events.WorldListener;
  60. import me.nick.npractice.party.Party;
  61. import me.nick.npractice.party.PartyListener;
  62. import me.nick.npractice.party.command.*;
  63. import me.nick.npractice.profile.Profile;
  64. import me.nick.npractice.profile.ProfileListener;
  65. import me.nick.npractice.profile.hotbar.Hotbar;
  66. import me.nick.npractice.queue.QueueThread;
  67. import me.nick.npractice.scoreboard.ScoreboardAdapter;
  68. import me.nick.npractice.event.impl.tournament.command.*;
  69. import me.nick.npractice.scoreboard.TabAdapter;
  70. import me.nick.npractice.util.InventoryUtil;
  71. import me.nick.npractice.util.essentials.Essentials;
  72. import me.nick.npractice.util.essentials.listener.EssentialsListener;
  73. import me.nick.npractice.util.events.ArmorListener;
  74. import me.nick.npractice.util.external.duration.Duration;
  75. import me.nick.npractice.util.external.duration.DurationTypeAdapter;
  76. import me.nick.npractice.util.external.menu.MenuListener;
  77. import com.mongodb.MongoClient;
  78. import com.mongodb.MongoClientOptions;
  79. import com.mongodb.MongoCredential;
  80. import com.mongodb.ServerAddress;
  81. import com.mongodb.client.MongoDatabase;
  82. import com.qrakn.honcho.Honcho;
  83. import com.qrakn.phoenix.lang.file.type.BasicConfigurationFile;
  84. import lombok.Getter;
  85. import me.joeleoli.frame.Frame;
  86. import net.milkbowl.vault.chat.Chat;
  87. import org.bukkit.Difficulty;
  88. import org.bukkit.Material;
  89. import org.bukkit.plugin.RegisteredServiceProvider;
  90. import org.bukkit.plugin.java.JavaPlugin;
  91.  
  92. import java.util.Arrays;
  93.  
  94. public class nPractice extends JavaPlugin {
  95.  
  96. private static nPractice nPractice;
  97.  
  98. @Getter
  99. private BasicConfigurationFile mainConfig;
  100. @Getter
  101. private BasicConfigurationFile arenasConfig;
  102. @Getter
  103. private BasicConfigurationFile kitsConfig;
  104. @Getter
  105. private BasicConfigurationFile eventsConfig;
  106.  
  107. @Getter
  108. private MongoDatabase mongoDatabase;
  109.  
  110. @Getter
  111. private SumoManager sumoManager;
  112. @Getter
  113. private BracketsManager bracketsManager;
  114. @Getter
  115. private FFAManager ffaManager;
  116. @Getter
  117. private JuggernautManager juggernautManager;
  118. @Getter
  119. private ParkourManager parkourManager;
  120. @Getter
  121. private WipeoutManager wipeoutManager;
  122. @Getter
  123. private SkyWarsManager skyWarsManager;
  124. @Getter
  125. private SpleefManager spleefManager;
  126.  
  127. @Getter
  128. private ArmorClassManager armorClassManager;
  129. @Getter
  130. private EffectRestorer effectRestorer;
  131.  
  132. @Getter
  133. private Essentials essentials;
  134.  
  135. @Getter
  136. private Chat chat;
  137.  
  138. @Getter
  139. private Honcho honcho;
  140.  
  141. @Override
  142. public void onEnable() {
  143. nPractice = this;
  144.  
  145. honcho = new Honcho(this);
  146.  
  147. mainConfig = new BasicConfigurationFile(this, "config");
  148. arenasConfig = new BasicConfigurationFile(this, "arenas");
  149. kitsConfig = new BasicConfigurationFile(this, "kits");
  150. eventsConfig = new BasicConfigurationFile(this, "events");
  151.  
  152. loadMongo();
  153.  
  154. Profile.init();
  155. Kit.init();
  156. Arena.init();
  157. Hotbar.init();
  158. Match.init();
  159. Party.init();
  160.  
  161. essentials = new Essentials(this);
  162. setupChat();
  163.  
  164. honcho.registerTypeAdapter(Arena.class, new ArenaTypeAdapter());
  165. honcho.registerTypeAdapter(ArenaType.class, new ArenaTypeTypeAdapter());
  166. honcho.registerTypeAdapter(Kit.class, new KitTypeAdapter());
  167.  
  168. for (Object command : Arrays.asList(
  169. //Staff commands
  170. new SetSpawnCommand(),
  171. new RemoveProfileCommand(),
  172.  
  173. //Player commands
  174. new TsbCommand(),
  175. new TduelCommand(),
  176. new TpmCommand(),
  177. new StatsCommand(),
  178. new LeaderboardsCommand(),
  179. new OptionsCommand(),
  180. new EventCommand(),
  181.  
  182.  
  183. //Arena commands
  184. new ArenaAddKitCommand(),
  185. new ArenaRemoveKitCommand(),
  186. new ArenaSetSpawnCommand(),
  187. new ArenaSetPointCommand(),
  188. new ArenaCreateCommand(),
  189. new ArenaRemoveCommand(),
  190. new ArenasCommand(),
  191. new ArenaTpCommand(),
  192.  
  193. //Duel commands
  194. new DuelCommand(),
  195. new DuelAcceptCommand(),
  196. new RematchCommand(),
  197. new ViewInventoryCommand(),
  198. new SpectateCommand(),
  199. new StopSpectatingCommand(),
  200.  
  201. //Party commands
  202. new PartyCloseCommand(),
  203. new PartyCreateCommand(),
  204. new PartyDisbandCommand(),
  205. new PartyHelpCommand(),
  206. new PartyInfoCommand(),
  207. new PartyInviteCommand(),
  208. new PartyJoinCommand(),
  209. new PartyKickCommand(),
  210. new PartyLeaveCommand(),
  211. new PartyOpenCommand(),
  212. new PartyLeaderCommand(),
  213. new PartyUnbanCommand(),
  214. new PartyBanCommand(),
  215.  
  216. //Kit commands
  217. new KitCreateCommand(),
  218. new KitGetLoadoutCommand(),
  219. new KitSetLoadoutCommand(),
  220. new KitListCommand(),
  221.  
  222. //Brackets commands
  223. new BracketsLeaveCommand(),
  224. new BracketsCancelCommand(),
  225. new BracketsCooldownCommand(),
  226. new BracketsJoinCommand(),
  227. new BracketsSetSpawnCommand(),
  228. new BracketsHostCommand(),
  229. new BracketsTpCommand(),
  230.  
  231. //Sumo commands
  232. new SumoCancelCommand(),
  233. new SumoCooldownCommand(),
  234. new SumoHostCommand(),
  235. new SumoJoinCommand(),
  236. new SumoLeaveCommand(),
  237. new SumoSetSpawnCommand(),
  238. new SumoTpCommand(),
  239.  
  240. //Spleef commands
  241. new FFACancelCommand(),
  242. new FFACooldownCommand(),
  243. new FFAHostCommand(),
  244. new FFAJoinCommand(),
  245. new FFALeaveCommand(),
  246. new FFASetSpawnCommand(),
  247. new FFATpCommand(),
  248.  
  249. //Juggernaut commands
  250. new JuggernautCancelCommand(),
  251. new JuggernautCooldownCommand(),
  252. new JuggernautHostCommand(),
  253. new JuggernautJoinCommand(),
  254. new JuggernautLeaveCommand(),
  255. new JuggernautSetSpawnCommand(),
  256. new JuggernautTpCommand(),
  257.  
  258. //Parkour commands
  259. new ParkourCancelCommand(),
  260. new ParkourCooldownCommand(),
  261. new ParkourHostCommand(),
  262. new ParkourJoinCommand(),
  263. new ParkourLeaveCommand(),
  264. new ParkourSetSpawnCommand(),
  265. new ParkourTpCommand(),
  266.  
  267. //Wipeout commands
  268. new WipeoutCancelCommand(),
  269. new WipeoutCooldownCommand(),
  270. new WipeoutHostCommand(),
  271. new WipeoutJoinCommand(),
  272. new WipeoutLeaveCommand(),
  273. new WipeoutSetSpawnCommand(),
  274. new WipeoutTpCommand(),
  275.  
  276. //SkyWars commands
  277. new SkyWarsCancelCommand(),
  278. new SkyWarsCooldownCommand(),
  279. new SkyWarsHostCommand(),
  280. new SkyWarsJoinCommand(),
  281. new SkyWarsLeaveCommand(),
  282. new SkyWarsSetSpawnCommand(),
  283. new SkyWarsTpCommand(),
  284.  
  285. //Spleef commands
  286. new SpleefCancelCommand(),
  287. new SpleefCooldownCommand(),
  288. new SpleefHostCommand(),
  289. new SpleefJoinCommand(),
  290. new SpleefLeaveCommand(),
  291. new SpleefSetSpawnCommand(),
  292. new SpleefTpCommand(),
  293.  
  294. //Tournament commands
  295. new TournamentCommand(),
  296. new TournamentLeaveCommand(),
  297. new TournamentJoinCommand(),
  298. new TournamentHostCommand(),
  299. new TournamentCancelCommand()
  300. )) {
  301. honcho.registerCommand(command);
  302. }
  303.  
  304. honcho.registerTypeAdapter(Duration.class, new DurationTypeAdapter());
  305.  
  306. sumoManager = new SumoManager();
  307. bracketsManager = new BracketsManager();
  308. ffaManager = new FFAManager();
  309. juggernautManager = new JuggernautManager();
  310. parkourManager = new ParkourManager();
  311. wipeoutManager = new WipeoutManager();
  312. skyWarsManager = new SkyWarsManager();
  313. spleefManager = new SpleefManager();
  314.  
  315.  
  316. this.effectRestorer = new EffectRestorer(this);
  317. this.armorClassManager = new ArmorClassManager(this);
  318.  
  319. Arrays.asList(
  320. Material.WORKBENCH,
  321. Material.STICK,
  322. Material.WOOD_PLATE,
  323. Material.WOOD_BUTTON,
  324. Material.SNOW_BLOCK
  325. ).forEach(InventoryUtil::removeCrafting);
  326.  
  327. getServer().getWorlds().forEach(world -> {
  328. world.setDifficulty(Difficulty.HARD);
  329. essentials.clearEntities(world);
  330. });
  331.  
  332. Arrays.asList(
  333. new ProfileListener(),
  334. new MenuListener(this),
  335. new EssentialsListener(this),
  336. new SumoListener(),
  337. new BracketsListener(),
  338. new FFAListener(),
  339. new JuggernautListener(),
  340. new ParkourListener(),
  341. new WipeoutListener(),
  342. new SkyWarsListener(),
  343. new SpleefListener(),
  344. new KitEditorListener(),
  345. new PartyListener(),
  346. new HotbarListener(),
  347. new MatchListener(),
  348. new WorldListener(),
  349. new QueueListener(),
  350. new ArmorListener()
  351. ).forEach(listener -> getServer().getPluginManager().registerEvents(listener, this));
  352.  
  353. new Ziggurat(this, new TabAdapter());
  354. new Frame(this, new ScoreboardAdapter(this));
  355.  
  356.  
  357. new QueueThread().start();
  358. }
  359.  
  360. @Override
  361. public void onDisable() {
  362. Match.cleanup();
  363. }
  364.  
  365. private void loadMongo() {
  366. if (mainConfig.getBoolean("MONGO.AUTHENTICATION.ENABLED")) {
  367. mongoDatabase = new MongoClient(
  368. new ServerAddress(
  369. mainConfig.getString("MONGO.HOST"),
  370. mainConfig.getInteger("MONGO.PORT")
  371. ),
  372. MongoCredential.createCredential(
  373. mainConfig.getString("MONGO.AUTHENTICATION.USERNAME"),
  374. "admin", mainConfig.getString("MONGO.AUTHENTICATION.PASSWORD").toCharArray()
  375. ),
  376. MongoClientOptions.builder().build()
  377. ).getDatabase(mainConfig.getString("MONGO.DATABASE"));
  378. } else {
  379. mongoDatabase = new MongoClient(mainConfig.getString("MONGO.HOST"), mainConfig.getInteger("MONGO.PORT"))
  380. .getDatabase(mainConfig.getString("MONGO.DATABASE"));
  381. }
  382. }
  383.  
  384. public static nPractice get() {
  385. return nPractice;
  386. }
  387.  
  388. public boolean setupChat()
  389. {
  390. RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
  391. this.chat = ((Chat)rsp.getProvider());
  392. return this.chat != null;
  393. }
  394. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement