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.
|
* 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.
|
* @param condition The condition to determine possible loot.
|
||||||
* @return The next loot item, or null if it doesn't exist.
|
* @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 {
|
allprojects {
|
||||||
|
|
||||||
version = "2.1.3"
|
version = "2.1.3.1"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ public class HookCheckTimerTask implements Runnable {
|
|||||||
this.tempEffect = new FishingEffect();
|
this.tempEffect = new FishingEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (
|
if (
|
||||||
@@ -225,13 +224,11 @@ public class HookCheckTimerTask implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setNextLoot() {
|
private void setNextLoot() {
|
||||||
Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(tempEffect, fishingPreparation);
|
Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(initialEffect, fishingPreparation);
|
||||||
if (nextLoot == null) {
|
if (nextLoot == null) {
|
||||||
this.loot = null;
|
this.loot = null;
|
||||||
CustomFishingPlugin.get().debug("No loot available at " + fishingPreparation.getLocation());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loot = nextLoot;
|
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
|
// 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);
|
EffectCarrier carrier = plugin.getEffectManager().getEffectCarrier(type, id);
|
||||||
if (carrier != null) {
|
if (carrier != null) {
|
||||||
if (!RequirementManager.isRequirementMet(condition, carrier.getRequirements()))
|
|
||||||
return;
|
|
||||||
Action[] actions = carrier.getActions(ActionTrigger.INTERACT);
|
Action[] actions = carrier.getActions(ActionTrigger.INTERACT);
|
||||||
if (actions != null)
|
if (actions != null)
|
||||||
for (Action action : actions) {
|
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.
|
* 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.
|
* @param condition The condition to determine possible loot.
|
||||||
* @return A map of loot keys and their weights.
|
* @return A map of loot keys and their weights.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@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);
|
Map<String, Double> lootWithWeight = ((RequirementManagerImpl) plugin.getRequirementManager()).getLootWithWeight(condition);
|
||||||
Player player = condition.getPlayer();
|
Player player = condition.getPlayer();
|
||||||
for (Pair<String, WeightModifier> pair : initialEffect.getWeightModifier()) {
|
for (Pair<String, WeightModifier> pair : effect.getWeightModifier()) {
|
||||||
Double previous = lootWithWeight.get(pair.left());
|
Double previous = lootWithWeight.get(pair.left());
|
||||||
if (previous != null)
|
if (previous != null)
|
||||||
lootWithWeight.put(pair.left(), pair.right().modify(player, previous));
|
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);
|
double previous = lootWithWeight.getOrDefault(pair.left(), 0d);
|
||||||
lootWithWeight.put(pair.left(), pair.right().modify(player, previous));
|
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.
|
* 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.
|
* @param condition The condition to determine possible loot.
|
||||||
* @return The next loot item, or null if it doesn't exist.
|
* @return The next loot item, or null if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Loot getNextLoot(Effect initialEffect, Condition condition) {
|
public Loot getNextLoot(Effect effect, Condition condition) {
|
||||||
String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(initialEffect, condition));
|
String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(effect, condition));
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user