mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-27 21:15:28 +01:00
Added proper support for the new SongodaCore data loading system.
This commit is contained in:
parent
aca80c173d
commit
d13ee3ef4d
@ -124,10 +124,38 @@ public class EpicFarming extends SongodaPlugin {
|
||||
this.farmManager = new FarmManager(levelManager);
|
||||
this.boostManager = new BoostManager();
|
||||
|
||||
/*
|
||||
* Register Farms into FarmManger from configuration
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
|
||||
// Register Listeners
|
||||
guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new EntityListeners(this), this);
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||
pluginManager.registerEvents(new UnloadListeners(this), this);
|
||||
pluginManager.registerEvents(new InventoryListeners(), this);
|
||||
|
||||
if (pluginManager.isPluginEnabled("FabledSkyBlock")) {
|
||||
try {
|
||||
SkyBlock.getInstance().getPermissionManager().registerPermission(
|
||||
(BasicPermission) Class.forName("com.songoda.epicfarming.compatibility.EpicFarmingPermission").newInstance());
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Start tasks
|
||||
this.growthTask = GrowthTask.startTask(this);
|
||||
this.farmTask = FarmTask.startTask(this);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("EpicHoppers"))
|
||||
HopperTask.startTask(this);
|
||||
}, 30L);
|
||||
|
||||
// Start auto save
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||
}
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
if (storage.containsGroup("farms")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("farms")) {
|
||||
Location location = Methods.unserializeLocation(row.getKey());
|
||||
@ -179,38 +207,6 @@ public class EpicFarming extends SongodaPlugin {
|
||||
|
||||
// Save data initially so that if the person reloads again fast they don't lose all their data.
|
||||
this.saveToFile();
|
||||
}, 10);
|
||||
|
||||
|
||||
// Register Listeners
|
||||
guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new EntityListeners(this), this);
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||
pluginManager.registerEvents(new UnloadListeners(this), this);
|
||||
pluginManager.registerEvents(new InventoryListeners(), this);
|
||||
|
||||
if (pluginManager.isPluginEnabled("FabledSkyBlock")) {
|
||||
try {
|
||||
SkyBlock.getInstance().getPermissionManager().registerPermission(
|
||||
(BasicPermission) Class.forName("com.songoda.epicfarming.compatibility.EpicFarmingPermission").newInstance());
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Start tasks
|
||||
this.growthTask = GrowthTask.startTask(this);
|
||||
this.farmTask = FarmTask.startTask(this);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("EpicHoppers"))
|
||||
HopperTask.startTask(this);
|
||||
}, 20L);
|
||||
|
||||
// Start auto save
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -287,8 +283,7 @@ public class EpicFarming extends SongodaPlugin {
|
||||
}
|
||||
|
||||
public int getLevelFromItem(ItemStack item) {
|
||||
NBTCore nbt = NmsManager.getNbt();
|
||||
NBTItem nbtItem = nbt.of(item);
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||
|
||||
if (nbtItem.has("level"))
|
||||
return nbtItem.getNBTObject("level").asInt();
|
||||
|
Loading…
Reference in New Issue
Block a user