9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2025-01-10 00:35:24 +08:00
parent 9393bde4b9
commit 9b18b7175e
6 changed files with 67 additions and 3 deletions

View File

@@ -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.loot.LootType;
import net.momirealms.customfishing.api.mechanic.totem.ActiveTotemList;
import org.bukkit.Location;
import org.bukkit.inventory.EquipmentSlot;
import java.util.Objects;
import java.util.Set;
/**
* 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<String> RANK = of("rank", String.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_Y = of("other_y", Integer.class);
public static final ContextKeys<Integer> OTHER_Z = of("other_z", Integer.class);

View File

@@ -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.hook.HookConfig;
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.common.helper.AdventureHelper;
import net.momirealms.customfishing.common.item.Item;
@@ -236,6 +237,7 @@ public class FishingGears {
// set totems
Collection<String> totemIDs = BukkitCustomFishingPlugin.getInstance().getTotemManager().getActivatedTotems(player.getLocation());
context.arg(ContextKeys.TOTEMS, new ActiveTotemList(totemIDs));
for (String id : totemIDs) {
BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(id, MechanicType.TOTEM).ifPresent(fishingGears.modifiers::add);
}

View File

@@ -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);
}
}