9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2024-03-03 18:30:10 +08:00
parent 19f58c2038
commit f7620d143e
9 changed files with 89 additions and 7 deletions

View File

@@ -39,6 +39,12 @@ public interface AdventureManager {
*/
void sendMessage(CommandSender sender, String msg);
/**
* Send a message with prefix
*
* @param sender command sender
* @param s message
*/
void sendMessageWithPrefix(CommandSender sender, String s);
/**

View File

@@ -29,6 +29,11 @@ import java.util.UUID;
public interface BagManager {
/**
* Is bag enabled
*
* @return enabled or not
*/
boolean isEnabled();
/**
@@ -39,6 +44,12 @@ public interface BagManager {
*/
Inventory getOnlineBagInventory(UUID uuid);
/**
* Get the rows of a player's fishing bag
*
* @param player player who owns the bag
* @return rows
*/
int getBagInventoryRows(Player player);
/**
@@ -49,15 +60,45 @@ public interface BagManager {
*/
void editOfflinePlayerBag(Player admin, OfflineUser userData);
/**
* Get the actions to perform when loot is automatically collected
*
* @return actions
*/
Action[] getCollectLootActions();
/**
* Get the actions to perform when bag is full
*
* @return actions
*/
Action[] getBagFullActions();
/**
* If bag can store fishing loots
*
* @return can store or not
*/
boolean doesBagStoreLoots();
/**
* Get the fishing bag's title
*
* @return title
*/
String getBagTitle();
/**
* Get a list of allowed items in bag
*
* @return whitelisted items
*/
List<Material> getBagWhiteListItems();
/**
* Get the requirements for automatically collecting loots
*
* @return requirements
*/
Requirement[] getCollectRequirements();
}

View File

@@ -134,6 +134,13 @@ public interface ItemManager {
@Nullable
BuildableItem getBuildableItem(String namespace, String value);
/**
* Get an itemStack's appearance (material + custom model data)
*
* @param player player
* @param material id
* @return appearance
*/
ItemStack getItemStackAppearance(Player player, String material);
/**

View File

@@ -38,6 +38,11 @@ public interface MarketManager {
*/
int getCachedDate();
/**
* Retrieves the current date as an integer in the format MMDD (e.g., September 21 as 0921).
*
* @return An integer representing the current date.
*/
int getDate();
/**

View File

@@ -62,6 +62,14 @@ public interface RequirementManager {
*/
@Nullable Requirement[] getRequirements(ConfigurationSection section, boolean advanced);
/**
* If a requirement type exists
*
* @param type type
* @return exists or not
*/
boolean hasRequirement(String type);
/**
* Retrieves a Requirement object based on a configuration section and advanced flag.
* <p>

View File

@@ -46,6 +46,11 @@ public interface StorageManager {
*/
@Nullable OnlineUser getOnlineUser(UUID uuid);
/**
* Get all the online users
*
* @return online users
*/
Collection<OnlineUser> getOnlineUsers();
/**

View File

@@ -7,7 +7,7 @@ plugins {
allprojects {
version = "2.1.0.2"
version = "2.1.0.3"
apply<JavaPlugin>()
apply(plugin = "java")

View File

@@ -280,6 +280,7 @@ public class RequirementManagerImpl implements RequirementManager {
return requirements.toArray(new Requirement[0]);
}
@Override
public boolean hasRequirement(String type) {
return requirementBuilderMap.containsKey(type);
}
@@ -1361,7 +1362,6 @@ public class RequirementManagerImpl implements RequirementManager {
* Loads requirement expansions from external JAR files located in the expansion folder.
* Each expansion JAR should contain classes that extends the RequirementExpansion class.
* Expansions are registered and used to create custom requirements.
* If an error occurs while loading or initializing an expansion, a warning message is logged.
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
private void loadExpansions() {

View File

@@ -20,12 +20,9 @@ package net.momirealms.customfishing.scheduler;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.util.LocationUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.util.Optional;
/**
* A scheduler implementation for "synchronous" tasks using Folia's RegionScheduler.
*/
@@ -45,7 +42,11 @@ public class FoliaSchedulerImpl implements SyncScheduler {
*/
@Override
public void runSyncTask(Runnable runnable, Location location) {
Bukkit.getRegionScheduler().execute(plugin, Optional.ofNullable(location).orElse(LocationUtils.getAnyLocationInstance()), runnable);
if (location == null) {
Bukkit.getGlobalRegionScheduler().execute(plugin, runnable);
} else {
Bukkit.getRegionScheduler().execute(plugin, location, runnable);
}
}
/**
@@ -59,6 +60,9 @@ public class FoliaSchedulerImpl implements SyncScheduler {
*/
@Override
public CancellableTask runTaskSyncTimer(Runnable runnable, Location location, long delay, long period) {
if (location == null) {
return new FoliaCancellableTask(Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, (scheduledTask -> runnable.run()), delay, period));
}
return new FoliaCancellableTask(Bukkit.getRegionScheduler().runAtFixedRate(plugin, location, (scheduledTask -> runnable.run()), delay, period));
}
@@ -73,7 +77,13 @@ public class FoliaSchedulerImpl implements SyncScheduler {
@Override
public CancellableTask runTaskSyncLater(Runnable runnable, Location location, long delay) {
if (delay == 0) {
return new FoliaSchedulerImpl.FoliaCancellableTask(Bukkit.getRegionScheduler().run(plugin, location, (scheduledTask -> runnable.run())));
if (location == null) {
return new FoliaCancellableTask(Bukkit.getGlobalRegionScheduler().run(plugin, (scheduledTask -> runnable.run())));
}
return new FoliaCancellableTask(Bukkit.getRegionScheduler().run(plugin, location, (scheduledTask -> runnable.run())));
}
if (location == null) {
return new FoliaCancellableTask(Bukkit.getGlobalRegionScheduler().runDelayed(plugin, (scheduledTask -> runnable.run()), delay));
}
return new FoliaCancellableTask(Bukkit.getRegionScheduler().runDelayed(plugin, location, (scheduledTask -> runnable.run()), delay));
}