11package github .nighter .smartspawner ;
22
3- import fr .xyness .SCS .API .SimpleClaimSystemAPI_Provider ;
4- import fr .xyness .SCS .SimpleClaimSystem ;
53import github .nighter .smartspawner .api .SmartSpawnerAPI ;
64import github .nighter .smartspawner .api .SmartSpawnerPlugin ;
75import github .nighter .smartspawner .api .SmartSpawnerAPIImpl ;
1311import github .nighter .smartspawner .commands .list .SpawnerListGUI ;
1412import github .nighter .smartspawner .commands .list .UserPreferenceCache ;
1513import github .nighter .smartspawner .commands .reload .ReloadCommand ;
16- import github .nighter .smartspawner .configs .TimeFormatter ;
17- import github .nighter .smartspawner .economy .ItemPriceManager ;
18- import github .nighter .smartspawner .economy .shops .providers .shopguiplus .SpawnerProvider ;
14+ import github .nighter .smartspawner .hooks .PluginCompatibilityHandler ;
15+ import github .nighter .smartspawner .spawner .natural .NaturalSpawnerListener ;
16+ import github .nighter .smartspawner .utils .TimeFormatter ;
17+ import github .nighter .smartspawner .hooks .economy .ItemPriceManager ;
18+ import github .nighter .smartspawner .hooks .economy .shops .providers .shopguiplus .SpawnerProvider ;
1919import github .nighter .smartspawner .extras .HopperHandler ;
20- import github .nighter .smartspawner .hooks .protections .api .Lands ;
21- import github .nighter .smartspawner .hooks .protections .api .SuperiorSkyblock2 ;
22- import github .nighter .smartspawner .hooks .rpg .AuraSkillsIntegration ;
20+ import github .nighter .smartspawner .hooks .IntegrationManager ;
2321import github .nighter .smartspawner .language .MessageService ;
2422import github .nighter .smartspawner .migration .SpawnerDataMigration ;
2523import github .nighter .smartspawner .spawner .gui .layout .GuiLayoutConfig ;
5048import github .nighter .smartspawner .language .LanguageManager ;
5149import github .nighter .smartspawner .updates .ConfigUpdater ;
5250import github .nighter .smartspawner .nms .VersionInitializer ;
53-
5451import github .nighter .smartspawner .updates .LanguageUpdater ;
5552import github .nighter .smartspawner .updates .UpdateChecker ;
5653import github .nighter .smartspawner .utils .SpawnerTypeChecker ;
54+
5755import lombok .Getter ;
5856import lombok .experimental .Accessors ;
5957
60- import me .ryanhamshire .GriefPrevention .GriefPrevention ;
61- import org .bukkit .Bukkit ;
62- import org .bukkit .plugin .Plugin ;
6358import org .bukkit .plugin .PluginManager ;
6459import org .bukkit .plugin .java .JavaPlugin ;
6560
@@ -74,6 +69,9 @@ public class SmartSpawner extends JavaPlugin implements SmartSpawnerPlugin {
7469 public final int DATA_VERSION = 3 ;
7570 private final boolean debugMode = getConfig ().getBoolean ("debug" , false );
7671
72+ // Integration Manager
73+ private IntegrationManager integrationManager ;
74+
7775 // Services
7876 private TimeFormatter timeFormatter ;
7977 private ConfigUpdater configUpdater ;
@@ -109,7 +107,8 @@ public class SmartSpawner extends JavaPlugin implements SmartSpawnerPlugin {
109107 private HopperHandler hopperHandler ;
110108
111109 // Event handlers and utilities
112- private GlobalEventHandlers globalEventHandlers ;
110+ private PluginCompatibilityHandler pluginCompatibilityHandler ;
111+ private NaturalSpawnerListener naturalSpawnerListener ;
113112 private SpawnerLootGenerator spawnerLootGenerator ;
114113 private SpawnerListGUI spawnerListGUI ;
115114 private SpawnerRangeChecker rangeChecker ;
@@ -130,20 +129,6 @@ public class SmartSpawner extends JavaPlugin implements SmartSpawnerPlugin {
130129 private ListCommand listCommand ;
131130 private HologramCommand hologramCommand ;
132131
133- // Integration with AuraSkills
134- private AuraSkillsIntegration auraSkillsIntegration ;
135- public static boolean hasAuraSkills = false ;
136-
137- // Integration flags - static for quick access
138- public static boolean hasTowny = false ;
139- public static boolean hasLands = false ;
140- public static boolean hasWorldGuard = false ;
141- public static boolean hasGriefPrevention = false ;
142- public static boolean hasSuperiorSkyblock2 = false ;
143- public static boolean hasBentoBox = false ;
144- public static boolean hasSimpleClaimSystem = false ;
145- public static boolean hasRedProtect = false ;
146-
147132 // API implementation
148133 private SmartSpawnerAPIImpl apiImpl ;
149134
@@ -155,15 +140,17 @@ public void onEnable() {
155140 // Initialize version-specific components
156141 initializeVersionComponents ();
157142
143+ // Initialize plugin integrations
144+ this .integrationManager = new IntegrationManager (this );
145+ integrationManager .initializeIntegrations ();
146+
158147 // Check for data migration needs
159148 migrateDataIfNeeded ();
160149
161- // Initialize core components in the same order as before
150+ // Initialize core components
162151 initializeComponents ();
163152
164153 // Setup plugin infrastructure
165- checkProtectionPlugins ();
166- checkIntegrationPlugins ();
167154 setupCommand ();
168155 setupBtatsMetrics ();
169156 registerListeners ();
@@ -266,7 +253,8 @@ private void initializeUIAndActions() {
266253 }
267254
268255 private void initializeListeners () {
269- this .globalEventHandlers = new GlobalEventHandlers (this );
256+ this .pluginCompatibilityHandler = new PluginCompatibilityHandler (this );
257+ this .naturalSpawnerListener = new NaturalSpawnerListener (this );
270258 this .spawnerExplosionListener = new SpawnerExplosionListener (this );
271259 this .spawnerBreakListener = new SpawnerBreakListener (this );
272260 this .spawnerPlaceListener = new SpawnerPlaceListener (this );
@@ -280,7 +268,7 @@ private void registerListeners() {
280268 PluginManager pm = getServer ().getPluginManager ();
281269
282270 // Register core listeners
283- pm .registerEvents (globalEventHandlers , this );
271+ pm .registerEvents (pluginCompatibilityHandler , this );
284272 pm .registerEvents (spawnerListGUI , this );
285273 pm .registerEvents (spawnerBreakListener , this );
286274 pm .registerEvents (spawnerPlaceListener , this );
@@ -317,91 +305,6 @@ private void setupBtatsMetrics() {
317305 );
318306 }
319307
320- private void checkProtectionPlugins () {
321- hasWorldGuard = checkPlugin ("WorldGuard" , () -> {
322- Plugin worldGuardPlugin = Bukkit .getPluginManager ().getPlugin ("WorldGuard" );
323- return worldGuardPlugin != null && worldGuardPlugin .isEnabled ();
324- }, true );
325-
326- hasGriefPrevention = checkPlugin ("GriefPrevention" , () -> {
327- Plugin griefPlugin = Bukkit .getPluginManager ().getPlugin ("GriefPrevention" );
328- return griefPlugin instanceof GriefPrevention ;
329- }, true );
330-
331- hasLands = checkPlugin ("Lands" , () -> {
332- Plugin landsPlugin = Bukkit .getPluginManager ().getPlugin ("Lands" );
333- if (landsPlugin != null ) {
334- new Lands (this );
335- return true ;
336- }
337- return false ;
338- }, true );
339-
340- hasTowny = checkPlugin ("Towny" , () -> {
341- try {
342- Class .forName ("com.palmergames.bukkit.towny.TownyAPI" );
343- return com .palmergames .bukkit .towny .TownyAPI .getInstance () != null ;
344- } catch (ClassNotFoundException e ) {
345- return false ;
346- }
347- }, true );
348-
349- hasSuperiorSkyblock2 = checkPlugin ("SuperiorSkyblock2" , () -> {
350- Plugin superiorSkyblock2 = Bukkit .getPluginManager ().getPlugin ("SuperiorSkyblock2" );
351- if (superiorSkyblock2 != null ) {
352- SuperiorSkyblock2 ssb2 = new SuperiorSkyblock2 ();
353- Bukkit .getPluginManager ().registerEvents (ssb2 , this );
354- return true ;
355- }
356- return false ;
357- }, true );
358-
359- hasBentoBox = checkPlugin ("BentoBox" , () -> {
360- Plugin bentoPlugin = Bukkit .getPluginManager ().getPlugin ("BentoBox" );
361- if (bentoPlugin != null ) {
362- return true ;
363- }
364- return false ;
365- }, true );
366- hasSimpleClaimSystem = checkPlugin ("SimpleClaimSystem" , () -> {
367- Plugin simpleClaimPlugin = Bukkit .getPluginManager ().getPlugin ("SimpleClaimSystem" );
368- SimpleClaimSystemAPI_Provider .initialize ((SimpleClaimSystem ) simpleClaimPlugin );
369- return simpleClaimPlugin != null ;
370- }, true );
371- hasRedProtect = checkPlugin ("RedProtect" , () -> {
372- Plugin pRP = Bukkit .getPluginManager ().getPlugin ("RedProtect" );
373- if (pRP != null && pRP .isEnabled ()){
374- return true ;
375- }
376- return false ;
377- }, true );
378- }
379-
380- private void checkIntegrationPlugins () {
381- hasAuraSkills = checkPlugin ("AuraSkills" , () -> {
382- Plugin auraSkillsPlugin = Bukkit .getPluginManager ().getPlugin ("AuraSkills" );
383- if (auraSkillsPlugin != null && auraSkillsPlugin .isEnabled ()) {
384- this .auraSkillsIntegration = new AuraSkillsIntegration (this );
385- return true ;
386- }
387- return false ;
388- }, true );
389- }
390-
391- private boolean checkPlugin (String pluginName , PluginCheck checker , boolean logSuccess ) {
392- try {
393- if (checker .check ()) {
394- if (logSuccess ) {
395- getLogger ().info (pluginName + " integration enabled successfully!" );
396- }
397- return true ;
398- }
399- } catch (NoClassDefFoundError | NullPointerException e ) {
400- // Silent fail - plugin not available
401- }
402- return false ;
403- }
404-
405308 public void reload () {
406309 // reload gui components
407310 guiLayoutConfig .reloadLayouts ();
@@ -410,9 +313,8 @@ public void reload() {
410313 filterConfigUI .reload ();
411314
412315 // reload services
413- if (auraSkillsIntegration != null ) {
414- auraSkillsIntegration .reloadConfig ();
415- }
316+ integrationManager .reload ();
317+ spawnerMenuAction .reload ();
416318 timeFormatter .clearCache ();
417319 itemCache .clear ();
418320 }
@@ -455,11 +357,6 @@ private void cleanupResources() {
455357 if (spawnerStorageUI != null ) spawnerStorageUI .cleanup ();
456358 }
457359
458- @ FunctionalInterface
459- private interface PluginCheck {
460- boolean check ();
461- }
462-
463360 // Spawner Provider for ShopGUI+ integration
464361 public SpawnerProvider getSpawnerProvider () {
465362 return new SpawnerProvider (this );
0 commit comments