· 8 years ago · Mar 04, 2018, 03:26 PM
1package net.ernioo.core;
2
3import org.bukkit.Bukkit;
4import org.bukkit.World;
5import org.bukkit.entity.Player;
6import org.bukkit.event.Listener;
7import org.bukkit.plugin.Plugin;
8import org.bukkit.plugin.PluginDescriptionFile;
9import org.bukkit.plugin.PluginManager;
10import org.bukkit.plugin.java.JavaPlugin;
11
12import codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI;
13import net.ernioo.core.commands.Command;
14import net.ernioo.core.commands.CommandManager;
15import net.ernioo.core.commands.guild.AllyCommand;
16import net.ernioo.core.commands.guild.CreateCommand;
17import net.ernioo.core.commands.guild.DeleteCommand;
18import net.ernioo.core.commands.guild.DescriptionCommand;
19import net.ernioo.core.commands.guild.EnlargeCommand;
20import net.ernioo.core.commands.guild.GuildAdminCommand;
21import net.ernioo.core.commands.guild.GuildHelpCommand;
22import net.ernioo.core.commands.guild.GuildHomeCommand;
23import net.ernioo.core.commands.guild.GuildSetHomeCommand;
24import net.ernioo.core.commands.guild.InfoCommand;
25import net.ernioo.core.commands.guild.InviteCommand;
26import net.ernioo.core.commands.guild.ItemsCommand;
27import net.ernioo.core.commands.guild.JoinCommand;
28import net.ernioo.core.commands.guild.LeaderCommand;
29import net.ernioo.core.commands.guild.LeaveCommand;
30import net.ernioo.core.commands.guild.OwnerCommand;
31import net.ernioo.core.commands.guild.ProlongCommand;
32import net.ernioo.core.commands.guild.PvpCommand;
33import net.ernioo.core.commands.user.AutoMessageCommand;
34import net.ernioo.core.commands.user.BackupCommand;
35import net.ernioo.core.commands.user.BanCommand;
36import net.ernioo.core.commands.user.BanIPCommand;
37import net.ernioo.core.commands.user.BroadcastCommand;
38import net.ernioo.core.commands.user.ChatCommand;
39import net.ernioo.core.commands.user.ClearCommand;
40import net.ernioo.core.commands.user.ClearEnderchestCommand;
41import net.ernioo.core.commands.user.CobblexCommand;
42import net.ernioo.core.commands.user.CraftingsCommand;
43import net.ernioo.core.commands.user.DayCommand;
44import net.ernioo.core.commands.user.EggCommand;
45import net.ernioo.core.commands.user.EnchantCommand;
46import net.ernioo.core.commands.user.EnderchestCommand;
47import net.ernioo.core.commands.user.FlyCommand;
48import net.ernioo.core.commands.user.GamemodeCommand;
49import net.ernioo.core.commands.user.GcCommand;
50import net.ernioo.core.commands.user.GiveCommand;
51import net.ernioo.core.commands.user.GodCommand;
52import net.ernioo.core.commands.user.GroupCommand;
53import net.ernioo.core.commands.user.HeadCommand;
54import net.ernioo.core.commands.user.HealCommand;
55import net.ernioo.core.commands.user.HelpCommand;
56import net.ernioo.core.commands.user.HelpOpCommand;
57import net.ernioo.core.commands.user.BCTitleCommand;
58import net.ernioo.core.commands.user.CzasCCommand;
59import net.ernioo.core.commands.user.HomeCommand;
60import net.ernioo.core.commands.user.IgnoreCommand;
61import net.ernioo.core.commands.user.ItemCommand;
62import net.ernioo.core.commands.user.ItemshopCommand;
63import net.ernioo.core.commands.user.KickAllCommand;
64import net.ernioo.core.commands.user.KitCommand;
65import net.ernioo.core.commands.user.ListCommand;
66import net.ernioo.core.commands.user.ManageCommand;
67import net.ernioo.core.commands.user.MessagesCommand;
68import net.ernioo.core.commands.user.MuteCommand;
69import net.ernioo.core.commands.user.NightCommand;
70import net.ernioo.core.commands.user.PayCommand;
71import net.ernioo.core.commands.user.PlayerInfoCommand;
72import net.ernioo.core.commands.user.RenameCommand;
73import net.ernioo.core.commands.user.RepairCommand;
74import net.ernioo.core.commands.user.ReplyCommand;
75import net.ernioo.core.commands.user.ScratchCommand;
76import net.ernioo.core.commands.user.SetHomeCommand;
77import net.ernioo.core.commands.user.SetSpawnCommand;
78import net.ernioo.core.commands.user.ShopCommand;
79import net.ernioo.core.commands.user.SlotCommand;
80import net.ernioo.core.commands.user.SpawnCommand;
81import net.ernioo.core.commands.user.SpeedCommand;
82import net.ernioo.core.commands.user.SsCommand;
83import net.ernioo.core.commands.user.StatsCommand;
84import net.ernioo.core.commands.user.StoneCommand;
85import net.ernioo.core.commands.user.StpCommand;
86import net.ernioo.core.commands.user.StreamerCommand;
87import net.ernioo.core.commands.user.TeleportCommand;
88import net.ernioo.core.commands.user.TellCommand;
89import net.ernioo.core.commands.user.TopCommand;
90import net.ernioo.core.commands.user.TpaCommand;
91import net.ernioo.core.commands.user.TpacceptCommand;
92import net.ernioo.core.commands.user.TpdenyCommmand;
93import net.ernioo.core.commands.user.TurboCommand;
94import net.ernioo.core.commands.user.UnBanCommand;
95import net.ernioo.core.commands.user.UnBanIpCommand;
96import net.ernioo.core.commands.user.UnLagCommand;
97import net.ernioo.core.commands.user.UnMuteCommand;
98import net.ernioo.core.commands.user.VanishCommand;
99import net.ernioo.core.commands.user.VipCommand;
100import net.ernioo.core.commands.user.WhiteListCommand;
101import net.ernioo.core.commands.user.WhoIsCommand;
102import net.ernioo.core.commands.user.WorkBenchCommand;
103import net.ernioo.core.commands.user.YouTuberCommand;
104import net.ernioo.core.configuration.CommandsGuilds;
105import net.ernioo.core.configuration.CommandsTools;
106import net.ernioo.core.configuration.Messages;
107import net.ernioo.core.configuration.Settings;
108import net.ernioo.core.listeners.bukkit.block.BlockBreakListener;
109import net.ernioo.core.listeners.bukkit.block.BlockFromToListener;
110import net.ernioo.core.listeners.bukkit.block.BlockPlaceListener;
111import net.ernioo.core.listeners.bukkit.block.CobblexListener;
112import net.ernioo.core.listeners.bukkit.block.DropBlockBreakListener;
113import net.ernioo.core.listeners.bukkit.block.GeneratorsListener;
114import net.ernioo.core.listeners.bukkit.block.PlayerBucketEmptyListener;
115import net.ernioo.core.listeners.bukkit.block.PlayerBucketFillListener;
116import net.ernioo.core.listeners.bukkit.entity.EntityDamageByEntityListener;
117import net.ernioo.core.listeners.bukkit.entity.EntityDamageListener;
118import net.ernioo.core.listeners.bukkit.entity.EntityDeathListener;
119import net.ernioo.core.listeners.bukkit.entity.GuildExplodeListener;
120import net.ernioo.core.listeners.bukkit.entity.TimerListener;
121import net.ernioo.core.listeners.bukkit.inventory.InventoryListener;
122import net.ernioo.core.listeners.bukkit.inventory.InventoryOpenListener;
123import net.ernioo.core.listeners.bukkit.other.InCommbatInGuildListener;
124import net.ernioo.core.listeners.bukkit.other.PunchPotyListener;
125import net.ernioo.core.listeners.bukkit.other.TakeCrystalListener;
126import net.ernioo.core.listeners.bukkit.player.AsyncPlayerChatListener;
127import net.ernioo.core.listeners.bukkit.player.PlayerDeathListener;
128import net.ernioo.core.listeners.bukkit.player.PlayerInteractListener;
129import net.ernioo.core.listeners.bukkit.player.PlayerJoinListener;
130import net.ernioo.core.listeners.bukkit.player.PlayerLoginListener;
131import net.ernioo.core.listeners.bukkit.player.PlayerMoveListener;
132import net.ernioo.core.listeners.bukkit.player.PlayerQuitJoinListener;
133import net.ernioo.core.listeners.bukkit.sign.SignChangeListener;
134import net.ernioo.core.managers.AntiLogoutManager;
135import net.ernioo.core.managers.BanIPManager;
136import net.ernioo.core.managers.BanManager;
137import net.ernioo.core.managers.DeathBanManager;
138import net.ernioo.core.managers.DropFile;
139import net.ernioo.core.managers.DropManager;
140import net.ernioo.core.managers.GuildManager;
141import net.ernioo.core.managers.MuteManager;
142import net.ernioo.core.managers.NameTagManager;
143import net.ernioo.core.managers.UserManager;
144import net.ernioo.core.menus.CraftingsMenu;
145import net.ernioo.core.objects.AntiLogout;
146import net.ernioo.core.storage.Store;
147import net.ernioo.core.storage.modes.StoreMode;
148import net.ernioo.core.storage.modes.mysql.StoreMySQL;
149import net.ernioo.core.storage.modes.sqlite.StoreSQLITE;
150import net.ernioo.core.tablist.variable.guild.GuildDeathsVariable;
151import net.ernioo.core.tablist.variable.guild.GuildHpVariable;
152import net.ernioo.core.tablist.variable.guild.GuildKillsVariable;
153import net.ernioo.core.tablist.variable.guild.GuildLeaderVariable;
154import net.ernioo.core.tablist.variable.guild.GuildOwnerVariable;
155import net.ernioo.core.tablist.variable.guild.GuildPointsVariable;
156import net.ernioo.core.tablist.variable.guild.GuildProlongVariable;
157import net.ernioo.core.tablist.variable.guild.GuildSizeVariable;
158import net.ernioo.core.tablist.variable.guild.GuildVariable;
159import net.ernioo.core.tablist.variable.tops.TopAssistsVariable;
160import net.ernioo.core.tablist.variable.tops.TopCoinsVariable;
161import net.ernioo.core.tablist.variable.tops.TopDeathsVariable;
162import net.ernioo.core.tablist.variable.tops.TopGuildDeathsVariable;
163import net.ernioo.core.tablist.variable.tops.TopGuildKillsVariable;
164import net.ernioo.core.tablist.variable.tops.TopGuildPointsVariable;
165import net.ernioo.core.tablist.variable.tops.TopKillsVariable;
166import net.ernioo.core.tablist.variable.tops.TopPointsVariable;
167import net.ernioo.core.tablist.variable.user.AssistsVariable;
168import net.ernioo.core.tablist.variable.user.CoinsVariable;
169import net.ernioo.core.tablist.variable.user.DeathsVariable;
170import net.ernioo.core.tablist.variable.user.KillsVariable;
171import net.ernioo.core.tablist.variable.user.LogoutsVariable;
172import net.ernioo.core.tablist.variable.user.LvlVariable;
173import net.ernioo.core.tablist.variable.user.PointsVariable;
174import net.ernioo.core.utils.BlockUtil;
175import net.ernioo.core.utils.Logger;
176import net.ernioo.core.utils.Ticking;
177import net.ernioo.core.utils.tasks.AntilogoutTask;
178import net.ernioo.core.utils.tasks.AutoMessageTask;
179import net.ernioo.core.utils.tasks.CheckValidityTask;
180import net.ernioo.core.utils.tasks.LimitTask;
181import net.ernioo.magiccase.commands.CaseCommand;
182import net.ernioo.magiccase.listeners.CaseDropListener;
183import net.ernioo.magiccase.listeners.CaseKickQuitListener;
184import net.ernioo.magiccase.listeners.CasePlaceListener;
185
186public class CorePlugin extends JavaPlugin {
187 private static CorePlugin instance;
188 private static CorePlugin plugin;
189 private static PluginManager pluginManager;
190 private static Store store;
191
192 public static CorePlugin getInstance() {
193 return instance;
194 }
195
196 public static CorePlugin getPlugin() {
197 return CorePlugin.plugin;
198
199 }
200
201 public static Store getStore() {
202 return CorePlugin.store;
203 }
204
205 public static void registerCommand() {
206 Logger.info("Ladowanie komend...");
207 final long start = System.currentTimeMillis();
208 CorePlugin.registerCommand(new ListCommand());
209 CorePlugin.registerCommand(new PlayerInfoCommand());
210 CorePlugin.registerCommand(new GodCommand());
211 CorePlugin.registerCommand(new BanCommand());
212 CorePlugin.registerCommand(new UnBanCommand());
213 CorePlugin.registerCommand(new UnBanIpCommand());
214 CorePlugin.registerCommand(new ChatCommand());
215 CorePlugin.registerCommand(new GamemodeCommand());
216 CorePlugin.registerCommand(new FlyCommand());
217 CorePlugin.registerCommand(new SpawnCommand());
218 CorePlugin.registerCommand(new SetSpawnCommand());
219 CorePlugin.registerCommand(new KitCommand());
220 CorePlugin.registerCommand(new TpacceptCommand());
221 CorePlugin.registerCommand(new TpdenyCommmand());
222 CorePlugin.registerCommand(new TpaCommand());
223 CorePlugin.registerCommand(new ClearCommand());
224 CorePlugin.registerCommand(new EnchantCommand());
225 CorePlugin.registerCommand(new GcCommand());
226 CorePlugin.registerCommand(new ItemCommand());
227 CorePlugin.registerCommand(new GiveCommand());
228 CorePlugin.registerCommand(new GroupCommand());
229 CorePlugin.registerCommand(new HeadCommand());
230 CorePlugin.registerCommand(new IgnoreCommand());
231 CorePlugin.registerCommand(new HealCommand());
232 CorePlugin.registerCommand(new HelpOpCommand());
233 CorePlugin.registerCommand(new HomeCommand());
234 CorePlugin.registerCommand(new KickAllCommand());
235 CorePlugin.registerCommand(new net.ernioo.core.commands.user.KickCommand());
236 CorePlugin.registerCommand(new ListCommand());
237 CorePlugin.registerCommand(new SetHomeCommand());
238 CorePlugin.registerCommand(new VanishCommand());
239 CorePlugin.registerCommand(new RepairCommand());
240 CorePlugin.registerCommand(new TellCommand());
241 CorePlugin.registerCommand(new ReplyCommand());
242 CorePlugin.registerCommand(new SlotCommand());
243 CorePlugin.registerCommand(new StpCommand());
244 CorePlugin.registerCommand(new StreamerCommand());
245 CorePlugin.registerCommand(new VipCommand());
246 CorePlugin.registerCommand(new YouTuberCommand());
247 CorePlugin.registerCommand(new CraftingsCommand());
248 CorePlugin.registerCommand(new BroadcastCommand());
249 CorePlugin.registerCommand(new TpaCommand());
250 CorePlugin.registerCommand(new WhiteListCommand());
251 CorePlugin.registerCommand(new WhoIsCommand());
252 CorePlugin.registerCommand(new StoneCommand());
253 CorePlugin.registerCommand(new TeleportCommand());
254 CorePlugin.registerCommand(new BackupCommand());
255 CorePlugin.registerCommand(new SsCommand());
256 CorePlugin.registerCommand(new MessagesCommand());
257 CorePlugin.registerCommand(new BanIPCommand());
258 CorePlugin.registerCommand(new ScratchCommand());
259 CorePlugin.registerCommand(new RenameCommand());
260 CorePlugin.registerCommand(new ItemshopCommand());
261 CorePlugin.registerCommand(new UnMuteCommand());
262 CorePlugin.registerCommand(new CobblexCommand());
263 CorePlugin.registerCommand(new WorkBenchCommand());
264 CorePlugin.registerCommand(new EnderchestCommand());
265 CorePlugin.registerCommand(new SpeedCommand());
266 CorePlugin.registerCommand(new TurboCommand());
267 CorePlugin.registerCommand(new StatsCommand());
268 CorePlugin.registerCommand(new CaseCommand());
269 CorePlugin.registerCommand(new CobblexCommand());
270 CorePlugin.registerCommand(new DayCommand());
271 CorePlugin.registerCommand(new TopCommand());
272 CorePlugin.registerCommand(new MuteCommand());
273 CorePlugin.registerCommand(new BCTitleCommand());
274 CorePlugin.registerCommand(new CzasCCommand());
275 CorePlugin.registerCommand(new PayCommand());
276 if (Settings.COST_SHOP_ENABLE) {
277 CorePlugin.registerCommand(new ShopCommand());
278 }
279 CorePlugin.registerCommand(new NightCommand());
280 CorePlugin.registerCommand(new ManageCommand());
281 CorePlugin.registerCommand(new ClearEnderchestCommand());
282 CorePlugin.registerCommand(new GuildAdminCommand());
283 CorePlugin.registerCommand(new AllyCommand());
284 CorePlugin.registerCommand(new CreateCommand());
285 CorePlugin.registerCommand(new DeleteCommand());
286 CorePlugin.registerCommand(new EnlargeCommand());
287 CorePlugin.registerCommand(new GuildSetHomeCommand());
288 CorePlugin.registerCommand(new GuildHomeCommand());
289 CorePlugin.registerCommand(new InfoCommand());
290 CorePlugin.registerCommand(new InviteCommand());
291 CorePlugin.registerCommand(new ItemsCommand());
292 CorePlugin.registerCommand(new DescriptionCommand());
293 CorePlugin.registerCommand(new JoinCommand());
294 CorePlugin.registerCommand(new net.ernioo.core.commands.guild.KickCommand());
295 CorePlugin.registerCommand(new LeaderCommand());
296 CorePlugin.registerCommand(new OwnerCommand());
297 CorePlugin.registerCommand(new ProlongCommand());
298 CorePlugin.registerCommand(new PvpCommand());
299 CorePlugin.registerCommand(new AutoMessageCommand());
300 CorePlugin.registerCommand(new LeaveCommand());
301 CorePlugin.registerCommand(new HelpCommand());
302 CorePlugin.registerCommand(new GuildHelpCommand());
303 CorePlugin.registerCommand(new EggCommand());
304 CorePlugin.registerCommand(new UnLagCommand());
305 Logger.info("Zaladowano komendy w " + (System.currentTimeMillis() - start) + "ms.");
306 }
307
308 public static void registerCommand(final Command command) {
309 CommandManager.register(command);
310 }
311
312 public static void registerListener(final Plugin plugin, final Listener... listeners) {
313 if (CorePlugin.pluginManager == null) {
314 CorePlugin.pluginManager = Bukkit.getPluginManager();
315 }
316 for (final Listener listener : listeners) {
317 CorePlugin.pluginManager.registerEvents(listener, plugin);
318 }
319 }
320
321 private void initTab() {
322 Logger.info("Ladowanie zmiennych (BungeeTabListPlus)...");
323 final long start = System.currentTimeMillis();
324
325 BungeeTabListPlusBukkitAPI.registerVariable(this, new PointsVariable("points"));
326 BungeeTabListPlusBukkitAPI.registerVariable(this, new KillsVariable("kills"));
327 BungeeTabListPlusBukkitAPI.registerVariable(this, new DeathsVariable("deaths"));
328 BungeeTabListPlusBukkitAPI.registerVariable(this, new AssistsVariable("assists"));
329 BungeeTabListPlusBukkitAPI.registerVariable(this, new LogoutsVariable("logouts"));
330 BungeeTabListPlusBukkitAPI.registerVariable(this, new CoinsVariable("coins"));
331 BungeeTabListPlusBukkitAPI.registerVariable(this, new LvlVariable("lvl"));
332
333 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildVariable("guild"));
334 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildProlongVariable("gprolong"));
335 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildPointsVariable("gpoints"));
336 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildKillsVariable("gkills"));
337 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildDeathsVariable("gdeaths"));
338 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildSizeVariable("gsize"));
339 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildHpVariable("ghp"));
340 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildOwnerVariable("gowner"));
341 BungeeTabListPlusBukkitAPI.registerVariable(this, new GuildLeaderVariable("gleader"));
342
343 for (int i = 1; i < 16; i++) {
344 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopPointsVariable("pointstop" + i, i));
345 }
346 for (int i = 1; i < 16; i++) {
347 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopKillsVariable("killstop" + i, i));
348 }
349 for (int i = 1; i < 16; i++) {
350 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopDeathsVariable("deathstop" + i, i));
351 }
352 for (int i = 1; i < 16; i++) {
353 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopAssistsVariable("assiststop" + i, i));
354 }
355 for (int i = 1; i < 16; i++) {
356 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopCoinsVariable("coinstop" + i, i));
357 }
358 for (int i = 1; i < 16; i++) {
359 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopGuildPointsVariable("gpointstop" + i, i));
360 }
361 for (int i = 1; i < 16; i++) {
362 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopGuildKillsVariable("gkillstop" + i, i));
363 }
364 for (int i = 1; i < 16; i++) {
365 BungeeTabListPlusBukkitAPI.registerVariable(this, new TopGuildDeathsVariable("gdeathstop" + i, i));
366 }
367 Logger.info("Zaladowano zmienne w " + (System.currentTimeMillis() - start) + "ms.");
368 }
369
370 public void onDisable() {
371 Bukkit.getScheduler().cancelTasks((Plugin) this);
372 for (final Player p : Bukkit.getOnlinePlayers()) {
373 AntiLogoutManager.removeCombat(p);
374 }
375 Bukkit.savePlayers();
376 for (final World w : Bukkit.getWorlds()) {
377 w.save();
378 }
379 try {
380 Thread.sleep(2000L);
381 } catch (final InterruptedException e) {
382 e.printStackTrace();
383 }
384 if (CorePlugin.store != null && CorePlugin.store.isConnected()) {
385 CorePlugin.store.disconnect();
386 }
387 CorePlugin.plugin = null;
388 }
389
390 public void onEnable() {
391 final long start = System.currentTimeMillis();
392
393 Logger.info("Inicjacja pluginu Core...");
394 CorePlugin.plugin = this;
395 instance = this;
396 initTab();
397 final PluginDescriptionFile pdf = getDescription();
398 if (!pdf.getAuthors().contains("ernioo")) {
399 Bukkit.getServer().getPluginManager().disablePlugin(this);
400 Logger.warning("Wykryto zmiane autora pluginu. Plugin zostaje wylaczony.");
401 return;
402 }
403 for (final Player p : Bukkit.getOnlinePlayers()) {
404 final AntiLogout c = AntiLogoutManager.getCombat(p);
405 if (c == null) {
406 AntiLogoutManager.createCombat(p);
407 }
408 }
409 new Ticking().start();
410 Settings.reloadConfig();
411 Messages.reloadLang();
412 CommandsTools.reloadCommandsTools();
413 CommandsGuilds.reloadCommandsGuilds();
414 registerDatabase();
415 registerOthers();
416 registerManager();
417 registerListener();
418 registerTasks();
419 registerCommand();
420 CraftingsMenu.registerRecipe();
421
422 Logger.info("Zaladowano plugin Core w " + (System.currentTimeMillis() - start) + "ms.");
423 }
424
425 public void onLoad() {
426 CorePlugin.plugin = this;
427 }
428
429 public boolean registerDatabase() {
430 switch (StoreMode.getByName(Settings.STORE_TYPE)) {
431 case MYSQL: {
432 CorePlugin.store = new StoreMySQL(Settings.STORE_MYSQL_HOST, Settings.STORE_MYSQL_PORT, Settings.STORE_MYSQL_USERNAME, Settings.STORE_MYSQL_PASSWORD, Settings.STORE_MYSQL_BASENAME, Settings.STORE_TABLE$PREFIX);
433 break;
434 }
435 case SQLITE: {
436 CorePlugin.store = new StoreSQLITE(Settings.STORE_SQLITE_BASENAME, Settings.STORE_TABLE$PREFIX);
437 break;
438 }
439 default: {
440 Logger.warning("Wartosc trybu bazy daych jest nieprawidlowa! Korzystam z bazy daych SQLite...");
441 CorePlugin.store = new StoreSQLITE(Settings.STORE_SQLITE_BASENAME, Settings.STORE_TABLE$PREFIX);
442 break;
443 }
444 }
445 final boolean conn = CorePlugin.store.connect();
446 if (conn) {
447 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, `kills` int(11) NOT NULL, `deaths` int(11) NOT NULL, `assists` int(11) NOT NULL, `logouts` int(11) NOT NULL, `coins` int(11) NOT NULL, `group` varchar(32) 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);");
448 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, `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, `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);");
449 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);");
450 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);");
451 store.update(true, "CREATE TABLE IF NOT EXISTS `{P}mutes` (" + (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);");
452 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);");
453 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);");
454 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);");
455 return conn;
456 }
457 return conn;
458 }
459
460 public void registerListener() {
461 Logger.info("Ladowanie listenerow...");
462 final long start = System.currentTimeMillis();
463 CorePlugin.registerListener((Plugin) this,
464
465 new BlockFromToListener(), new PlayerJoinListener(), new PlayerQuitJoinListener(), new PlayerDeathListener(), new PlayerMoveListener(), new PlayerInteractListener(), new PlayerBucketEmptyListener(), new PlayerBucketFillListener(), new DropBlockBreakListener(), new BlockBreakListener(), new BlockPlaceListener(), new net.ernioo.core.listeners.bukkit.inventory.InventoryClickListener(), new InventoryOpenListener(), new InventoryListener(), new EntityDamageByEntityListener(), new EntityDamageListener(), new EntityDeathListener(), new AsyncPlayerChatListener(), new GuildExplodeListener(), new InCommbatInGuildListener(), new TakeCrystalListener(), new PlayerLoginListener(), new GeneratorsListener(), new PunchPotyListener(), new CobblexListener(), new TimerListener(), new SignChangeListener(), new CaseDropListener(), new CasePlaceListener(), new CaseKickQuitListener(), new net.ernioo.magiccase.listeners.InventoryClickListener());
466
467 Logger.info("Zaladowano listenery w " + (System.currentTimeMillis() - start) + "ms.");
468 }
469
470 public void registerManager() {
471 Logger.info("Ladowanie managerow...");
472 final long start = System.currentTimeMillis();
473 NameTagManager.enable();
474 DropFile.saveDefaultConfig();
475 DropManager.setup();
476 UserManager.loadUsers();
477 GuildManager.loadGuilds();
478 MuteManager.loadMutes();
479 BanManager.loadBans();
480 BanIPManager.loadBans();
481 DeathBanManager.loadDeathsBans();
482 Logger.info("Zaladowano managery w " + (System.currentTimeMillis() - start) + "ms.");
483 }
484
485 public void registerOthers() {
486 Logger.info("Ladowanie wyrzymalosci blokow...");
487 final long start = System.currentTimeMillis();
488 if (Settings.TNT_DURABILITY_ENABLED) {
489 for (final String s : Settings.TNT_DURABILITY_BLOCKS) {
490 BlockUtil.setDurability(s.split(" ")[0], Float.parseFloat(s.split(" ")[1]));
491 }
492 }
493 Logger.info("Zaladowano wytrzymalosc blokow w " + (System.currentTimeMillis() - start) + "ms.");
494 }
495
496 public void registerTasks() {
497 Logger.info("Ladowanie taskow...");
498 final long start = System.currentTimeMillis();
499 new CheckValidityTask().runTaskTimer((Plugin) this, 2400L, 2400L);
500 new AntilogoutTask().runTaskTimerAsynchronously((Plugin) this, 40L, 20L);
501 new LimitTask().runTaskTimer((Plugin) this, 300L, 300L);
502 new AutoMessageTask().runTaskTimerAsynchronously(this, 1200L, 1200L);
503 // new LicenseSystem().runTaskTimer(this, 0L, 20*60*5L );
504 Logger.info("Zaladowano taski w " + (System.currentTimeMillis() - start) + "ms.");
505 }
506}