Add SuperiorSkyblock hook for mob drops
This commit is contained in:
parent
1dfd18a943
commit
fd8572a276
|
@ -139,6 +139,13 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>SuperiorSkyblockAPI</artifactId>
|
||||
<version>2023.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>uk.antiperson</groupId>
|
||||
<artifactId>stackmob</artifactId>
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.craftaro.ultimatestacker.database.migrations._3_BlockStacks;
|
|||
import com.craftaro.ultimatestacker.database.migrations._6_RemoveStackedEntityTable;
|
||||
import com.craftaro.ultimatestacker.hook.StackerHook;
|
||||
import com.craftaro.ultimatestacker.hook.hooks.JobsHook;
|
||||
import com.craftaro.ultimatestacker.hook.hooks.SuperiorSkyblock2Hook;
|
||||
import com.craftaro.ultimatestacker.listeners.BlockListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.BreedListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.ClearLagListeners;
|
||||
|
@ -99,6 +100,7 @@ public class UltimateStacker extends SongodaPlugin {
|
|||
private CustomEntityManager customEntityManager;
|
||||
private StackingTask stackingTask;
|
||||
private UltimateStackerApi API;
|
||||
private SuperiorSkyblock2Hook superiorSkyblock2Hook;
|
||||
|
||||
public static UltimateStacker getInstance() {
|
||||
return INSTANCE;
|
||||
|
@ -106,6 +108,7 @@ public class UltimateStacker extends SongodaPlugin {
|
|||
|
||||
@Override
|
||||
protected Set<Dependency> getDependencies() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,7 +156,10 @@ public class UltimateStacker extends SongodaPlugin {
|
|||
new CommandConvert( guiManager)
|
||||
);
|
||||
|
||||
this.lootablesManager = new LootablesManager();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
this.superiorSkyblock2Hook = new SuperiorSkyblock2Hook(pluginManager.isPluginEnabled("SuperiorSkyblock2"));
|
||||
|
||||
this.lootablesManager = new LootablesManager(superiorSkyblock2Hook);
|
||||
this.lootablesManager.createDefaultLootables();
|
||||
this.getLootablesManager().getLootManager().loadLootables();
|
||||
|
||||
|
@ -196,7 +202,7 @@ public class UltimateStacker extends SongodaPlugin {
|
|||
this.customEntityManager = new CustomEntityManager();
|
||||
|
||||
guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10))
|
||||
pluginManager.registerEvents(new BreedListeners(this), this);
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
|
@ -399,6 +405,10 @@ public class UltimateStacker extends SongodaPlugin {
|
|||
HologramManager.removeHologram(stack.getHologramId());
|
||||
}
|
||||
|
||||
public SuperiorSkyblock2Hook getSuperiorSkyblock2Hook() {
|
||||
return superiorSkyblock2Hook;
|
||||
}
|
||||
|
||||
//////// Convenient API //////////
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.craftaro.ultimatestacker.hook.hooks;
|
||||
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
|
||||
import com.bgsoftware.superiorskyblock.api.island.Island;
|
||||
import com.craftaro.core.hooks.Hook;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class SuperiorSkyblock2Hook {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
public SuperiorSkyblock2Hook(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "SuperiorSkyblock2";
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public int getDropMultiplier(Location mobDeathLocation) {
|
||||
Island island = SuperiorSkyblockAPI.getIslandAt(mobDeathLocation);
|
||||
if (island == null) {
|
||||
return 1;
|
||||
}
|
||||
return island.getUpgrades().getOrDefault("mob-drops", 0);
|
||||
}
|
||||
}
|
|
@ -39,10 +39,12 @@ public class LootablesManager {
|
|||
|
||||
private final String lootablesDir = UltimateStacker.getInstance().getDataFolder() + File.separator + "lootables";
|
||||
private final static int MAX_INT = Integer.MAX_VALUE/2;
|
||||
private final SuperiorSkyblock2Hook superiorSkyblock2Hook;
|
||||
|
||||
public LootablesManager() {
|
||||
public LootablesManager(SuperiorSkyblock2Hook superiorSkyblock2Hook) {
|
||||
this.lootables = new Lootables(lootablesDir);
|
||||
this.lootManager = new LootManager(lootables);
|
||||
this.superiorSkyblock2Hook = superiorSkyblock2Hook;
|
||||
}
|
||||
|
||||
public List<Drop> getDrops(LivingEntity entity) {
|
||||
|
@ -62,6 +64,13 @@ public class LootablesManager {
|
|||
for (Loot loot : lootable.getRegisteredLoot())
|
||||
toDrop.addAll(runLoot(entity, loot, rerollChance, looting));
|
||||
|
||||
//Apply SuperiorSkyblock2 mob-drops multiplier if present
|
||||
if (superiorSkyblock2Hook.isEnabled()) {
|
||||
for (Drop drop : toDrop) {
|
||||
drop.getItemStack().setAmount(superiorSkyblock2Hook.getDropMultiplier(entity.getLocation()) * drop.getItemStack().getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
return toDrop;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue