Skip to content

Commit 16ab4f4

Browse files
committed
Added 1.21.6 compatibility, fixed filter items cant be sold, fixed ESGUI-Premium hooks
1 parent 75943c6 commit 16ab4f4

31 files changed

Lines changed: 331 additions & 275 deletions

NMS/v1_21_4/src/main/java/github/nighter/smartspawner/v1_21/ParticleInitializer.java renamed to NMS/v1_21_4/src/main/java/github/nighter/smartspawner/v1_21_4/ParticleInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package github.nighter.smartspawner.v1_21;
1+
package github.nighter.smartspawner.v1_21_4;
22

33
import github.nighter.smartspawner.nms.ParticleWrapper;
44
import org.bukkit.Particle;

NMS/v1_21_4/src/main/java/github/nighter/smartspawner/v1_21/SpawnerInitializer.java renamed to NMS/v1_21_4/src/main/java/github/nighter/smartspawner/v1_21_4/SpawnerInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package github.nighter.smartspawner.v1_21;
1+
package github.nighter.smartspawner.v1_21_4;
22
import org.bukkit.entity.EntityType;
33
import github.nighter.smartspawner.nms.SpawnerWrapper;
44
import java.util.Arrays;

NMS/v1_21_4/src/main/java/github/nighter/smartspawner/v1_21/TextureInitializer.java renamed to NMS/v1_21_4/src/main/java/github/nighter/smartspawner/v1_21_4/TextureInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package github.nighter.smartspawner.v1_21;
1+
package github.nighter.smartspawner.v1_21_4;
22

33
import github.nighter.smartspawner.nms.TextureWrapper;
44
import org.bukkit.entity.EntityType;

build.gradle

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ allprojects {
99
apply plugin: 'maven-publish'
1010

1111
group = 'github.nighter'
12-
version = '1.3.7'
12+
version = '1.3.8'
1313

1414
repositories {
1515
mavenCentral()
@@ -32,19 +32,6 @@ subprojects {
3232
withJavadocJar()
3333
withSourcesJar()
3434
}
35-
36-
publishing {
37-
repositories {
38-
maven {
39-
name = "GitHubPackages"
40-
url = uri("https://maven.pkg.github.com/ptthanh02/SmartSpawner")
41-
credentials {
42-
username = System.getenv("GITHUB_USERNAME") ?: project.findProperty("gpr.user")
43-
password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.key")
44-
}
45-
}
46-
}
47-
}
4835
}
4936

5037
def targetJavaVersion = 21

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jar {
4141
from { project(':NMS:v1_21').sourceSets.main.output }
4242
from { project(':NMS:v1_21_4').sourceSets.main.output }
4343

44-
// destinationDirectory = file('C:\\Users\\ADMIN\\OneDrive\\Desktop\\Paper\\plugins\\')
44+
// destinationDirectory = file('C:\\Users\\ADMIN\\OneDrive\\Desktop\\Paper1216\\plugins\\')
4545
from sourceSets.main.output
4646

4747
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

core/src/main/java/github/nighter/smartspawner/SmartSpawner.java

Lines changed: 22 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package github.nighter.smartspawner;
22

3-
import fr.xyness.SCS.API.SimpleClaimSystemAPI_Provider;
4-
import fr.xyness.SCS.SimpleClaimSystem;
53
import github.nighter.smartspawner.api.SmartSpawnerAPI;
64
import github.nighter.smartspawner.api.SmartSpawnerPlugin;
75
import github.nighter.smartspawner.api.SmartSpawnerAPIImpl;
@@ -13,13 +11,13 @@
1311
import github.nighter.smartspawner.commands.list.SpawnerListGUI;
1412
import github.nighter.smartspawner.commands.list.UserPreferenceCache;
1513
import 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;
1919
import 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;
2321
import github.nighter.smartspawner.language.MessageService;
2422
import github.nighter.smartspawner.migration.SpawnerDataMigration;
2523
import github.nighter.smartspawner.spawner.gui.layout.GuiLayoutConfig;
@@ -50,16 +48,13 @@
5048
import github.nighter.smartspawner.language.LanguageManager;
5149
import github.nighter.smartspawner.updates.ConfigUpdater;
5250
import github.nighter.smartspawner.nms.VersionInitializer;
53-
5451
import github.nighter.smartspawner.updates.LanguageUpdater;
5552
import github.nighter.smartspawner.updates.UpdateChecker;
5653
import github.nighter.smartspawner.utils.SpawnerTypeChecker;
54+
5755
import lombok.Getter;
5856
import lombok.experimental.Accessors;
5957

60-
import me.ryanhamshire.GriefPrevention.GriefPrevention;
61-
import org.bukkit.Bukkit;
62-
import org.bukkit.plugin.Plugin;
6358
import org.bukkit.plugin.PluginManager;
6459
import 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);

core/src/main/java/github/nighter/smartspawner/extras/HopperHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private void transferItems(Location hopperLoc, Location spawnerLoc) {
201201

202202
try {
203203
VirtualInventory virtualInv = spawner.getVirtualInventory();
204-
Hopper hopper = (Hopper) hopperLoc.getBlock().getState(false); // Should be fine to disable snapshots
204+
Hopper hopper = (Hopper) hopperLoc.getBlock().getState(false);
205205

206206
int itemsPerTransfer = plugin.getConfig().getInt("hopper.stack_per_transfer", 5);
207207
int transferred = 0;

0 commit comments

Comments
 (0)