· 7 years ago · Feb 02, 2019, 06:48 PM
1package pl.kopara.guild.listeners;
2
3import org.bukkit.Bukkit;
4import org.bukkit.Location;
5import org.bukkit.Material;
6import org.bukkit.entity.Player;
7import org.bukkit.event.EventHandler;
8import org.bukkit.event.EventPriority;
9import org.bukkit.event.Listener;
10import org.bukkit.event.player.PlayerJoinEvent;
11import org.bukkit.event.player.PlayerKickEvent;
12import org.bukkit.event.player.PlayerQuitEvent;
13import org.bukkit.event.player.PlayerTeleportEvent;
14import org.bukkit.inventory.ItemStack;
15
16import pl.kopara.guild.Combat;
17import pl.kopara.guild.data.base.guild.Guild;
18import pl.kopara.guild.data.base.user.User;
19import pl.kopara.guild.lang.Config;
20import pl.kopara.guild.managers.CombatManager;
21import pl.kopara.guild.managers.GuildManager;
22import pl.kopara.guild.managers.UserManager;
23import pl.kopara.guild.utils.ChatUtil;
24import pl.kopara.guild.utils.RandomUtil;
25import pl.kopara.guild.utils.TagUtil;
26import pl.kopara.guild.GuildPlugin;
27
28public class PlayerQuitJoinListener implements Listener {
29
30 @EventHandler(priority = EventPriority.LOW)
31 public void onJoin(final PlayerJoinEvent e) {
32 e.setJoinMessage((String)null);
33 final Player p = e.getPlayer();
34 final User u = UserManager.getUser(p);
35 if (u == null) {
36 UserManager.createrUser(p);
37 p.getInventory().clear();
38 p.getEnderChest().clear();
39 p.getInventory().setHelmet(null);
40 p.getInventory().setChestplate(null);
41 p.getInventory().setLeggings(null);
42 p.getInventory().setBoots(null);
43 ChatUtil.giveItems(p, new ItemStack(Material.IRON_PICKAXE));
44 ChatUtil.giveItems(p, new ItemStack(Material.COOKED_BEEF, 64));
45 ChatUtil.giveItems(p, new ItemStack(Material.ENDER_CHEST));
46 ChatUtil.giveItems(p, new ItemStack(Material.WOOD, 48));
47 final int x = RandomUtil.getRandInt(-400, 400);
48 final int z = RandomUtil.getRandInt(-400, 400);
49 final double y = p.getWorld().getHighestBlockYAt(x, z) + 1.5f;
50 final Location loc = new Location(p.getWorld(), (double)x, y, (double)z);
51 p.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
52 p.updateInventory();
53 }
54 else
55 {
56 if (u.isGod() && !p.hasPermission("core.cmd.mod")) {
57 u.setGod(false);
58 }
59 }
60
61 if (p.getWorld().getName().equals("world_nether") && !Config.ENABLE_NETHER) {
62 ChatUtil.sendMessage(p, "&7Nether jest tymczasowo wylaczony!, Teleportuje Cie na spawn!");
63 p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
64 return;
65 }
66
67 final Combat combat = CombatManager.getCombat(p);
68 if (combat == null) {
69 CombatManager.createCombat(p);
70 }
71 }
72
73 @EventHandler(priority = EventPriority.LOWEST)
74 public void onKick(final PlayerKickEvent e) {
75 quitGame(e.getPlayer());
76 e.setLeaveMessage((String)null);
77 }
78
79 @EventHandler(priority = EventPriority.LOWEST)
80 public void onQuit(final PlayerQuitEvent e) {
81 quitGame(e.getPlayer());
82 e.setQuitMessage((String)null);
83 }
84
85 @EventHandler(priority = EventPriority.NORMAL)
86 public void PlayerJoinTag(final PlayerJoinEvent e) {
87 Bukkit.getScheduler().runTaskAsynchronously((Plugin)GuildPlugin.getPlugin(), () -> {
88 try {
89 TagUtil.createBoard(e.getPlayer());
90 }
91 catch (Exception ex) {}
92 TagUtil.refreshAll();
93 });
94 }
95
96 public static void quitGame(final Player p) {
97 final Combat combat = CombatManager.getCombat(p);
98 if (!combat.hasFight()) {
99 return;
100 }
101 p.setHealth(0.0);
102 final Guild g = GuildManager.getGuild(p);
103 ChatUtil.sendMessage(Bukkit.getOnlinePlayers(), "&7Gracz &c" + p.getName() +" "+ (g == null ? "" : "&8[&c" + g.getTag() + "&8] ") + " &7wylogowal sie podczas walki!");
104 }
105}
106
107package pl.kopara.guild;
108
109import org.bukkit.Bukkit;
110import org.bukkit.World;
111import org.bukkit.entity.Player;
112import org.bukkit.event.Listener;
113import org.bukkit.plugin.Plugin;
114import org.bukkit.plugin.PluginManager;
115import org.bukkit.plugin.RegisteredServiceProvider;
116import org.bukkit.plugin.java.JavaPlugin;
117
118import codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI;
119import magiccase.command.CaseCommand;
120import magiccase.listeners.CaseDropListener;
121import magiccase.listeners.CaseKickQuitListener;
122import magiccase.listeners.CasePlaceListener;
123import net.milkbowl.vault.chat.Chat;
124import pl.kopara.guild.commands.Command;
125import pl.kopara.guild.commands.CommandManager;
126import pl.kopara.guild.commands.cmd.AutoMsgCommand;
127import pl.kopara.guild.commands.cmd.BackupCommand;
128import pl.kopara.guild.commands.cmd.BanCommand;
129import pl.kopara.guild.commands.cmd.BanIPCommand;
130import pl.kopara.guild.commands.cmd.BroadcastCommand;
131import pl.kopara.guild.commands.cmd.ChatCommand;
132import pl.kopara.guild.commands.cmd.ClearCommand;
133import pl.kopara.guild.commands.cmd.ClearEnderchestCommand;
134import pl.kopara.guild.commands.cmd.CobblexCommand;
135import pl.kopara.guild.commands.cmd.ConfigCommand;
136import pl.kopara.guild.commands.cmd.CraftCommand;
137import pl.kopara.guild.commands.cmd.DayCommand;
138import pl.kopara.guild.commands.cmd.EfektCommand;
139import pl.kopara.guild.commands.cmd.EnableCommand;
140import pl.kopara.guild.commands.cmd.EnchantCommand;
141import pl.kopara.guild.commands.cmd.EnderSeeCommand;
142import pl.kopara.guild.commands.cmd.EnderchestCommand;
143import pl.kopara.guild.commands.cmd.FlyCommand;
144import pl.kopara.guild.commands.cmd.GamemodeCommand;
145import pl.kopara.guild.commands.cmd.GcCommand;
146import pl.kopara.guild.commands.cmd.GiveCommand;
147import pl.kopara.guild.commands.cmd.GodCommand;
148import pl.kopara.guild.commands.cmd.HcCommand;
149import pl.kopara.guild.commands.cmd.HeadCommand;
150import pl.kopara.guild.commands.cmd.HealCommand;
151import pl.kopara.guild.commands.cmd.HelpCommand;
152import pl.kopara.guild.commands.cmd.AEventyCommand;
153import pl.kopara.guild.commands.cmd.HelpOpCommand;
154import pl.kopara.guild.commands.cmd.HomeCommand;
155import pl.kopara.guild.commands.cmd.InvCommand;
156import pl.kopara.guild.commands.cmd.IsCommand;
157import pl.kopara.guild.commands.cmd.ItemCommand;
158import pl.kopara.guild.commands.cmd.HelperCommand;
159import pl.kopara.guild.commands.cmd.KickAllCommand;
160import pl.kopara.guild.commands.cmd.KickCommand;
161import pl.kopara.guild.commands.cmd.KitCommand;
162import pl.kopara.guild.commands.cmd.ListCommand;
163import pl.kopara.guild.commands.cmd.NadajCommand;
164import pl.kopara.guild.commands.cmd.NaprawKilofCommand;
165import pl.kopara.guild.commands.cmd.NightCommand;
166import pl.kopara.guild.commands.cmd.RankingCommand;
167import pl.kopara.guild.commands.cmd.RenameCommand;
168import pl.kopara.guild.commands.cmd.RepairCommand;
169import pl.kopara.guild.commands.cmd.ReplyCommand;
170import pl.kopara.guild.commands.cmd.SchowekCommand;
171import pl.kopara.guild.commands.cmd.SetHomeCommand;
172import pl.kopara.guild.commands.cmd.SetSpawnCommand;
173import pl.kopara.guild.commands.cmd.SklepCommand;
174import pl.kopara.guild.commands.cmd.SlotCommand;
175import pl.kopara.guild.commands.cmd.SlowmodeCommand;
176import pl.kopara.guild.commands.cmd.SniezkaCommand;
177import pl.kopara.guild.commands.cmd.SpawnCommand;
178import pl.kopara.guild.commands.cmd.SpeedCommand;
179import pl.kopara.guild.commands.cmd.SsCommand;
180import pl.kopara.guild.commands.cmd.StatsCommand;
181import pl.kopara.guild.commands.cmd.StoneCommand;
182import pl.kopara.guild.commands.cmd.StpCommand;
183import pl.kopara.guild.commands.cmd.TeleportCommand;
184import pl.kopara.guild.commands.cmd.EventyCommand;
185import pl.kopara.guild.commands.cmd.TellCommand;
186import pl.kopara.guild.commands.cmd.TpaCommand;
187import pl.kopara.guild.commands.cmd.TpacceptCommand;
188import pl.kopara.guild.commands.cmd.TpdenyCommmand;
189import pl.kopara.guild.commands.cmd.TurboCommand;
190import pl.kopara.guild.commands.cmd.UnBanCommand;
191import pl.kopara.guild.commands.cmd.UnBanIpCommand;
192import pl.kopara.guild.commands.cmd.VanishCommand;
193import pl.kopara.guild.commands.cmd.VipCommand;
194import pl.kopara.guild.commands.cmd.WhiteListCommand;
195import pl.kopara.guild.commands.cmd.WhoIsCommand;
196import pl.kopara.guild.commands.cmd.WiadomosciCommand;
197import pl.kopara.guild.commands.cmd.WorkBenchCommand;
198import pl.kopara.guild.commands.cmd.YouTubeCommand;
199import pl.kopara.guild.commands.guild.AllyCommand;
200import pl.kopara.guild.commands.guild.CreateCommand;
201import pl.kopara.guild.commands.guild.DeleteCommand;
202import pl.kopara.guild.commands.guild.EnlargeCommand;
203import pl.kopara.guild.commands.guild.GaCommand;
204import pl.kopara.guild.commands.guild.GuildHelpCommand;
205import pl.kopara.guild.commands.guild.GuildHomeCommand;
206import pl.kopara.guild.commands.guild.GuildSetHomeCommand;
207import pl.kopara.guild.commands.guild.InfoCommand;
208import pl.kopara.guild.commands.guild.InviteCommand;
209import pl.kopara.guild.commands.guild.JoinCommand;
210import pl.kopara.guild.commands.guild.LeaderCommand;
211import pl.kopara.guild.commands.guild.LeaveCommand;
212import pl.kopara.guild.commands.guild.OwnerCommand;
213import pl.kopara.guild.commands.guild.ProlongCommand;
214import pl.kopara.guild.commands.guild.PvpCommand;
215import pl.kopara.guild.lang.Config;
216import pl.kopara.guild.lang.Lang;
217import pl.kopara.guild.listeners.AsyncPlayerChatListener;
218import pl.kopara.guild.listeners.BlockCraftingListener;
219import pl.kopara.guild.listeners.BlockListener;
220import pl.kopara.guild.listeners.BorderMapListener;
221import pl.kopara.guild.listeners.BoyListener;
222import pl.kopara.guild.listeners.ChatGuildsListener;
223import pl.kopara.guild.listeners.CheckLoginListener;
224import pl.kopara.guild.listeners.CobblexListener;
225import pl.kopara.guild.listeners.DropBlockBreakListener;
226import pl.kopara.guild.listeners.EfektListener;
227import pl.kopara.guild.listeners.EntityDamageByEntityListener;
228import pl.kopara.guild.listeners.EntityDamageListener;
229import pl.kopara.guild.listeners.EntityDeathListener;
230import pl.kopara.guild.listeners.EventyListener;
231import pl.kopara.guild.listeners.GuildExplodeListener;
232import pl.kopara.guild.listeners.InCommbatInGuildListener;
233import pl.kopara.guild.listeners.InventoryClickListener;
234import pl.kopara.guild.listeners.InventoryListener;
235import pl.kopara.guild.listeners.OpenInventoryListener;
236import pl.kopara.guild.listeners.PierozekListener;
237import pl.kopara.guild.listeners.PlayerDeathListener;
238import pl.kopara.guild.listeners.PlayerInteractListener;
239import pl.kopara.guild.listeners.PlayerJoinListener;
240import pl.kopara.guild.listeners.PlayerMoveListener;
241import pl.kopara.guild.listeners.PlayerQuitJoinListener;
242import pl.kopara.guild.listeners.PunchPotyListener;
243import pl.kopara.guild.listeners.SignChangeListener;
244import pl.kopara.guild.listeners.TakeCrystalListener;
245import pl.kopara.guild.listeners.UnkownCommandListener;
246import pl.kopara.guild.listeners.action.BlockBreakListener;
247import pl.kopara.guild.listeners.action.BlockPlaceListener;
248import pl.kopara.guild.listeners.action.PlayerBucketEmptyListener;
249import pl.kopara.guild.listeners.action.PlayerBucketFillListener;
250import pl.kopara.guild.managers.BanIPManager;
251import pl.kopara.guild.managers.BanManager;
252import pl.kopara.guild.managers.CombatManager;
253import pl.kopara.guild.managers.DeathBanManager;
254import pl.kopara.guild.managers.DropFile;
255import pl.kopara.guild.managers.DropManager;
256import pl.kopara.guild.managers.GuildManager;
257import pl.kopara.guild.managers.NameTagManager;
258import pl.kopara.guild.managers.TimerManager;
259import pl.kopara.guild.managers.UserManager;
260import pl.kopara.guild.mysql.store.Store;
261import pl.kopara.guild.mysql.store.modes.StoreMode;
262import pl.kopara.guild.mysql.store.modes.StoreMySQL;
263import pl.kopara.guild.mysql.store.modes.StoreSQLITE;
264import pl.kopara.guild.rank.variable.AsystsVariable;
265import pl.kopara.guild.rank.variable.CoinsVariable;
266import pl.kopara.guild.rank.variable.DeathsVariable;
267import pl.kopara.guild.rank.variable.GuildDeathsVariable;
268import pl.kopara.guild.rank.variable.GuildKillsVariable;
269import pl.kopara.guild.rank.variable.GuildLifeVariable;
270import pl.kopara.guild.rank.variable.GuildLimitVariable;
271import pl.kopara.guild.rank.variable.GuildPointsVariable;
272import pl.kopara.guild.rank.variable.GuildSizeVariable;
273import pl.kopara.guild.rank.variable.GuildVariable;
274import pl.kopara.guild.rank.variable.KDVariable;
275import pl.kopara.guild.rank.variable.KillsVariable;
276import pl.kopara.guild.rank.variable.LvlVariable;
277import pl.kopara.guild.rank.variable.PointsVariable;
278import pl.kopara.guild.rank.variable.PositionVariable;
279import pl.kopara.guild.rank.variable.TopGuildVariable;
280import pl.kopara.guild.rank.variable.TopVariable;
281import pl.kopara.guild.tasks.AutoMsgTask;
282import pl.kopara.guild.tasks.CheckValidityTask;
283import pl.kopara.guild.tasks.ClearItemTask;
284import pl.kopara.guild.tasks.CombatTask;
285import pl.kopara.guild.tasks.LimitTask;
286import pl.kopara.guild.utils.CraftingUtil;
287import pl.kopara.guild.utils.Logger;
288import pl.kopara.guild.utils.TagUtil;
289import pl.kopara.guild.utils.Ticking;
290
291public class GuildPlugin extends JavaPlugin {
292 private static GuildPlugin plugin;
293 private static Store store;
294 private static Chat chat;
295 private static PluginManager pluginManager;
296
297 public void onLoad() {
298 GuildPlugin.plugin = this;
299 }
300
301 static {
302 GuildPlugin.chat = null;
303 }
304
305 public void onEnable() {
306 final long start = System.currentTimeMillis();
307 Logger.info("Inicjacja pluginu Core...");
308 initTab();
309 if (!this.setupChat()) {
310 Logger.warning(new String[]{"NIE ZNALEZIONO VAULT!"});
311 }
312 for (Player p : Bukkit.getOnlinePlayers()) {
313 final Combat c = CombatManager.getCombat(p);
314 if (c == null) {
315 CombatManager.createCombat(p);
316 }
317 }
318 new Ticking().start();
319 TagUtil.init();
320 Config.reloadConfig();
321 Lang.reloadLang();
322 this.registerDatabase();
323 registerManager();
324 registerListener();
325 registerTasks();
326 registerCommand();
327 CraftingUtil.registerRecipe();
328 Logger.info("Zaladowano plugin Core w " + (System.currentTimeMillis() - start) + "ms.");
329 }
330
331 public void onDisable() {
332 Bukkit.getScheduler().cancelTasks((Plugin)this);
333 for (final Player p : Bukkit.getOnlinePlayers()) {
334 CombatManager.removeCombat(p);
335 }
336 Bukkit.savePlayers();
337 for (final World w : Bukkit.getWorlds()) {
338 w.save();
339 }
340 try {
341 Thread.sleep(2000L);
342 } catch (InterruptedException e) {
343 e.printStackTrace();
344 }
345 if (GuildPlugin.store != null && GuildPlugin.store.isConnected()) {
346 GuildPlugin.store.disconnect();
347 }
348 GuildPlugin.plugin = null;
349 }
350
351 public static GuildPlugin getPlugin() {
352 return GuildPlugin.plugin;
353
354 }
355
356 protected boolean registerDatabase() {
357 switch (StoreMode.getByName(Config.DATABASE_MODE)) {
358 case MYSQL: {
359 GuildPlugin.store = new StoreMySQL(Config.DATABASE_MYSQL_HOST, Config.DATABASE_MYSQL_PORT, Config.DATABASE_MYSQL_USER, Config.DATABASE_MYSQL_PASS, Config.DATABASE_MYSQL_NAME, Config.DATABASE_TABLEPREFIX);
360 break;
361 }
362 case SQLITE: {
363 GuildPlugin.store = new StoreSQLITE(Config.DATABASE_SQLITE_NAME, Config.DATABASE_TABLEPREFIX);
364 break;
365 }
366 default: {
367 Logger.warning("Wartosc trybu bazy daych jest nieprawidlowa! Korzystam z bazy daych SQLite...");
368 GuildPlugin.store = new StoreSQLITE(Config.DATABASE_SQLITE_NAME, Config.DATABASE_TABLEPREFIX);
369 break;
370 }
371 }
372 final boolean conn = GuildPlugin.store.connect();
373 if (conn) {
374 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}users` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`name` varchar(32) NOT NULL,`points` int(11) NOT NULL,`coins` int(11) NOT NULL, `kills` int(11) NOT NULL, `deaths` int(11) NOT NULL, `asyst` int(11) NOT NULL, `kox` int(11) NOT NULL, `refil` int(11) NOT NULL, `perly` int(11) NOT NULL, `logout` int(11) NOT NULL, " + "`firstIP` varchar(64) NOT NULL, `lastIP` varchar(64) NOT NULL, `firstJoin` bigint(22) NOT NULL, `kit_start` bigint(64) NOT NULL, `kit_yt` bigint(22) NOT NULL, `kit_tw` bigint(22) NOT NULL, " + "`kit_vip` bigint(22) NOT NULL, `kit_svip` bigint(22) NOT NULL, `turboDrop` bigint(22) NOT NULL, `turboExp` bigint(22) NOT NULL,`home` varchar(255) NOT NULL, `lastKill` varchar(32) NOT NULL, `lastKillTime` bigint(22) NOT NULL, `god` int(1) NOT NULL, `lvl` int(11) NOT NULL, `exp` int(11) NOT NULL);");
375 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}guilds` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`tag` varchar(5) NOT NULL, `name` varchar(32) NOT NULL, `owner` varchar(64) NOT NULL, `leader` varchar(64) NOT NULL, `cuboidX` int(11) NOT NULL, `cuboidZ` int(11) NOT NULL, `cuboidSize` int(11) NOT NULL, `life` int(11) NOT NULL, " + "`lifeLastAttack` bigint(22) NOT NULL, `prolong` bigint(22) NOT NULL, `pvp` int(2) NOT NULL, `createTime` bigint(22) NOT NULL, `homeX` double NOT NULL, `homeY` double NOT NULL, `homeZ` double NOT NULL, `ally` varchar(255) NOT NULL, `points` int(11) NOT NULL, `kills` int(11) NOT NULL, `deaths` int(11) NOT NULL, `pvpAlly` int(1) NOT NULL);");
376 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}members` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`name` varchar(32) NOT NULL,`tag` varchar(5) NOT NULL);");
377 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}bans` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`name` varchar(32) NOT NULL,`time` bigint(22) NOT NULL, `reason` text NOT NULL, `admin` varchar(32) NOT NULL, `start` BIGINT(22) NOT NULL);");
378 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}bansip` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`ip` varchar(32) NOT NULL,`time` bigint(22) NOT NULL, `reason` text NOT NULL, `admin` varchar(32) NOT NULL, `start` BIGINT(22) NOT NULL);");
379 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}backups` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`name` varchar(32) NOT NULL,`time` bigint(22) NOT NULL, `killer` varchar(32) NOT NULL, `ping` int(11) NOT NULL, `inventory` text NOT NULL, `armor` text NOT NULL, `enderchest` text NOT NULL);");
380 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}warp` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`name` varchar(32) NOT NULL,`location` text NOT NULL, `group` varchar(32) NOT NULL NOT NULL);");
381 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}deathbans` (" + (store.getStoreMode() == StoreMode.MYSQL ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`name` varchar(32) NOT NULL,`mode` int(1) NOT NULL, `time` bigint(11) NOT NULL NOT NULL);");
382 return conn;
383 }
384 return conn;
385 }
386
387 public static void registerCommand(final Command command) {
388 CommandManager.register(command);
389 }
390
391 public static void registerListener(final Plugin plugin, final Listener... listeners) {
392 if (GuildPlugin.pluginManager == null) {
393 GuildPlugin.pluginManager = Bukkit.getPluginManager();
394 }
395 for (final Listener listener : listeners) {
396 GuildPlugin.pluginManager.registerEvents(listener, plugin);
397 }
398 }
399
400 private boolean setupChat() {
401 if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
402 return false;
403 }
404 final RegisteredServiceProvider<Chat> rsp = (RegisteredServiceProvider<Chat>)this.getServer().getServicesManager().getRegistration((Class<Chat>)Chat.class);
405 GuildPlugin.chat = (Chat)rsp.getProvider();
406 return GuildPlugin.chat != null;
407 }
408
409 public static Chat getChat() {
410 return GuildPlugin.chat;
411 }
412
413 public static Store getStore() {
414 return GuildPlugin.store;
415 }
416
417 public static void registerCommand() {
418 Logger.info("Ladowanie komend...");
419 final long start = System.currentTimeMillis();
420 GuildPlugin.registerCommand((Command) new ListCommand());
421 GuildPlugin.registerCommand((Command) new RankingCommand());
422 GuildPlugin.registerCommand((Command) new GodCommand());
423 GuildPlugin.registerCommand((Command) new BanCommand());
424 GuildPlugin.registerCommand((Command) new UnBanCommand());
425 GuildPlugin.registerCommand((Command) new UnBanIpCommand());
426 GuildPlugin.registerCommand((Command) new ChatCommand());
427 GuildPlugin.registerCommand((Command) new GamemodeCommand());
428 GuildPlugin.registerCommand((Command) new FlyCommand());
429 GuildPlugin.registerCommand((Command) new SpawnCommand());
430 GuildPlugin.registerCommand((Command) new SetSpawnCommand());
431 GuildPlugin.registerCommand((Command) new KitCommand());
432 GuildPlugin.registerCommand((Command) new TpacceptCommand());
433 GuildPlugin.registerCommand((Command) new TpdenyCommmand());
434 GuildPlugin.registerCommand((Command) new TpaCommand());
435 GuildPlugin.registerCommand((Command) new ClearCommand());
436 GuildPlugin.registerCommand((Command) new EnchantCommand());
437 GuildPlugin.registerCommand((Command) new GcCommand());
438 GuildPlugin.registerCommand((Command) new ItemCommand());
439 GuildPlugin.registerCommand((Command) new GiveCommand());
440 GuildPlugin.registerCommand((Command) new HeadCommand());
441 GuildPlugin.registerCommand((Command) new HealCommand());
442 GuildPlugin.registerCommand((Command) new HelpOpCommand());
443 GuildPlugin.registerCommand((Command) new EnderSeeCommand());
444 GuildPlugin.registerCommand((Command) new HomeCommand());
445 GuildPlugin.registerCommand((Command) new KickAllCommand());
446 GuildPlugin.registerCommand((Command) new KickCommand());
447 GuildPlugin.registerCommand((Command) new ListCommand());
448 GuildPlugin.registerCommand((Command) new SetHomeCommand());
449 GuildPlugin.registerCommand((Command) new RepairCommand());
450 GuildPlugin.registerCommand((Command) new TellCommand());
451 GuildPlugin.registerCommand((Command) new ReplyCommand());
452 GuildPlugin.registerCommand((Command) new SlotCommand());
453 GuildPlugin.registerCommand((Command) new SlowmodeCommand());
454 GuildPlugin.registerCommand((Command) new StpCommand());
455 GuildPlugin.registerCommand((Command) new VipCommand());
456 GuildPlugin.registerCommand((Command) new YouTubeCommand());
457 GuildPlugin.registerCommand((Command) new AEventyCommand());
458 GuildPlugin.registerCommand((Command) new EventyCommand());
459 GuildPlugin.registerCommand((Command) new CraftCommand());
460 GuildPlugin.registerCommand((Command) new BroadcastCommand());
461 GuildPlugin.registerCommand((Command) new TpaCommand());
462 GuildPlugin.registerCommand((Command) new NadajCommand());
463 GuildPlugin.registerCommand((Command) new WhiteListCommand());
464 GuildPlugin.registerCommand((Command) new WhoIsCommand());
465 GuildPlugin.registerCommand((Command) new EfektCommand());
466 GuildPlugin.registerCommand((Command) new StoneCommand());
467 GuildPlugin.registerCommand((Command) new VanishCommand());
468 GuildPlugin.registerCommand((Command) new TeleportCommand());
469 GuildPlugin.registerCommand((Command) new BackupCommand());
470 GuildPlugin.registerCommand((Command) new BanIPCommand());
471 GuildPlugin.registerCommand((Command) new RenameCommand());
472 GuildPlugin.registerCommand((Command) new IsCommand());
473 GuildPlugin.registerCommand((Command) new CobblexCommand());
474 GuildPlugin.registerCommand((Command) new WorkBenchCommand());
475 GuildPlugin.registerCommand((Command) new EnderchestCommand());
476 GuildPlugin.registerCommand((Command) new SpeedCommand());
477 GuildPlugin.registerCommand((Command) new TurboCommand());
478 GuildPlugin.registerCommand((Command) new StatsCommand());
479 GuildPlugin.registerCommand((Command) new CaseCommand());
480 GuildPlugin.registerCommand((Command) new CobblexCommand());
481 GuildPlugin.registerCommand((Command) new HcCommand());
482 GuildPlugin.registerCommand((Command) new SklepCommand());
483 GuildPlugin.registerCommand((Command) new InvCommand());
484 GuildPlugin.registerCommand((Command) new SchowekCommand());
485 GuildPlugin.registerCommand((Command) new NaprawKilofCommand());
486 GuildPlugin.registerCommand((Command) new HelperCommand());
487 GuildPlugin.registerCommand((Command) new DayCommand());
488 GuildPlugin.registerCommand((Command) new NightCommand());
489 GuildPlugin.registerCommand((Command) new EnableCommand());
490 GuildPlugin.registerCommand((Command) new ConfigCommand());
491 GuildPlugin.registerCommand((Command) new ClearEnderchestCommand());
492
493 GuildPlugin.registerCommand((Command) new GaCommand());
494 GuildPlugin.registerCommand((Command) new AllyCommand());
495 GuildPlugin.registerCommand((Command) new CreateCommand());
496 GuildPlugin.registerCommand((Command) new DeleteCommand());
497 GuildPlugin.registerCommand((Command) new EnlargeCommand());
498 GuildPlugin.registerCommand((Command) new GuildSetHomeCommand());
499 GuildPlugin.registerCommand((Command) new GuildHomeCommand());
500 GuildPlugin.registerCommand((Command) new InfoCommand());
501 GuildPlugin.registerCommand((Command) new InviteCommand());
502 GuildPlugin.registerCommand((Command) new pl.kopara.guild.commands.guild.ItemCommand());
503 GuildPlugin.registerCommand((Command) new JoinCommand());
504 GuildPlugin.registerCommand((Command) new pl.kopara.guild.commands.guild.KickCommand());
505 GuildPlugin.registerCommand((Command) new KickCommand());
506 GuildPlugin.registerCommand((Command) new LeaderCommand());
507 GuildPlugin.registerCommand((Command) new OwnerCommand());
508 GuildPlugin.registerCommand((Command) new ProlongCommand());
509 GuildPlugin.registerCommand((Command) new PvpCommand());
510 GuildPlugin.registerCommand((Command) new AutoMsgCommand());
511 GuildPlugin.registerCommand((Command) new SsCommand());
512 GuildPlugin.registerCommand((Command) new LeaveCommand());
513 GuildPlugin.registerCommand((Command) new HelpCommand());
514 GuildPlugin.registerCommand((Command) new GuildHelpCommand());
515 GuildPlugin.registerCommand((Command) new SniezkaCommand());
516 GuildPlugin.registerCommand((Command) new WiadomosciCommand());
517 Logger.info("Zaladowano komendy w " + (System.currentTimeMillis() - start) + "ms.");
518
519
520
521 }
522
523 public void registerTasks() {
524 Logger.info("Ladowanie taskow...");
525 final long start = System.currentTimeMillis();
526 new CheckValidityTask().runTaskTimer(this, 2400L, 2400L);
527 new CombatTask().runTaskTimerAsynchronously(this, 40L, 20L);
528 new LimitTask().runTaskTimer(this, 300L, 300L);
529 Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, (Runnable)new ClearItemTask(), 3L, 3400L);
530 new AutoMsgTask().runTaskTimerAsynchronously(this, 1200L, 1200L);
531 Logger.info("Zaladowano taski w " + (System.currentTimeMillis() - start) + "ms.");
532 }
533
534 public void registerManager() {
535 Logger.info("Ladowanie managerow...");
536 final long start = System.currentTimeMillis();
537 NameTagManager.enable();
538 DropFile.saveDefaultConfig();
539 DropManager.setup();
540 UserManager.loadUsers();
541 GuildManager.loadGuilds();
542 DeathBanManager.loadDeathsBans();
543 BanManager.loadBans();
544 BanIPManager.loadBans();
545 Logger.info("Zaladowano managery w " + (System.currentTimeMillis() - start) + "ms.");
546 }
547
548 private void initTab(){
549 Logger.info("Ladowanie zmiennych (BungeeTabListPlus)...");
550 final long start = System.currentTimeMillis();
551 BungeeTabListPlusBukkitAPI.registerVariable(this, new PointsVariable("points"));
552 BungeeTabListPlusBukkitAPI.registerVariable(this, new KillsVariable("kills"));
553 BungeeTabListPlusBukkitAPI.registerVariable(this, new DeathsVariable("deaths"));
554 BungeeTabListPlusBukkitAPI.registerVariable(this, new AsystsVariable("asysty"));
555 BungeeTabListPlusBukkitAPI.registerVariable(this, new LvlVariable("lvl"));
556 BungeeTabListPlusBukkitAPI.registerVariable(this, new PositionVariable("position"));
557 BungeeTabListPlusBukkitAPI.registerVariable(this, new CoinsVariable("coins"));
558 BungeeTabListPlusBukkitAPI.registerVariable(this, new KDVariable("kd"));
559
560 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildVariable("guild"));
561 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildPointsVariable("gpoints"));
562 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildKillsVariable("gkills"));
563 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildDeathsVariable("gdeaths"));
564 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildSizeVariable("gsize"));
565 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildLifeVariable("glife"));
566 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildLimitVariable("gonline"));
567 for (int i = 1; i < 16; i ++) {
568 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopVariable("top" + i, i));
569 }
570 for (int i = 1; i < 16; i++) {
571 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopGuildVariable("gtop" + i , i)) ;
572 Logger.info("Zaladowano zmienne w " + (System.currentTimeMillis() - start) + "ms.");
573 }
574 }
575
576 public void registerListener() {
577 Logger.info("Ladowanie listenerow...");
578 final long start = System.currentTimeMillis();
579 GuildPlugin.registerListener((Plugin) this, new InventoryClickListener(),
580 new PlayerQuitJoinListener(),
581 new PlayerJoinListener(),
582 new TimerManager(),
583 new AsyncPlayerChatListener(),
584 new ChatGuildsListener(),
585 new PlayerMoveListener(),
586 new BlockBreakListener(),
587 new BlockPlaceListener(),
588 new PlayerBucketEmptyListener(),
589 new PlayerBucketFillListener(),
590 new GuildExplodeListener(),
591 new EfektListener(),
592 new BorderMapListener(),
593 new BlockCraftingListener(),
594 new EntityDamageByEntityListener(),
595 new EntityDamageListener(),
596 new PlayerDeathListener(),
597 new UnkownCommandListener(),
598 new BlockListener(),
599 new InCommbatInGuildListener(),
600 new TakeCrystalListener(),
601 new InventoryListener(),
602 new InventoryClickListener(),
603 new CheckLoginListener(),
604 new BoyListener(),
605 new PlayerInteractListener(),
606 new PunchPotyListener(),
607 new DropBlockBreakListener(),
608 new EntityDeathListener(),
609
610
611 new InventoryClickListener(),
612 new OpenInventoryListener(),
613 new SignChangeListener(),
614 new CaseDropListener(),
615 new CasePlaceListener(),
616 new CaseKickQuitListener(),
617 new PierozekListener(),
618 new EventyListener(),
619 new magiccase.listeners.InventoryClickListener(),
620
621 new CobblexListener());
622 Logger.info("Zaladowano listenery w " + (System.currentTimeMillis() - start) + "ms.");
623
624 }
625
626}