mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-23 17:09:27 +00:00
Improved drops for multiple identical items
This commit is contained in:
@@ -9,6 +9,7 @@ import com.willfp.eco.core.items.builder.ItemBuilder;
|
|||||||
import com.willfp.eco.core.items.builder.ItemStackBuilder;
|
import com.willfp.eco.core.items.builder.ItemStackBuilder;
|
||||||
import com.willfp.eco.core.recipe.Recipes;
|
import com.willfp.eco.core.recipe.Recipes;
|
||||||
import com.willfp.eco.core.tuples.Pair;
|
import com.willfp.eco.core.tuples.Pair;
|
||||||
|
import com.willfp.eco.util.NumberUtils;
|
||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effects;
|
import com.willfp.ecobosses.bosses.effects.Effects;
|
||||||
@@ -142,8 +143,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
/**
|
/**
|
||||||
* The drops.
|
* The drops.
|
||||||
*/
|
*/
|
||||||
@Getter
|
private final List<String> drops;
|
||||||
private final Map<ItemStack, Double> drops;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exp to drop.
|
* The exp to drop.
|
||||||
@@ -335,23 +335,8 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
this.spawnTotemDisabledWorldNames = this.getConfig().getStrings("spawn-totem.world-blacklist").stream().map(String::toLowerCase).collect(Collectors.toList());
|
this.spawnTotemDisabledWorldNames = this.getConfig().getStrings("spawn-totem.world-blacklist").stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||||
|
|
||||||
// Rewards
|
// Rewards
|
||||||
this.drops = new HashMap<>();
|
this.drops = new ArrayList<>();
|
||||||
for (String string : this.getConfig().getStrings("rewards.drops")) {
|
drops.addAll(this.getConfig().getStrings("rewards.drops", false));
|
||||||
YamlConfiguration tempConfig = new YamlConfiguration();
|
|
||||||
double chance = 100;
|
|
||||||
if (string.contains("::")) {
|
|
||||||
String[] split = string.split("::");
|
|
||||||
chance = Double.parseDouble(split[0]);
|
|
||||||
string = split[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack itemStack = Items.lookup(string).getItem();
|
|
||||||
if (itemStack.getType() == Material.AIR) {
|
|
||||||
Bukkit.getLogger().warning(this.getName() + " has an invalid drop configured! (" + string + ")");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.drops.put(itemStack, chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.experienceOptions = new ExperienceOptions(
|
this.experienceOptions = new ExperienceOptions(
|
||||||
this.getConfig().getInt("rewards.xp.minimum"),
|
this.getConfig().getInt("rewards.xp.minimum"),
|
||||||
@@ -588,6 +573,31 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ItemStack> generateDrops() {
|
||||||
|
List<ItemStack> drops = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String dropName : this.drops) {
|
||||||
|
double chance = 100;
|
||||||
|
if (dropName.contains("::")) {
|
||||||
|
String[] split = dropName.split("::");
|
||||||
|
chance = Double.parseDouble(split[0]);
|
||||||
|
dropName = split[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemStack = Items.lookup(dropName).getItem();
|
||||||
|
if (itemStack.getType() == Material.AIR) {
|
||||||
|
Bukkit.getLogger().warning(this.getName() + " has an invalid drop configured! (" + dropName + ")");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NumberUtils.randFloat(0, 100) <= chance) {
|
||||||
|
drops.add(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return drops;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create effect tickers for Living Boss.
|
* Create effect tickers for Living Boss.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -131,12 +131,7 @@ public class DeathListeners extends PluginDependent<EcoPlugin> implements Listen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ItemStack> drops = new ArrayList<>();
|
List<ItemStack> drops = boss.generateDrops();
|
||||||
for (Map.Entry<ItemStack, Double> entry : boss.getDrops().entrySet()) {
|
|
||||||
if (NumberUtils.randFloat(0, 100) < entry.getValue()) {
|
|
||||||
drops.add(entry.getKey().clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Entity nearby : entity.getNearbyEntities(boss.getNearbyRadius(), boss.getNearbyRadius(), boss.getNearbyRadius())) {
|
for (Entity nearby : entity.getNearbyEntities(boss.getNearbyRadius(), boss.getNearbyRadius(), boss.getNearbyRadius())) {
|
||||||
if (nearby instanceof Player) {
|
if (nearby instanceof Player) {
|
||||||
|
|||||||
Reference in New Issue
Block a user