9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-31 21:06:47 +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

@@ -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));
}