mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
2.1.3.1
This commit is contained in:
@@ -88,9 +88,9 @@ public interface LootManager {
|
||||
/**
|
||||
* Get the next loot item based on fishing effect and condition.
|
||||
*
|
||||
* @param initialEffect The effect to apply weight modifiers.
|
||||
* @param effect The effect to apply weight modifiers.
|
||||
* @param condition The condition to determine possible loot.
|
||||
* @return The next loot item, or null if it doesn't exist.
|
||||
*/
|
||||
@Nullable Loot getNextLoot(Effect initialEffect, Condition condition);
|
||||
@Nullable Loot getNextLoot(Effect effect, Condition condition);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
|
||||
version = "2.1.3"
|
||||
version = "2.1.3.1"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -92,7 +92,6 @@ public class HookCheckTimerTask implements Runnable {
|
||||
this.tempEffect = new FishingEffect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (
|
||||
@@ -225,13 +224,11 @@ public class HookCheckTimerTask implements Runnable {
|
||||
}
|
||||
|
||||
private void setNextLoot() {
|
||||
Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(tempEffect, fishingPreparation);
|
||||
Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(initialEffect, fishingPreparation);
|
||||
if (nextLoot == null) {
|
||||
this.loot = null;
|
||||
CustomFishingPlugin.get().debug("No loot available at " + fishingPreparation.getLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
this.loot = nextLoot;
|
||||
}
|
||||
|
||||
|
||||
@@ -996,11 +996,9 @@ public class ItemManagerImpl implements ItemManager, Listener {
|
||||
}
|
||||
|
||||
// because the id can be from other plugins, so we can't infer the type of the item
|
||||
for (String type : List.of("util", "bait", "rod", "hook")) {
|
||||
for (String type : List.of("util", "bait", "hook")) {
|
||||
EffectCarrier carrier = plugin.getEffectManager().getEffectCarrier(type, id);
|
||||
if (carrier != null) {
|
||||
if (!RequirementManager.isRequirementMet(condition, carrier.getRequirements()))
|
||||
return;
|
||||
Action[] actions = carrier.getActions(ActionTrigger.INTERACT);
|
||||
if (actions != null)
|
||||
for (Action action : actions) {
|
||||
|
||||
@@ -168,21 +168,21 @@ public class LootManagerImpl implements LootManager {
|
||||
/**
|
||||
* Get a map of possible loot keys with their corresponding weights, considering fishing effect and condition.
|
||||
*
|
||||
* @param initialEffect The effect to apply weight modifiers.
|
||||
* @param effect The effect to apply weight modifiers.
|
||||
* @param condition The condition to determine possible loot.
|
||||
* @return A map of loot keys and their weights.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Double> getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition) {
|
||||
public Map<String, Double> getPossibleLootKeysWithWeight(Effect effect, Condition condition) {
|
||||
Map<String, Double> lootWithWeight = ((RequirementManagerImpl) plugin.getRequirementManager()).getLootWithWeight(condition);
|
||||
Player player = condition.getPlayer();
|
||||
for (Pair<String, WeightModifier> pair : initialEffect.getWeightModifier()) {
|
||||
for (Pair<String, WeightModifier> pair : effect.getWeightModifier()) {
|
||||
Double previous = lootWithWeight.get(pair.left());
|
||||
if (previous != null)
|
||||
lootWithWeight.put(pair.left(), pair.right().modify(player, previous));
|
||||
}
|
||||
for (Pair<String, WeightModifier> pair : initialEffect.getWeightModifierIgnored()) {
|
||||
for (Pair<String, WeightModifier> pair : effect.getWeightModifierIgnored()) {
|
||||
double previous = lootWithWeight.getOrDefault(pair.left(), 0d);
|
||||
lootWithWeight.put(pair.left(), pair.right().modify(player, previous));
|
||||
}
|
||||
@@ -192,14 +192,14 @@ public class LootManagerImpl implements LootManager {
|
||||
/**
|
||||
* Get the next loot item based on fishing effect and condition.
|
||||
*
|
||||
* @param initialEffect The effect to apply weight modifiers.
|
||||
* @param effect The effect to apply weight modifiers.
|
||||
* @param condition The condition to determine possible loot.
|
||||
* @return The next loot item, or null if it doesn't exist.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Loot getNextLoot(Effect initialEffect, Condition condition) {
|
||||
String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(initialEffect, condition));
|
||||
public Loot getNextLoot(Effect effect, Condition condition) {
|
||||
String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(effect, condition));
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user