mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-30 22:43:35 +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.farmManager = new FarmManager(levelManager);
|
||||||
this.boostManager = new BoostManager();
|
this.boostManager = new BoostManager();
|
||||||
|
|
||||||
/*
|
// Register Listeners
|
||||||
* Register Farms into FarmManger from configuration
|
guiManager.init();
|
||||||
*/
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
|
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")) {
|
if (storage.containsGroup("farms")) {
|
||||||
for (StorageRow row : storage.getRowsByGroup("farms")) {
|
for (StorageRow row : storage.getRowsByGroup("farms")) {
|
||||||
Location location = Methods.unserializeLocation(row.getKey());
|
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.
|
// Save data initially so that if the person reloads again fast they don't lose all their data.
|
||||||
this.saveToFile();
|
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
|
@Override
|
||||||
@ -287,8 +283,7 @@ public class EpicFarming extends SongodaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getLevelFromItem(ItemStack item) {
|
public int getLevelFromItem(ItemStack item) {
|
||||||
NBTCore nbt = NmsManager.getNbt();
|
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||||
NBTItem nbtItem = nbt.of(item);
|
|
||||||
|
|
||||||
if (nbtItem.has("level"))
|
if (nbtItem.has("level"))
|
||||||
return nbtItem.getNBTObject("level").asInt();
|
return nbtItem.getNBTObject("level").asInt();
|
||||||
|
Loading…
Reference in New Issue
Block a user