mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-28 19:39:06 +00:00
left click
This commit is contained in:
@@ -220,16 +220,16 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
|
||||
"org.mongodb:bson:4.10.2", mavenRepo,
|
||||
"org.xerial:sqlite-jdbc:3.43.0.0", mavenRepo,
|
||||
"dev.jorel:commandapi-bukkit-shade:9.2.0", mavenRepo,
|
||||
"xyz.xenondevs.invui:invui-core:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r8:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r9:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r10:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r11:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r12:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r13:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r14:1.19", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r15:1.19", "https://repo.xenondevs.xyz/releases/"
|
||||
"xyz.xenondevs.invui:invui-core:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r8:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r9:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r10:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r11:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r12:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r13:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r14:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r15:1.23", "https://repo.xenondevs.xyz/releases/"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customfishing.mechanic.fishing;
|
||||
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customfishing.CustomFishingPluginImpl;
|
||||
@@ -57,7 +58,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -67,6 +70,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class FishingManagerImpl implements Listener, FishingManager {
|
||||
|
||||
@@ -154,6 +158,25 @@ public class FishingManagerImpl implements Listener, FishingManager {
|
||||
this.removeTempFishingState(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Known bug: When you fish, both left click air and right click air
|
||||
* are triggered. And you can't cancel the left click event.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onLeftClick(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.LEFT_CLICK_AIR)
|
||||
return;
|
||||
if (event.getMaterial() != Material.FISHING_ROD)
|
||||
return;
|
||||
if (event.getHand() != EquipmentSlot.HAND)
|
||||
return;
|
||||
GamingPlayer gamingPlayer = gamingPlayerMap.get(event.getPlayer().getUniqueId());
|
||||
if (gamingPlayer != null) {
|
||||
if (gamingPlayer.onLeftClick())
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSwapHand(PlayerSwapHandItemsEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
@@ -304,7 +327,12 @@ public class FishingManagerImpl implements Listener, FishingManager {
|
||||
this.hookCacheMap.put(player.getUniqueId(), fishHook);
|
||||
// fishHook.setMaxWaitTime(Math.max(100, (int) (fishHook.getMaxWaitTime() * initialEffect.getHookTimeModifier())));
|
||||
// fishHook.setMinWaitTime(Math.max(100, (int) (fishHook.getMinWaitTime() * initialEffect.getHookTimeModifier())));
|
||||
fishHook.setWaitTime(Math.max(1, (int) (fishHook.getWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
if (CFConfig.overrideVanilla) {
|
||||
double initialTime = ThreadLocalRandom.current().nextInt(CFConfig.waterMaxTime - CFConfig.waterMinTime + 1) + CFConfig.waterMinTime;
|
||||
fishHook.setWaitTime(Math.max(1, (int) (initialTime * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
} else {
|
||||
fishHook.setWaitTime(Math.max(1, (int) (fishHook.getWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
}
|
||||
// Reduce amount & Send animation
|
||||
var baitItem = fishingPreparation.getBaitItemStack();
|
||||
if (baitItem != null) {
|
||||
@@ -532,11 +560,11 @@ public class FishingManagerImpl implements Listener, FishingManager {
|
||||
if (player.getGameMode() != GameMode.CREATIVE)
|
||||
outer: {
|
||||
ItemStack rod = tempFishingState.getPreparation().getRodItemStack();
|
||||
PlayerItemDamageEvent damageEvent = new PlayerItemDamageEvent(player, rod, 1, 1);
|
||||
Bukkit.getPluginManager().callEvent(damageEvent);
|
||||
if (damageEvent.isCancelled()) {
|
||||
break outer;
|
||||
}
|
||||
// PlayerItemDamageEvent damageEvent = new PlayerItemDamageEvent(player, rod, 1, 1);
|
||||
// Bukkit.getPluginManager().callEvent(damageEvent);
|
||||
// if (damageEvent.isCancelled()) {
|
||||
// break outer;
|
||||
// }
|
||||
ItemUtils.decreaseHookDurability(rod, 1, false);
|
||||
ItemUtils.decreaseDurability(player, rod, 1, true);
|
||||
}
|
||||
|
||||
@@ -204,10 +204,20 @@ public class HookCheckTimerTask implements Runnable {
|
||||
*/
|
||||
private void startLavaFishingMechanic() {
|
||||
// get random time
|
||||
int random = ThreadLocalRandom.current().nextInt(CFConfig.lavaMinTime, CFConfig.lavaMaxTime);
|
||||
random -= lureLevel * 100;
|
||||
random *= initialEffect.getWaitTimeMultiplier();
|
||||
random = Math.max(CFConfig.lavaMinTime, random);
|
||||
int random;
|
||||
if (CFConfig.overrideVanilla) {
|
||||
random = ThreadLocalRandom.current().nextInt(CFConfig.lavaMinTime, CFConfig.lavaMaxTime);
|
||||
random *= initialEffect.getWaitTimeMultiplier();
|
||||
random += initialEffect.getWaitTime();
|
||||
random = Math.max(1, random);
|
||||
} else {
|
||||
random = ThreadLocalRandom.current().nextInt(CFConfig.lavaMinTime, CFConfig.lavaMaxTime);
|
||||
random -= lureLevel * 100;
|
||||
random = Math.max(CFConfig.lavaMinTime, random);
|
||||
random *= initialEffect.getWaitTimeMultiplier();
|
||||
random += initialEffect.getWaitTime();
|
||||
random = Math.max(1, random);
|
||||
}
|
||||
|
||||
// lava effect task (Three seconds in advance)
|
||||
this.lavaFishingTask = new LavaEffectTask(
|
||||
|
||||
@@ -237,8 +237,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
if (face) progress++;
|
||||
else progress--;
|
||||
if (progress > totalWidth) {
|
||||
@@ -312,8 +311,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
if (player.isSneaking()) addV();
|
||||
else reduceV();
|
||||
if (timer < 40 - (settings.getDifficulty() / 10)) {
|
||||
@@ -443,8 +441,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
if (struggling_time <= 0) {
|
||||
if (Math.random() < ((double) settings.getDifficulty() / 4000)) {
|
||||
struggling_time = (int) (10 + Math.random() * (settings.getDifficulty() / 4));
|
||||
@@ -519,8 +516,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
showUI();
|
||||
}
|
||||
|
||||
@@ -575,8 +571,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
timer++;
|
||||
if (timer % (21 - settings.getDifficulty() / 5) == 0) {
|
||||
movePointer();
|
||||
@@ -665,8 +660,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
if (face) {
|
||||
progress++;
|
||||
if (progress >= barEffectiveWidth - 1) {
|
||||
@@ -750,8 +744,7 @@ public class GameManagerImpl implements GameManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
public void onTick() {
|
||||
if (timer < 40 - (settings.getDifficulty() / 10)) {
|
||||
timer++;
|
||||
} else {
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.util.Objects;
|
||||
public class CFConfig {
|
||||
|
||||
// config version
|
||||
public static String configVersion = "28";
|
||||
public static String configVersion = "29";
|
||||
// Debug mode
|
||||
public static boolean debug;
|
||||
// language
|
||||
@@ -70,6 +70,10 @@ public class CFConfig {
|
||||
public static String bagTitle;
|
||||
public static List<Material> bagWhiteListItems;
|
||||
|
||||
// Fishing wait time
|
||||
public static boolean overrideVanilla;
|
||||
public static int waterMinTime;
|
||||
public static int waterMaxTime;
|
||||
// Lava fishing
|
||||
public static int lavaMinTime;
|
||||
public static int lavaMaxTime;
|
||||
@@ -138,6 +142,10 @@ public class CFConfig {
|
||||
bagStoreLoots = config.getBoolean("mechanics.fishing-bag.can-store-loot", false);
|
||||
bagWhiteListItems = config.getStringList("mechanics.fishing-bag.whitelist-items").stream().map(it -> Material.valueOf(it.toUpperCase(Locale.ENGLISH))).toList();
|
||||
|
||||
overrideVanilla = config.getBoolean("mechanics.fishing-wait-time.override-vanilla", false);
|
||||
waterMinTime = config.getInt("mechanics.fishing-wait-time.min-wait-time", 100);
|
||||
waterMaxTime = config.getInt("mechanics.fishing-wait-time.min-wait-time", 600);
|
||||
|
||||
lavaMinTime = config.getInt("mechanics.lava-fishing.min-wait-time", 100);
|
||||
lavaMaxTime = config.getInt("mechanics.lava-fishing.max-wait-time", 600);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Developer: @Xiao-MoMi
|
||||
# Wiki: https://mo-mi.gitbook.io/xiaomomi-plugins/
|
||||
config-version: '28'
|
||||
config-version: '29'
|
||||
|
||||
# Debug
|
||||
debug: false
|
||||
@@ -114,6 +114,18 @@ mechanics:
|
||||
whitelist-items:
|
||||
- fishing_rod
|
||||
|
||||
# Fishing wait time
|
||||
# This section would take effect if you set "override-vanilla" to true
|
||||
# That also means vanilla mechanics for example lure enchantment
|
||||
# would not longer take effect, so you have to configurate its effect
|
||||
# in enchantment effects.
|
||||
fishing-wait-time:
|
||||
# override vanilla mechanic
|
||||
override-vanilla: false
|
||||
# ticks
|
||||
min-wait-time: 100
|
||||
max-wait-time: 600
|
||||
|
||||
# Lava fishing settings
|
||||
# To modify vanilla fishing time, you should edit paper-world-defaults.yml where there's a section called fishing-time-range
|
||||
lava-fishing:
|
||||
|
||||
0
plugin/src/main/resources/effect-conditions.yml
Normal file
0
plugin/src/main/resources/effect-conditions.yml
Normal file
Reference in New Issue
Block a user