mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
2.3.1
This commit is contained in:
@@ -19,10 +19,12 @@ package net.momirealms.customfishing.api.mechanic.context;
|
|||||||
|
|
||||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionGoal;
|
import net.momirealms.customfishing.api.mechanic.competition.CompetitionGoal;
|
||||||
import net.momirealms.customfishing.api.mechanic.loot.LootType;
|
import net.momirealms.customfishing.api.mechanic.loot.LootType;
|
||||||
|
import net.momirealms.customfishing.api.mechanic.totem.ActiveTotemList;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents keys for accessing context values with specific types.
|
* Represents keys for accessing context values with specific types.
|
||||||
@@ -65,6 +67,7 @@ public class ContextKeys<T> {
|
|||||||
public static final ContextKeys<Double> MAX_SIZE = of("max_size", Double.class);
|
public static final ContextKeys<Double> MAX_SIZE = of("max_size", Double.class);
|
||||||
public static final ContextKeys<String> RANK = of("rank", String.class);
|
public static final ContextKeys<String> RANK = of("rank", String.class);
|
||||||
public static final ContextKeys<Location> OTHER_LOCATION = of("other_location", Location.class);
|
public static final ContextKeys<Location> OTHER_LOCATION = of("other_location", Location.class);
|
||||||
|
public static final ContextKeys<ActiveTotemList> TOTEMS = of("totems", ActiveTotemList.class);
|
||||||
public static final ContextKeys<Integer> OTHER_X = of("other_x", Integer.class);
|
public static final ContextKeys<Integer> OTHER_X = of("other_x", Integer.class);
|
||||||
public static final ContextKeys<Integer> OTHER_Y = of("other_y", Integer.class);
|
public static final ContextKeys<Integer> OTHER_Y = of("other_y", Integer.class);
|
||||||
public static final ContextKeys<Integer> OTHER_Z = of("other_z", Integer.class);
|
public static final ContextKeys<Integer> OTHER_Z = of("other_z", Integer.class);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
|||||||
import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
|
import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
|
||||||
import net.momirealms.customfishing.api.mechanic.hook.HookConfig;
|
import net.momirealms.customfishing.api.mechanic.hook.HookConfig;
|
||||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
||||||
|
import net.momirealms.customfishing.api.mechanic.totem.ActiveTotemList;
|
||||||
import net.momirealms.customfishing.api.storage.user.UserData;
|
import net.momirealms.customfishing.api.storage.user.UserData;
|
||||||
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||||
import net.momirealms.customfishing.common.item.Item;
|
import net.momirealms.customfishing.common.item.Item;
|
||||||
@@ -236,6 +237,7 @@ public class FishingGears {
|
|||||||
|
|
||||||
// set totems
|
// set totems
|
||||||
Collection<String> totemIDs = BukkitCustomFishingPlugin.getInstance().getTotemManager().getActivatedTotems(player.getLocation());
|
Collection<String> totemIDs = BukkitCustomFishingPlugin.getInstance().getTotemManager().getActivatedTotems(player.getLocation());
|
||||||
|
context.arg(ContextKeys.TOTEMS, new ActiveTotemList(totemIDs));
|
||||||
for (String id : totemIDs) {
|
for (String id : totemIDs) {
|
||||||
BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(id, MechanicType.TOTEM).ifPresent(fishingGears.modifiers::add);
|
BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(id, MechanicType.TOTEM).ifPresent(fishingGears.modifiers::add);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) <2024> <XiaoMoMi>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.momirealms.customfishing.api.mechanic.totem;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ActiveTotemList {
|
||||||
|
|
||||||
|
private final Set<String> totems;
|
||||||
|
|
||||||
|
public ActiveTotemList(Collection<String> totems) {
|
||||||
|
this.totems = new HashSet<>(totems);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(final String totem) {
|
||||||
|
totems.add(totem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> totems() {
|
||||||
|
return totems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasTotem(String totem) {
|
||||||
|
return totems.contains(totem);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -693,8 +693,8 @@ public class BukkitActionManager implements ActionManager<Player> {
|
|||||||
private void registerSoundAction() {
|
private void registerSoundAction() {
|
||||||
registerAction((args, chance) -> {
|
registerAction((args, chance) -> {
|
||||||
if (args instanceof Section section) {
|
if (args instanceof Section section) {
|
||||||
MathValue<Player> volume = MathValue.auto(section.get("volume"));
|
MathValue<Player> volume = MathValue.auto(section.get("volume", 1));
|
||||||
MathValue<Player> pitch = MathValue.auto(section.get("pitch"));
|
MathValue<Player> pitch = MathValue.auto(section.get("pitch", 1));
|
||||||
Key key = Key.key(section.getString("key"));
|
Key key = Key.key(section.getString("key"));
|
||||||
Sound.Source source = Sound.Source.valueOf(section.getString("source", "PLAYER").toUpperCase(Locale.ENGLISH));
|
Sound.Source source = Sound.Source.valueOf(section.getString("source", "PLAYER").toUpperCase(Locale.ENGLISH));
|
||||||
return context -> {
|
return context -> {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
|||||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementExpansion;
|
import net.momirealms.customfishing.api.mechanic.requirement.RequirementExpansion;
|
||||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementFactory;
|
import net.momirealms.customfishing.api.mechanic.requirement.RequirementFactory;
|
||||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
|
||||||
|
import net.momirealms.customfishing.api.mechanic.totem.ActiveTotemList;
|
||||||
import net.momirealms.customfishing.api.util.MoonPhase;
|
import net.momirealms.customfishing.api.util.MoonPhase;
|
||||||
import net.momirealms.customfishing.bukkit.integration.VaultHook;
|
import net.momirealms.customfishing.bukkit.integration.VaultHook;
|
||||||
import net.momirealms.customfishing.common.util.ClassUtils;
|
import net.momirealms.customfishing.common.util.ClassUtils;
|
||||||
@@ -202,6 +203,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
|
|||||||
this.registerGameModeRequirement();
|
this.registerGameModeRequirement();
|
||||||
this.registerEquipmentRequirement();
|
this.registerEquipmentRequirement();
|
||||||
this.registerLiquidDepthRequirement();
|
this.registerLiquidDepthRequirement();
|
||||||
|
this.registerTotemRequirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerImpossibleRequirement() {
|
private void registerImpossibleRequirement() {
|
||||||
@@ -755,6 +757,22 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
|
|||||||
}, "liquid-depth");
|
}, "liquid-depth");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTotemRequirement() {
|
||||||
|
registerRequirement((args, actions, advanced) -> {
|
||||||
|
List<String> totems = ListUtils.toList(args);
|
||||||
|
return context -> {
|
||||||
|
ActiveTotemList totemList = context.arg(ContextKeys.TOTEMS);
|
||||||
|
if (totemList != null) {
|
||||||
|
for (String totem : totems) {
|
||||||
|
if (totemList.hasTotem(totem)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (advanced) ActionManager.trigger(context, actions);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}, "totem");
|
||||||
|
}
|
||||||
|
|
||||||
private void registerLevelRequirement() {
|
private void registerLevelRequirement() {
|
||||||
registerRequirement((args, actions, runActions) -> {
|
registerRequirement((args, actions, runActions) -> {
|
||||||
MathValue<Player> value = MathValue.auto(args);
|
MathValue<Player> value = MathValue.auto(args);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Project settings
|
# Project settings
|
||||||
# Rule: [major update].[feature update].[bug fix]
|
# Rule: [major update].[feature update].[bug fix]
|
||||||
project_version=2.3.0
|
project_version=2.3.1
|
||||||
config_version=38
|
config_version=38
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user