| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  | package de.npid7.serverlite;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-24 12:03:15 +01:00
										 |  |  | import de.npid7.serverlite.Commands.D7Command;
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  | import de.npid7.serverlite.Commands.PlaytimeCommand;
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  | import de.npid7.serverlite.Commands.StatusCommand;
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  | import de.npid7.serverlite.Commands.TimerCommand;
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  | import de.npid7.serverlite.Configs.PlayerConfig;
 | 
					
						
							|  |  |  | import de.npid7.serverlite.Configs.PluginConfig;
 | 
					
						
							|  |  |  | import de.npid7.serverlite.Listeners.JoinListener;
 | 
					
						
							| 
									
										
										
										
											2024-11-24 12:03:15 +01:00
										 |  |  | import de.npid7.serverlite.TabCompleters.D7Completer;
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  | import de.npid7.serverlite.TabCompleters.PlaytimeCompleter;
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  | import de.npid7.serverlite.TabCompleters.StatusCompleter;
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  | import de.npid7.serverlite.TabCompleters.TimerCompleter;
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  | import de.npid7.serverlite.Tasks.TablistTask;
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  | import org.bukkit.Bukkit;
 | 
					
						
							|  |  |  | import org.bukkit.plugin.java.JavaPlugin;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * d7serverlite java plugin
 | 
					
						
							|  |  |  |  */
 | 
					
						
							|  |  |  | public class D7ServerLite extends JavaPlugin {
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |   // Declare static Instance To access with getInst();
 | 
					
						
							|  |  |  |   // using this to access Configs from this Class
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  |   private static D7ServerLite inst;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |   // declare TablistTask and Configs
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  |   private TablistTask tablistUpdater;
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  |   private PluginConfig pluginConfig;
 | 
					
						
							|  |  |  |   private PlayerConfig playerConfig;
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |   // Override onLoad to set static inst to this class
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  |   @Override
 | 
					
						
							|  |  |  |   public void onLoad() {
 | 
					
						
							|  |  |  |     inst = this;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |   // Override on Enabel to init the Plugin
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  |   @Override
 | 
					
						
							|  |  |  |   public void onEnable() {
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |     // Create Data Folder
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  |     if (!getDataFolder().exists()) {
 | 
					
						
							|  |  |  |       getDataFolder().mkdirs();
 | 
					
						
							|  |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |     // Init Configs
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  |     pluginConfig = new PluginConfig(getDataFolder() + "/config.json");
 | 
					
						
							|  |  |  |     playerConfig = new PlayerConfig(getDataFolder() + "/player_config.json");
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |     // Run Tablist Updater
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  |     tablistUpdater = new TablistTask();
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |     // declare commands
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  |     getCommand("status").setExecutor(new StatusCommand());
 | 
					
						
							|  |  |  |     getCommand("status").setTabCompleter(new StatusCompleter());
 | 
					
						
							| 
									
										
										
										
											2024-11-24 12:03:15 +01:00
										 |  |  |     getCommand("d7").setExecutor(new D7Command());
 | 
					
						
							|  |  |  |     getCommand("d7").setTabCompleter(new D7Completer());
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |     getCommand("timer").setExecutor(new TimerCommand());
 | 
					
						
							|  |  |  |     getCommand("trimer").setTabCompleter(new TimerCompleter());
 | 
					
						
							|  |  |  |     getCommand("playtime").setExecutor(new PlaytimeCommand());
 | 
					
						
							|  |  |  |     getCommand("playtime").setTabCompleter(new PlaytimeCompleter());
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |     // Register onJoin Event to generate PlayerConfigEntry
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  |     Bukkit.getPluginManager().registerEvents(new JoinListener(), this);
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 12:39:49 +00:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * Getters declared below
 | 
					
						
							|  |  |  |    */
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   public static D7ServerLite getInst() {
 | 
					
						
							|  |  |  |     return inst;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2024-11-23 19:14:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   public PluginConfig getPluginConfig() {
 | 
					
						
							|  |  |  |     return this.pluginConfig;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public PlayerConfig getPlayerConfig() {
 | 
					
						
							|  |  |  |     return this.playerConfig;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2024-11-23 18:17:14 +01:00
										 |  |  | }
 |