9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-30 04:19:30 +00:00

redo effect system

This commit is contained in:
XiaoMoMi
2023-11-05 17:10:53 +08:00
parent 4640e9007e
commit b82c74ca08
20 changed files with 304 additions and 207 deletions

View File

@@ -21,9 +21,11 @@ import net.momirealms.customfishing.api.manager.*;
import net.momirealms.customfishing.api.scheduler.Scheduler;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public abstract class CustomFishingPlugin extends JavaPlugin {
protected boolean initialized;
protected Scheduler scheduler;
protected CommandManager commandManager;
protected VersionManager versionManager;
@@ -54,9 +56,10 @@ public abstract class CustomFishingPlugin extends JavaPlugin {
}
public static CustomFishingPlugin get() {
return instance;
return getInstance();
}
@NotNull
public static CustomFishingPlugin getInstance() {
return instance;
}
@@ -145,15 +148,15 @@ public abstract class CustomFishingPlugin extends JavaPlugin {
return placeholderManager;
}
public CompetitionManager getCompetitionManager() {
return competitionManager;
}
public abstract void reload();
public abstract YamlConfiguration getConfig(String file);
public abstract boolean isHookedPluginEnabled(String plugin);
public CompetitionManager getCompetitionManager() {
return competitionManager;
}
public abstract void debug(String message);
}

View File

