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

2.0-backup-1

This commit is contained in:
XiaoMoMi
2023-09-01 02:23:12 +08:00
parent ce9829aeee
commit d60de693bb
416 changed files with 16225 additions and 18659 deletions

104
.gitignore vendored
View File

@@ -1,17 +1,8 @@
# User-specific stuff # Folders
.idea/ .idea/
.gradle/
*.iml build/
*.ipr target/
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file # Compiled class file
*.class *.class
@@ -22,6 +13,9 @@ atlassian-ide-plugin.xml
# BlueJ files # BlueJ files
*.ctxt *.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files # # Package Files #
*.war *.war
*.nar *.nar
@@ -32,86 +26,4 @@ atlassian-ide-plugin.xml
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
replay_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

42
api/.gitignore vendored Normal file
View File

@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

5
api/build.gradle.kts Normal file
View File

@@ -0,0 +1,5 @@
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
implementation("de.tr7zw:item-nbt-api:2.11.3")
}

View File

@@ -0,0 +1,125 @@
package net.momirealms.customfishing.api;
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;
public abstract class CustomFishingPlugin extends JavaPlugin {
protected Scheduler scheduler;
protected CommandManager commandManager;
protected VersionManager versionManager;
protected ItemManager itemManager;
protected RequirementManager requirementManager;
protected ActionManager actionManager;
protected LootManager lootManager;
protected FishingManager fishingManager;
protected EffectManager effectManager;
protected MobManager mobManager;
protected BlockManager blockManager;
protected AdventureManager adventure;
protected BagManager bagManager;
protected GameManager gameManager;
protected MarketManager marketManager;
protected IntegrationManager integrationManager;
protected CompetitionManager competitionManager;
protected StorageManager storageManager;
protected PlaceholderManager placeholderManager;
private static CustomFishingPlugin instance;
public CustomFishingPlugin() {
instance = this;
}
public static CustomFishingPlugin get() {
return instance;
}
public static CustomFishingPlugin getInstance() {
return instance;
}
public Scheduler getScheduler() {
return scheduler;
}
public CommandManager getCommandManager() {
return commandManager;
}
public VersionManager getVersionManager() {
return versionManager;
}
public RequirementManager getRequirementManager() {
return requirementManager;
}
public ActionManager getActionManager() {
return actionManager;
}
public GameManager getGameManager() {
return gameManager;
}
public BlockManager getBlockManager() {
return blockManager;
}
public MobManager getMobManager() {
return mobManager;
}
public ItemManager getItemManager() {
return itemManager;
}
public EffectManager getEffectManager() {
return effectManager;
}
public MarketManager getMarketManager() {
return marketManager;
}
public FishingManager getFishingManager() {
return fishingManager;
}
public AdventureManager getAdventure() {
return adventure;
}
public BagManager getBagManager() {
return bagManager;
}
public LootManager getLootManager() {
return lootManager;
}
public StorageManager getStorageManager() {
return storageManager;
}
public IntegrationManager getIntegrationManager() {
return integrationManager;
}
public PlaceholderManager getPlaceholderManager() {
return placeholderManager;
}
public abstract void reload();
public abstract YamlConfiguration getConfig(String file);
public abstract boolean isHookedPluginEnabled(String plugin);
public CompetitionManager getCompetitionManager() {
return competitionManager;
}
}

View File

