9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-04 15:41:35 +00:00

checkpoint - 21

This commit is contained in:
XiaoMoMi
2024-07-03 02:55:33 +08:00
parent 71de6ea626
commit f3d21e466d
46 changed files with 657 additions and 403 deletions

View File

@@ -1,10 +1,12 @@
package net.momirealms.customfishing.bukkit;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.event.CustomFishingReloadEvent;
import net.momirealms.customfishing.api.mechanic.config.ConfigManager;
import net.momirealms.customfishing.api.mechanic.item.MechanicType;
import net.momirealms.customfishing.api.mechanic.misc.cooldown.CoolDownManager;
import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlaceholderManager;
import net.momirealms.customfishing.api.util.EventUtils;
import net.momirealms.customfishing.bukkit.action.BukkitActionManager;
import net.momirealms.customfishing.bukkit.bag.BukkitBagManager;
import net.momirealms.customfishing.bukkit.block.BukkitBlockManager;
@@ -51,7 +53,7 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
private final PluginLogger logger;
private ChatCatcherManager chatCatcherManager;
private BukkitCommandManager commandManager;
private Consumer<String> debugger;
private Consumer<Object> debugger;
public BukkitCustomFishingPluginImpl(Plugin boostrap) {
super(boostrap);
@@ -139,7 +141,7 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
this.placeholderManager.reload();
this.configManager.reload();
// after ConfigManager
this.debugger = ConfigManager.debug() ? (s) -> logger.info("[DEBUG] " + s) : (s) -> {};
this.debugger = ConfigManager.debug() ? (s) -> logger.info("[DEBUG] " + s.toString()) : (s) -> {};
this.actionManager.reload();
this.requirementManager.reload();
@@ -160,6 +162,8 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
this.effectManager.load();
this.hookManager.load();
this.totemManager.load();
EventUtils.fireAndForget(new CustomFishingReloadEvent(this));
}
@Override
@@ -217,7 +221,7 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
}
@Override
public void debug(String message) {
public void debug(Object message) {
this.debugger.accept(message);
}

View File

@@ -140,6 +140,7 @@ public class BukkitActionManager implements ActionManager<Player> {
this.registerPluginExpAction();
this.registerSoundAction();
this.registerHologramAction();
this.registerFakeItemAction();
this.registerTitleAction();
}
@@ -159,7 +160,7 @@ public class BukkitActionManager implements ActionManager<Player> {
List<String> messages = ListUtils.toList(args);
return context -> {
if (Math.random() > chance) return;
String random = messages.get(RandomUtils.generateRandomInt(0, messages.size()));
String random = messages.get(RandomUtils.generateRandomInt(0, messages.size() - 1));
random = BukkitPlaceholderManager.getInstance().parse(context.getHolder(), random, context.placeholderMap());
Audience audience = plugin.getSenderFactory().getAudience(context.getHolder());
audience.sendMessage(AdventureHelper.miniMessage(random));
@@ -299,7 +300,7 @@ public class BukkitActionManager implements ActionManager<Player> {
List<String> texts = ListUtils.toList(args);
return context -> {
if (Math.random() > chance) return;
String random = texts.get(RandomUtils.generateRandomInt(0, texts.size()));
String random = texts.get(RandomUtils.generateRandomInt(0, texts.size() - 1));
random = plugin.getPlaceholderManager().parse(context.getHolder(), random, context.placeholderMap());
Audience audience = plugin.getSenderFactory().getAudience(context.getHolder());
audience.sendActionBar(AdventureHelper.miniMessage(random));
@@ -340,7 +341,7 @@ public class BukkitActionManager implements ActionManager<Player> {
return context -> {
if (Math.random() > chance) return;
final Player player = context.getHolder();
player.getLocation().getWorld().spawn(player.getLocation(), ExperienceOrb.class, e -> e.setExperience((int) value.evaluate(context)));
player.getLocation().getWorld().spawn(player.getLocation().clone().add(0,0.5,0), ExperienceOrb.class, e -> e.setExperience((int) value.evaluate(context)));
};
});
registerAction("exp", (args, chance) -> {
@@ -348,7 +349,7 @@ public class BukkitActionManager implements ActionManager<Player> {
return context -> {
if (Math.random() > chance) return;
final Player player = context.getHolder();
player.giveExp((int) value.evaluate(context));
player.giveExp((int) Math.round(value.evaluate(context)));
Audience audience = plugin.getSenderFactory().getAudience(player);
AdventureHelper.playSound(audience, Sound.sound(Key.key("minecraft:entity.experience_orb.pickup"), Sound.Source.PLAYER, 1, 1));
};
@@ -696,8 +697,8 @@ public class BukkitActionManager implements ActionManager<Player> {
int fadeOut = section.getInt("fade-out", 10);
return context -> {
if (Math.random() > chance) return;
TextValue<Player> title = TextValue.auto(titles.get(RandomUtils.generateRandomInt(0, titles.size())));
TextValue<Player> subtitle = TextValue.auto(subtitles.get(RandomUtils.generateRandomInt(0, subtitles.size())));
TextValue<Player> title = TextValue.auto(titles.get(RandomUtils.generateRandomInt(0, titles.size() - 1)));
TextValue<Player> subtitle = TextValue.auto(subtitles.get(RandomUtils.generateRandomInt(0, subtitles.size() - 1)));
final Player player = context.getHolder();
Audience audience = plugin.getSenderFactory().getAudience(player);
AdventureHelper.sendTitle(audience,
@@ -745,6 +746,60 @@ public class BukkitActionManager implements ActionManager<Player> {
});
}
private void registerFakeItemAction() {
registerAction("fake-item", ((args, chance) -> {
if (args instanceof Section section) {
String itemID = section.getString("item", "");
String[] split = itemID.split(":");
if (split.length >= 2) itemID = split[split.length - 1];
MathValue<Player> duration = MathValue.auto(section.get("duration", 20));
boolean position = !section.getString("position", "player").equals("player");
MathValue<Player> x = MathValue.auto(section.get("x", 0));
MathValue<Player> y = MathValue.auto(section.get("y", 0));
MathValue<Player> z = MathValue.auto(section.get("z", 0));
MathValue<Player> yaw = MathValue.auto(section.get("yaw", 0));
int range = section.getInt("range", 0);
boolean opposite = section.getBoolean("opposite-yaw", false);
String finalItemID = itemID;
return context -> {
if (Math.random() > chance) return;
Player owner = context.getHolder();
Location location = position ? requireNonNull(context.arg(ContextKeys.HOOK_LOCATION)).clone() : owner.getLocation().clone();
location.add(x.evaluate(context), y.evaluate(context) - 1, z.evaluate(context));
if (opposite) location.setYaw(-owner.getLocation().getYaw());
else location.setYaw((float) yaw.evaluate(context));
FakeArmorStand armorStand = SparrowHeart.getInstance().createFakeArmorStand(location);
armorStand.invisible(true);
armorStand.equipment(EquipmentSlot.HEAD, plugin.getItemManager().buildInternal(context, finalItemID));
ArrayList<Player> viewers = new ArrayList<>();
if (range > 0) {
for (Entity player : location.getWorld().getNearbyEntities(location, range, range, range, entity -> entity instanceof Player)) {
double distance = LocationUtils.getDistance(player.getLocation(), location);
if (distance <= range) {
viewers.add((Player) player);
}
}
} else {
viewers.add(owner);
}
for (Player player : viewers) {
armorStand.spawn(player);
}
plugin.getScheduler().asyncLater(() -> {
for (Player player : viewers) {
if (player.isOnline() && player.isValid()) {
armorStand.destroy(player);
}
}
}, (long) (duration.evaluate(context) * 50), TimeUnit.MILLISECONDS);
};
} else {
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at fake-item action which is expected to be `Section`");
return EmptyAction.INSTANCE;
}
}));
}
private void registerHologramAction() {
registerAction("hologram", ((args, chance) -> {
if (args instanceof Section section) {
@@ -758,8 +813,7 @@ public class BukkitActionManager implements ActionManager<Player> {
return context -> {
if (Math.random() > chance) return;
Player owner = context.getHolder();
Location location = position ? requireNonNull(context.arg(ContextKeys.LOCATION)).clone() : owner.getLocation().clone();
Location location = position ? requireNonNull(context.arg(ContextKeys.HOOK_LOCATION)).clone() : owner.getLocation().clone();
location.add(x.evaluate(context), y.evaluate(context), z.evaluate(context));
FakeArmorStand armorStand = SparrowHeart.getInstance().createFakeArmorStand(location);
armorStand.invisible(true);

View File

@@ -336,7 +336,7 @@ public class BukkitBlockManager implements BlockManager, Listener {
if (tuple.left().evaluate(context) > Math.random()) {
ItemStack itemStack = plugin.getItemManager().buildAny(context, tuple.mid());
if (itemStack != null) {
itemStack.setAmount(RandomUtils.generateRandomInt((int) tuple.right().left().evaluate(context), (int) (tuple.right().right().evaluate(context) + 1)));
itemStack.setAmount(RandomUtils.generateRandomInt((int) tuple.right().left().evaluate(context), (int) (tuple.right().right().evaluate(context))));
inventory.setItem(unused.pop(), itemStack);
}
}

View File

@@ -63,7 +63,7 @@ public class ActionBarSender {
@SuppressWarnings("DuplicatedCode")
private void updatePrivatePlaceholders() {
this.privateContext.arg(ContextKeys.SCORE, String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
int rank = competition.getRanking().getPlayerRank(player.getName());
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : StandardLocales.COMPETITION_NO_RANK);
this.privateContext.combine(competition.getPublicContext());

View File

@@ -73,7 +73,7 @@ public class BossBarSender {
@SuppressWarnings("DuplicatedCode")
private void updatePrivatePlaceholders() {
this.privateContext.arg(ContextKeys.SCORE, String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, String.format("%.2f", competition.getRanking().getPlayerScore(player.getName())));
int rank = competition.getRanking().getPlayerRank(player.getName());
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : StandardLocales.COMPETITION_NO_RANK);
this.privateContext.combine(competition.getPublicContext());

View File

@@ -16,6 +16,8 @@ import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.mechanic.effect.EffectProperties;
import net.momirealms.customfishing.api.mechanic.event.EventManager;
import net.momirealms.customfishing.api.mechanic.item.MechanicType;
import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
import net.momirealms.customfishing.api.mechanic.misc.value.TextValue;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
@@ -148,6 +150,8 @@ public class BukkitConfigManager extends ConfigManager {
enableBag = config.getBoolean("mechanics.fishing-bag.enable", true);
multipleLootSpawnDelay = config.getInt("mechanics.multiple-loot-spawn-delay", 4);
Section placeholderSection = config.getSection("other-settings.placeholder-register");
if (placeholderSection != null) {
for (Map.Entry<String, Object> entry : placeholderSection.getStringRouteMappedValues(false).entrySet()) {
@@ -159,12 +163,31 @@ public class BukkitConfigManager extends ConfigManager {
globalEffects = new ArrayList<>();
Section globalEffectSection = config.getSection("mechanics.global-effects");
if (globalEffectSection != null)
if (globalEffectSection != null) {
for (Map.Entry<String, Object> entry : globalEffectSection.getStringRouteMappedValues(false).entrySet()) {
if (entry.getValue() instanceof Section innerSection) {
globalEffects.add(parseEffect(innerSection));
}
}
}
EventManager.GLOBAL_ACTIONS.clear();
EventManager.GLOBAL_TIMES_ACTION.clear();
Section globalEvents = config.getSection("mechanics.global-events");
if (globalEvents != null) {
for (Map.Entry<String, Object> entry : globalEvents.getStringRouteMappedValues(false).entrySet()) {
MechanicType type = MechanicType.index().value(entry.getKey());
if (entry.getValue() instanceof Section inner) {
Map<ActionTrigger, Action<Player>[]> actionMap = new HashMap<>();
for (Map.Entry<String, Object> innerEntry : inner.getStringRouteMappedValues(false).entrySet()) {
if (innerEntry.getValue() instanceof Section actionSection) {
actionMap.put(ActionTrigger.valueOf(innerEntry.getKey().toUpperCase(Locale.ENGLISH)), plugin.getActionManager().parseActions(actionSection));
}
}
EventManager.GLOBAL_ACTIONS.put(type, actionMap);
}
}
}
}
private void loadConfigs() {

View File

@@ -116,8 +116,12 @@ public class BukkitEntityManager implements EntityManager {
} else {
entity = entityProviders.get("vanilla").spawn(hookLocation, entityID, config.propertyMap());
}
Vector vector = playerLocation.subtract(hookLocation).toVector().multiply(config.horizontalVector().evaluate(context) - 1);
vector = vector.setY((vector.getY() + 0.2) * config.verticalVector().evaluate(context));
double d0 = playerLocation.getX() - hookLocation.getX();
double d1 = playerLocation.getY() - hookLocation.getY();
double d2 = playerLocation.getZ() - hookLocation.getZ();
double d3 = config.horizontalVector().evaluate(context);
double d4 = config.verticalVector().evaluate(context);
Vector vector = new Vector(d0 * 0.1D * d3, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D * d4, d2 * 0.1D * d3);
entity.setVelocity(vector);
return entity;
}

View File

@@ -36,18 +36,18 @@ public class BukkitEventManager implements EventManager, Listener {
@Override
public void load() {
Bukkit.getPluginManager().registerEvents(this, plugin.getBoostrap());
Bukkit.getPluginManager().registerEvents(this, this.plugin.getBoostrap());
}
@Override
public Optional<EventCarrier> getEventCarrier(String id, MechanicType type) {
return Optional.ofNullable(carriers.get(type.getType() + ":" + id));
return Optional.ofNullable(this.carriers.get(type.getType() + ":" + id));
}
@Override
public boolean registerEventCarrier(EventCarrier carrier) {
if (carriers.containsKey(carrier.id())) return false;
carriers.put(carrier.type().getType() + ":" + carrier.id(), carrier);
if (this.carriers.containsKey(carrier.id())) return false;
this.carriers.put(carrier.type().getType() + ":" + carrier.id(), carrier);
return true;
}
@@ -60,8 +60,8 @@ public class BukkitEventManager implements EventManager, Listener {
ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR || itemStack.getAmount() == 0)
return;
String id = plugin.getItemManager().getItemID(itemStack);
Optional.ofNullable(carriers.get(id)).ifPresent(carrier -> {
String id = this.plugin.getItemManager().getItemID(itemStack);
Optional.ofNullable(this.carriers.get(id)).ifPresent(carrier -> {
carrier.trigger(Context.player(event.getPlayer()), ActionTrigger.INTERACT);
});
}

View File

@@ -1,14 +1,16 @@
package net.momirealms.customfishing.bukkit.fishing;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.event.FishingHookStateEvent;
import net.momirealms.customfishing.api.event.RodCastEvent;
import net.momirealms.customfishing.api.mechanic.config.ConfigManager;
import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.fishing.CustomFishingHook;
import net.momirealms.customfishing.api.mechanic.fishing.FishingGears;
import net.momirealms.customfishing.api.mechanic.fishing.FishingManager;
import net.momirealms.customfishing.api.mechanic.fishing.hook.VanillaMechanic;
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
import net.momirealms.customfishing.bukkit.util.EventUtils;
import net.momirealms.customfishing.api.util.EventUtils;
import net.momirealms.customfishing.common.helper.VersionHelper;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@@ -127,9 +129,30 @@ public class BukkitFishingManager implements FishingManager, Listener {
case CAUGHT_FISH -> onCaughtFish(event);
case BITE -> onBite(event);
case IN_GROUND -> onInGround(event);
case FAILED_ATTEMPT -> onFailedAttempt(event);
}
}
// for vanilla mechanics
private void onFailedAttempt(PlayerFishEvent event) {
Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
if (hook.getCurrentHookMechanic() instanceof VanillaMechanic vanillaMechanic) {
vanillaMechanic.onFailedAttempt();
}
});
}
// for vanilla mechanics
private void onBite(PlayerFishEvent event) {
Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
if (hook.getCurrentHookMechanic() instanceof VanillaMechanic vanillaMechanic) {
vanillaMechanic.onBite();
}
});
}
private void onCaughtEntity(PlayerFishEvent event) {
final Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
@@ -138,7 +161,8 @@ public class BukkitFishingManager implements FishingManager, Listener {
Objects.requireNonNull(NamespacedKey.fromString("temp-entity", plugin.getBoostrap())),
PersistentDataType.STRING
) != null) {
event.setCancelled(true);
hook.onReelIn();
}
});
}
@@ -146,20 +170,15 @@ public class BukkitFishingManager implements FishingManager, Listener {
private void onReelIn(PlayerFishEvent event) {
Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
event.setCancelled(true);
hook.onReelIn();
});
}
private void onBite(PlayerFishEvent event) {
Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
hook.onBite();
});
}
private void onCaughtFish(PlayerFishEvent event) {
Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
event.setCancelled(true);
hook.onReelIn();
});
}
@@ -169,24 +188,19 @@ public class BukkitFishingManager implements FishingManager, Listener {
Player player = event.getPlayer();
Context<Player> context = Context.player(player);
FishingGears gears = new FishingGears(context);
if (!RequirementManager.isSatisfied(context, ConfigManager.mechanicRequirements())) {
this.destroy(player.getUniqueId());
return;
}
if (!gears.canFish()) {
event.setCancelled(true);
return;
}
if (EventUtils.fireAndCheckCancel(new RodCastEvent(event, gears))) {
return;
}
plugin.debug(context.toString());
gears.cast();
CustomFishingHook customHook = new CustomFishingHook(hook, gears, context);
plugin.debug(context);
CustomFishingHook customHook = new CustomFishingHook(plugin, hook, gears, context);
this.castHooks.put(player.getUniqueId(), customHook);
}
@@ -202,6 +216,19 @@ public class BukkitFishingManager implements FishingManager, Listener {
}
}
@EventHandler
public void onHookStateChange(FishingHookStateEvent event) {
Player player = event.getPlayer();
getFishHook(player).ifPresent(hook -> {
switch (event.getState()) {
case BITE -> hook.onBite();
case LAND -> hook.onLand();
case ESCAPE -> hook.onEscape();
case LURE -> hook.onLure();
}
});
}
@Override
public void destroy(UUID uuid) {
this.getFishHook(uuid).ifPresent(hook -> {

View File

@@ -27,7 +27,6 @@ import net.momirealms.customfishing.bukkit.integration.enchant.AdvancedEnchantme
import net.momirealms.customfishing.bukkit.integration.enchant.VanillaEnchantmentsProvider;
import net.momirealms.customfishing.bukkit.integration.entity.ItemsAdderEntityProvider;
import net.momirealms.customfishing.bukkit.integration.entity.MythicEntityProvider;
import net.momirealms.customfishing.bukkit.integration.entity.VanillaEntityProvider;
import net.momirealms.customfishing.bukkit.integration.item.*;
import net.momirealms.customfishing.bukkit.integration.level.*;
import net.momirealms.customfishing.bukkit.integration.quest.BattlePassQuest;

View File

@@ -1,7 +1,6 @@
package net.momirealms.customfishing.bukkit.item;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.event.FishingLootPreSpawnEvent;
import net.momirealms.customfishing.api.event.FishingLootSpawnEvent;
import net.momirealms.customfishing.api.integration.ExternalProvider;
import net.momirealms.customfishing.api.integration.ItemProvider;
@@ -15,12 +14,14 @@ import net.momirealms.customfishing.bukkit.integration.item.CustomFishingItemPro
import net.momirealms.customfishing.bukkit.util.ItemUtils;
import net.momirealms.customfishing.bukkit.util.LocationUtils;
import net.momirealms.customfishing.common.item.Item;
import net.momirealms.sparrow.heart.SparrowHeart;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
@@ -152,19 +153,28 @@ public class BukkitItemManager implements ItemManager, Listener {
@Nullable
@Override
@SuppressWarnings("all")
public org.bukkit.entity.Item dropItemLoot(@NotNull Context<Player> context) {
public org.bukkit.entity.Item dropItemLoot(@NotNull Context<Player> context, ItemStack rod, FishHook hook) {
String id = requireNonNull(context.arg(ContextKeys.ID));
ItemStack itemStack = requireNonNull(buildInternal(context, id));
ItemStack itemStack;
if (id.equals("vanilla")) {
itemStack = SparrowHeart.getInstance().getFishingLoot(context.getHolder(), hook, rod).stream().findAny().orElseThrow(() -> new RuntimeException("new EntityItem would throw if for whatever reason (mostly shitty datapacks) the fishing loot turns out to be empty"));
} else {
itemStack = requireNonNull(buildInternal(context, id));
}
if (itemStack.getType() == Material.AIR) {
return null;
}
Player player = context.getHolder();
Location playerLocation = player.getLocation();
Location hookLocation = requireNonNull(context.arg(ContextKeys.HOOK_LOCATION));
FishingLootPreSpawnEvent preSpawnEvent = new FishingLootPreSpawnEvent(player, hookLocation, itemStack);
Bukkit.getPluginManager().callEvent(preSpawnEvent);
if (preSpawnEvent.isCancelled()) {
return null;
}
double d0 = playerLocation.getX() - hookLocation.getX();
double d1 = playerLocation.getY() - hookLocation.getY();
double d2 = playerLocation.getZ() - hookLocation.getZ();
double d3 = 0.1D;
Vector vector = new Vector(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
org.bukkit.entity.Item itemEntity = hookLocation.getWorld().dropItem(hookLocation, itemStack);
FishingLootSpawnEvent spawnEvent = new FishingLootSpawnEvent(player, hookLocation, itemEntity);
@@ -181,8 +191,6 @@ public class BukkitItemManager implements ItemManager, Listener {
itemEntity.setInvulnerable(false);
}, 1, TimeUnit.SECONDS);
Vector vector = playerLocation.subtract(hookLocation).toVector().multiply(0.105);
vector = vector.setY((vector.getY() + 0.22) * 1.18);
itemEntity.setVelocity(vector);
return itemEntity;
@@ -346,4 +354,9 @@ public class BukkitItemManager implements ItemManager, Listener {
public Collection<String> getItemIDs() {
return items.keySet();
}
@Override
public Item<ItemStack> wrap(ItemStack itemStack) {
return factory.wrap(itemStack);
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright (C) <2022> <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.bukkit.util;
import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
public class EventUtils {
public static void fireAndForget(Event event) {
Bukkit.getPluginManager().callEvent(event);
}
public static boolean fireAndCheckCancel(Event event) {
if (!(event instanceof Cancellable cancellable))
throw new IllegalArgumentException("Only cancellable events are allowed here");
Bukkit.getPluginManager().callEvent(event);
return cancellable.isCancelled();
}
}

View File

@@ -122,7 +122,7 @@ mechanics:
value:
duration: 35
position: other
item: util:lava_effect
item: lava_effect
priority_2:
conditions:
lava-fishing: false
@@ -132,7 +132,7 @@ mechanics:
value:
duration: 35
position: other
item: util:water_effect
item: water_effect
# Global properties which would help you reduce duplicated lines
global-loot-property:

View File

@@ -12,6 +12,12 @@ vanilla:
disable-stat: true
group:
- river
events:
success:
action_mending:
type: mending
value: 1~7
chance: 1.0
# Some rubbish
stick:
tag: false

View File

@@ -60,6 +60,7 @@ competition.no_player: "No Player"
competition.no_rank: "No Rank"
competition.goal.catch_amount: "Fish count caught"
competition.goal.max_size: "Largest fish caught"
competition.goal.min_size: "Smallest fish caught"
competition.goal.total_score: "Cumulative score of fish caught"
competition.goal.total_size: "Total length of fish caught"
format.day: "d"