· 6 years ago · Jan 28, 2020, 03:46 PM
1package pl.kraftowany.tools;
2
3import org.bukkit.plugin.java.*;
4
5import pl.kraftowany.mysql.*;
6import pl.kraftowany.tools.utils.*;
7
8import org.bukkit.*;
9import org.bukkit.event.*;
10import org.bukkit.plugin.*;
11import pl.kraftowany.tools.tasks.*;
12import pl.kraftowany.tools.recipes.*;
13import pl.kraftowany.tools.commands.*;
14import org.bukkit.command.*;
15import pl.kraftowany.tools.listeners.*;
16import pl.kraftowany.mysql.modes.*;
17import pl.kraftowany.tools.configuration.*;
18import pl.kraftowany.tools.managers.*;
19
20public class Main extends JavaPlugin
21{
22
23 public static Main plugin;
24 public static Store store;
25 public static Main inst;
26
27 public static Main getPlugin() {
28 return Main.plugin;
29 }
30 public Main() {
31 Main.plugin = this;
32 }
33
34 public static Store getStore() {
35 return Main.store;
36 }
37
38 public void onEnable() {
39 Logger.info("WINTERPACK v1.4");
40 (Main.inst = this).saveDefaultConfig();
41 ConfigManager.load();
42 this.getServer().getPluginManager().registerEvents((Listener)new PingListener(), (Plugin)this);
43 Bukkit.getPluginManager().registerEvents((Listener)new PlayerQuitJoinListener(), (Plugin)this);
44 Bukkit.getPluginManager().registerEvents((Listener)new ChatListener(), (Plugin)this);
45 Bukkit.getPluginManager().registerEvents((Listener)new SklepListener(), (Plugin)this);
46 Bukkit.getPluginManager().registerEvents((Listener)new EfektyListener(), (Plugin)this);
47 Bukkit.getPluginManager().registerEvents((Listener)new OnPlaceListener(), (Plugin)this);
48 Bukkit.getPluginManager().registerEvents((Listener)new CobblexListener(), (Plugin)this);
49 Bukkit.getPluginManager().registerEvents((Listener)new CraftDiamondListener(), (Plugin)this);
50 Bukkit.getPluginManager().registerEvents((Listener)new BlockedCommandListener(), (Plugin)this);
51 Bukkit.getPluginManager().registerEvents((Listener)new RzucaneTntListener(), (Plugin)this);
52 Bukkit.getPluginManager().registerEvents((Listener)new BoyFarmerListener(), (Plugin)this);
53 this.saveDefaultConfig();
54 SuperEventTask.start();
55 new AutoMsgTask().runTaskTimerAsynchronously((Plugin)this, 1200L, 1200L);
56 new CobblexCommand(this);
57 new EnderchestCommand(this);
58 new KickCommand(this);
59 new ACoinsCommand(this);
60 new CraftingCommand(this);
61 new MsgCommand(this);
62 new IsCommand(this);
63 new PrzelewCommand(this);
64 new WorkbenchCommand(this);
65 new WinterPackCommand(this);
66 new EnchantCommand(this);
67 new YTDajCommand(this);
68 new AutoMsgCommand(this);
69 new RepairCommand(this);
70 new RainCommand(this);
71 new SunCommand(this);
72 new CoinsCommand(this);
73 new NightCommand(this);
74 new DayCommand(this);
75 new SklepCommand(this);
76 new EfektyCommand(this);
77 new SpawnCommand(this);
78 new WinterCaseCommand(this);
79 new DiamondCraftCommand(this);
80 new LiveCommand(this);
81 new ClearCommand(this);
82 new FlyCommand(this);
83 new WhoisCommand(this);
84 new VanishCommand(this);
85 new TPCommand(this);
86 new SuperEventCommand(this);
87 new GameModeCommand(this);
88 new AdropCommand(this);
89 new DropCommand(this);
90 new InvseeCommand(this);
91 new HealCommand(this);
92 new StpCommand(this);
93 new TPCommand(this);
94 new GodModeCommand(this);
95 new BroadCastCommand(this);
96 new ChatCommand(this);
97 new KoszCommand(this);
98 new HelpopCommand(this);
99 new KitCommand(this);
100 new SetspawnCommand(this);
101 new TpacceptCommand(this);
102 new TpaCommand(this);
103 new TpdenyCommand(this);
104 new SpeedCommand(this);
105 new SlotCommand(this);
106 new SetwarpCommand(this);
107 new WarpCommand(this);
108 new DelwarpCommand(this);
109 new SethomeCommand(this);
110 new HomeComamnd(this);
111 this.registerDatabase();
112 this.registerManager();
113 this.getCommand("vanish").setExecutor((CommandExecutor)new VanishCommand(this));
114 this.getCommand("god").setExecutor((CommandExecutor)new GodModeCommand(this));
115 this.getCommand("msg").setExecutor((CommandExecutor)new MsgCommand(this));
116 this.getCommand("kick").setExecutor((CommandExecutor)new KickCommand(this));
117 this.getCommand("kosz").setExecutor((CommandExecutor)new KoszCommand(this));
118 this.getCommand("enderchest").setExecutor((CommandExecutor)new EnderchestCommand(this));
119 this.getCommand("day").setExecutor((CommandExecutor)new DayCommand(this));
120 this.getCommand("coins").setExecutor((CommandExecutor)new CoinsCommand(this));
121 this.getCommand("sun").setExecutor((CommandExecutor)new SunCommand(this));
122 this.getCommand("winterpack").setExecutor((CommandExecutor)new WinterPackCommand(this));
123 this.getCommand("workbench").setExecutor((CommandExecutor)new WorkbenchCommand(this));
124 this.getCommand("rain").setExecutor((CommandExecutor)new RainCommand(this));
125 this.getCommand("night").setExecutor((CommandExecutor)new NightCommand(this));
126 this.getCommand("sklep").setExecutor((CommandExecutor)new SklepCommand(this));
127 this.getCommand("efekty").setExecutor((CommandExecutor)new EfektyCommand(this));
128 this.getCommand("wintercase").setExecutor((CommandExecutor)new WinterCaseCommand(this));
129 this.getCommand("gm").setExecutor((CommandExecutor)new GameModeCommand(this));
130 this.getCommand("kit").setExecutor((CommandExecutor)new KitCommand(this));
131 this.getCommand("snowman").setExecutor((CommandExecutor)new SnowmanCommand());
132 Bukkit.getServer().getPluginManager().registerEvents((Listener)new SnowmanDeathListener(), (Plugin)this);
133 Bukkit.getPluginManager().registerEvents((Listener)new GodListener(), (Plugin)this);
134 Bukkit.getPluginManager().registerEvents((Listener)new LightningListener(), (Plugin)this);
135 Bukkit.getPluginManager().registerEvents((Listener)new OnPlaceListener(), (Plugin)this);
136 Bukkit.getPluginManager().registerEvents((Listener)new InventoryListener(), (Plugin)this);
137 Bukkit.getPluginManager().registerEvents((Listener)new EventListener(), (Plugin)this);
138 Bukkit.getPluginManager().registerEvents((Listener)new DropBlockBreakPlaceListener(), (Plugin)this);
139 Bukkit.getPluginManager().registerEvents((Listener)new EatListener(), (Plugin)this);
140 Bukkit.getPluginManager().registerEvents((Listener)new TimerManager(), (Plugin)this);
141 this.getCommand("bc").setExecutor((CommandExecutor)new BroadCastCommand(this));
142 this.getCommand("Clear").setExecutor((CommandExecutor)new ClearCommand(this));
143 this.getCommand("Fly").setExecutor((CommandExecutor)new FlyCommand(this));
144 EnderchestRecipe.createRecipe();
145 StoniarkaRecipe.createRecipe();
146 BoyFarmerRecipe.createRecipe();
147 SandFarmerRecipe.createRecipe();
148 KopaczFosyRecipe.createRecipe();
149 RzucaneTntRecipe.createRecipe();
150 }
151
152 protected boolean registerDatabase() {
153 switch (StoreMode.getByName(getPlugin().getConfig().getString("mysql.mode"))) {
154 case MYSQL: {
155 Main.store = new StoreMySQL(getPlugin().getConfig().getString("mysql.host"), getPlugin().getConfig().getInt("mysql.port"), getPlugin().getConfig().getString("mysql.user"), getPlugin().getConfig().getString("mysql.pass"), getPlugin().getConfig().getString("mysql.base"), getPlugin().getConfig().getString("mysql.tableprefix"));
156 break;
157 }
158 case SQLITE: {
159 Main.store = new StoreSQLITE("minecraft.db", getPlugin().getConfig().getString("mysql.tableprefix"));
160 break;
161 }
162 default: {
163 Logger.warning("Value of databse mode is not valid! Using SQLITE as database!");
164 Main.store = new StoreSQLITE("minecraft.db", getPlugin().getConfig().getString("mysql.tableprefix"));
165 break;
166 }
167 }
168 final boolean conn = Main.store.connect();
169 if (conn) {
170 Main.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}users` (" + ((Main.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, `coins` bigint(22) NOT NULL, `kit_pierozek` bigint(22) NOT NULL, `kit_premiumcase` bigint(22) NOT NULL, `kit_vip` bigint(22) NOT NULL, `kit_start` bigint(22) NOT NULL, `kit_svip` bigint(22) NOT NULL, `kit_sponsor` bigint(22) NOT NULL, `turboDrop` bigint(22) NOT NULL, `turboExp` bigint(22) NOT NULL, `lvl` int(11) NOT NULL, `exp` int(11) NOT NULL, `home` text NOT NULL);");
171 Main.store.update(true, "CREATE TABLE IF NOT EXISTS `{P}warp` (" + ((Main.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);");
172 return conn;
173 }
174 return conn;
175 }
176
177 public void registerManager() {
178 WarpManager.loadWarps();
179 DropConfiguration.reloadConfig();
180 DropManager.setup();
181 ToolsConfiguration.reloadConfig();
182 UserManager.loadUsers();
183 }
184
185 public void onDisable() {
186 Logger.info("Wylaczam plugin...");
187 }
188}