· 5 years ago · Feb 15, 2020, 07:06 PM
1package pl.karas.api;
2
3import java.sql.ResultSet;
4import java.sql.SQLException;
5
6
7import org.bukkit.Bukkit;
8import org.bukkit.World;
9import org.bukkit.entity.Player;
10import org.bukkit.event.Listener;
11import org.bukkit.plugin.Plugin;
12import org.bukkit.plugin.PluginManager;
13import org.bukkit.plugin.java.JavaPlugin;
14
15import pl.karas.api.Config;
16import pl.karas.api.commands.Command;
17import pl.karas.api.commands.CommandManager;
18import pl.karas.api.commands.cmd.AEventCommand;
19import pl.karas.api.commands.cmd.ANagrodaCommand;
20import pl.karas.api.commands.cmd.AntyCheatCommand;
21import pl.karas.api.commands.cmd.AutoMsgCommand;
22import pl.karas.api.commands.cmd.BackupCommand;
23import pl.karas.api.commands.cmd.BanCommand;
24import pl.karas.api.commands.cmd.BanIPCommand;
25import pl.karas.api.commands.cmd.BlokiCommand;
26import pl.karas.api.commands.cmd.BorderCommand;
27import pl.karas.api.commands.cmd.BroadcastCommand;
28import pl.karas.api.commands.cmd.BroadcastTitleCommand;
29import pl.karas.api.commands.cmd.ChatCommand;
30import pl.karas.api.commands.cmd.ClearCommand;
31import pl.karas.api.commands.cmd.NaprawKilofCommand;
32import pl.karas.api.commands.cmd.ClearEnderchestCommand;
33import pl.karas.api.commands.cmd.ConfigCommand;
34import pl.karas.api.commands.cmd.EnderchestCommand;
35import pl.karas.api.commands.cmd.CraftCommand;
36import pl.karas.api.commands.cmd.DayCommand;
37import pl.karas.api.commands.cmd.DcCommand;
38import pl.karas.api.commands.cmd.DiscoCommand;
39import pl.karas.api.commands.cmd.EfektyCommand;
40import pl.karas.api.commands.cmd.EnableCommand;
41import pl.karas.api.commands.cmd.EnchantCommand;
42import pl.karas.api.commands.cmd.FlyCommand;
43import pl.karas.api.commands.cmd.GamemodeCommand;
44import pl.karas.api.commands.cmd.GcCommand;
45import pl.karas.api.commands.cmd.GiveCommand;
46import pl.karas.api.commands.cmd.GiveYTCommand;
47import pl.karas.api.commands.cmd.GodCommand;
48import pl.karas.api.commands.cmd.GuildItemCommand;
49import pl.karas.api.commands.cmd.HcCommand;
50import pl.karas.api.commands.cmd.HealCommand;
51import pl.karas.api.commands.cmd.HelpCommand;
52import pl.karas.api.commands.cmd.HelpOpCommand;
53import pl.karas.api.commands.cmd.HomeCommand;
54import pl.karas.api.commands.cmd.IgnoreCommand;
55import pl.karas.api.commands.cmd.InvCommand;
56import pl.karas.api.commands.cmd.IsCommand;
57import pl.karas.api.commands.cmd.ItemCommand;
58import pl.karas.api.commands.cmd.KickAllCommand;
59import pl.karas.api.commands.cmd.KickCommand;
60import pl.karas.api.commands.cmd.KitCommand;
61import pl.karas.api.commands.cmd.KsiazkiCommand;
62import pl.karas.api.commands.cmd.LevelCommand;
63import pl.karas.api.commands.cmd.ListCommand;
64import pl.karas.api.commands.cmd.MVipCommand;
65import pl.karas.api.commands.cmd.MarmurCommand;
66import pl.karas.api.commands.cmd.MoreCommand;
67import pl.karas.api.commands.cmd.MuteCommand;
68import pl.karas.api.commands.cmd.NagrodaCommand;
69import pl.karas.api.commands.cmd.NetherCommand;
70import pl.karas.api.commands.cmd.NightCommand;
71import pl.karas.api.commands.cmd.OtchlanCommand;
72import pl.karas.api.commands.cmd.PaczkaCommand;
73import pl.karas.api.commands.cmd.PayCommand;
74import pl.karas.api.commands.cmd.RankingCommand;
75import pl.karas.api.commands.cmd.RenameCommand;
76import pl.karas.api.commands.cmd.RepairCommand;
77import pl.karas.api.commands.cmd.ReplyCommand;
78import pl.karas.api.commands.cmd.ResetRankingCommand;
79import pl.karas.api.commands.cmd.SVipCommand;
80import pl.karas.api.commands.cmd.SchowekCommand;
81import pl.karas.api.commands.cmd.SetHomeCommand;
82import pl.karas.api.commands.cmd.SetSpawnCommand;
83import pl.karas.api.commands.cmd.SetWarpCommand;
84import pl.karas.api.commands.cmd.SklepCommand;
85import pl.karas.api.commands.cmd.SlotCommand;
86import pl.karas.api.commands.cmd.SlowmodeCommand;
87import pl.karas.api.commands.cmd.SmietnikCommand;
88import pl.karas.api.commands.cmd.SpawnCommand;
89import pl.karas.api.commands.cmd.SpeedCommand;
90import pl.karas.api.commands.cmd.StatsCommand;
91import pl.karas.api.commands.cmd.StatystykiCommand;
92import pl.karas.api.commands.cmd.StoneCommand;
93import pl.karas.api.commands.cmd.StpCommand;
94import pl.karas.api.commands.cmd.TeleportCommand;
95import pl.karas.api.commands.cmd.TellCommand;
96import pl.karas.api.commands.cmd.TpaCommand;
97import pl.karas.api.commands.cmd.TpacceptCommand;
98import pl.karas.api.commands.cmd.TpdenyCommmand;
99import pl.karas.api.commands.cmd.TurboCommand;
100import pl.karas.api.commands.cmd.UnBanCommand;
101import pl.karas.api.commands.cmd.UnBanIpCommand;
102import pl.karas.api.commands.cmd.UnMuteCommand;
103import pl.karas.api.commands.cmd.VipCommand;
104import pl.karas.api.commands.cmd.VoucherCommand;
105import pl.karas.api.commands.cmd.WarpCommand;
106import pl.karas.api.commands.cmd.WhiteListCommand;
107import pl.karas.api.commands.cmd.WiadomosciCommand;
108import pl.karas.api.commands.cmd.WorkBenchCommand;
109import pl.karas.api.commands.cmd.WymianaCommand;
110import pl.karas.api.commands.cmd.YouTubeCommand;
111import pl.karas.api.commands.cmd.ZnakiCommand;
112import pl.karas.api.commands.guild.AllyCommand;
113import pl.karas.api.commands.guild.CreateCommand;
114import pl.karas.api.commands.guild.DeleteCommand;
115import pl.karas.api.commands.guild.EnlargeCommand;
116import pl.karas.api.commands.guild.GuildAdminCommand;
117import pl.karas.api.commands.guild.GuildHelpCommand;
118import pl.karas.api.commands.guild.GuildHomeCommand;
119import pl.karas.api.commands.guild.GuildManageCommand;
120import pl.karas.api.commands.guild.GuildSetHomeCommand;
121import pl.karas.api.commands.guild.InfoCommand;
122import pl.karas.api.commands.guild.InviteCommand;
123import pl.karas.api.commands.guild.ItemkiCommand;
124import pl.karas.api.commands.guild.JoinCommand;
125import pl.karas.api.commands.guild.LeaderCommand;
126import pl.karas.api.commands.guild.LeaveCommand;
127import pl.karas.api.commands.guild.OwnerCommand;
128import pl.karas.api.commands.guild.ProlongCommand;
129import pl.karas.api.commands.guild.PvpCommand;
130import pl.karas.api.data.base.Combat;
131import pl.karas.api.data.base.guild.Guild;
132import pl.karas.api.gui.action.CustomEnchantInventoryListener;
133import pl.karas.api.gui.action.PlayerInteraktListener;
134import pl.karas.api.listeners.AntiLagListener;
135import pl.karas.api.listeners.AsyncPlayerChatListener;
136import pl.karas.api.listeners.BlockCraftingListener;
137import pl.karas.api.listeners.BlockDebilListener;
138import pl.karas.api.listeners.BlockListener;
139import pl.karas.api.listeners.BlokowanieListener;
140import pl.karas.api.listeners.BorderMapListener;
141import pl.karas.api.listeners.BoyListener;
142import pl.karas.api.listeners.ChatGuildsListener;
143import pl.karas.api.listeners.CheckLoginListener;
144import pl.karas.api.listeners.RedstoneListener;
145import pl.karas.api.listeners.DropBlockBreakListener;
146import pl.karas.api.listeners.EfektyListener;
147import pl.karas.api.listeners.EnchantItemListener;
148import pl.karas.api.listeners.EnderChestListener;
149import pl.karas.api.listeners.EntityDamageByEntityListener;
150import pl.karas.api.listeners.EntityDamageListener;
151import pl.karas.api.listeners.EntityDeathListener;
152import pl.karas.api.listeners.EventyListener;
153import pl.karas.api.listeners.FarmeryListener;
154import pl.karas.api.listeners.GrupoweListener;
155import pl.karas.api.listeners.GuildExplodeListener;
156import pl.karas.api.listeners.InCommbatInGuildListener;
157import pl.karas.api.listeners.InventoryClickListener;
158import pl.karas.api.listeners.InventoryListener;
159import pl.karas.api.listeners.KilofListener;
160import pl.karas.api.listeners.KoxBlockedListener;
161import pl.karas.api.listeners.MarmurListener;
162import pl.karas.api.listeners.Nether;
163import pl.karas.disco.listeners.EntityDiscoListener;
164import pl.karas.disco.listeners.InventoryDiscoListener;
165import pl.karas.disco.listeners.ToggleListener;
166import pl.karas.api.listeners.OpenInventoryListener;
167import pl.karas.api.listeners.PlayerCommandPreprocessListener;
168import pl.karas.api.listeners.PlayerDeathListener;
169import pl.karas.api.listeners.PlayerInteractListener;
170import pl.karas.api.listeners.PlayerJoinListener;
171import pl.karas.api.listeners.PlayerMoveListener;
172import pl.karas.api.listeners.PlayerQuitJoinListener;
173import pl.karas.api.listeners.PunchPotyListener;
174import pl.karas.tools.data.base.disco.DataManager;
175import pl.karas.tools.data.base.disco.DiscoTask;
176import pl.karas.tools.data.base.disco.PacketEquipment;
177import pl.karas.api.listeners.RainStartListener;
178import pl.karas.api.listeners.SignChangeListener;
179import pl.karas.api.listeners.TakeCrystalListener;
180import pl.karas.api.listeners.TntDamage;
181import pl.karas.api.listeners.TntEvent;
182import pl.karas.api.listeners.WymianaListener;
183import pl.karas.api.listeners.action.BlockBreakListener;
184import pl.karas.api.listeners.action.BlockPlaceListener;
185import pl.karas.api.listeners.action.BorderBreakListener;
186import pl.karas.api.listeners.action.BorderPlaceListener;
187import pl.karas.api.listeners.action.PlayerBucketEmptyListener;
188import pl.karas.api.listeners.action.PlayerBucketFillListener;
189import pl.karas.api.managers.BanIPManager;
190import pl.karas.api.managers.BanManager;
191import pl.karas.api.managers.CombatManager;
192import pl.karas.api.managers.DropFile;
193import pl.karas.api.managers.DropManager;
194import pl.karas.api.managers.GuildManager;
195import pl.karas.api.managers.MuteManager;
196import pl.karas.api.managers.TimerManager;
197import pl.karas.api.managers.UserManager;
198import pl.karas.api.managers.WarpManager;
199import pl.karas.api.mysql.store.Store;
200import pl.karas.api.mysql.store.modes.StoreMode;
201import pl.karas.api.mysql.store.modes.StoreMySQL;
202import pl.karas.api.mysql.store.modes.StoreSQLITE;
203import pl.karas.api.rank.variable.guild.GuildDeathsVariable;
204import pl.karas.api.rank.variable.guild.GuildHpVariable;
205import pl.karas.api.rank.variable.guild.GuildOnlineVartible;
206import pl.karas.api.rank.variable.guild.GuildKdVariable;
207import pl.karas.api.rank.variable.guild.GuildKillsVariable;
208import pl.karas.api.rank.variable.guild.GuildPointsVariable;
209import pl.karas.api.rank.variable.guild.GuildVariable;
210import pl.karas.api.rank.variable.tops.TopAssistsVariable;
211import pl.karas.api.rank.variable.tops.TopCoinsVariable;
212import pl.karas.api.rank.variable.tops.TopDeathsVariable;
213import pl.karas.api.rank.variable.tops.TopGuildPointsVariable;
214import pl.karas.api.rank.variable.tops.TopKillsVariable;
215import pl.karas.api.rank.variable.tops.TopPointsVariable;
216import pl.karas.api.rank.variable.user.AssistsVariable;
217import pl.karas.api.rank.variable.user.CoinsVariable;
218import pl.karas.api.rank.variable.user.DeathsVariable;
219import pl.karas.api.rank.variable.user.KDVariable;
220import pl.karas.api.rank.variable.user.KillsVariable;
221import pl.karas.api.rank.variable.user.LvlVariable;
222import pl.karas.api.rank.variable.user.PointsVariable;
223import pl.karas.api.rank.variable.user.WykopanyStoneVariable;
224import pl.karas.api.tasks.AutoMsgTask;
225import pl.karas.api.tasks.AbbysTask;
226import pl.karas.api.tasks.CheckValidityTask;
227import pl.karas.api.tasks.CombatTask;
228import pl.karas.api.tasks.LimitTask;
229import pl.karas.api.tasks.TabFreshRunnable;
230import pl.karas.api.utils.CraftingUtil;
231import pl.karas.api.utils.Logger;
232import codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI;
233import codecrafter47.bungeetablistplus.api.bukkit.Variable;
234
235public class ServerPlugin extends JavaPlugin
236{
237 private static ServerPlugin plugin;
238 private static Store store;
239 private static PluginManager pluginManager;
240
241 public void onLoad() {
242 ServerPlugin.plugin = this;
243 }
244
245 public void onEnable() {
246 this.initTab();
247 for (final Player p : Bukkit.getOnlinePlayers()) {
248 final Combat c = CombatManager.getCombat(p);
249 if (c == null) {
250 CombatManager.createCombat(p);
251 }
252 }
253 BorderMapListener.setBorder();
254 this.registerDatabase();
255 this.registerManager();
256 this.registerListener();
257 this.registerTasks();
258 registerCommand();
259 CraftingUtil.registerRecipe();
260 }
261
262 public void onDisable() {
263 this.unTab();
264 Bukkit.getScheduler().cancelTasks((Plugin)this);
265 final ResultSet rs = getStore().query("SELECT * FROM `{P}guilds`");
266 try {
267 while (rs.next()) {
268 final Guild g = GuildManager.getGuild(rs.getNString(0));
269 getStore().update(false, "UPDATE `{P}guilds` SET `hp` = '" + g.getHp() + "' WHERE `tag` ='" + g.getTag() + "';");
270 }
271 for (final Player player : Bukkit.getOnlinePlayers()) {
272 if (DataManager.getDisco().containsKey(player.getName())) {
273 player.setSneaking(false);
274 for (int i = 0; i < 4; ++i) {
275 for (final Player online : Bukkit.getOnlinePlayers()) {
276 if (!online.getName().equals(player.getName())) {
277 PacketEquipment.sendEquipment(online, player
278 .getEntityId(), 1 + i, player
279 .getInventory().getArmorContents()[i]);
280 }
281 }
282 }
283 DataManager.getDisco().remove(player.getName());
284 DataManager.getLastColor().remove(player.getName());
285 DataManager.getShiftArmor().remove(player.getName());
286 }
287 }
288 DataManager.getDisco().clear();
289 DataManager.getShiftArmor().clear();
290 DataManager.getLastColor().clear();
291 }
292 catch (SQLException e1) {
293 e1.printStackTrace();
294 }
295 for (final Player p : Bukkit.getOnlinePlayers()) {
296 CombatManager.removeCombat(p);
297 }
298 Bukkit.savePlayers();
299 for (final World w : Bukkit.getWorlds()) {
300 w.save();
301 }
302 try {
303 Thread.sleep(2000L);
304 }
305 catch (InterruptedException e2) {
306 e2.printStackTrace();
307 }
308 if (ServerPlugin.store != null && ServerPlugin.store.isConnected()) {
309 ServerPlugin.store.disconnect();
310 }
311 ServerPlugin.plugin = null;
312 }
313
314
315 public static ServerPlugin getPlugin() {
316 return ServerPlugin.plugin;
317 }
318
319 protected boolean registerDatabase() {
320 switch (StoreMode.getByName(Config.DATABASE_MODE)) {
321 case MYSQL: {
322 ServerPlugin.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);
323 break;
324 }
325 case SQLITE: {
326 ServerPlugin.store = new StoreSQLITE(Config.DATABASE_SQLITE_NAME, Config.DATABASE_TABLEPREFIX);
327 break;
328 }
329 default: {
330 Logger.warning("Value of databse mode is not valid! Using SQLITE as database!");
331 ServerPlugin.store = new StoreSQLITE(Config.DATABASE_SQLITE_NAME, Config.DATABASE_TABLEPREFIX);
332 break;
333 }
334 }
335 final boolean conn = ServerPlugin.store.connect();
336 if (conn) {
337 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}users` (" + ((ServerPlugin.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, `wykstone` int(11) NOT NULL, `logout` int(11) NOT NULL, `kox` int(11) NOT NULL, `koxeat` int(11) NOT NULL, `refil` int(11) NOT NULL, `refileat` int(11) NOT NULL, `perly` int(11) NOT NULL, `perlycyk` int(11) NOT NULL, `strzaly` int(11) NOT NULL, `caseopen` text NOT NULL, `jajopen` int(11) NOT NULL, `zdrapkaopen` int(11) NOT NULL, `cobblexopen` int(11) NOT NULL, `join` int(11) NOT NULL, `time` bigint(22) NOT NULL, `timelast` bigint(22) 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);");
338 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}guilds` (" + ((ServerPlugin.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, `description` varchar(64) 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, `hp` int(11) NOT NULL, " + "`hpLastAttack` bigint(22) 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, `sojusz` int(11) NOT NULL, `coins` int(11) NOT NULL, `kills` int(11) NOT NULL, `deaths` int(11) NOT NULL, `turboDrop` bigint(22) NOT NULL, `turboExp` bigint(22) NOT NULL, `exp` int(11) NOT NULL, `pvpAlly` int(1) NOT NULL);");
339 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}members` (" + ((ServerPlugin.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);");
340 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}bans` (" + ((ServerPlugin.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);");
341 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}bansip` (" + ((ServerPlugin.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);");
342 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}mutes` (" + ((ServerPlugin.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);");
343 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}backups` (" + ((ServerPlugin.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);");
344 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}warp` (" + ((ServerPlugin.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, `pex` varchar(32) NOT NULL NOT NULL);");
345 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}deathbans` (" + ((ServerPlugin.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);");
346 ServerPlugin.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}sejfs` (" + ((ServerPlugin.store.getStoreMode() == StoreMode.MYSQL) ? "`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT," : "`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,") + "`owner` varchar(32) NOT NULL, `opis` varchar(32) NOT NULL, `itemy` text NOT NULL);");
347 return conn;
348 }
349 return conn;
350 }
351
352 public static void registerCommand(final Command command) {
353 CommandManager.register(command);
354 }
355
356 public static void registerListener(final Plugin plugin, final Listener... listeners) {
357 if (ServerPlugin.pluginManager == null) {
358 ServerPlugin.pluginManager = Bukkit.getPluginManager();
359 }
360 for (final Listener listener : listeners) {
361 ServerPlugin.pluginManager.registerEvents(listener, plugin);
362 }
363 }
364
365 public static Store getStore() {
366 return ServerPlugin.store;
367 }
368
369 public static void registerCommand() {
370 registerCommand(new AEventCommand());
371 registerCommand(new ListCommand());
372 registerCommand(new RankingCommand());
373 registerCommand(new GodCommand());
374 registerCommand(new BanIPCommand());
375 registerCommand(new BanCommand());
376 registerCommand(new UnBanCommand());
377 registerCommand(new MoreCommand());
378 registerCommand(new UnBanIpCommand());
379 registerCommand(new ChatCommand());
380 registerCommand(new GamemodeCommand());
381 registerCommand(new FlyCommand());
382 registerCommand(new SpawnCommand());
383 registerCommand(new SetSpawnCommand());
384 registerCommand(new KitCommand());
385 registerCommand(new TpacceptCommand());
386 registerCommand(new TpdenyCommmand());
387 registerCommand(new ClearCommand());
388 registerCommand(new EnchantCommand());
389 registerCommand(new GcCommand());
390 registerCommand(new ItemCommand());
391 registerCommand(new GiveCommand());
392 registerCommand(new HealCommand());
393 registerCommand(new HelpOpCommand());
394 registerCommand(new HomeCommand());
395 registerCommand(new KickAllCommand());
396 registerCommand(new KickCommand());
397 registerCommand(new SetHomeCommand());
398 registerCommand(new RepairCommand());
399 registerCommand(new ResetRankingCommand());
400 registerCommand(new TellCommand());
401 registerCommand(new ReplyCommand());
402 registerCommand(new SlotCommand());
403 registerCommand(new SlowmodeCommand());
404 registerCommand(new StpCommand());
405 registerCommand(new VipCommand());
406 registerCommand(new SVipCommand());
407 registerCommand(new MVipCommand());
408 registerCommand(new YouTubeCommand());
409 registerCommand(new CraftCommand());
410 registerCommand(new SmietnikCommand());
411 registerCommand(new BroadcastCommand());
412 registerCommand(new BroadcastTitleCommand());
413 registerCommand(new TpaCommand());
414 registerCommand(new WhiteListCommand());
415 registerCommand(new SchowekCommand());
416 registerCommand(new StoneCommand());
417 registerCommand(new NaprawKilofCommand());
418 registerCommand(new TeleportCommand());
419 registerCommand(new BackupCommand());
420 registerCommand(new RenameCommand());
421 registerCommand(new IsCommand());
422 registerCommand(new MarmurCommand());
423 registerCommand(new WorkBenchCommand());
424 registerCommand(new SpeedCommand());
425 registerCommand(new LevelCommand());
426 registerCommand(new TurboCommand());
427 registerCommand(new EnableCommand());
428 registerCommand(new ItemkiCommand());
429 registerCommand(new StatsCommand());
430 registerCommand(new GuildItemCommand());
431 registerCommand(new NagrodaCommand());
432 registerCommand(new HcCommand());
433 registerCommand(new DayCommand());
434 registerCommand(new NightCommand());
435 registerCommand(new NetherCommand());
436 registerCommand(new EnderchestCommand());
437 registerCommand(new ConfigCommand());
438 registerCommand(new ClearEnderchestCommand());
439 registerCommand(new GuildAdminCommand());
440 registerCommand(new AllyCommand());
441 registerCommand(new CreateCommand());
442 registerCommand(new DeleteCommand());
443 registerCommand(new EnlargeCommand());
444 registerCommand(new GuildSetHomeCommand());
445 registerCommand(new EfektyCommand());
446 registerCommand(new GuildHomeCommand());
447 registerCommand(new DcCommand());
448 registerCommand(new InfoCommand());
449 registerCommand(new InviteCommand());
450 registerCommand(new AntyCheatCommand());
451 registerCommand(new JoinCommand());
452 registerCommand(new pl.karas.api.commands.guild.KickCommand());
453 registerCommand(new pl.karas.api.commands.guild.ItemCommand());
454 registerCommand(new LeaderCommand());
455 registerCommand(new OwnerCommand());
456 registerCommand(new ProlongCommand());
457 registerCommand(new PvpCommand());
458 registerCommand(new AutoMsgCommand());
459 registerCommand(new LeaveCommand());
460 registerCommand(new HelpCommand());
461 registerCommand(new GuildHelpCommand());
462 registerCommand(new GiveYTCommand());
463 registerCommand(new PaczkaCommand());
464 registerCommand(new ANagrodaCommand());
465 registerCommand(new InvCommand());
466 registerCommand(new DiscoCommand());
467 registerCommand(new BorderCommand());
468 registerCommand(new SklepCommand());
469 registerCommand(new OtchlanCommand());
470 registerCommand(new WiadomosciCommand());
471 registerCommand(new IgnoreCommand());
472 registerCommand(new PayCommand());
473 registerCommand(new WymianaCommand());
474 registerCommand(new MuteCommand());
475 registerCommand(new SetWarpCommand());
476 registerCommand(new KsiazkiCommand());
477 registerCommand(new WarpCommand());
478 registerCommand(new UnMuteCommand());
479 registerCommand(new VoucherCommand());
480 registerCommand(new GuildManageCommand());
481 registerCommand(new StatystykiCommand());
482 registerCommand(new BlokiCommand());
483 registerCommand(new ZnakiCommand());
484 }
485
486 public void registerTasks() {
487 new CheckValidityTask().runTaskTimer((Plugin)this, 2400L, 2400L);
488 new CombatTask().runTaskTimerAsynchronously((Plugin)this, 40L, 20L);
489 new LimitTask().runTaskTimer((Plugin)this, 200L, 200L);
490 new AutoMsgTask().runTaskTimerAsynchronously((Plugin)this, 1200L, 1200L);
491 new TabFreshRunnable().runTaskTimerAsynchronously((Plugin)this, 500L, 500L);
492 Bukkit.getScheduler().runTaskTimer((Plugin) this,
493 (Runnable) new DiscoTask(), 20L, 10L);
494 new AbbysTask();
495 AbbysTask.startTask();
496 }
497
498 public void registerManager() {
499 DropFile.saveDefaultConfig();
500 DropManager.setup();
501 UserManager.loadUsers();
502 GuildManager.loadGuilds();
503 BanManager.loadBans();
504 BanIPManager.loadBans();
505 MuteManager.loadMutes();
506 WarpManager.loadWarp();
507 }
508
509 private void initTab() {
510 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new PointsVariable("points"));
511 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new KillsVariable("kills"));
512 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new DeathsVariable("deaths"));
513 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new AssistsVariable("assists"));
514 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new KDVariable("kd"));
515 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new LvlVariable("lvl"));
516 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new CoinsVariable("coins"));
517 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new WykopanyStoneVariable("stone"));
518 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildVariable("guild"));
519 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildPointsVariable("gpoints"));
520 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildKillsVariable("gkills"));
521 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildDeathsVariable("gdeaths"));
522 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildHpVariable("ghp"));
523 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildKdVariable("gkd"));
524 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new GuildOnlineVartible("gonline"));
525
526 for (int i = 1; i < 16; ++i) {
527 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new TopPointsVariable("pointstop" + i, i));
528 }
529 for (int i = 1; i < 16; ++i) {
530 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new TopKillsVariable("killstop" + i, i));
531 }
532 for (int i = 1; i < 16; ++i) {
533 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new TopDeathsVariable("deathstop" + i, i));
534 }
535 for (int i = 1; i < 16; ++i) {
536 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new TopAssistsVariable("assiststop" + i, i));
537 }
538 for (int i = 1; i < 16; ++i) {
539 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new TopCoinsVariable("coinsstop" + i, i));
540 }
541 for (int i = 1; i < 16; ++i) {
542 BungeeTabListPlusBukkitAPI.registerVariable((Plugin)this, (Variable)new TopGuildPointsVariable("gpointstop" + i, i));
543 }
544 }
545
546 private void unTab() {
547 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new PointsVariable("points"));
548 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new KillsVariable("kills"));
549 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new DeathsVariable("deaths"));
550 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new AssistsVariable("assists"));
551 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new KDVariable("kd"));
552 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new LvlVariable("lvl"));
553 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new CoinsVariable("coins"));
554 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new WykopanyStoneVariable("stone"));
555 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new GuildVariable("guild"));
556 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new GuildPointsVariable("gpoints"));
557 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new GuildKillsVariable("gkills"));
558 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new GuildDeathsVariable("gdeaths"));
559 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new GuildHpVariable("ghp"));
560 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new GuildKdVariable("gkd"));
561 for (int i = 1; i < 16; ++i) {
562 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new TopPointsVariable("pointstop" + i, i));
563 }
564 for (int i = 1; i < 16; ++i) {
565 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new TopKillsVariable("killstop" + i, i));
566 }
567 for (int i = 1; i < 16; ++i) {
568 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new TopDeathsVariable("deathstop" + i, i));
569 }
570 for (int i = 1; i < 16; ++i) {
571 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new TopAssistsVariable("assiststop" + i, i));
572 }
573 for (int i = 1; i < 16; ++i) {
574 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new TopCoinsVariable("coinsstop" + i, i));
575 }
576 for (int i = 1; i < 16; ++i) {
577 BungeeTabListPlusBukkitAPI.unregisterVariable((Variable)new TopGuildPointsVariable("gpointstop" + i, i));
578 }
579 }
580
581 public void registerListener() {
582 registerListener((Plugin)this, new InventoryClickListener(),new KilofListener(), new EnderChestListener(),new CustomEnchantInventoryListener(),new ToggleListener(), new PlayerInteraktListener(), new InventoryDiscoListener(),new BlockDebilListener(),new RedstoneListener(), new EntityDiscoListener(), new PlayerCommandPreprocessListener(),new KoxBlockedListener(), new AntiLagListener(), new WymianaListener(), new PlayerQuitJoinListener(), new EfektyListener(), new PlayerJoinListener(), new TimerManager(), new AsyncPlayerChatListener(), new BlockListener(), new FarmeryListener(), new ChatGuildsListener(), new PlayerMoveListener(), new GrupoweListener(), new BlockBreakListener(), new BlockPlaceListener(), new PlayerBucketEmptyListener(), new PlayerBucketFillListener(), new GuildExplodeListener(), new EntityDamageByEntityListener(), new EntityDamageListener(), new PlayerDeathListener(), new InCommbatInGuildListener(), new TakeCrystalListener(), new CheckLoginListener(), new Nether(), new BoyListener(), new EnchantItemListener(), new PlayerInteractListener(), new PunchPotyListener(), new DropBlockBreakListener(), new EntityDeathListener(), new BorderMapListener(), new RainStartListener(), new TntEvent(), new TntDamage(), new BlokowanieListener(), new EventyListener(), new BorderBreakListener(), new BorderPlaceListener(), new BlockCraftingListener(), new InventoryListener(), new OpenInventoryListener(), new SignChangeListener(), new MarmurListener());
583 }
584}