mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 11:59:11 +00:00
Updated expansions & placeholders
This commit is contained in:
@@ -43,6 +43,7 @@ public abstract class CustomFishingPlugin extends JavaPlugin {
|
||||
protected CompetitionManager competitionManager;
|
||||
protected StorageManager storageManager;
|
||||
protected PlaceholderManager placeholderManager;
|
||||
protected StatisticsManager statisticsManager;
|
||||
|
||||
private static CustomFishingPlugin instance;
|
||||
|
||||
@@ -126,6 +127,10 @@ public abstract class CustomFishingPlugin extends JavaPlugin {
|
||||
return integrationManager;
|
||||
}
|
||||
|
||||
public StatisticsManager getStatisticsManager() {
|
||||
return statisticsManager;
|
||||
}
|
||||
|
||||
public PlaceholderManager getPlaceholderManager() {
|
||||
return placeholderManager;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
package net.momirealms.customfishing.api.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.action.ActionBuilder;
|
||||
import net.momirealms.customfishing.api.mechanic.action.ActionFactory;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public interface ActionManager {
|
||||
|
||||
boolean registerAction(String type, ActionBuilder actionBuilder);
|
||||
boolean registerAction(String type, ActionFactory actionFactory);
|
||||
|
||||
boolean unregisterAction(String type);
|
||||
|
||||
@@ -31,5 +31,5 @@ public interface ActionManager {
|
||||
|
||||
Action[] getActions(ConfigurationSection section);
|
||||
|
||||
ActionBuilder getActionBuilder(String type);
|
||||
ActionFactory getActionBuilder(String type);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customfishing.api.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.CompetitionGoal;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -27,6 +28,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
public interface CompetitionManager {
|
||||
Set<String> getAllCompetitions();
|
||||
|
||||
String getCompetitionLocale(CompetitionGoal goal);
|
||||
|
||||
void startCompetition(String competition, boolean force, boolean allServers);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -19,7 +19,7 @@ package net.momirealms.customfishing.api.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.TempFishingState;
|
||||
import net.momirealms.customfishing.api.mechanic.effect.Effect;
|
||||
import net.momirealms.customfishing.api.mechanic.game.Game;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GameInstance;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GameSettings;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GamingPlayer;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
@@ -44,5 +44,5 @@ public interface FishingManager {
|
||||
|
||||
void startFishingGame(Player player, Loot loot, Effect effect);
|
||||
|
||||
void startFishingGame(Player player, GameSettings settings, Game game);
|
||||
void startFishingGame(Player player, GameSettings settings, GameInstance gameInstance);
|
||||
}
|
||||
|
||||
@@ -17,25 +17,25 @@
|
||||
|
||||
package net.momirealms.customfishing.api.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.game.Game;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GameConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GameCreator;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GameFactory;
|
||||
import net.momirealms.customfishing.api.mechanic.game.GameInstance;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface GameManager {
|
||||
|
||||
|
||||
boolean registerGameType(String type, GameCreator gameCreator);
|
||||
boolean registerGameType(String type, GameFactory gameFactory);
|
||||
|
||||
boolean unregisterGameType(String type);
|
||||
|
||||
@Nullable GameCreator getGameCreator(String type);
|
||||
@Nullable GameFactory getGameCreator(String type);
|
||||
|
||||
@Nullable Game getGame(String key);
|
||||
@Nullable GameInstance getGame(String key);
|
||||
|
||||
@Nullable GameConfig getGameConfig(String key);
|
||||
|
||||
Game getRandomGame();
|
||||
GameInstance getRandomGame();
|
||||
|
||||
GameConfig getRandomGameConfig();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package net.momirealms.customfishing.api.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.condition.Condition;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementBuilder;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementFactory;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.HashMap;
|
||||
|
||||
public interface RequirementManager {
|
||||
|
||||
boolean registerRequirement(String type, RequirementBuilder requirementBuilder);
|
||||
boolean registerRequirement(String type, RequirementFactory requirementFactory);
|
||||
|
||||
boolean unregisterRequirement(String type);
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface RequirementManager {
|
||||
|
||||
Requirement getRequirement(String key, Object value);
|
||||
|
||||
RequirementBuilder getRequirementBuilder(String type);
|
||||
RequirementFactory getRequirementBuilder(String type);
|
||||
|
||||
static boolean isRequirementsMet(Requirement[] requirements, Condition condition) {
|
||||
if (requirements == null) return true;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface StatisticsManager {
|
||||
Statistics getStatistics(UUID uuid);
|
||||
|
||||
@Nullable List<String> getCategory(String key);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.momirealms.customfishing.api.mechanic.action;
|
||||
|
||||
public abstract class ActionExpansion {
|
||||
|
||||
public abstract String getVersion();
|
||||
|
||||
public abstract String getAuthor();
|
||||
|
||||
public abstract String getActionType();
|
||||
|
||||
public abstract ActionFactory getActionFactory();
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.api.mechanic.action;
|
||||
|
||||
public interface ActionBuilder {
|
||||
public interface ActionFactory {
|
||||
|
||||
Action build(Object args, double chance);
|
||||
}
|
||||
@@ -22,5 +22,6 @@ public enum ActionTrigger {
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
HOOK,
|
||||
CONSUME
|
||||
CONSUME,
|
||||
CAST
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ package net.momirealms.customfishing.api.mechanic.competition;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface FishingCompetition {
|
||||
void start();
|
||||
|
||||
@@ -29,7 +31,7 @@ public interface FishingCompetition {
|
||||
|
||||
boolean isOnGoing();
|
||||
|
||||
void refreshData(Player player, double score, boolean doubleScore);
|
||||
void refreshData(Player player, double score);
|
||||
|
||||
boolean hasPlayerJoined(OfflinePlayer player);
|
||||
|
||||
@@ -44,4 +46,8 @@ public interface FishingCompetition {
|
||||
CompetitionGoal getGoal();
|
||||
|
||||
Ranking getRanking();
|
||||
|
||||
ConcurrentHashMap<String, String> getCachedPlaceholders();
|
||||
|
||||
String getCachedPlaceholder(String papi);
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface GameConfig {
|
||||
|
||||
@Nullable
|
||||
Pair<Game, GameSettings> getRandomGame(Effect effect);
|
||||
Pair<GameInstance, GameSettings> getRandomGame(Effect effect);
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ public abstract class GameExpansion {
|
||||
|
||||
public abstract String getGameType();
|
||||
|
||||
public abstract GameCreator getGameCreator();
|
||||
public abstract GameFactory getGameFactory();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package net.momirealms.customfishing.api.mechanic.game;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public interface GameCreator {
|
||||
public interface GameFactory {
|
||||
|
||||
Game setArgs(ConfigurationSection section);
|
||||
GameInstance setArgs(ConfigurationSection section);
|
||||
|
||||
}
|
||||
@@ -62,10 +62,10 @@ public class GameGroup implements GameConfig {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Pair<Game, GameSettings> getRandomGame(Effect effect) {
|
||||
public Pair<GameInstance, GameSettings> getRandomGame(Effect effect) {
|
||||
String key = WeightUtils.getRandom(gamePairs);
|
||||
Game game = CustomFishingPlugin.get().getGameManager().getGame(key);
|
||||
if (game == null) {
|
||||
GameInstance gameInstance = CustomFishingPlugin.get().getGameManager().getGame(key);
|
||||
if (gameInstance == null) {
|
||||
CustomFishingPlugin.get().getLogger().warning(String.format("Game %s doesn't exist!", key));
|
||||
return null;
|
||||
}
|
||||
@@ -73,6 +73,6 @@ public class GameGroup implements GameConfig {
|
||||
ThreadLocalRandom.current().nextInt(minTime, maxTime + 1),
|
||||
(int) (ThreadLocalRandom.current().nextInt(minDifficulty, maxDifficulty + 1) + effect.getDifficultyModifier())
|
||||
);
|
||||
return Pair.of(game, settings);
|
||||
return Pair.of(gameInstance, settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GameGroups implements GameConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Pair<Game, GameSettings> getRandomGame(Effect effect) {
|
||||
public @Nullable Pair<GameInstance, GameSettings> getRandomGame(Effect effect) {
|
||||
String group = WeightUtils.getRandom(gamesWithWeight);
|
||||
GameConfig gameConfig = CustomFishingPlugin.get().getGameManager().getGameConfig(group);
|
||||
if (gameConfig == null) {
|
||||
|
||||
@@ -20,7 +20,7 @@ package net.momirealms.customfishing.api.mechanic.game;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Game {
|
||||
public interface GameInstance {
|
||||
|
||||
GamingPlayer start(Player player, FishHook hook, GameSettings settings);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.momirealms.customfishing.api.mechanic.requirement;
|
||||
|
||||
public abstract class RequirementExpansion {
|
||||
|
||||
public abstract String getVersion();
|
||||
|
||||
public abstract String getAuthor();
|
||||
|
||||
public abstract String getRequirementType();
|
||||
|
||||
public abstract RequirementFactory getRequirementFactory();
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RequirementBuilder {
|
||||
public interface RequirementFactory {
|
||||
|
||||
Requirement build(Object args, List<Action> notMetActions, boolean checkAction);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Statistics {
|
||||
}
|
||||
}
|
||||
|
||||
public int getFishAmount(String key) {
|
||||
public int getLootAmount(String key) {
|
||||
Integer amount = statisticMap.get(key);
|
||||
return amount == null ? 0 : amount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user