mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-30 12:29:19 +00:00
prepare for mojmap
This commit is contained in:
@@ -42,40 +42,42 @@ public class CommandManagerImpl implements CommandManager {
|
||||
|
||||
public CommandManagerImpl(CustomFishingPluginImpl plugin) {
|
||||
this.plugin = plugin;
|
||||
if (!CommandAPI.isLoaded())
|
||||
CommandAPI.onLoad(new CommandAPIBukkitConfig(plugin).silentLogs(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
new CommandAPICommand("customfishing")
|
||||
.withAliases("cfishing")
|
||||
.withPermission("customfishing.admin")
|
||||
.withSubcommands(
|
||||
getReloadCommand(),
|
||||
getMarketCommand(),
|
||||
getAboutCommand(),
|
||||
GUIEditorCommand.INSTANCE.getEditorCommand(),
|
||||
DataCommand.INSTANCE.getDataCommand(),
|
||||
CompetitionCommand.INSTANCE.getCompetitionCommand(),
|
||||
ItemCommand.INSTANCE.getItemCommand(),
|
||||
DebugCommand.INSTANCE.getDebugCommand(),
|
||||
StatisticsCommand.INSTANCE.getStatisticsCommand()
|
||||
)
|
||||
.register();
|
||||
|
||||
if (plugin.getMarketManager().isEnable()) {
|
||||
new CommandAPICommand("sellfish")
|
||||
.withPermission("customfishing.sellfish")
|
||||
.executesPlayer((player, args) -> {
|
||||
if (plugin.getMarketManager().isEnable())
|
||||
plugin.getMarketManager().openMarketGUI(player);
|
||||
})
|
||||
if (!plugin.getVersionManager().isMojmap()) {
|
||||
if (!CommandAPI.isLoaded())
|
||||
CommandAPI.onLoad(new CommandAPIBukkitConfig(plugin).silentLogs(true));
|
||||
new CommandAPICommand("customfishing")
|
||||
.withAliases("cfishing")
|
||||
.withPermission("customfishing.admin")
|
||||
.withSubcommands(
|
||||
getReloadCommand(),
|
||||
getMarketCommand(),
|
||||
getAboutCommand(),
|
||||
GUIEditorCommand.INSTANCE.getEditorCommand(),
|
||||
DataCommand.INSTANCE.getDataCommand(),
|
||||
CompetitionCommand.INSTANCE.getCompetitionCommand(),
|
||||
ItemCommand.INSTANCE.getItemCommand(),
|
||||
DebugCommand.INSTANCE.getDebugCommand(),
|
||||
StatisticsCommand.INSTANCE.getStatisticsCommand()
|
||||
)
|
||||
.register();
|
||||
}
|
||||
|
||||
if (plugin.getBagManager().isEnabled()) {
|
||||
FishingBagCommand.INSTANCE.getBagCommand().register();
|
||||
if (plugin.getMarketManager().isEnable()) {
|
||||
new CommandAPICommand("sellfish")
|
||||
.withPermission("customfishing.sellfish")
|
||||
.executesPlayer((player, args) -> {
|
||||
if (plugin.getMarketManager().isEnable())
|
||||
plugin.getMarketManager().openMarketGUI(player);
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
if (plugin.getBagManager().isEnabled()) {
|
||||
FishingBagCommand.INSTANCE.getBagCommand().register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SchedulerImpl implements Scheduler {
|
||||
|
||||
public SchedulerImpl(CustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.syncScheduler = plugin.getVersionManager().isFolia() ?
|
||||
this.syncScheduler = plugin.getVersionManager().hasRegionScheduler() ?
|
||||
new FoliaSchedulerImpl(plugin) : new BukkitSchedulerImpl(plugin);
|
||||
this.schedule = new ScheduledThreadPoolExecutor(1);
|
||||
this.schedule.setMaximumPoolSize(1);
|
||||
|
||||
@@ -39,7 +39,8 @@ public class VersionManagerImpl implements VersionManager {
|
||||
private final String serverVersion;
|
||||
private final CustomFishingPluginImpl plugin;
|
||||
private final boolean isSpigot;
|
||||
private boolean isFolia;
|
||||
private boolean hasRegionScheduler;
|
||||
private boolean isMojmap;
|
||||
private final String pluginVersion;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -73,7 +74,15 @@ public class VersionManagerImpl implements VersionManager {
|
||||
// Check if the server is Folia
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.scheduler.AsyncScheduler");
|
||||
this.isFolia = true;
|
||||
this.hasRegionScheduler = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
}
|
||||
|
||||
// Check if the server is Mojmap
|
||||
try {
|
||||
Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket");
|
||||
this.isMojmap = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
}
|
||||
@@ -109,8 +118,13 @@ public class VersionManagerImpl implements VersionManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFolia() {
|
||||
return isFolia;
|
||||
public boolean hasRegionScheduler() {
|
||||
return hasRegionScheduler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMojmap() {
|
||||
return isMojmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user