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
2023-07-19 02:42:01 +08:00
parent 76a0930084
commit c7f8eecb21
24 changed files with 299 additions and 203 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
group = 'net.momirealms'
version = '1.3.2.2'
version = '1.3.2.3'
repositories {
maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"}
@@ -35,7 +35,7 @@ dependencies {
compileOnly('me.clip:placeholderapi:2.11.3')
compileOnly("com.github.oraxen:oraxen:1.158.0")
compileOnly('io.lumine:Mythic-Dist:5.2.1')
compileOnly('dev.dejvokep:boosted-yaml:1.3')
compileOnly('dev.dejvokep:boosted-yaml:1.3.1')
compileOnly('com.github.LoneDev6:api-itemsadder:3.4.1-r4')
compileOnly('net.objecthunter:exp4j:0.4.8')
compileOnly('org.mariadb.jdbc:mariadb-java-client:3.1.4')

View File

@@ -138,7 +138,7 @@ public final class CustomFishing extends JavaPlugin {
String libRepo = timeZone.getID().startsWith("Asia") ? "https://maven.aliyun.com/repository/public/" : "https://repo.maven.apache.org/maven2/";
LibraryLoader.load("org.apache.commons","commons-pool2","2.11.1", libRepo);
LibraryLoader.load("redis.clients","jedis","4.4.3", "https://repo.maven.apache.org/maven2/");
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3", libRepo);
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3.1", libRepo);
LibraryLoader.load("com.zaxxer","HikariCP","5.0.1", libRepo);
LibraryLoader.load("net.objecthunter","exp4j","0.4.8", libRepo);
LibraryLoader.load("org.mariadb.jdbc","mariadb-java-client","3.1.4", libRepo);

View File

@@ -19,7 +19,6 @@ package net.momirealms.customfishing.api.event;
import net.momirealms.customfishing.fishing.FishResult;
import net.momirealms.customfishing.fishing.loot.Loot;
import net.momirealms.customfishing.fishing.loot.LootImpl;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.api.event;
import net.momirealms.customfishing.fishing.Effect;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

View File

@@ -26,8 +26,10 @@ public abstract class FishingBar {
protected String[] titles;
protected String font;
protected String barImage;
protected String tip;
public FishingBar(ConfigurationSection section) {
this.tip = section.getString("tip");
this.titles = section.getStringList("title").size() == 0 ? new String[]{section.getString("title")} : section.getStringList("title").toArray(new String[0]);
this.font = section.getString("subtitle.font", "customfishing:bar");
this.barImage = section.getString("subtitle.bar","");
@@ -44,4 +46,8 @@ public abstract class FishingBar {
public String getFont() {
return font;
}
public String getTip() {
return tip;
}
}

View File

@@ -28,7 +28,6 @@ public class ModeOneBar extends FishingBar {
private final double[] successRate;
private final int totalWidth;
private final int pointerWidth;
private final String pointerImage;
private final int pointerOffset;

View File

@@ -21,80 +21,80 @@ import org.bukkit.configuration.ConfigurationSection;
public class ModeThreeBar extends FishingBar {
private final String fish_image;
private final int fish_icon_width;
private final String fishImage;
private final int fishIconWidth;
private final String[] strain;
private final String[] struggling_fish_image;
private final int bar_effective_width;
private final int fish_offset;
private final int fish_start_position;
private final int success_position;
private final double ultimate_strain;
private final double normal_increase;
private final double struggling_increase;
private final double strain_loss;
private final String[] strugglingFishImage;
private final int barEffectiveWidth;
private final int fishOffset;
private final int fishStartPosition;
private final int successPosition;
private final double ultimateStrain;
private final double normalIncrease;
private final double strugglingIncrease;
private final double strainLoss;
public ModeThreeBar(ConfigurationSection section) {
super(section);
this.fish_icon_width = section.getInt("arguments.fish-icon-width");
this.fish_image = section.getString("subtitle.fish");
this.fishIconWidth = section.getInt("arguments.fish-icon-width");
this.fishImage = section.getString("subtitle.fish");
this.strain = section.getStringList("strain").toArray(new String[0]);
this.struggling_fish_image = section.getStringList("subtitle.struggling-fish").toArray(new String[0]);
this.bar_effective_width = section.getInt("arguments.bar-effective-area-width");
this.fish_offset = section.getInt("arguments.fish-offset");
this.fish_start_position = section.getInt("arguments.fish-start-position");
this.success_position = section.getInt("arguments.success-position");
this.ultimate_strain = section.getDouble("arguments.ultimate-strain", 50);
this.normal_increase = section.getDouble("arguments.normal-pull-strain-increase", 1);
this.struggling_increase = section.getDouble("arguments.struggling-strain-increase", 2);
this.strain_loss = section.getDouble("arguments.loosening-strain-loss", 2);
this.strugglingFishImage = section.getStringList("subtitle.struggling-fish").toArray(new String[0]);
this.barEffectiveWidth = section.getInt("arguments.bar-effective-area-width");
this.fishOffset = section.getInt("arguments.fish-offset");
this.fishStartPosition = section.getInt("arguments.fish-start-position");
this.successPosition = section.getInt("arguments.success-position");
this.ultimateStrain = section.getDouble("arguments.ultimate-strain", 50);
this.normalIncrease = section.getDouble("arguments.normal-pull-strain-increase", 1);
this.strugglingIncrease = section.getDouble("arguments.struggling-strain-increase", 2);
this.strainLoss = section.getDouble("arguments.loosening-strain-loss", 2);
}
public String getFish_image() {
return fish_image;
public String getFishImage() {
return fishImage;
}
public int getFish_icon_width() {
return fish_icon_width;
public int getFishIconWidth() {
return fishIconWidth;
}
public String[] getStrain() {
return strain;
}
public int getBar_effective_width() {
return bar_effective_width;
public int getBarEffectiveWidth() {
return barEffectiveWidth;
}
public int getFish_offset() {
return fish_offset;
public int getFishOffset() {
return fishOffset;
}
public int getFish_start_position() {
return fish_start_position;
public int getFishStartPosition() {
return fishStartPosition;
}
public int getSuccess_position() {
return success_position;
public int getSuccessPosition() {
return successPosition;
}
public String[] getStruggling_fish_image() {
return struggling_fish_image;
public String[] getStrugglingFishImage() {
return strugglingFishImage;
}
public double getUltimate_strain() {
return ultimate_strain;
public double getUltimateStrain() {
return ultimateStrain;
}
public double getNormal_increase() {
return normal_increase;
public double getNormalIncrease() {
return normalIncrease;
}
public double getStruggling_increase() {
return struggling_increase;
public double getStrugglingIncrease() {
return strugglingIncrease;
}
public double getStrain_loss() {
return strain_loss;
public double getStrainLoss() {
return strainLoss;
}
}

View File

@@ -23,63 +23,61 @@ import java.util.Random;
public class ModeTwoBar extends FishingBar {
private final int[] time_requirements;
private final String judgement_area_image;
private final String fish_image;
private final int bar_effective_width;
private final int judgement_area_offset;
private final int judgement_area_width;
private final int fish_icon_width;
private final int[] timeRequirements;
private final String judgementAreaImage;
private final String fishImage;
private final int barEffectiveWidth;
private final int judgementAreaOffset;
private final int judgementAreaWidth;
private final int fishIconWidth;
private final String[] progress;
private final double punishment;
private final double water_resistance;
private final double pulling_strength;
private final double loosening_loss;
private final boolean sneakMode;
private final double waterResistance;
private final double pullingStrength;
private final double looseningLoss;
public ModeTwoBar(ConfigurationSection section) {
super(section);
this.time_requirements = section.getIntegerList("hold-time-requirements").stream().mapToInt(Integer::intValue).toArray();
this.judgement_area_image = section.getString("subtitle.judgment-area");
this.fish_image = section.getString("subtitle.fish");
this.bar_effective_width = section.getInt("arguments.bar-effective-area-width");
this.judgement_area_offset = section.getInt("arguments.judgment-area-offset");
this.judgement_area_width = section.getInt("arguments.judgment-area-width");
this.fish_icon_width = section.getInt("arguments.fish-icon-width");
this.timeRequirements = section.getIntegerList("hold-time-requirements").stream().mapToInt(Integer::intValue).toArray();
this.judgementAreaImage = section.getString("subtitle.judgment-area");
this.fishImage = section.getString("subtitle.fish");
this.barEffectiveWidth = section.getInt("arguments.bar-effective-area-width");
this.judgementAreaOffset = section.getInt("arguments.judgment-area-offset");
this.judgementAreaWidth = section.getInt("arguments.judgment-area-width");
this.fishIconWidth = section.getInt("arguments.fish-icon-width");
this.punishment = section.getDouble("arguments.punishment");
this.progress = section.getStringList("progress").toArray(new String[0]);
this.water_resistance = section.getDouble("arguments.water-resistance", 0.15);
this.pulling_strength = section.getDouble("arguments.pulling-strength", 0.45);
this.loosening_loss = section.getDouble("arguments.loosening-strength-loss", 0.3);
this.sneakMode = section.getString("arguments.pull-method", "sneak").equalsIgnoreCase("sneak");
this.waterResistance = section.getDouble("arguments.water-resistance", 0.15);
this.pullingStrength = section.getDouble("arguments.pulling-strength", 0.45);
this.looseningLoss = section.getDouble("arguments.loosening-strength-loss", 0.3);
}
public int getRandomTimeRequirement() {
return time_requirements[new Random().nextInt(time_requirements.length)] * 20;
return timeRequirements[new Random().nextInt(timeRequirements.length)] * 20;
}
public String getJudgement_area_image() {
return judgement_area_image;
public String getJudgementAreaImage() {
return judgementAreaImage;
}
public String getFish_image() {
return fish_image;
public String getFishImage() {
return fishImage;
}
public int getBar_effective_width() {
return bar_effective_width;
public int getBarEffectiveWidth() {
return barEffectiveWidth;
}
public int getJudgement_area_offset() {
return judgement_area_offset;
public int getJudgementAreaOffset() {
return judgementAreaOffset;
}
public int getJudgement_area_width() {
return judgement_area_width;
public int getJudgementAreaWidth() {
return judgementAreaWidth;
}
public int getFish_icon_width() {
return fish_icon_width;
public int getFishIconWidth() {
return fishIconWidth;
}
public String[] getProgress() {
@@ -90,19 +88,15 @@ public class ModeTwoBar extends FishingBar {
return punishment;
}
public double getWater_resistance() {
return water_resistance;
public double getWaterResistance() {
return waterResistance;
}
public double getPulling_strength() {
return pulling_strength;
public double getPullingStrength() {
return pullingStrength;
}
public double getLoosening_loss() {
return loosening_loss;
}
public boolean isSneakMode() {
return sneakMode;
public double getLooseningLoss() {
return looseningLoss;
}
}

View File

@@ -29,6 +29,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffectType;
import java.time.LocalTime;
import java.util.concurrent.ScheduledFuture;
public abstract class FishingGame implements Runnable {
@@ -42,8 +43,18 @@ public abstract class FishingGame implements Runnable {
protected String title;
protected FishHook fishHook;
protected ScheduledFuture<?> gameTask;
protected boolean success;
private int doubleCheckTime;
public FishingGame(CustomFishing plugin, FishingManager fishingManager, long deadline, Player player, int difficulty, FishingBar fishingBar) {
public FishingGame(
CustomFishing plugin,
FishingManager fishingManager,
long deadline,
Player player,
int difficulty,
FishingBar fishingBar
) {
this.plugin = plugin;
this.offsetManager = plugin.getOffsetManager();
this.fishingManager = fishingManager;
this.player = player;
@@ -51,6 +62,7 @@ public abstract class FishingGame implements Runnable {
this.difficulty = difficulty;
this.title = fishingBar.getRandomTitle();
this.fishHook = fishingManager.getHook(player.getUniqueId());
this.success = false;
}
@Override
@@ -79,6 +91,7 @@ public abstract class FishingGame implements Runnable {
}
protected void switchItemCheck() {
if (!isANewSecond()) return;
PlayerInventory playerInventory = player.getInventory();
if (playerInventory.getItemInMainHand().getType() != Material.FISHING_ROD && playerInventory.getItemInOffHand().getType() != Material.FISHING_ROD) {
cancel();
@@ -100,4 +113,37 @@ public abstract class FishingGame implements Runnable {
this.gameTask.cancel(false);
}
}
public void success() {
success = true;
proceedTheResult();
cancel();
}
public void fail() {
success = false;
proceedTheResult();
cancel();
}
public void proceedTheResult() {
plugin.getScheduler().runTask(() -> {
FishHook fishHook = fishingManager.getHook(player.getUniqueId());
if (fishHook != null) {
fishingManager.proceedReelIn(fishHook.getLocation(), player, this);
fishingManager.removeHook(player.getUniqueId());
fishingManager.removeFishingPlayer(player);
}
}, fishHook.getLocation());
}
private boolean isANewSecond() {
int minute = LocalTime.now().getSecond();
if (doubleCheckTime != minute) {
doubleCheckTime = minute;
return true;
} else {
return false;
}
}
}

View File

@@ -31,11 +31,18 @@ public class ModeOneGame extends FishingGame {
private boolean face;
private final ModeOneBar modeOneBar;
public ModeOneGame(CustomFishing plugin, FishingManager fishingManager, long deadline, Player player, int difficulty, ModeOneBar modeOneBar) {
public ModeOneGame(
CustomFishing plugin,
FishingManager fishingManager,
long deadline,
Player player,
int difficulty,
ModeOneBar modeOneBar
) {
super(plugin, fishingManager, deadline, player, difficulty, modeOneBar);
this.face = true;
this.modeOneBar = modeOneBar;
this.gameTask = plugin.getScheduler().runTaskTimer(this, 50, 54 - difficulty * 4L, TimeUnit.MILLISECONDS);
this.gameTask = plugin.getScheduler().runTaskTimerAsync(this, 50, Math.max(55 - difficulty * 5L, 5), TimeUnit.MILLISECONDS);
this.progress = -1;
}

View File

@@ -30,19 +30,27 @@ public class ModeThreeGame extends FishingGame {
private final ModeThreeBar modeThreeBar;
private int fish_position;
private boolean success;
private int timer;
private final int timer_max;
private double strain;
private int struggling_time;
private boolean played;
public ModeThreeGame(CustomFishing plugin, FishingManager fishingManager, long deadline, Player player, int difficulty, ModeThreeBar modeThreeBar) {
public ModeThreeGame(
CustomFishing plugin,
FishingManager fishingManager,
long deadline,
Player player,
int difficulty,
ModeThreeBar modeThreeBar
) {
super(plugin, fishingManager, deadline, player, difficulty, modeThreeBar);
this.fish_position = modeThreeBar.getFish_start_position();
this.fish_position = modeThreeBar.getFishStartPosition();
this.success = false;
this.modeThreeBar = modeThreeBar;
this.timer_max = modeThreeBar.getStruggling_fish_image().length;
this.gameTask = plugin.getScheduler().runTaskTimer(this, 50, 40, TimeUnit.MILLISECONDS);
this.timer_max = modeThreeBar.getStrugglingFishImage().length;
this.gameTask = plugin.getScheduler().runTaskTimerAsync(this, 50, 40, TimeUnit.MILLISECONDS);
this.played = false;
}
@Override
@@ -53,65 +61,57 @@ public class ModeThreeGame extends FishingGame {
timer = 0;
}
if (struggling_time <= 0) {
if (Math.random() < ((double) difficulty / 200)) {
struggling_time = (int) (20 + Math.random() * difficulty * 3);
if (Math.random() < ((double) difficulty / 300)) {
struggling_time = (int) (15 + Math.random() * difficulty * 3);
}
}
else {
} else {
struggling_time--;
}
if (player.isSneaking()) pull();
else loosen();
if (fish_position < modeThreeBar.getSuccess_position() - modeThreeBar.getFish_icon_width() - 1) {
success = true;
FishHook fishHook = fishingManager.getHook(player.getUniqueId());
if (fishHook != null) {
fishingManager.proceedReelIn(fishHook.getLocation(), player, this);
fishingManager.removeHook(player.getUniqueId());
}
fishingManager.removeFishingPlayer(player);
cancel();
if (fish_position < modeThreeBar.getSuccessPosition() - modeThreeBar.getFishIconWidth() - 1) {
success();
return;
}
if (fish_position + modeThreeBar.getFish_icon_width() > modeThreeBar.getBar_effective_width() || strain >= modeThreeBar.getUltimate_strain()) {
FishHook fishHook = fishingManager.getHook(player.getUniqueId());
if (fishHook != null) {
fishingManager.proceedReelIn(fishHook.getLocation(), player, this);
fishingManager.removeHook(player.getUniqueId());
}
fishingManager.removeFishingPlayer(player);
cancel();
if (fish_position + modeThreeBar.getFishIconWidth() > modeThreeBar.getBarEffectiveWidth() || strain >= modeThreeBar.getUltimateStrain()) {
fail();
return;
}
showBar();
}
public void pull() {
played = true;
if (struggling_time > 0) {
strain += (modeThreeBar.getStruggling_increase() + ((double) difficulty / 5));
strain += (modeThreeBar.getStrugglingIncrease() + ((double) difficulty / 5));
fish_position -= 1;
} else {
strain += modeThreeBar.getNormal_increase();
strain += modeThreeBar.getNormalIncrease();
fish_position -= 2;
}
}
public void loosen() {
fish_position++;
strain -= modeThreeBar.getStrain_loss();
strain -= modeThreeBar.getStrainLoss();
}
@Override
public void showBar() {
String bar = "<font:" + modeThreeBar.getFont() + ">" + modeThreeBar.getBarImage()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getFish_offset() + fish_position) + "</font>"
+ (struggling_time > 0 ? modeThreeBar.getStruggling_fish_image()[timer] : modeThreeBar.getFish_image())
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getBar_effective_width() - fish_position - modeThreeBar.getFish_icon_width()) + "</font>"
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getFishOffset() + fish_position) + "</font>"
+ (struggling_time > 0 ? modeThreeBar.getStrugglingFishImage()[timer] : modeThreeBar.getFishImage())
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getBarEffectiveWidth() - fish_position - modeThreeBar.getFishIconWidth()) + "</font>"
+ "</font>";
strain = Math.max(0, Math.min(strain, modeThreeBar.getUltimate_strain()));
AdventureUtils.playerTitle(player,
title.replace("{strain}", modeThreeBar.getStrain()[(int) ((strain / modeThreeBar.getUltimate_strain()) * modeThreeBar.getStrain().length)])
, bar,0,500,0
strain = Math.max(0, Math.min(strain, modeThreeBar.getUltimateStrain()));
AdventureUtils.playerTitle(
player,
modeThreeBar.getTip() != null && !played ? modeThreeBar.getTip() :
title.replace("{strain}", modeThreeBar.getStrain()[(int) ((strain / modeThreeBar.getUltimateStrain()) * modeThreeBar.getStrain().length)]),
bar,
0,
500,
0
);
}

View File

@@ -25,12 +25,12 @@ import net.momirealms.customfishing.util.LocationUtils;
import org.bukkit.Location;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
import java.util.concurrent.TimeUnit;
public class ModeTwoGame extends FishingGame {
private boolean success;
private double hold_time;
private final ModeTwoBar modeTwoBar;
private double judgement_position;
@@ -39,35 +39,34 @@ public class ModeTwoGame extends FishingGame {
private double fish_velocity;
private int timer;
private final int time_requirement;
private final Location hookLoc;
private double distance;
private boolean played;
public ModeTwoGame(CustomFishing plugin, FishingManager fishingManager, long deadline, Player player, int difficulty, ModeTwoBar modeTwoBar, Location hookLoc) {
public ModeTwoGame(
CustomFishing plugin,
FishingManager fishingManager,
long deadline,
Player player,
int difficulty,
ModeTwoBar modeTwoBar,
Location hookLoc
) {
super(plugin, fishingManager, deadline, player, difficulty, modeTwoBar);
this.success = false;
this.judgement_position = (double) (modeTwoBar.getBar_effective_width() - modeTwoBar.getJudgement_area_width()) / 2;
this.judgement_position = (double) (modeTwoBar.getBarEffectiveWidth() - modeTwoBar.getJudgementAreaWidth()) / 2;
this.fish_position = 0;
this.timer = 0;
this.modeTwoBar = modeTwoBar;
this.time_requirement = modeTwoBar.getRandomTimeRequirement();
this.hookLoc = hookLoc;
this.distance = LocationUtils.getDistance(player.getLocation(), hookLoc);
this.gameTask = plugin.getScheduler().runTaskTimer(this, 50, 33, TimeUnit.MILLISECONDS);
this.played = false;
this.gameTask = plugin.getScheduler().runTaskTimerAsync(this, 50, 40, TimeUnit.MILLISECONDS);
}
@Override
public void run() {
super.run();
if (modeTwoBar.isSneakMode()) {
if (player.isSneaking()) addV(true);
if (player.isSneaking()) addV();
else reduceV();
} else {
double newDistance = LocationUtils.getDistance(player.getLocation(), hookLoc);
if (distance < newDistance) addV(true);
else if (distance > newDistance) addV(false);
distance = newDistance;
}
if (timer < 30) {
if (timer < 40 - difficulty) {
timer++;
} else {
timer = 0;
@@ -77,24 +76,15 @@ public class ModeTwoGame extends FishingGame {
}
judgement_position += judgement_velocity;
fish_position += fish_velocity;
fraction();
calibrate();
if (fish_position >= judgement_position - 2 && fish_position + modeTwoBar.getFish_icon_width() <= judgement_position + modeTwoBar.getJudgement_area_width() + 2) {
if (fish_position >= judgement_position - 2 && fish_position + modeTwoBar.getFishIconWidth() <= judgement_position + modeTwoBar.getJudgementAreaWidth() + 2) {
hold_time += 0.66;
} else {
hold_time -= modeTwoBar.getPunishment() * 0.66;
}
if (hold_time >= time_requirement) {
success = true;
FishHook fishHook = fishingManager.getHook(player.getUniqueId());
if (fishHook != null) {
fishingManager.proceedReelIn(fishHook.getLocation(), player, this);
fishingManager.removeHook(player.getUniqueId());
}
fishingManager.removeFishingPlayer(player);
cancel();
success();
return;
}
showBar();
@@ -103,22 +93,28 @@ public class ModeTwoGame extends FishingGame {
@Override
public void showBar() {
String bar = "<font:" + modeTwoBar.getFont() + ">" + modeTwoBar.getBarImage()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getJudgement_area_offset() + judgement_position)) + "</font>"
+ modeTwoBar.getJudgement_area_image()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getBar_effective_width() - judgement_position - modeTwoBar.getJudgement_area_width())) + "</font>"
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (-modeTwoBar.getBar_effective_width() - 1 + fish_position)) + "</font>"
+ modeTwoBar.getFish_image()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getBar_effective_width() - fish_position - modeTwoBar.getFish_icon_width() + 1)) + "</font>"
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getJudgementAreaOffset() + judgement_position)) + "</font>"
+ modeTwoBar.getJudgementAreaImage()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getBarEffectiveWidth() - judgement_position - modeTwoBar.getJudgementAreaWidth())) + "</font>"
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (-modeTwoBar.getBarEffectiveWidth() - 1 + fish_position)) + "</font>"
+ modeTwoBar.getFishImage()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getBarEffectiveWidth() - fish_position - modeTwoBar.getFishIconWidth() + 1)) + "</font>"
+ "</font>";
hold_time = Math.max(0, Math.min(hold_time, time_requirement));
AdventureUtils.playerTitle(player,
AdventureUtils.playerTitle(
player,
modeTwoBar.getTip() != null && !played ? modeTwoBar.getTip() :
title.replace("{progress}", modeTwoBar.getProgress()[(int) ((hold_time / time_requirement) * modeTwoBar.getProgress().length)])
, bar,0,500,0
,
bar,
0,
500,
0
);
}
private void burst() {
if (Math.random() < (judgement_position / modeTwoBar.getBar_effective_width())) {
if (Math.random() < (judgement_position / modeTwoBar.getBarEffectiveWidth())) {
judgement_velocity = -1 - 0.8 * Math.random() * difficulty;
} else {
judgement_velocity = 1 + 0.8 * Math.random() * difficulty;
@@ -127,21 +123,21 @@ public class ModeTwoGame extends FishingGame {
private void fraction() {
if (judgement_velocity > 0) {
judgement_velocity -= modeTwoBar.getWater_resistance();
judgement_velocity -= modeTwoBar.getWaterResistance();
if (judgement_velocity < 0) judgement_velocity = 0;
} else {
judgement_velocity += modeTwoBar.getWater_resistance();
judgement_velocity += modeTwoBar.getWaterResistance();
if (judgement_velocity > 0) judgement_velocity = 0;
}
}
private void reduceV() {
fish_velocity -= modeTwoBar.getLoosening_loss();
fish_velocity -= modeTwoBar.getLooseningLoss();
}
private void addV(boolean add) {
if (add) fish_velocity += modeTwoBar.getPulling_strength();
else fish_velocity -= modeTwoBar.getPulling_strength();
private void addV() {
played = true;
fish_velocity += modeTwoBar.getPullingStrength();
}
private void calibrate() {
@@ -149,16 +145,16 @@ public class ModeTwoGame extends FishingGame {
fish_position = 0;
fish_velocity = 0;
}
if (fish_position + modeTwoBar.getFish_icon_width() > modeTwoBar.getBar_effective_width()) {
fish_position = modeTwoBar.getBar_effective_width() - modeTwoBar.getFish_icon_width();
if (fish_position + modeTwoBar.getFishIconWidth() > modeTwoBar.getBarEffectiveWidth()) {
fish_position = modeTwoBar.getBarEffectiveWidth() - modeTwoBar.getFishIconWidth();
fish_velocity = 0;
}
if (judgement_position < 0) {
judgement_position = 0;
judgement_velocity = 0;
}
if (judgement_position + modeTwoBar.getJudgement_area_width() > modeTwoBar.getBar_effective_width()) {
judgement_position = modeTwoBar.getBar_effective_width() - modeTwoBar.getJudgement_area_width();
if (judgement_position + modeTwoBar.getJudgementAreaWidth() > modeTwoBar.getBarEffectiveWidth()) {
judgement_position = modeTwoBar.getBarEffectiveWidth() - modeTwoBar.getJudgementAreaWidth();
judgement_velocity = 0;
}
}

View File

@@ -1,6 +1,5 @@
package net.momirealms.customfishing.integration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;

View File

@@ -1,7 +1,6 @@
package net.momirealms.customfishing.integration.item;
import net.momirealms.customfishing.integration.ItemInterface;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

View File

@@ -22,7 +22,6 @@ import io.github.battlepass.quests.quests.external.executor.ExternalQuestExecuto
import io.github.battlepass.registry.quest.QuestRegistry;
import net.momirealms.customfishing.api.event.FishResultEvent;
import net.momirealms.customfishing.fishing.FishResult;
import net.momirealms.customfishing.helper.Log;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View File

@@ -22,7 +22,6 @@ import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.api.event.FishResultEvent;
import net.momirealms.customfishing.fishing.FishResult;
import net.momirealms.customfishing.fishing.loot.Loot;
import net.momirealms.customfishing.fishing.loot.LootImpl;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View File

@@ -21,7 +21,6 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
import net.momirealms.customfishing.integration.SkillInterface;
import org.bukkit.entity.Player;

View File

@@ -364,8 +364,7 @@ public class FishingManager extends Function {
}
//else vanilla fishing mechanic
}
}
else {
} else {
// No custom loot
if (loot == null) {
event.setCancelled(true);
@@ -381,8 +380,7 @@ public class FishingManager extends Function {
showFishingBar(player, loot);
}
}
}
else {
} else {
event.setCancelled(true);
removeHook(uuid);
proceedReelIn(event.getHook().getLocation(), player, fishingGame);
@@ -992,7 +990,7 @@ public class FishingManager extends Function {
}
public void removeHook(UUID uuid) {
FishHook fishHook = hooks.remove(uuid);
FishHook fishHook = removeHookCache(uuid);
if (fishHook != null) {
if (plugin.getVersionHelper().isFolia()) {
plugin.getScheduler().runTask(fishHook::remove, fishHook.getLocation());
@@ -1002,6 +1000,10 @@ public class FishingManager extends Function {
}
}
public FishHook removeHookCache(UUID uuid) {
return hooks.remove(uuid);
}
@Nullable
public FishHook getHook(UUID uuid) {
return hooks.get(uuid);

View File

@@ -0,0 +1,22 @@
package net.momirealms.customfishing.scheduler;
import org.bukkit.scheduler.BukkitTask;
public class BukkitTimerTask implements TimerTask {
private final BukkitTask bukkitTask;
public BukkitTimerTask(BukkitTask bukkitTask) {
this.bukkitTask = bukkitTask;
}
@Override
public void cancel() {
this.bukkitTask.cancel();
}
@Override
public boolean isCancelled() {
return bukkitTask.isCancelled();
}
}

View File

@@ -0,0 +1,22 @@
package net.momirealms.customfishing.scheduler;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
public class FoliaTimerTask implements TimerTask {
private final ScheduledTask timerTask;
public FoliaTimerTask(ScheduledTask timerTask) {
this.timerTask = timerTask;
}
@Override
public void cancel() {
this.timerTask.cancel();
}
@Override
public boolean isCancelled() {
return timerTask.isCancelled();
}
}

View File

@@ -36,15 +36,15 @@ public class Scheduler extends Function {
} else {
this.schedulerPlatform = new BukkitSchedulerImpl(plugin);
}
this.schedule = new ScheduledThreadPoolExecutor(1);
this.schedule.setMaximumPoolSize(1);
this.schedule = new ScheduledThreadPoolExecutor(4);
this.schedule.setMaximumPoolSize(4);
this.schedule.setKeepAliveTime(10, TimeUnit.SECONDS);
this.schedule.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
}
public void reload() {
this.schedule.setCorePoolSize(ConfigManager.corePoolSize);
this.schedule.setMaximumPoolSize(ConfigManager.maximumPoolSize);
this.schedule.setCorePoolSize(Math.max(ConfigManager.corePoolSize, 4));
this.schedule.setMaximumPoolSize(Math.max(Math.max(ConfigManager.maximumPoolSize, 4), ConfigManager.corePoolSize));
this.schedule.setKeepAliveTime(ConfigManager.keepAliveTime, TimeUnit.SECONDS);
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customfishing.scheduler;
public interface TimerTask {
void cancel();
boolean isCancelled();
}

View File

@@ -187,11 +187,12 @@ other-settings:
# 线程池设置
thread-pool-settings:
# The size of the core Thread pool, that is, the size of the Thread pool when there is no task to execute
# Increase the size of corePoolSize when you are running a large server with many players fishing at the same time
# 核心线程池大小,即在没有任务需要执行的时候线程池的大小
corePoolSize: 1
corePoolSize: 4
# The maximum number of threads allowed to be created in the Thread pool. The current number of threads in the Thread pool will not exceed this value
# 线程池中允许创建的最大线程数,线程池中的当前线程数目不会超过该值
maximumPoolSize: 4
maximumPoolSize: 8
# If a thread is idle for more than this attribute value, it will exit due to timeout
# 如果一个线程处在空闲状态的时间超过了该属性值,就会因为超时而退出(秒)
keepAliveTime: 10

View File

@@ -507,14 +507,14 @@ bar_9:
bar_10:
game-type: 2
title: '{progress}'
# Tip would show on the title to guide the player how to play
tip: '<gray>Press <red><key:key.sneak> <gray>to start'
subtitle:
font: 'customfishing:default'
bar: '뀌'
judgment-area: '뀍'
fish: '뀎'
arguments:
# sneak / move
pull-method: sneak
punishment: 0.2
bar-effective-area-width: 155
judgment-area-offset: -160
@@ -540,13 +540,14 @@ bar_10:
- '<font:customfishing:icons>뀈</font>'
- '<font:customfishing:icons>뀉</font>'
###############
# Game Type 3 #
###############
bar_11:
game-type: 3
title: '{strain}'
# Tip would show on the title to guide the player how to play
tip: '<gray>Press <red><key:key.sneak> <gray>to start'
subtitle:
font: 'customfishing:default'
bar: '뀓'
@@ -576,4 +577,3 @@ bar_11:
- '<font:customfishing:icons>뀗</font>'
- '<font:customfishing:icons>뀘</font>'
- '<font:customfishing:icons>뀙</font>'