@@ -0,0 +1,29 @@
package net.momirealms.customfishing.api.common;
public record Key(String namespace, String value) {
public static Key of(String namespace, String value) {
return new Key(namespace, value);
}
@Override
public int hashCode() {
int result = this.namespace.hashCode();
result = (31 * result) + this.value.hashCode();
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof Key key)) return false;
return this.namespace.equals(key.namespace()) && this.value.equals(key.value());
}
@Override
public String toString() {
return namespace + ":" + value;
}
}

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.object; package net.momirealms.customfishing.api.common;
public record Pair<L, R>(L left, R right) { public record Pair<L, R>(L left, R right) {

View File

@@ -0,0 +1,42 @@
package net.momirealms.customfishing.api.common;
public class Tuple<L, M, R> {
private L left;
private M mid;
private R right;
public Tuple(L left, M mid, R right) {
this.left = left;
this.mid = mid;
this.right = right;
}
public static <L, M, R> Tuple<L, M, R> of(final L left, final M mid, final R right) {
return new Tuple<>(left, mid, right);
}
public L getLeft() {
return left;
}
public void setLeft(L left) {
this.left = left;
}
public M getMid() {
return mid;
}
public void setMid(M mid) {
this.mid = mid;
}
public R getRight() {
return right;
}
public void setRight(R right) {
this.right = right;
}
}

View File

@@ -15,29 +15,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.fishing.totem; package net.momirealms.customfishing.api.data;
public class CorePos { import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
private final int x; public interface DataStorageInterface {
private final int y;
private final int z;
public CorePos(int x, int z, int y) { void initialize();
this.x = x; void disable();
this.z = z;
this.y = y;
}
public int getX() { StorageType getStorageType();
return this.x;
}
public int getY() { CompletableFuture<Optional<PlayerData>> getPlayerData(UUID uuid, boolean force);
return this.y;
}
public int getZ() { CompletableFuture<Boolean> setPlayData(UUID uuid, PlayerData playerData, boolean unlock);
return this.z;
}
} }

View File

@@ -15,25 +15,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.fishing; package net.momirealms.customfishing.api.data;
import org.bukkit.inventory.ItemStack; import com.google.gson.annotations.SerializedName;
public class VanillaLoot { public class EarningData {
private final ItemStack itemStack; @SerializedName("earnings")
private final int xp; public double earnings;
@SerializedName("date")
public int date;
public VanillaLoot(ItemStack itemStack, int xp) { public EarningData(double earnings, int date) {
this.itemStack = itemStack; this.earnings = earnings;
this.xp = xp; this.date = date;
} }
public ItemStack getItemStack() { public static EarningData empty() {
return itemStack; return new EarningData(0d, 0);
}
public int getXp() {
return xp;
} }
} }

View File

@@ -0,0 +1,21 @@
package net.momirealms.customfishing.api.data;
import com.google.gson.annotations.SerializedName;
public class InventoryData {
@SerializedName("inventory")
public String serialized;
@SerializedName("size")
public int size;
public static InventoryData empty() {
return new InventoryData("", 9);
}
public InventoryData(String serialized, int size) {
this.serialized = serialized;
this.size = size;
}
}

View File

@@ -0,0 +1,81 @@
package net.momirealms.customfishing.api.data;
import com.google.gson.annotations.SerializedName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlayerData {
@SerializedName("name")
protected String name;
@SerializedName("stats")
protected StatisticData statisticsData;
@SerializedName("bag")
protected InventoryData bagData;
@SerializedName("trade")
protected EarningData earningData;
public static PlayerData NEVER_PLAYED = empty();
public static PlayerData empty() {
return new Builder()
.setBagData(InventoryData.empty())
.setEarningData(EarningData.empty())
.setStats(StatisticData.empty())
.build();
}
public static class Builder {
private final PlayerData playerData;
public Builder() {
this.playerData = new PlayerData();
}
@NotNull
public Builder setName(@Nullable String name) {
this.playerData.name = name;
return this;
}
@NotNull
public Builder setStats(@Nullable StatisticData statisticsData) {
this.playerData.statisticsData = statisticsData;
return this;
}
@NotNull
public Builder setBagData(@Nullable InventoryData inventoryData) {
this.playerData.bagData = inventoryData;
return this;
}
@NotNull
public Builder setEarningData(@Nullable EarningData earningData) {
this.playerData.earningData = earningData;
return this;
}
@NotNull
public PlayerData build() {
return this.playerData;
}
}
public StatisticData getStatistics() {
return statisticsData;
}
public InventoryData getBagData() {
return bagData;
}
public EarningData getEarningData() {
return earningData;
}
public String getName() {
return name;
}
}

View File

@@ -0,0 +1,21 @@
package net.momirealms.customfishing.api.data;
import com.google.gson.annotations.SerializedName;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class StatisticData {
@SerializedName("stats")
public Map<String, Integer> statisticMap;
public StatisticData(@NotNull Map<String, Integer> data) {
this.statisticMap = data;
}
public static StatisticData empty() {
return new StatisticData(new HashMap<>());
}
}

View File

@@ -0,0 +1,14 @@
package net.momirealms.customfishing.api.data;
public enum StorageType {
JSON,
YAML,
H2,
SQLite,
MySQL,
MariaDB,
MongoDB,
Redis
}

View File

@@ -0,0 +1,24 @@
package net.momirealms.customfishing.api.data.user;
import net.momirealms.customfishing.api.data.EarningData;
import net.momirealms.customfishing.api.data.PlayerData;
import net.momirealms.customfishing.api.mechanic.bag.FishingBagHolder;
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
import java.util.UUID;
public interface OfflineUser {
String getName();
UUID getUUID();
FishingBagHolder getHolder();
EarningData getEarningData();
Statistics getStatistics();
boolean isOnline();
PlayerData getPlayerData();
}

View File

@@ -0,0 +1,27 @@
package net.momirealms.customfishing.api.data.user;
import net.momirealms.customfishing.api.data.EarningData;
import net.momirealms.customfishing.api.data.PlayerData;
import net.momirealms.customfishing.api.mechanic.bag.FishingBagHolder;
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
import org.bukkit.entity.Player;
import java.util.UUID;
public interface OnlineUser {
Player getPlayer();
String getName();
UUID getUUID();
FishingBagHolder getHolder();
EarningData getEarningData();
Statistics getStatistics();
boolean isOnline();
PlayerData getPlayerData();
}

View File

@@ -0,0 +1,56 @@
package net.momirealms.customfishing.api.event;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
public class LavaFishingEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlerList = new HandlerList();
private final State state;
private boolean isCancelled;
private final FishHook hook;
public LavaFishingEvent(@NotNull Player who, State state, FishHook hook) {
super(who);
this.state = state;
this.isCancelled = false;
this.hook = hook;
}
public State getState() {
return state;
}
public FishHook getHook() {
return hook;
}
public static HandlerList getHandlerList() {
return handlerList;
}
@NotNull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
public enum State {
REEL_IN,
CAUGHT_FISH, BITE
}
}

View File

@@ -0,0 +1,50 @@
package net.momirealms.customfishing.api.event;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.jetbrains.annotations.NotNull;
public class RodCastEvent extends PlayerEvent implements Cancellable {
private final Effect effect;
private boolean isCancelled;
private final PlayerFishEvent event;
private static final HandlerList handlerList = new HandlerList();
public RodCastEvent(PlayerFishEvent event, Effect effect) {
super(event.getPlayer());
this.effect = effect;
this.event = event;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.isCancelled = cancel;
}
public static HandlerList getHandlerList() {
return handlerList;
}
@NotNull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
public Effect getEffect() {
return effect;
}
public PlayerFishEvent getBukkitPlayerFishEvent() {
return event;
}
}

View File

@@ -0,0 +1,4 @@
package net.momirealms.customfishing.api.event;
public class TotemActivateEvent {
}

View File

@@ -1,4 +1,4 @@
package net.momirealms.customfishing.integration; package net.momirealms.customfishing.api.integration;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.api.integration;
import org.bukkit.entity.Player;
public interface LevelInterface {
void addXp(Player player, String target, double amount);
int getLevel(Player player, String target);
}

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.integration; package net.momirealms.customfishing.api.integration;
import org.bukkit.World; import org.bukkit.World;

View File

@@ -0,0 +1,18 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.mechanic.action.Action;
import net.momirealms.customfishing.api.mechanic.action.ActionBuilder;
import org.bukkit.configuration.ConfigurationSection;
public interface ActionManager {
boolean registerAction(String type, ActionBuilder actionBuilder);
boolean unregisterAction(String type);
Action getAction(ConfigurationSection section);
Action[] getActions(ConfigurationSection section);
ActionBuilder getActionBuilder(String type);
}

View File

@@ -0,0 +1,116 @@
package net.momirealms.customfishing.api.manager;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public interface AdventureManager {
/**
* Get component from text
* @param text text
* @return component
*/
Component getComponentFromMiniMessage(String text);
/**
* Send a message to a command sender
* @param sender sender
* @param msg message
*/
void sendMessage(CommandSender sender, String msg);
void sendMessageWithPrefix(CommandSender sender, String s);
/**
* Send a message to console
* @param msg message
*/
void sendConsoleMessage(String msg);
/**
* Send a message to a player
* @param player player
* @param msg message
*/
void sendPlayerMessage(Player player, String msg);
/**
* Send a title to a player
* @param player player
* @param title title
* @param subtitle subtitle
* @param in in (ms)
* @param duration duration (ms)
* @param out out (ms)
*/
void sendTitle(Player player, String title, String subtitle, int in, int duration, int out);
/**
* Send a title to a player
* @param player player
* @param title title
* @param subtitle subtitle
* @param in in (ms)
* @param duration duration (ms)
* @param out out (ms)
*/
void sendTitle(Player player, Component title, Component subtitle, int in, int duration, int out);
/**
* Send actionbar
* @param player player
* @param msg msg
*/
void sendActionbar(Player player, String msg);
/**
* Play a sound to a player
* @param player player
* @param source sound source
* @param key sound key
* @param volume volume
* @param pitch pitch
*/
void sendSound(Player player, Sound.Source source, Key key, float volume, float pitch);
void sendSound(Player player, Sound sound);
/**
* Replace legacy color codes to MiniMessage format
* @param legacy legacy text
* @return MiniMessage format text
*/
String legacyToMiniMessage(String legacy);
/**
* if a char is legacy color code
* @param c char
* @return is legacy color
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isColorCode(char c);
/**
* Get legacy format text
* @param component component
* @return legacy format text
*/
String componentToLegacy(Component component);
/**
* Get json
* @param component component
* @return json
*/
String componentToJson(Component component);
/**
* Get paper component
* @param component shaded component
* @return paper component
*/
Object shadedComponentToPaperComponent(Component component);
}

View File

@@ -0,0 +1,11 @@
package net.momirealms.customfishing.api.manager;
import org.bukkit.inventory.Inventory;
import java.util.UUID;
public interface BagManager {
boolean isBagEnabled();
Inventory getOnlineBagInventory(UUID uuid);
}

View File

@@ -0,0 +1,22 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.mechanic.block.BlockLibrary;
import net.momirealms.customfishing.api.mechanic.block.BlockDataModifierBuilder;
import net.momirealms.customfishing.api.mechanic.block.BlockStateModifierBuilder;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public interface BlockManager {
boolean registerBlockLibrary(BlockLibrary library);
boolean unregisterBlockLibrary(BlockLibrary library);
boolean unregisterBlockLibrary(String library);
boolean registerBlockDataModifierBuilder(String type, BlockDataModifierBuilder builder);
boolean registerBlockStateModifierBuilder(String type, BlockStateModifierBuilder builder);
void summonBlock(Player player, Location hookLocation, Location playerLocation, Loot loot);
}

View File

@@ -0,0 +1,6 @@
package net.momirealms.customfishing.api.manager;
public interface CommandManager {
void loadCommands();
}

View File

@@ -0,0 +1,26 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfig;
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
public interface CompetitionManager {
Set<String> getAllCompetitions();
void startCompetition(String competition, boolean force, boolean allServers);
@Nullable
FishingCompetition getOnGoingCompetition();
void startCompetition(CompetitionConfig config, boolean force, boolean allServers);
int getNextCompetitionSeconds();
CompletableFuture<Integer> getPlayerCount();
@Nullable
CompetitionConfig getConfig(String key);
}

View File

@@ -0,0 +1,15 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.common.Key;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.jetbrains.annotations.Nullable;
public interface EffectManager {
boolean registerEffect(Key key, Effect effect);
boolean unregisterEffect(Key key);
@Nullable Effect getEffect(String namespace, String id);
Effect getInitialEffect();
}

View File

@@ -0,0 +1,27 @@
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.GameSettings;
import net.momirealms.customfishing.api.mechanic.game.GamingPlayer;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.bukkit.entity.Player;
import java.util.UUID;
public interface FishingManager {
boolean removeHook(UUID uuid);
void setTempFishingState(Player player, TempFishingState tempFishingState);
void removeHookCheckTask(Player player);
void removeTempFishingState(Player player);
void processGameResult(GamingPlayer gamingPlayer);
void startFishingGame(Player player, Loot loot, Effect effect);
void startFishingGame(Player player, GameSettings settings, Game game);
}

View File

@@ -0,0 +1,29 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.mechanic.game.Game;
import net.momirealms.customfishing.api.mechanic.game.GameConfig;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.Nullable;
public interface GameManager {
boolean registerGameType(String type, GameCreator gameCreator);
boolean unregisterGameType(String type);
@Nullable GameCreator getGameCreator(String type);
@Nullable Game getGame(String key);
@Nullable GameConfig getGameConfig(String key);
Game getRandomGame();
GameConfig getRandomGameConfig();
public interface GameCreator {
Game setArgs(ConfigurationSection section);
}
}

View File

@@ -0,0 +1,27 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.integration.EnchantmentInterface;
import net.momirealms.customfishing.api.integration.LevelInterface;
import net.momirealms.customfishing.api.integration.SeasonInterface;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public interface IntegrationManager {
boolean registerLevelPlugin(String plugin, LevelInterface level);
boolean unregisterLevelPlugin(String plugin);
boolean registerEnchantment(String plugin, EnchantmentInterface enchantment);
boolean unregisterEnchantment(String plugin);
LevelInterface getLevelHook(String plugin);
List<String> getEnchantments(ItemStack rod);
SeasonInterface getSeasonInterface();
void setSeasonInterface(SeasonInterface season);
}

View File

@@ -0,0 +1,59 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.common.Key;
import net.momirealms.customfishing.api.mechanic.item.BuildableItem;
import net.momirealms.customfishing.api.mechanic.item.ItemBuilder;
import net.momirealms.customfishing.api.mechanic.item.ItemLibrary;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Set;
public interface ItemManager {
@Nullable
ItemStack build(Player player, String namespace, String value);
@Nullable
ItemStack build(Player player, String namespace, String value, Map<String, String> placeholders);
@NotNull
ItemStack build(Player player, ItemBuilder builder);
ItemStack buildAnyItemByID(Player player, String id);
@Nullable
String getItemID(ItemStack itemStack);
String getAnyItemID(ItemStack itemStack);
@Nullable
ItemBuilder getItemBuilder(ConfigurationSection section, String type, String id);
ItemStack build(Player player, ItemBuilder builder, Map<String, String> placeholders);
Set<Key> getAllItemsKey();
boolean registerCustomItem(String namespace, String value, BuildableItem buildableItem);
boolean unregisterCustomItem(String namespace, String value);
@Nullable
BuildableItem getBuildableItem(String namespace, String value);
boolean registerItemLibrary(ItemLibrary itemLibrary);
boolean unRegisterItemLibrary(ItemLibrary itemLibrary);
boolean unRegisterItemLibrary(String itemLibrary);
void dropItem(Player player, Location hookLocation, Location playerLocation, Loot loot, Map<String, String> args);
void dropItem(Location hookLocation, Location playerLocation, ItemStack itemStack);
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.jetbrains.annotations.Nullable;
public interface LootManager {
@Nullable Loot getLoot(String key);
}

View File

@@ -0,0 +1,13 @@
package net.momirealms.customfishing.api.manager;
import org.bukkit.inventory.ItemStack;
public interface MarketManager {
int getDate();
double getItemPrice(ItemStack itemStack);
String getFormula();
double getPrice(float base, float bonus, float size);
}

View File

@@ -0,0 +1,15 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import net.momirealms.customfishing.api.mechanic.mob.MobLibrary;
import org.bukkit.Location;
public interface MobManager {
boolean registerMobLibrary(MobLibrary mobLibrary);
boolean unregisterMobLibrary(String lib);
boolean unregisterMobLibrary(MobLibrary mobLibrary);
void summonMob(Location hookLocation, Location playerLocation, Loot loot);
}

View File

@@ -0,0 +1,23 @@
package net.momirealms.customfishing.api.manager;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
public interface PlaceholderManager {
String setPlaceholders(Player player, String text);
String setPlaceholders(OfflinePlayer player, String text);
List<String> detectPlaceholders(String text);
String getSingleValue(@Nullable Player player, String placeholder, Map<String, String> placeholders);
String parse(@Nullable OfflinePlayer player, String text, Map<String, String> placeholders);
List<String> parse(@Nullable OfflinePlayer player, List<String> list, Map<String, String> replacements);
}

View File

@@ -0,0 +1,41 @@
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 org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
public interface RequirementManager {
boolean registerRequirement(String type, RequirementBuilder requirementBuilder);
boolean unregisterRequirement(String type);
HashMap<String, Double> getLootWithWeight(Condition condition);
@Nullable Requirement[] getRequirements(ConfigurationSection section, boolean advanced);
Requirement getRequirement(ConfigurationSection section, boolean checkAction);
Requirement getRequirement(String key, Object value);
RequirementBuilder getRequirementBuilder(String type);
static boolean isRequirementsMet(Requirement[] requirements, Condition condition) {
if (requirements == null) return true;
for (Requirement requirement : requirements) {
if (!requirement.isConditionMet(condition)) {
return false;
}
}
return true;
}
static boolean isRequirementMet(Requirement requirement, Condition condition) {
if (requirement == null) return true;
return requirement.isConditionMet(condition);
}
}

View File

@@ -0,0 +1,58 @@
package net.momirealms.customfishing.api.manager;
import net.momirealms.customfishing.api.data.DataStorageInterface;
import net.momirealms.customfishing.api.data.PlayerData;
import net.momirealms.customfishing.api.data.user.OfflineUser;
import net.momirealms.customfishing.api.data.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public interface StorageManager {
/**
* Get server unique id
* @return id
*/
String getUniqueID();
/**
* Get online user's data
* @param uuid uuid
* @return online user data
*/
OnlineUser getOnlineUser(UUID uuid);
/**
* Get an offline user's data
* force reading would ignore the database lock
* Otherwise it would return Optional.empty() if data is locked
* It an offline user never played the server, its name would equal "" (empty string)
* @param uuid uuid
* @param force force
* @return offline user data
*/
CompletableFuture<Optional<OfflineUser>> getOfflineUser(UUID uuid, boolean force);
/**
* Get all the players in servers that connected to the same redis server
* @return amount
*/
CompletableFuture<Integer> getRedisPlayerCount();
/**
* Get plugin data source
* @return data source
*/
DataStorageInterface getDataSource();
boolean isRedisEnabled();
byte[] toBytes(@NotNull PlayerData data);
@NotNull String toJson(@NotNull PlayerData data);
@NotNull PlayerData fromBytes(byte[] data);
}

View File

@@ -0,0 +1,4 @@
package net.momirealms.customfishing.api.manager;
public interface TotemManager {
}

View File

@@ -0,0 +1,18 @@
package net.momirealms.customfishing.api.manager;
import java.util.concurrent.CompletableFuture;
public interface VersionManager {
boolean isVersionNewerThan1_19_R2();
CompletableFuture<Boolean> checkUpdate();
boolean isSpigot();
public boolean isFolia();
String getPluginVersion();
String getServerVersion();
}

View File

@@ -0,0 +1,30 @@
package net.momirealms.customfishing.api.mechanic;
import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
public class TempFishingState {
private final Effect effect;
private final FishingPreparation preparation;
private final Loot loot;
public TempFishingState(Effect effect, FishingPreparation preparation, Loot loot) {
this.effect = effect;
this.preparation = preparation;
this.loot = loot;
}
public Effect getEffect() {
return effect;
}
public FishingPreparation getPreparation() {
return preparation;
}
public Loot getLoot() {
return loot;
}
}

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.api.mechanic.action;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
public interface Action {
void trigger(Condition condition);
}

View File

@@ -0,0 +1,6 @@
package net.momirealms.customfishing.api.mechanic.action;
public interface ActionBuilder {
Action build(Object args, double chance);
}

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.api.mechanic.action;
public enum ActionTrigger {
SUCCESS,
FAILURE,
HOOK,
CONSUME
}

View File

@@ -0,0 +1,35 @@
package net.momirealms.customfishing.api.mechanic.bag;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class FishingBagHolder implements InventoryHolder {
private final UUID owner;
private Inventory inventory;
public FishingBagHolder(UUID owner) {
this.owner = owner;
}
@Override
public @NotNull Inventory getInventory() {
return inventory;
}
public void setItems(ItemStack[] itemStacks) {
this.inventory.setContents(itemStacks);
}
public UUID getOwner() {
return owner;
}
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
}

View File

@@ -0,0 +1,86 @@
package net.momirealms.customfishing.api.mechanic.block;
import java.util.List;
public class BlockConfig implements BlockSettings {
private String blockID;
private List<BlockDataModifier> dataModifierList;
private List<BlockStateModifier> stateModifierList;
private boolean persist;
private double horizontalVector;
private double verticalVector;
@Override
public String getBlockID() {
return blockID;
}
@Override
public List<BlockDataModifier> getDataModifier() {
return dataModifierList;
}
@Override
public List<BlockStateModifier> getStateModifierList() {
return stateModifierList;
}
@Override
public boolean isPersist() {
return persist;
}
@Override
public double getHorizontalVector() {
return horizontalVector;
}
@Override
public double getVerticalVector() {
return verticalVector;
}
public static class Builder {
private final BlockConfig config;
public Builder() {
this.config = new BlockConfig();
}
public Builder persist(boolean value) {
config.persist = value;
return this;
}
public Builder horizontalVector(double value) {
config.horizontalVector = value;
return this;
}
public Builder verticalVector(double value) {
config.verticalVector = value;
return this;
}
public Builder blockID(String value) {
config.blockID = value;
return this;
}
public Builder dataModifiers(List<BlockDataModifier> value) {
config.dataModifierList = value;
return this;
}
public Builder stateModifiers(List<BlockStateModifier> value) {
config.stateModifierList = value;
return this;
}
public BlockConfig build() {
return config;
}
}
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customfishing.api.mechanic.block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
public interface BlockDataModifier {
void apply(Player player, BlockData blockData);
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customfishing.api.mechanic.block;
import java.util.InvalidPropertiesFormatException;
public interface BlockDataModifierBuilder {
BlockDataModifier build(Object args);
}

View File

@@ -0,0 +1,14 @@
package net.momirealms.customfishing.api.mechanic.block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
public interface BlockLibrary {
String identification();
BlockData getBlockData(Player player, String id, List<BlockDataModifier> modifiers);
}

View File

@@ -0,0 +1,17 @@
package net.momirealms.customfishing.api.mechanic.block;
import java.util.List;
public interface BlockSettings {
String getBlockID();
List<BlockDataModifier> getDataModifier();
List<BlockStateModifier> getStateModifierList();
boolean isPersist();
double getHorizontalVector();
double getVerticalVector();
}

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.api.mechanic.block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
public interface BlockStateModifier {
void apply(Player player, BlockState blockState);
}

View File

@@ -0,0 +1,6 @@
package net.momirealms.customfishing.api.mechanic.block;
public interface BlockStateModifierBuilder {
BlockStateModifier build(Object args);
}

View File

@@ -0,0 +1,25 @@
package net.momirealms.customfishing.api.mechanic.competition;
public abstract class AbstractCompetitionInfo {
protected int refreshRate;
protected int switchInterval;
protected boolean showToAll;
protected String[] texts;
public int getRefreshRate() {
return refreshRate;
}
public int getSwitchInterval() {
return switchInterval;
}
public boolean isShowToAll() {
return showToAll;
}
public String[] getTexts() {
return texts;
}
}

View File

@@ -0,0 +1,37 @@
package net.momirealms.customfishing.api.mechanic.competition;
public class ActionBarConfig extends AbstractCompetitionInfo {
public static class Builder {
private final ActionBarConfig config;
public Builder() {
this.config = new ActionBarConfig();
}
public Builder showToAll(boolean showToAll) {
this.config.showToAll = showToAll;
return this;
}
public Builder refreshRate(int rate) {
this.config.refreshRate = rate;
return this;
}
public Builder switchInterval(int interval) {
this.config.switchInterval = interval;
return this;
}
public Builder text(String[] texts) {
this.config.texts = texts;
return this;
}
public ActionBarConfig build() {
return this.config;
}
}
}

View File

@@ -0,0 +1,68 @@
package net.momirealms.customfishing.api.mechanic.competition;
import org.bukkit.boss.BarColor;
public class BossBarConfig extends AbstractCompetitionInfo {
private BarColor color;
private Overlay overlay;
public BarColor getColor() {
return color;
}
public Overlay getOverlay() {
return overlay;
}
public static class Builder {
private final BossBarConfig config;
public Builder() {
this.config = new BossBarConfig();
}
public Builder showToAll(boolean showToAll) {
this.config.showToAll = showToAll;
return this;
}
public Builder refreshRate(int rate) {
this.config.refreshRate = rate;
return this;
}
public Builder switchInterval(int interval) {
this.config.switchInterval = interval;
return this;
}
public Builder text(String[] texts) {
this.config.texts = texts;
return this;
}
public Builder color(BarColor color) {
this.config.color = color;
return this;
}
public Builder overlay(Overlay overlay) {
this.config.overlay = overlay;
return this;
}
public BossBarConfig build() {
return this.config;
}
}
public enum Overlay {
NOTCHED_6,
NOTCHED_10,
NOTCHED_12,
NOTCHED_20,
PROGRESS
}
}

View File

@@ -0,0 +1,131 @@
package net.momirealms.customfishing.api.mechanic.competition;
import net.momirealms.customfishing.api.mechanic.action.Action;
import java.util.HashMap;
public class CompetitionConfig {
private final String key;
private int duration;
private int minPlayers;
private BossBarConfig bossBarConfig;
private ActionBarConfig actionBarConfig;
private Action[] skipActions;
private Action[] startActions;
private Action[] endActions;
private Action[] joinActions;
private CompetitionGoal goal;
private HashMap<String, Action[]> rewards;
public CompetitionConfig(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public int getDuration() {
return duration;
}
public int getMinPlayers() {
return minPlayers;
}
public Action[] getStartActions() {
return startActions;
}
public Action[] getEndActions() {
return endActions;
}
public Action[] getJoinActions() {
return joinActions;
}
public Action[] getSkipActions() {
return skipActions;
}
public CompetitionGoal getGoal() {
return goal;
}
public HashMap<String, Action[]> getRewards() {
return rewards;
}
public BossBarConfig getBossBarConfig() {
return bossBarConfig;
}
public ActionBarConfig getActionBarConfig() {
return actionBarConfig;
}
public static class Builder {
private final CompetitionConfig config;
public Builder(String key) {
this.config = new CompetitionConfig(key);
}
public Builder duration(int duration) {
config.duration = duration;
return this;
}
public Builder minPlayers(int min) {
config.minPlayers = min;
return this;
}
public Builder startActions(Action[] startActions) {
config.startActions = startActions;
return this;
}
public Builder endActions(Action[] endActions) {
config.endActions = endActions;
return this;
}
public Builder skipActions(Action[] skipActions) {
config.skipActions = skipActions;
return this;
}
public Builder joinActions(Action[] joinActions) {
config.joinActions = joinActions;
return this;
}
public Builder actionbar(ActionBarConfig actionBarConfig) {
config.actionBarConfig = actionBarConfig;
return this;
}
public Builder bossbar(BossBarConfig bossBarConfig) {
config.bossBarConfig = bossBarConfig;
return this;
}
public Builder goal(CompetitionGoal goal) {
config.goal = goal;
return this;
}
public Builder rewards(HashMap<String, Action[]> rewards) {
config.rewards = rewards;
return this;
}
public CompetitionConfig build() {
return config;
}
}
}

View File

@@ -15,21 +15,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.fishing.action; package net.momirealms.customfishing.api.mechanic.competition;
public abstract class AbstractAction { import java.util.concurrent.ThreadLocalRandom;
protected double chance; public enum CompetitionGoal {
public AbstractAction(double chance) { CATCH_AMOUNT,
this.chance = chance; TOTAL_SCORE,
} MAX_SIZE,
TOTAL_SIZE,
RANDOM;
public double getChance() { public static CompetitionGoal getRandom() {
return chance; return CompetitionGoal.values()[ThreadLocalRandom.current().nextInt(CompetitionGoal.values().length - 1)];
}
public boolean canExecute() {
return Math.random() < chance;
} }
} }

View File

@@ -15,35 +15,38 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.fishing.competition; package net.momirealms.customfishing.api.mechanic.competition;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class CompetitionPlayer implements Comparable<CompetitionPlayer>{ public class CompetitionPlayer implements Comparable<CompetitionPlayer>{
public static CompetitionPlayer empty = new CompetitionPlayer("", 0);
private long time; private long time;
private final String player; private final String player;
private float score; private double score;
public static CompetitionPlayer emptyPlayer = new CompetitionPlayer(null, 0); public CompetitionPlayer(String player, double score) {
public CompetitionPlayer(String player, float score) {
this.player = player; this.player = player;
this.score = score; this.score = score;
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
} }
public void addScore(float score){ public void addScore(double score){
this.score += score; this.score += score;
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
} }
public void setScore(float score){ public void setScore(double score){
this.score = score; this.score = score;
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
} }
public float getScore() { public long getTime() {
return time;
}
public double getScore() {
return this.score; return this.score;
} }
@@ -55,17 +58,19 @@ public class CompetitionPlayer implements Comparable<CompetitionPlayer>{
public int compareTo(@NotNull CompetitionPlayer competitionPlayer) { public int compareTo(@NotNull CompetitionPlayer competitionPlayer) {
if (competitionPlayer.getScore() != this.score) { if (competitionPlayer.getScore() != this.score) {
return (competitionPlayer.getScore() > this.score) ? 1 : -1; return (competitionPlayer.getScore() > this.score) ? 1 : -1;
} else if (competitionPlayer.getTime() != this.time) {
return (competitionPlayer.getTime() > this.time) ? 1 : -1;
} else { } else {
return (competitionPlayer.getScore() > this.time) ? 1 : -1; return 0;
} }
} }
@Override @Override
public String toString() { public String toString() {
return "CompetitionPlayer{" + return "CompetitionPlayer[" +
"time=" + time + "time=" + time +
", player='" + player + '\'' + ", player='" + player + '\'' +
", score=" + score + ", score=" + score +
'}'; ']';
} }
} }

View File

@@ -0,0 +1,30 @@
package net.momirealms.customfishing.api.mechanic.competition;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public interface FishingCompetition {
void start();
void stop();
void end();
boolean isOnGoing();
void refreshData(Player player, double score, boolean doubleScore);
boolean hasPlayerJoined(OfflinePlayer player);
float getProgress();
long getRemainingTime();
long getStartTime();
CompetitionConfig getConfig();
CompetitionGoal getGoal();
Ranking getRanking();
}

View File

@@ -15,24 +15,33 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customfishing.fishing.competition.ranking; package net.momirealms.customfishing.api.mechanic.competition;
import net.momirealms.customfishing.fishing.competition.CompetitionPlayer; import net.momirealms.customfishing.api.common.Pair;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Iterator; import java.util.Iterator;
public interface RankingInterface { public interface Ranking {
void clear(); void clear();
CompetitionPlayer getCompetitionPlayer(String player); CompetitionPlayer getCompetitionPlayer(String player);
Iterator<String> getIterator();
Iterator<Pair<String, Double>> getIterator();
int getSize(); int getSize();
String getPlayerRank(String player);
float getPlayerScore(String player); int getPlayerRank(String player);
void refreshData(String player, float score);
void setData(String player, float score); double getPlayerScore(String player);
void refreshData(String player, double score);
void setData(String player, double score);
@Nullable @Nullable
String getPlayerAt(int rank); String getPlayerAt(int rank);
float getScoreAt(int rank);
double getScoreAt(int rank);
} }

View File

@@ -0,0 +1,72 @@
package net.momirealms.customfishing.api.mechanic.condition;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
public class Condition {
@Nullable
protected final Location location;
@Nullable
protected final Player player;
@NotNull
protected final HashMap<String, String> args;
public Condition() {
this(null, null, new HashMap<>());
}
public Condition(HashMap<String, String> args) {
this(null, null, args);
}
public Condition(Player player) {
this(player.getLocation(), player, new HashMap<>());
}
public Condition(Player player, HashMap<String, String> args) {
this(player.getLocation(), player, args);
}
public Condition(@Nullable Location location, @Nullable Player player, @NotNull HashMap<String, String> args) {
this.location = location;
this.player = player;
this.args = args;
if (player != null)
this.args.put("player", player.getName());
if (location != null) {
this.args.put("x", String.valueOf(location.getX()));
this.args.put("y", String.valueOf(location.getY()));
this.args.put("z", String.valueOf(location.getZ()));
this.args.put("world", location.getWorld().getName());
}
}
@Nullable
public Location getLocation() {
return location;
}
@Nullable
public Player getPlayer() {
return player;
}
@NotNull
public HashMap<String, String> getArgs() {
return args;
}
@Nullable
public String getArg(String key) {
return args.get(key);
}
public void insertArg(String key, String value) {
args.put(key, value);
}
}

View File

@@ -0,0 +1,143 @@
package net.momirealms.customfishing.api.mechanic.condition;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class FishingPreparation extends Condition {
private final boolean rodOnMainHand;
private final @NotNull ItemStack rodItemStack;
private final @NotNull String rodItemID;
private final @Nullable Effect rodEffect;
private @Nullable ItemStack baitItemStack;
private @Nullable String baitItemID;
private @Nullable Effect baitEffect;
private final List<Effect> utilEffects;
private boolean canFish = true;
public FishingPreparation(Player player, CustomFishingPlugin plugin) {
super(player);
PlayerInventory playerInventory = player.getInventory();
ItemStack mainHandItem = playerInventory.getItemInMainHand();
ItemStack offHandItem = playerInventory.getItemInOffHand();
this.utilEffects = new ArrayList<>();
this.rodOnMainHand = mainHandItem.getType() == Material.FISHING_ROD;
this.rodItemStack = this.rodOnMainHand ? mainHandItem : offHandItem;
this.rodItemID = plugin.getItemManager().getAnyItemID(this.rodItemStack);
this.rodEffect = plugin.getEffectManager().getEffect("rod", this.rodItemID);
super.insertArg("rod", this.rodItemID);
String baitItemID = plugin.getItemManager().getAnyItemID(this.rodOnMainHand ? offHandItem : mainHandItem);
Effect baitEffect = plugin.getEffectManager().getEffect("bait", baitItemID);
if (baitEffect != null) {
this.baitItemID = baitItemID;
this.baitItemStack = this.rodOnMainHand ? offHandItem : mainHandItem;
this.baitEffect = baitEffect;
} else if (plugin.getBagManager().isBagEnabled()) {
Inventory fishingBag = plugin.getBagManager().getOnlineBagInventory(player.getUniqueId());
HashSet<String> uniqueUtils = new HashSet<>(4);
if (fishingBag != null) {
for (int i = 0; i < fishingBag.getSize(); i++) {
ItemStack itemInBag = fishingBag.getItem(i);
String bagItemID = plugin.getItemManager().getItemID(itemInBag);
if (bagItemID == null) continue;
if (this.baitEffect == null) {
Effect effect = plugin.getEffectManager().getEffect("bait", bagItemID);
if (effect != null) {
this.baitItemID = bagItemID;
this.baitItemStack = itemInBag;
this.baitEffect = effect;
continue;
}
}
Effect utilEffect = plugin.getEffectManager().getEffect("util", bagItemID);
if (utilEffect != null
&& !uniqueUtils.contains(bagItemID)
&& utilEffect.canMerge(this)) {
utilEffects.add(utilEffect);
uniqueUtils.add(bagItemID);
}
}
}
} else {
this.baitItemID = null;
this.baitItemStack = null;
this.baitEffect = null;
}
if (this.baitEffect != null) {
if (!this.baitEffect.canMerge(this)) {
this.canFish = false;
return;
}
super.insertArg("bait", this.baitItemID);
}
if (this.rodEffect != null) {
if (!this.rodEffect.canMerge(this)) {
this.canFish = false;
}
}
}
public boolean isRodOnMainHand() {
return rodOnMainHand;
}
@NotNull
public ItemStack getRodItemStack() {
return rodItemStack;
}
@NotNull
public String getRodItemID() {
return rodItemID;
}
@Nullable
public ItemStack getBaitItemStack() {
return baitItemStack;
}
@Nullable
public String getBaitItemID() {
return baitItemID;
}
@Nullable
public Effect getRodEffect() {
return rodEffect;
}
@Nullable
public Effect getBaitEffect() {
return baitEffect;
}
public boolean canFish() {
return this.canFish;
}
@Override
public @NotNull Player getPlayer() {
assert super.player != null;
return super.player;
}
public List<Effect> getUtilEffects() {
return utilEffects;
}
}

View File

@@ -0,0 +1,96 @@
package net.momirealms.customfishing.api.mechanic.effect;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.loot.Modifier;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
import java.util.ArrayList;
import java.util.List;
public class AbstractEffect implements Effect {
protected boolean lavaFishing = false;
protected double multipleLootChance = 0;
protected double sizeMultiplier = 1;
protected double scoreMultiplier = 1;
protected double timeModifier = 1;
protected double difficultyModifier = 0;
protected double gameTimeModifier = 0;
protected Requirement[] requirements;
protected List<Pair<String, Modifier>> lootWeightModifier = new ArrayList<>();
@Override
public boolean persist() {
return false;
}
@Override
public Requirement[] getRequirements() {
return requirements;
}
@Override
public boolean canLavaFishing() {
return lavaFishing;
}
@Override
public double getMultipleLootChance() {
return multipleLootChance;
}
@Override
public double getSizeMultiplier() {
return sizeMultiplier;
}
@Override
public double getScoreMultiplier() {
return scoreMultiplier;
}
@Override
public double getTimeModifier() {
return timeModifier;
}
@Override
public double getGameTimeModifier() {
return gameTimeModifier;
}
@Override
public double getDifficultyModifier() {
return difficultyModifier;
}
@Override
public AbstractEffect merge(Effect another) {
if (another == null) return this;
if (another.canLavaFishing()) this.lavaFishing = true;
this.scoreMultiplier += (another.getScoreMultiplier() -1);
this.sizeMultiplier += (another.getSizeMultiplier() -1);
this.timeModifier += (another.getTimeModifier() -1);
this.multipleLootChance += another.getMultipleLootChance();
this.difficultyModifier += another.getDifficultyModifier();
this.gameTimeModifier += another.getGameTimeModifier();
return this;
}
@Override
public List<Pair<String, Modifier>> getLootWeightModifier() {
return lootWeightModifier;
}
@Override
public boolean canMerge(Condition condition) {
if (this.requirements == null) return true;
for (Requirement requirement : requirements) {
if (!requirement.isConditionMet(condition)) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,35 @@
package net.momirealms.customfishing.api.mechanic.effect;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.loot.Modifier;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
import java.util.List;
public interface Effect {
boolean persist();
Requirement[] getRequirements();
boolean canLavaFishing();
double getMultipleLootChance();
double getSizeMultiplier();
double getScoreMultiplier();
double getTimeModifier();
double getGameTimeModifier();
double getDifficultyModifier();
Effect merge(Effect another);
List<Pair<String, Modifier>> getLootWeightModifier();
boolean canMerge(Condition condition);
}

View File

@@ -0,0 +1,68 @@
package net.momirealms.customfishing.api.mechanic.effect;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.loot.Modifier;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
import java.util.List;
public class FishingEffect extends AbstractEffect {
public static class Builder {
private final FishingEffect effect;
public Builder() {
this.effect = new FishingEffect();
}
public Builder lootWeightModifier(List<Pair<String, Modifier>> modifier) {
effect.lootWeightModifier = modifier;
return this;
}
public Builder multipleLootChance(double multipleLootChance) {
effect.multipleLootChance = multipleLootChance;
return this;
}
public Builder difficultyModifier(double difficultyModifier) {
effect.difficultyModifier = difficultyModifier;
return this;
}
public Builder sizeMultiplier(double sizeMultiplier) {
effect.sizeMultiplier = sizeMultiplier;
return this;
}
public Builder timeModifier(double timeModifier) {
effect.timeModifier = timeModifier;
return this;
}
public Builder scoreMultiplier(double scoreMultiplier) {
effect.scoreMultiplier = scoreMultiplier;
return this;
}
public Builder gameTimeModifier(double gameTimeModifier) {
effect.gameTimeModifier = gameTimeModifier;
return this;
}
public Builder lavaFishing(boolean lavaFishing) {
effect.lavaFishing = lavaFishing;
return this;
}
public Builder requirements(Requirement[] requirements) {
effect.requirements = requirements;
return this;
}
public FishingEffect build() {
return effect;
}
}
}

View File

@@ -0,0 +1,14 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.manager.FishingManager;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
public abstract class AbstractGame implements Game {
public AbstractGame(ConfigurationSection config) {
}
@Override
public abstract GamingPlayer start(Player player, GameSettings settings, FishingManager manager);
}

View File

@@ -0,0 +1,101 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.manager.FishingManager;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffectType;
import java.util.concurrent.TimeUnit;
public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
protected boolean succeeded;
protected CancellableTask task;
protected Player player;
protected GameSettings settings;
protected FishingManager manager;
private final long deadline;
public AbstractGamingPlayer(Player player, GameSettings settings, FishingManager manager) {
this.player = player;
this.settings = settings;
this.manager = manager;
this.deadline = System.currentTimeMillis() + settings.getTime() * 1000L;
this.arrangeTask();
}
public void arrangeTask() {
this.task = CustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(this, 50, 50, TimeUnit.MILLISECONDS);
}
@Override
public void cancel() {
if (task != null && !task.isCancelled())
task.cancel();
}
@Override
public boolean isSucceeded() {
return succeeded;
}
@Override
public boolean onRightClick() {
manager.processGameResult(this);
return true;
}
@Override
public boolean onLeftClick() {
return false;
}
@Override
public boolean onSwapHand() {
return false;
}
@Override
public boolean onJump() {
return false;
}
@Override
public Player getPlayer() {
return player;
}
@Override
public Effect getEffectReward() {
return null;
}
@Override
public void run() {
timeOutCheck();
switchItemCheck();
}
protected void timeOutCheck() {
if (System.currentTimeMillis() > deadline) {
cancel();
if (manager.removeHook(player.getUniqueId())) {
manager.processGameResult(this);
}
}
}
protected void switchItemCheck() {
PlayerInventory playerInventory = player.getInventory();
if (playerInventory.getItemInMainHand().getType() != Material.FISHING_ROD
&& playerInventory.getItemInOffHand().getType() != Material.FISHING_ROD) {
cancel();
manager.processGameResult(this);
player.removePotionEffect(PotionEffectType.SLOW);
}
}
}

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.manager.FishingManager;
import org.bukkit.entity.Player;
public interface Game {
GamingPlayer start(Player player, GameSettings settings, FishingManager manager);
}

View File

@@ -0,0 +1,11 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.jetbrains.annotations.Nullable;
public interface GameConfig {
@Nullable
Pair<Game, GameSettings> getRandomGame(Effect effect);
}

View File

@@ -0,0 +1,61 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.util.WeightUtils;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class GameGroup implements GameConfig {
private final List<Pair<String, Double>> gamePairs;
private int minTime;
private int maxTime;
private int minDifficulty;
private int maxDifficulty;
public GameGroup(List<Pair<String, Double>> gamePairs) {
this.gamePairs = gamePairs;
}
public GameGroup difficulty(int value) {
minDifficulty = (maxDifficulty = value);
return this;
}
public GameGroup time(int value) {
minTime = (maxTime = value);
return this;
}
public GameGroup difficulty(int min, int max) {
minDifficulty = min;
maxDifficulty = max;
return this;
}
public GameGroup time(int min, int max) {
minTime = min;
maxTime = max;
return this;
}
@Override
@Nullable
public Pair<Game, GameSettings> getRandomGame(Effect effect) {
String key = WeightUtils.getRandom(gamePairs);
Game game = CustomFishingPlugin.get().getGameManager().getGame(key);
if (game == null) {
CustomFishingPlugin.get().getLogger().warning(String.format("Game %s doesn't exist!", key));
return null;
}
GameSettings settings = new GameSettings(
ThreadLocalRandom.current().nextInt(minTime, maxTime + 1),
(int) (ThreadLocalRandom.current().nextInt(minDifficulty, maxDifficulty + 1) + effect.getDifficultyModifier())
);
return Pair.of(game, settings);
}
}

View File

@@ -0,0 +1,33 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.util.WeightUtils;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class GameGroups implements GameConfig {
private final List<Pair<String, Double>> gamesWithWeight;
public GameGroups(List<Pair<String, Double>> gamesWithWeight) {
this.gamesWithWeight = gamesWithWeight;
}
@Override
public @Nullable Pair<Game, GameSettings> getRandomGame(Effect effect) {
String group = WeightUtils.getRandom(gamesWithWeight);
GameConfig gameConfig = CustomFishingPlugin.get().getGameManager().getGameConfig(group);
if (gameConfig == null) {
CustomFishingPlugin.get().getLogger().warning(String.format("Game config %s doesn't exist!", group));
return null;
}
if (!(gameConfig instanceof GameGroup gameGroup)) {
CustomFishingPlugin.get().getLogger().warning(String.format("%s is not a game group!", group));
return null;
}
return gameGroup.getRandomGame(effect);
}
}

View File

@@ -0,0 +1,20 @@
package net.momirealms.customfishing.api.mechanic.game;
public class GameSettings {
private final int time;
private final int difficulty;
public GameSettings(int time, int difficulty) {
this.time = time;
this.difficulty = difficulty;
}
public int getTime() {
return time;
}
public int getDifficulty() {
return difficulty;
}
}

View File

@@ -0,0 +1,23 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.bukkit.entity.Player;
public interface GamingPlayer {
void cancel();
boolean isSucceeded();
boolean onRightClick();
boolean onLeftClick();
boolean onSwapHand();
boolean onJump();
Player getPlayer();
Effect getEffectReward();
}

View File

@@ -0,0 +1,25 @@
package net.momirealms.customfishing.api.mechanic.item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
public interface BuildableItem {
default ItemStack build() {
return build(null, new HashMap<>());
}
default ItemStack build(Player player) {
return build(player, new HashMap<>());
}
ItemStack build(Player player, Map<String, String> placeholders);
/**
* Whether the item would be removed from cache when reloading
*/
boolean persist();
}

View File

@@ -0,0 +1,72 @@
package net.momirealms.customfishing.api.mechanic.item;
import de.tr7zw.changeme.nbtapi.NBTItem;
import net.momirealms.customfishing.api.common.Pair;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface ItemBuilder {
ItemBuilder customModelData(int value);
ItemBuilder name(String name);
ItemBuilder amount(int amount);
ItemBuilder tag(boolean tag, String type, String id);
ItemBuilder unbreakable(boolean unbreakable);
ItemBuilder lore(List<String> lore);
ItemBuilder nbt(Map<String, Object> nbt);
ItemBuilder itemFlag(List<ItemFlag> itemFlags);
ItemBuilder nbt(ConfigurationSection section);
ItemBuilder enchantment(List<Pair<String, Short>> enchantments, boolean store);
ItemBuilder maxDurability(int max);
ItemBuilder price(float base, float bonus);
ItemBuilder size(Pair<Float, Float> size);
ItemBuilder stackable(boolean stackable);
ItemBuilder preventGrabbing(boolean prevent);
ItemBuilder head(String base64);
ItemBuilder randomDamage(boolean damage);
@NotNull
String getId();
@NotNull
String getLibrary();
int getAmount();
Collection<ItemPropertyEditor> getEditors();
ItemBuilder removeEditor(String type);
ItemBuilder registerCustomEditor(String type, ItemPropertyEditor editor);
interface ItemPropertyEditor {
void edit(Player player, NBTItem nbtItem, Map<String, String> placeholders);
default void edit(Player player, NBTItem nbtItem) {
edit(player, nbtItem, null);
}
}
}

View File

@@ -0,0 +1,13 @@
package net.momirealms.customfishing.api.mechanic.item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public interface ItemLibrary {
String identification();
ItemStack buildItem(Player player, String id);
String getItemID(ItemStack itemStack);
}

View File

@@ -0,0 +1,77 @@
package net.momirealms.customfishing.api.mechanic.loot;
import net.momirealms.customfishing.api.mechanic.action.Action;
import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
import net.momirealms.customfishing.api.mechanic.game.GameConfig;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
public interface Loot {
boolean instanceGame();
/**
* get the loot id
* @return id
*/
String getID();
/**
* get the loot type
* @return type
*/
LootType getType();
/**
* nick would be display.name or key name if not set (MiniMessage format)
* @return nick
*/
@NotNull
String getNick();
/**
* if the loot can be seen from the finder
* @return show in finder or not
*/
boolean showInFinder();
/**
* get the score in competition
* @return score
*/
double getScore();
/**
* if the game is disabled
* @return disabled or not
*/
boolean disableGame();
/**
* if the statistics is disabled
* @return disabled or not
*/
boolean disableStats();
/**
* Get the game config
* @return game config
*/
GameConfig getGameConfig();
/**
* get actions triggered by certain events
* @return actions
*/
Action[] getActions(ActionTrigger actionTrigger);
/**
* get actions when succeeding in fishing for certain times
* @param times times
* @return actions
*/
Action[] getSuccessTimesActions(int times);
HashMap<Integer, Action[]> getSuccessTimesActionMap();
}

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.api.mechanic.loot;
public enum LootType {
LOOT,
MOB,
BLOCK,
GLOBAL
}

View File

@@ -0,0 +1,5 @@
package net.momirealms.customfishing.api.mechanic.loot;
public interface Modifier {
double modify(double weight);
}

View File

@@ -0,0 +1,19 @@
package net.momirealms.customfishing.api.mechanic.market;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
public class MarketGUI implements InventoryHolder {
private Inventory inventory;
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
@Override
public @NotNull Inventory getInventory() {
return inventory;
}
}

View File

@@ -0,0 +1,75 @@
package net.momirealms.customfishing.api.mechanic.mob;
import java.util.Map;
public class MobConfig implements MobSettings {
private String mob;
private double horizontalVector;
private double verticalVector;
private Map<String, Object> propertyMap;
private boolean persist;
@Override
public boolean isPersist() {
return persist;
}
@Override
public double getHorizontalVector() {
return horizontalVector;
}
@Override
public double getVerticalVector() {
return verticalVector;
}
@Override
public String getMobID() {
return mob;
}
@Override
public Map<String, Object> getPropertyMap() {
return propertyMap;
}
public static class Builder {
private final MobConfig config;
public Builder() {
this.config = new MobConfig();
}
public Builder mobID(String value) {
this.config.mob = value;
return this;
}
public Builder persist(boolean value) {
this.config.persist = value;
return this;
}
public Builder verticalVector(double value) {
this.config.verticalVector = value;
return this;
}
public Builder horizontalVector(double value) {
this.config.horizontalVector = value;
return this;
}
public Builder propertyMap(Map<String, Object> value) {
this.config.propertyMap = value;
return this;
}
public MobConfig build() {
return config;
}
}
}

View File

@@ -0,0 +1,13 @@
package net.momirealms.customfishing.api.mechanic.mob;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import java.util.Map;
public interface MobLibrary {
String identification();
Entity spawn(Location location, String id, Map<String, Object> mobPropertyMap);
}

View File

@@ -0,0 +1,15 @@
package net.momirealms.customfishing.api.mechanic.mob;
import java.util.Map;
public interface MobSettings {
boolean isPersist();
double getHorizontalVector();
double getVerticalVector();
String getMobID();
Map<String, Object> getPropertyMap();
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customfishing.api.mechanic.requirement;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
public interface Requirement {
boolean isConditionMet(Condition condition);
}

View File

@@ -0,0 +1,14 @@
package net.momirealms.customfishing.api.mechanic.requirement;
import net.momirealms.customfishing.api.mechanic.action.Action;
import java.util.List;
public interface RequirementBuilder {
Requirement build(Object args, List<Action> notMetActions, boolean checkAction);
default Requirement build(Object args) {
return build(args, null, false);
}
}

View File

@@ -0,0 +1,85 @@
package net.momirealms.customfishing.api.mechanic.statistic;
import com.google.gson.annotations.SerializedName;
import net.momirealms.customfishing.api.data.StatisticData;
import net.momirealms.customfishing.api.mechanic.action.Action;
import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.bukkit.configuration.ConfigurationSection;
import java.util.HashMap;
import java.util.Map;
public class Statistics {
@SerializedName("statistic_map")
private final HashMap<String, Integer> statisticMap;
private int total;
public Statistics() {
this.statisticMap = new HashMap<>();
this.total = 0;
}
public Statistics(ConfigurationSection section) {
this.statisticMap = new HashMap<>();
this.total = 0;
for (String key : section.getKeys(false)) {
int amount = section.getInt(key);
total += amount;
statisticMap.put(key, amount);
}
}
public Statistics(StatisticData statisticData) {
this.statisticMap = new HashMap<>(statisticData.statisticMap);
this.total = statisticMap.values().stream().mapToInt(Integer::intValue).sum();
}
public void addLootAmount(Loot loot, FishingPreparation fishingPreparation, int amount) {
Integer previous = statisticMap.get(loot.getID());
if (previous == null) previous = 0;
int after = previous + amount;
statisticMap.put(loot.getID(), after);
total += amount;
doSuccessTimesAction(previous, after, fishingPreparation, loot);
}
private void doSuccessTimesAction(Integer previous, int after, FishingPreparation fishingPreparation, Loot loot) {
HashMap<Integer, Action[]> actionMap = loot.getSuccessTimesActionMap();
if (actionMap != null) {
for (Map.Entry<Integer, Action[]> entry : actionMap.entrySet()) {
if (entry.getKey() > previous && entry.getKey() <= after) {
for (Action action : entry.getValue()) {
action.trigger(fishingPreparation);
}
}
}
}
}
public int getFishAmount(String key) {
Integer amount = statisticMap.get(key);
return amount == null ? 0 : amount;
}
public boolean hasFished(String key) {
return statisticMap.containsKey(key);
}
public void reset() {
statisticMap.clear();
}
public HashMap<String, Integer> getStatisticMap() {
return statisticMap;
}
public void setData(String key, int value) {
statisticMap.put(key, value);
}
public int getTotalCatchAmount() {
return total;
}
}

View File

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

View File

@@ -0,0 +1,22 @@
package net.momirealms.customfishing.api.scheduler;
import org.bukkit.Location;
import java.util.concurrent.TimeUnit;
public interface Scheduler {
void runTaskSync(Runnable runnable, Location location);
CancellableTask runTaskSyncTimer(Runnable runnable, Location location, long delay, long period);
CancellableTask runTaskAsyncLater(Runnable runnable, long delay, TimeUnit timeUnit);
void runTaskAsync(Runnable runnable);
CancellableTask runTaskSyncLater(Runnable runnable, Location location, long delay, TimeUnit timeUnit);
CancellableTask runTaskSyncLater(Runnable runnable, Location location, long delay);
CancellableTask runTaskAsyncTimer(Runnable runnable, long delay, long period, TimeUnit timeUnit);
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customfishing.api.util;
public class FontUtils {
public static String surroundWithFont(String text, String font) {
return "<font:" + font + ">" + text + "</font>";
}
}

View File

@@ -0,0 +1,138 @@
package net.momirealms.customfishing.api.util;
import net.kyori.adventure.text.Component;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class InventoryUtils {
public static Inventory createInventory(InventoryHolder inventoryHolder, int size, Component component) {
try {
boolean isSpigot = CustomFishingPlugin.get().getVersionManager().isSpigot();
Method createInvMethod = ReflectionUtils.bukkitClass.getMethod(
"createInventory",
InventoryHolder.class,
int.class,
isSpigot ? String.class : ReflectionUtils.componentClass
);
return (Inventory) createInvMethod.invoke(
null,
inventoryHolder,
size,
isSpigot ? CustomFishingPlugin.get().getAdventure().componentToLegacy(component) : CustomFishingPlugin.get().getAdventure().shadedComponentToPaperComponent(component)
);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException exception) {
exception.printStackTrace();
return null;
}
}
public static Inventory createInventory(InventoryHolder inventoryHolder, InventoryType type, Component component) {
try {
boolean isSpigot = CustomFishingPlugin.get().getVersionManager().isSpigot();
Method createInvMethod = ReflectionUtils.bukkitClass.getMethod(
"createInventory",
InventoryHolder.class,
InventoryType.class,
isSpigot ? String.class : ReflectionUtils.componentClass
);
return (Inventory) createInvMethod.invoke(
null,
inventoryHolder,
type,
isSpigot ? CustomFishingPlugin.get().getAdventure().componentToLegacy(component) : CustomFishingPlugin.get().getAdventure().shadedComponentToPaperComponent(component)
);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException exception) {
exception.printStackTrace();
return null;
}
}
public static @NotNull String stacksToBase64(ItemStack[] contents) {
if (contents.length == 0) {
return "";
}
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(contents.length);
for (ItemStack itemStack : contents) {
dataOutput.writeObject(itemStack);
}
dataOutput.close();
byte[] byteArr = outputStream.toByteArray();
outputStream.close();
return Base64Coder.encodeLines(byteArr);
} catch (IOException e) {
LogUtils.warn("Encoding error", e);
}
return "";
}
/**
* Get itemStacks from base64
* @param base64 base64
* @return itemStacks
*/
@Nullable
public static ItemStack[] getInventoryItems(String base64) {
ItemStack[] itemStacks = null;
try {
itemStacks = stacksFromBase64(base64);
} catch (IllegalArgumentException exception) {
exception.printStackTrace();
}
return itemStacks;
}
private static ItemStack[] stacksFromBase64(String data) {
if (data == null || data.equals("")) return new ItemStack[]{};
ByteArrayInputStream inputStream;
try {
inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
} catch (IllegalArgumentException e) {
return new ItemStack[]{};
}
BukkitObjectInputStream dataInput = null;
ItemStack[] stacks = null;
try {
dataInput = new BukkitObjectInputStream(inputStream);
stacks = new ItemStack[dataInput.readInt()];
} catch (IOException e) {
e.printStackTrace();
}
if (stacks == null) return new ItemStack[]{};
for (int i = 0; i < stacks.length; i++) {
try {
stacks[i] = (ItemStack) dataInput.readObject();
} catch (IOException | ClassNotFoundException | NullPointerException e) {
try {
dataInput.close();
} catch (IOException exception) {
LogUtils.severe("Failed to read fishing bag data");
}
return null;
}
}
try {
dataInput.close();
} catch (IOException ignored) {
}
return stacks;
}
}

View File

@@ -23,9 +23,9 @@
* SOFTWARE. * SOFTWARE.
*/ */
package net.momirealms.customfishing.helper; package net.momirealms.customfishing.api.util;
import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.api.CustomFishingPlugin;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -34,29 +34,29 @@ import java.util.logging.Level;
/** /**
* Utility for quickly accessing a logger instance without using {@link Bukkit#getLogger()} * Utility for quickly accessing a logger instance without using {@link Bukkit#getLogger()}
*/ */
public final class Log { public final class LogUtils {
public static void info(@NotNull String s) { public static void info(@NotNull String s) {
CustomFishing.getInstance().getLogger().info(s); CustomFishingPlugin.getInstance().getLogger().info(s);
} }
public static void warn(@NotNull String s) { public static void warn(@NotNull String s) {
CustomFishing.getInstance().getLogger().warning(s); CustomFishingPlugin.getInstance().getLogger().warning(s);
} }
public static void severe(@NotNull String s) { public static void severe(@NotNull String s) {
CustomFishing.getInstance().getLogger().severe(s); CustomFishingPlugin.getInstance().getLogger().severe(s);
} }
public static void warn(@NotNull String s, Throwable t) { public static void warn(@NotNull String s, Throwable t) {
CustomFishing.getInstance().getLogger().log(Level.WARNING, s, t); CustomFishingPlugin.getInstance().getLogger().log(Level.WARNING, s, t);
} }
public static void severe(@NotNull String s, Throwable t) { public static void severe(@NotNull String s, Throwable t) {
CustomFishing.getInstance().getLogger().log(Level.SEVERE, s, t); CustomFishingPlugin.getInstance().getLogger().log(Level.SEVERE, s, t);
} }
private Log() { private LogUtils() {
throw new UnsupportedOperationException("This class cannot be instantiated"); throw new UnsupportedOperationException("This class cannot be instantiated");
} }

View File

@@ -0,0 +1,126 @@
package net.momirealms.customfishing.api.util;
import org.bukkit.configuration.ConfigurationSection;
public class OffsetUtils {
private static String font;
private static String negative_1;
private static String negative_2;
private static String negative_4;
private static String negative_8;
private static String negative_16;
private static String negative_32;
private static String negative_64;
private static String negative_128;
private static String positive_1;
private static String positive_2;
private static String positive_4;
private static String positive_8;
private static String positive_16;
private static String positive_32;
private static String positive_64;
private static String positive_128;
public static void loadConfig(ConfigurationSection section) {
if (section != null) {
font = section.getString("font", "customfishing:offset_chars");
positive_1 = section.getString("1");
positive_2 = section.getString("2");
positive_4 = section.getString("4");
positive_8 = section.getString("8");
positive_16 = section.getString("16");
positive_32 = section.getString("32");
positive_64 = section.getString("64");
positive_128 = section.getString("128");
negative_1 = section.getString("-1");
negative_2 = section.getString("-2");
negative_4 = section.getString("-4");
negative_8 = section.getString("-8");
negative_16 = section.getString("-16");
negative_32 = section.getString("-32");
negative_64 = section.getString("-64");
negative_128 = section.getString("-128");
}
}
public static String getShortestNegChars(int n) {
StringBuilder stringBuilder = new StringBuilder();
while (n >= 128) {
stringBuilder.append(negative_128);
n -= 128;
}
if (n - 64 >= 0) {
stringBuilder.append(negative_64);
n -= 64;
}
if (n - 32 >= 0) {
stringBuilder.append(negative_32);
n -= 32;
}
if (n - 16 >= 0) {
stringBuilder.append(negative_16);
n -= 16;
}
if (n - 8 >= 0) {
stringBuilder.append(negative_8);
n -= 8;
}
if (n - 4 >= 0) {
stringBuilder.append(negative_4);
n -= 4;
}
if (n - 2 >= 0) {
stringBuilder.append(negative_2);
n -= 2;
}
if (n - 1 >= 0) {
stringBuilder.append(negative_1);
}
return stringBuilder.toString();
}
public static String getShortestPosChars(int n) {
StringBuilder stringBuilder = new StringBuilder();
while (n >= 128) {
stringBuilder.append(positive_128);
n -= 128;
}
if (n - 64 >= 0) {
stringBuilder.append(positive_64);
n -= 64;
}
if (n - 32 >= 0) {
stringBuilder.append(positive_32);
n -= 32;
}
if (n - 16 >= 0) {
stringBuilder.append(positive_16);
n -= 16;
}
if (n - 8 >= 0) {
stringBuilder.append(positive_8);
n -= 8;
}
if (n - 4 >= 0) {
stringBuilder.append(positive_4);
n -= 4;
}
if (n - 2 >= 0) {
stringBuilder.append(positive_2);
n -= 2;
}
if (n - 1 >= 0) {
stringBuilder.append(positive_1);
}
return stringBuilder.toString();
}
public static String getOffsetChars(int n) {
if (n > 0) {
return "<font:" + font + ">" + getShortestPosChars(n) + "</font>";
} else {
return "<font:" + font + ">" + getShortestNegChars(-n) + "</font>";
}
}
}

View File

@@ -1,56 +1,58 @@
package net.momirealms.customfishing.object; package net.momirealms.customfishing.api.util;
import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftReflection;
import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.util.AdventureUtils;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class Reflection { public class ReflectionUtils {
public static Class<?> textComponentClass;
public static Class<?> componentClass;
public static Class<?> bukkitClass;
public static Class<?> textColorClass;
public static Class<?> keyClass;
public static Class<?> textDecorationClass;
public static Class<?> textDecorationStateClass;
public static Object removeBossBarPacket; public static Object removeBossBarPacket;
public static Constructor<?> progressConstructor; public static Constructor<?> progressConstructor;
public static Constructor<?> updateConstructor; public static Constructor<?> updateConstructor;
public static Method iChatComponentMethod; public static Method iChatComponentMethod;
public static Method gsonDeserializeMethod;
public static Object gsonInstance;
public static Class<?> componentClass;
public static Class<?> bukkitClass;
public static void load() { public static void load() {
if (CustomFishing.getInstance().getVersionHelper().isSpigot()) return;
try { try {
textComponentClass = Class.forName("net;kyori;adventure;text;TextComponent".replace(";", "."));
componentClass = Class.forName("net;kyori;adventure;text;Component".replace(";", "."));
bukkitClass = Class.forName("org;bukkit;Bukkit".replace(";", "."));
textColorClass = Class.forName("net;kyori;adventure;text;format;TextColor".replace(";", "."));
keyClass = Class.forName("net;kyori;adventure;key;Key".replace(";", "."));
textDecorationClass = Class.forName("net;kyori;adventure;text;format;TextDecoration".replace(";", "."));
textDecorationStateClass = Class.forName("net;kyori;adventure;text;format;TextDecoration$State".replace(";", "."));
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss"); Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
Field remove = bar.getDeclaredField("f"); Field remove = bar.getDeclaredField("f");
remove.setAccessible(true); remove.setAccessible(true);
removeBossBarPacket = remove.get(null); removeBossBarPacket = remove.get(null);
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f"); Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class); progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
progressConstructor.setAccessible(true); progressConstructor.setAccessible(true);
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e"); Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass()); updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
updateConstructor.setAccessible(true); updateConstructor.setAccessible(true);
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class); iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
iChatComponentMethod.setAccessible(true); iChatComponentMethod.setAccessible(true);
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException exception) { } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException exception) {
AdventureUtils.consoleMessage("<red>[CustomFishing] Error occurred when loading reflections"); LogUtils.severe("Error occurred when loading reflections", exception);
exception.printStackTrace(); exception.printStackTrace();
return;
}
if (CustomFishingPlugin.get().getVersionManager().isSpigot()) return;
try {
componentClass = Class.forName("net;kyori;adventure;text;Component".replace(";", "."));
bukkitClass = Class.forName("org;bukkit;Bukkit".replace(";", "."));
Class<?> gsonComponentSerializerClass = Class.forName("net;kyori;adventure;text;serializer;gson;GsonComponentSerializer".replace(";", "."));
Class<?> gsonComponentSerializerImplClass = Class.forName("net;kyori;adventure;text;serializer;gson;GsonComponentSerializerImpl".replace(";", "."));
Method gsonMethod = gsonComponentSerializerClass.getMethod("gson");
gsonInstance = gsonMethod.invoke(null);
gsonDeserializeMethod = gsonComponentSerializerImplClass.getMethod("deserialize", String.class);
gsonDeserializeMethod.setAccessible(true);
} catch (ClassNotFoundException exception) {
LogUtils.severe("Error occurred when loading reflections", exception);
exception.printStackTrace();
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
} }
} }
} }

View File

@@ -0,0 +1,60 @@
package net.momirealms.customfishing.api.util;
import net.momirealms.customfishing.api.common.Pair;
import java.util.*;
public class WeightUtils {
public static <T> T getRandom(List<Pair<T, Double>> pairs) {
List<T> available = new ArrayList<>();
double[] weights = new double[pairs.size()];
int index = 0;
for (Pair<T, Double> pair : pairs){
double weight = pair.right();
T key = pair.left();
if (weight <= 0) continue;
available.add(key);
weights[index++] = weight;
}
return getRandom(weights, available, index);
}
public static <T> T getRandom(HashMap<T, Double> map) {
List<T> available = new ArrayList<>();
double[] weights = new double[map.size()];
int index = 0;
for (Map.Entry<T, Double> entry : map.entrySet()){
double weight = entry.getValue();
T key = entry.getKey();
if (weight <= 0) continue;
available.add(key);
weights[index++] = weight;
}
return getRandom(weights, available, index);
}
private static <T> T getRandom(double[] weights, List<T> available, int effectiveSize) {
double total = Arrays.stream(weights).sum();
double[] weightRatios = new double[effectiveSize];
for (int i = 0; i < effectiveSize; i++){
weightRatios[i] = weights[i]/total;
}
double[] weightRange = new double[effectiveSize];
double startPos = 0;
for (int i = 0; i < effectiveSize; i++) {
weightRange[i] = startPos + weightRatios[i];
startPos += weightRatios[i];
}
double random = Math.random();
int pos = Arrays.binarySearch(weightRange, random);
if (pos < 0) {
pos = -pos - 1;
}
if (pos < weightRange.length && random < weightRange[pos]) {
return available.get(pos);
}
return null;
}
}

View File

@@ -1,99 +0,0 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
group = 'net.momirealms'
version = '1.3.2.5'
repositories {
maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"}
maven {name = 'papermc-repo'; url = 'https://papermc.io/repo/repository/maven-public/'}
maven {name = 'sonatype-repo'; url = 'https://oss.sonatype.org/content/groups/public/'}
maven {name = "dmulloy2-repo"; url = "https://repo.dmulloy2.net/repository/public/"}
maven {name = "clip-repo"; url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'}
maven {name = "codemc-repo"; url = "https://repo.codemc.org/repository/maven-public/"}
maven {name = "sk89q-repo"; url = "https://maven.enginehub.org/repo/"}
maven {name = "jitpack-repo"; url = "https://jitpack.io"}
maven {name = "Lumine-repo"; url = "https://mvn.lumine.io/repository/maven-public"}
maven {name = 'rapture-repo'; url = 'https://repo.rapture.pw/repository/maven-releases/'}
maven {name = 'mmo-repo'; url = 'https://nexus.phoenixdevt.fr/repository/maven-public/'}
maven {name = 'i-repo'; url = 'https://r.irepo.space/maven/'}
maven {name = 'auxilor-repo'; url = 'https://repo.auxilor.io/repository/maven-public/'}
maven {name = 'betonquest-repo'; url = 'https://betonquest.org/nexus/repository/betonquest/'}
mavenCentral()
}
dependencies {
compileOnly fileTree(dir:'libs',includes:['*.jar'])
implementation fileTree(dir:'libs',includes:['BiomeAPI.jar'])
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly('dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT')
compileOnly('com.zaxxer:HikariCP:5.0.1')
compileOnly('commons-io:commons-io:2.11.0')
compileOnly('com.github.Archy-X:AureliumSkills:Beta1.3.6')
compileOnly('redis.clients:jedis:4.4.3')
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.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')
compileOnly('com.google.code.gson:gson:2.10.1')
compileOnly('com.willfp:EcoEnchants:10.13.0')
compileOnly("pers.neige.neigeitems:NeigeItems:1.14.23")
compileOnly('net.Indyuce:MMOItems-API:6.9.2-SNAPSHOT')
compileOnly('io.lumine:MythicLib-dist:1.6-SNAPSHOT')
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly('net.Indyuce:MMOCore-API:1.12-SNAPSHOT')
compileOnly('com.github.Zrips:Jobs:4.17.2')
compileOnly("com.willfp:eco:6.65.1")
compileOnly("com.willfp:EcoJobs:3.13.0")
compileOnly("com.willfp:EcoSkills:3.8.1")
compileOnly("pl.betoncraft:betonquest:1.12.10")
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.21")
implementation('net.kyori:adventure-api:4.14.0')
implementation('net.kyori:adventure-platform-bukkit:4.3.0')
implementation('net.kyori:adventure-text-minimessage:4.14.0')
implementation('net.kyori:adventure-text-serializer-legacy:4.14.0')
implementation('de.tr7zw:item-nbt-api:2.11.3')
implementation('org.bstats:bstats-bukkit:3.0.1')
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.release = targetJavaVersion
options.encoding = "UTF-8"
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
shadowJar {
relocate 'de.tr7zw', 'net.momirealms.customfishing.libs.de.tr7zw'
relocate 'net.kyori', 'net.momirealms.customfishing.libs.net.kyori'
relocate 'org.bstats', 'net.momirealms.customfishing.libs.org.bstats'
relocate 'net.momirealms.biomeapi', 'net.momirealms.customfishing.libs.net.momirealms.biomeapi'
}
tasks.register("delete", Delete).get().delete("build/libs/"+project.name+"-"+project.version+".jar")
tasks.named("build").get().dependsOn("shadowJar").finalizedBy("delete").doLast {
println("Deleting: "+ "build/libs/"+project.name+"-"+project.version+".jar")
}

73
build.gradle.kts Normal file
View File

@@ -0,0 +1,73 @@
plugins {
id("java")
id("application")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "8.1.1"
}
allprojects {
version = "2.0-beta"
apply<JavaPlugin>()
apply(plugin = "java")
apply(plugin = "application")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "org.gradle.maven-publish")
application {
mainClass.set("")
}
repositories {
maven("https://maven.aliyun.com/repository/public/")
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://repo.dmulloy2.net/repository/public/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://maven.enginehub.org/repo/")
maven("https://jitpack.io/")
maven("https://mvn.lumine.io/repository/maven-public/")
maven("https://repo.rapture.pw/repository/maven-releases/")
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
maven("https://r.irepo.space/maven/")
maven("https://repo.auxilor.io/repository/maven-public/")
maven("https://betonquest.org/nexus/repository/betonquest/")
maven("https://repo.william278.net/releases/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}
subprojects {
tasks.processResources {
val props = mapOf("version" to version)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("plugin.yml") {
expand(props)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.shadowJar {
destinationDirectory.set(file("$rootDir/target"))
archiveClassifier.set("")
archiveFileName.set("CustomFishing-" + project.name + "-" + project.version + ".jar")
}
// tasks.javadoc.configure {
// options.quiet()
// }
//
// if ("api" == project.name) {
// java {
// withSourcesJar()
// withJavadocJar()
// }
// }
}

View File

@@ -0,0 +1,8 @@
systemProp.socks.proxyHost=127.0.0.1
systemProp.socks.proxyPort=7890
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890

Binary file not shown.

View File

@@ -1,3 +1,4 @@
#Sat Jul 29 00:16:20 SGT 2023
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip

2
gradlew vendored
View File

@@ -86,7 +86,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx128m" "-Xms128m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum

Some files were not shown because too many files have changed in this diff Show More