11package net .badlion .bukkitapi ;
22
3- import net .badlion .bukkitapi .cosmetics .CosmeticManager ;
4- import net .badlion .bukkitapi .listener .PlayerListener ;
5- import net .badlion .bukkitapi .timers .TimerApi ;
6- import net .badlion .bukkitapi .timers .TimerApiImpl ;
7- import net .badlion .bukkitapi .waypoints .WaypointManager ;
8- import org .bukkit .plugin .java .JavaPlugin ;
9-
10- import java .io .File ;
11- import java .io .IOException ;
12- import java .util .logging .Level ;
13-
14- public class BukkitBadlionPlugin extends JavaPlugin {
15- private final BukkitBadlionApi badlionApi ;
16- private final BukkitPluginMessageSender messageSender ;
17- private final TimerApiImpl timerApi ;
18- private final WaypointManager waypointManager ;
19- private final CosmeticManager cosmeticManager ;
20-
3+ public class BukkitBadlionPlugin extends AbstractBukkitBadlionPlugin {
214 public BukkitBadlionPlugin () {
22- this .badlionApi = new BukkitBadlionApi (this );
23- this .messageSender = new BukkitPluginMessageSender (this );
24- this .timerApi = new TimerApiImpl (this );
25- this .waypointManager = new WaypointManager (this );
26- this .badlionApi .setWaypointManager (this .waypointManager );
27- this .cosmeticManager = new CosmeticManager ();
28- this .badlionApi .setCosmeticManager (this .cosmeticManager );
29- }
30-
31- @ Override
32- public void onEnable () {
33- if (!this .getDataFolder ().exists ()) {
34- if (!this .getDataFolder ().mkdir ()) {
35- this .getLogger ().log (Level .SEVERE , "Failed to create plugin directory." );
36- }
37- }
38-
39- try {
40- this .badlionApi .loadConfig (new File (this .getDataFolder (), "config.json" ));
41-
42- this .waypointManager .loadWaypoints ();
43-
44- // Register channel
45- this .getServer ().getMessenger ().registerOutgoingPluginChannel (this , "badlion:mods" );
46- this .getServer ().getMessenger ().registerOutgoingPluginChannel (this , "badlion:modapi" );
47- this .getServer ().getMessenger ().registerOutgoingPluginChannel (this , TimerApi .CHANNEL_NAME );
48-
49- // Only register the listener if the config loads successfully
50- this .getServer ().getPluginManager ().registerEvents (new PlayerListener (this ), this );
51- this .getServer ().getPluginManager ().registerEvents (this .waypointManager , this );
52- this .getServer ().getPluginManager ().registerEvents (this .cosmeticManager , this );
53-
54- this .getServer ().getScheduler ().runTaskTimer (this , new Runnable () {
55- @ Override
56- public void run () {
57- BukkitBadlionPlugin .this .getTimerApi ().tickTimers ();
58- }
59- }, 1L , 1L );
60-
61- this .getServer ().getScheduler ().runTaskTimer (this , new Runnable () {
62- @ Override
63- public void run () {
64- BukkitBadlionPlugin .this .getTimerApi ().syncTimers ();
65- }
66- }, 60L , 60L );
67-
68- this .getLogger ().log (Level .INFO , "Successfully setup BadlionClientModAPI plugin." );
69-
70- } catch (IOException e ) {
71- this .getLogger ().log (Level .SEVERE , "Error with config for BadlionClientModAPI plugin." );
72- e .printStackTrace ();
73- }
74- }
75-
76- public BukkitBadlionApi getBadlionApi () {
77- return this .badlionApi ;
78- }
79-
80- public BukkitPluginMessageSender getMessageSender () {
81- return this .messageSender ;
82- }
83-
84- public TimerApiImpl getTimerApi () {
85- return this .timerApi ;
86- }
87-
88- public WaypointManager getWaypointManager () {
89- return this .waypointManager ;
90- }
91-
92- public CosmeticManager getCosmeticManager () {
93- return this .cosmeticManager ;
5+ this .setMessageSender (new BukkitPluginMessageSender (this ));
946 }
95- }
7+ }
0 commit comments