@@ -1,3 +1,20 @@
/*
* 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.api.event;
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;

View File

@@ -0,0 +1,47 @@
/*
* 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.api.event;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class CustomFishingReloadEvent extends Event {
private static final HandlerList handlerList = new HandlerList();
private final CustomFishingPlugin plugin;
public CustomFishingReloadEvent(CustomFishingPlugin plugin) {
this.plugin = plugin;
}
public static HandlerList getHandlerList() {
return handlerList;
}
@NotNull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
public CustomFishingPlugin getPluginInstance() {
return plugin;
}
}

View File

@@ -28,15 +28,25 @@ public interface Effect {
double getMultipleLootChance();
double getSize();
double getSizeMultiplier();
double getScore();
double getScoreMultiplier();
double getHookTimeModifier();
double getWaitTime();
double getGameTimeModifier();
double getWaitTimeMultiplier();
double getDifficultyModifier();
double getGameTime();
double getGameTimeMultiplier();
double getDifficulty();
double getDifficultyMultiplier();
List<Pair<String, WeightModifier>> getWeightModifier();

View File

@@ -27,11 +27,17 @@ public class FishingEffect implements Effect {
private boolean lavaFishing = false;
private double multipleLootChance = 0;
private double waitTime = 0;
private double waitTimeMultiplier = 1;
private double size = 0;
private double sizeMultiplier = 1;
private double score = 0;
private double scoreMultiplier = 1;
private double hookTimeModifier = 1;
private double difficultyModifier = 0;
private double gameTimeModifier = 0;
private double difficulty = 0;
private double difficultyMultiplier = 1;
private double gameTime = 0;
private double gameTimeMultiplier = 1;
private final List<Pair<String, WeightModifier>> weightModifier = new ArrayList<>();
private final List<Pair<String, WeightModifier>> weightModifierIgnored = new ArrayList<>();
@@ -68,6 +74,17 @@ public class FishingEffect implements Effect {
return this;
}
/**
* Sets the size.
*
* @param size The size value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setSize(double size) {
this.size = size;
return this;
}
/**
* Sets the score multiplier.
*
@@ -80,38 +97,83 @@ public class FishingEffect implements Effect {
}
/**
* Sets the hook time modifier.
* Sets the score
*
* @param timeModifier The hook time modifier value to set.
* @param score The score value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setHookTimeModifier(double timeModifier) {
this.hookTimeModifier = timeModifier;
public FishingEffect setScore(double score) {
this.score = score;
return this;
}
/**
* Sets the difficulty modifier.
* Sets the wait time multiplier.
*
* @param difficultyModifier The difficulty modifier value to set.
* @param timeMultiplier The wait time multiplier value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setDifficultyModifier(double difficultyModifier) {
this.difficultyModifier = difficultyModifier;
public FishingEffect setWaitTimeMultiplier(double timeMultiplier) {
this.waitTimeMultiplier = timeMultiplier;
return this;
}
/**
* Sets the game time modifier.
* Sets the wait time.
*
* @param gameTimeModifier The game time modifier value to set.
* @param waitTime The wait time value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setGameTimeModifier(double gameTimeModifier) {
this.gameTimeModifier = gameTimeModifier;
public FishingEffect setWaitTime(double waitTime) {
this.waitTime = waitTime;
return this;
}
/**
* Sets the difficulty.
*
* @param difficulty The difficulty value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setDifficulty(double difficulty) {
this.difficulty = difficulty;
return this;
}
/**
* Sets the difficulty multiplier.
*
* @param difficultyMultiplier The difficulty multiplier value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setDifficultyMultiplier(double difficultyMultiplier) {
this.difficultyMultiplier = difficultyMultiplier;
return this;
}
/**
* Sets the game time.
*
* @param gameTime The game time value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setGameTime(double gameTime) {
this.gameTime = gameTime;
return this;
}
/**
* Sets the game time multiplier.
*
* @param gameTimeMultiplier The game time multiplier value to set.
* @return The FishingEffect instance for method chaining.
*/
public FishingEffect setGameTimeMultiplier(double gameTimeMultiplier) {
this.gameTimeMultiplier = gameTimeMultiplier;
return this;
}
/**
* Adds weight modifiers to the FishingEffect.
*
@@ -164,6 +226,16 @@ public class FishingEffect implements Effect {
return sizeMultiplier;
}
/**
* Retrieves the size.
*
* @return The size value.
*/
@Override
public double getSize() {
return size;
}
/**
* Retrieves the score multiplier.
*
@@ -175,33 +247,73 @@ public class FishingEffect implements Effect {
}
/**
* Retrieves the hook time modifier.
* Retrieves the wait time multiplier.
*
* @return The hook time modifier value.
* @return The wait time multiplier value.
*/
@Override
public double getHookTimeModifier() {
return hookTimeModifier;
public double getWaitTimeMultiplier() {
return waitTimeMultiplier;
}
/**
* Retrieves the game time modifier.
* Retrieves the wait time.
*
* @return The game time modifier value.
* @return The wait time .
*/
@Override
public double getGameTimeModifier() {
return gameTimeModifier;
public double getWaitTime() {
return waitTime;
}
/**
* Retrieves the difficulty modifier.
* Retrieves the game time.
*
* @return The difficulty modifier value.
* @return The game time value.
*/
@Override
public double getDifficultyModifier() {
return difficultyModifier;
public double getGameTime() {
return gameTime;
}
/**
* Retrieves the game time multiplier.
*
* @return The game time value multiplier.
*/
@Override
public double getGameTimeMultiplier() {
return gameTimeMultiplier;
}
/**
* Retrieves score modifier.
*
* @return The score value.
*/
@Override
public double getScore() {
return score;
}
/**
* Retrieves the difficulty.
*
* @return The difficulty value.
*/
@Override
public double getDifficulty() {
return difficulty;
}
/**
* Retrieves the difficulty multiplier.
*
* @return The difficulty multiplier value.
*/
@Override
public double getDifficultyMultiplier() {
return difficultyMultiplier;
}
/**
@@ -234,136 +346,16 @@ public class FishingEffect implements Effect {
if (another == null) return;
if (another.canLavaFishing()) this.lavaFishing = true;
this.scoreMultiplier += (another.getScoreMultiplier() -1);
this.score += another.getScore();
this.sizeMultiplier += (another.getSizeMultiplier() -1);
this.hookTimeModifier += (another.getHookTimeModifier() -1);
this.size += another.getSize();
this.difficultyMultiplier += (another.getDifficultyMultiplier() -1);
this.difficulty += another.getDifficulty();
this.gameTimeMultiplier += (another.getGameTimeMultiplier() - 1);
this.gameTime += another.getGameTime();
this.waitTimeMultiplier += (another.getWaitTimeMultiplier() -1);
this.multipleLootChance += another.getMultipleLootChance();
this.difficultyModifier += another.getDifficultyModifier();
this.gameTimeModifier += another.getGameTimeModifier();
this.weightModifierIgnored.addAll(another.getWeightModifierIgnored());
this.weightModifier.addAll(another.getWeightModifier());
}
public static Builder builder() {
return new Builder();
}
/**
* Builder class for creating instances of the {@link FishingEffect} class with customizable properties.
*/
public static class Builder {
private final FishingEffect effect;
public Builder() {
this.effect = new FishingEffect();
}
/**
* Adds weight modifiers to the FishingEffect.
*
* @param modifier A list of pairs representing weight modifiers.
* @return The Builder instance for method chaining.
*/
public Builder addWeightModifier(List<Pair<String, WeightModifier>> modifier) {
effect.weightModifier.addAll(modifier);
return this;
}
/**
* Adds weight modifiers ignoring conditions to the FishingEffect.
*
* @param modifier A list of pairs representing ignoring conditions weight modifiers.
* @return The Builder instance for method chaining.
*/
public Builder addWeightModifierIgnored(List<Pair<String, WeightModifier>> modifier) {
effect.weightModifierIgnored.addAll(modifier);
return this;
}
/**
* Sets the multiple loot chance for the FishingEffect.
*
* @param multipleLootChance The multiple loot chance value to set.
* @return The Builder instance for method chaining.
*/
public Builder multipleLootChance(double multipleLootChance) {
effect.multipleLootChance = multipleLootChance;
return this;
}
/**
* Sets the difficulty modifier for the FishingEffect.
*
* @param difficultyModifier The difficulty modifier value to set.
* @return The Builder instance for method chaining.
*/
public Builder difficultyModifier(double difficultyModifier) {
effect.difficultyModifier = difficultyModifier;
return this;
}
/**
* Sets the size multiplier for the FishingEffect.
*
* @param sizeMultiplier The size multiplier value to set.
* @return The Builder instance for method chaining.
*/
public Builder sizeMultiplier(double sizeMultiplier) {
effect.sizeMultiplier = sizeMultiplier;
return this;
}
/**
* Sets the time modifier for the FishingEffect.
*
* @param timeModifier The time modifier value to set.
* @return The Builder instance for method chaining.
*/
public Builder timeModifier(double timeModifier) {
effect.hookTimeModifier = timeModifier;
return this;
}
/**
* Sets the score multiplier for the FishingEffect.
*
* @param scoreMultiplier The score multiplier value to set.
* @return The Builder instance for method chaining.
*/
public Builder scoreMultiplier(double scoreMultiplier) {
effect.scoreMultiplier = scoreMultiplier;
return this;
}
/**
* Sets the game time modifier for the FishingEffect.
*
* @param gameTimeModifier The game time modifier value to set.
* @return The Builder instance for method chaining.
*/
public Builder gameTimeModifier(double gameTimeModifier) {
effect.gameTimeModifier = gameTimeModifier;
return this;
}
/**
* Sets whether lava fishing is enabled for the FishingEffect.
*
* @param lavaFishing True if lava fishing is enabled, false otherwise.
* @return The Builder instance for method chaining.
*/
public Builder lavaFishing(boolean lavaFishing) {
effect.lavaFishing = lavaFishing;
return this;
}
/**
* Builds and returns the finalized FishingEffect instance.
*
* @return The created FishingEffect instance.
*/
public FishingEffect build() {
return effect;
}
}
}

View File

@@ -79,8 +79,8 @@ public class BasicGameConfig {
@Nullable
public GameSettings getGameSetting(Effect effect) {
return new GameSettings(
ThreadLocalRandom.current().nextInt(minTime, maxTime + 1) + effect.getGameTimeModifier(),
(int) Math.min(100, Math.max(1, ThreadLocalRandom.current().nextInt(minDifficulty, maxDifficulty + 1) + effect.getDifficultyModifier()))
ThreadLocalRandom.current().nextInt(minTime, maxTime + 1) * effect.getGameTimeMultiplier() + effect.getGameTime(),
(int) Math.min(100, Math.max(1, ThreadLocalRandom.current().nextInt(minDifficulty, maxDifficulty + 1) * effect.getDifficultyMultiplier() + effect.getDifficulty()))
);
}
}