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-01-08 04:49:31 +08:00
parent 795f2b6daf
commit 19d5e0246c
5 changed files with 38 additions and 12 deletions

View File

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

View File

@@ -114,7 +114,7 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
if (CFConfig.updateChecker)
this.versionManager.checkUpdate().thenAccept(result -> {
if (!result) this.getAdventure().sendConsoleMessage("[CustomFishing] You are using the latest version.");
else this.getAdventure().sendConsoleMessage("[CustomFishing] Update is available: <u>https://polymart.org/resource/customfishing.2723<!u>");
else this.getAdventure().sendConsoleMessage("[CustomFishing] Update is available: <u>https://polymart.org/resource/2723<!u>");
});
}

View File

@@ -21,6 +21,7 @@ import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIBukkitConfig;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.arguments.EntitySelectorArgument;
import dev.jorel.commandapi.arguments.UUIDArgument;
import net.momirealms.customfishing.CustomFishingPluginImpl;
import net.momirealms.customfishing.adventure.AdventureManagerImpl;
import net.momirealms.customfishing.api.CustomFishingPlugin;
@@ -28,10 +29,12 @@ import net.momirealms.customfishing.api.manager.CommandManager;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.command.sub.*;
import net.momirealms.customfishing.setting.CFLocale;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.Collection;
import java.util.UUID;
public class CommandManagerImpl implements CommandManager {
@@ -39,7 +42,8 @@ public class CommandManagerImpl implements CommandManager {
public CommandManagerImpl(CustomFishingPluginImpl plugin) {
this.plugin = plugin;
CommandAPI.onLoad(new CommandAPIBukkitConfig(plugin).silentLogs(true));
if (!CommandAPI.isLoaded())
CommandAPI.onLoad(new CommandAPIBukkitConfig(plugin).silentLogs(true));
}
@Override
@@ -92,7 +96,7 @@ public class CommandManagerImpl implements CommandManager {
private CommandAPICommand getMarketCommand() {
CommandAPICommand command = new CommandAPICommand("open");
if (plugin.getMarketManager().isEnable()) {
command.withSubcommand(
command.withSubcommands(
new CommandAPICommand("market")
.withArguments(new EntitySelectorArgument.ManyPlayers("player"))
.executes((sender, args) -> {
@@ -102,10 +106,20 @@ public class CommandManagerImpl implements CommandManager {
plugin.getMarketManager().openMarketGUI(player);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Market_GUI_Open.replace("{player}", player.getName()));
}
}));
}),
new CommandAPICommand("market-uuid")
.withArguments(new UUIDArgument("uuid"))
.executes((sender, args) -> {
UUID uuid = (UUID) args.get("uuid");
Player player = Bukkit.getPlayer(uuid);
if (player == null) return;
plugin.getMarketManager().openMarketGUI(player);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Market_GUI_Open.replace("{player}", player.getName()));
})
);
}
if (plugin.getBagManager().isEnabled()) {
command.withSubcommand(
command.withSubcommands(
new CommandAPICommand("bag")
.withArguments(new EntitySelectorArgument.ManyPlayers("player"))
.executes((sender, args) -> {
@@ -120,7 +134,22 @@ public class CommandManagerImpl implements CommandManager {
LogUtils.warn("Player " + player.getName() + "'s bag data has not been loaded.");
}
}
}));
}),
new CommandAPICommand("bag-uuid")
.withArguments(new UUIDArgument("uuid"))
.executes((sender, args) -> {
UUID uuid = (UUID) args.get("uuid");
Player player = Bukkit.getPlayer(uuid);
if (player == null) return;
Inventory inventory = plugin.getBagManager().getOnlineBagInventory(uuid);
if (inventory != null) {
player.openInventory(inventory);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Fishing_Bag_Open.replace("{player}", player.getName()));
} else {
LogUtils.warn("Player " + player.getName() + "'s bag data has not been loaded.");
}
})
);
}
return command;
}

View File

@@ -42,7 +42,7 @@ public class NextPageItem extends PageItem implements Icon {
.addLoreLines(new ShadedAdventureComponentWrapper(AdventureManagerImpl.getInstance().getComponentFromMiniMessage(
gui.hasNextPage()
? CFLocale.GUI_GOTO_NEXT_PAGE
.replace("{0}", String.valueOf(gui.getCurrentPage()))
.replace("{0}", String.valueOf(gui.getCurrentPage() + 2))
.replace("{1}", String.valueOf(gui.getPageAmount()))
: CFLocale.GUI_CANNOT_GOTO_NEXT_PAGE
)));

View File

@@ -24,10 +24,7 @@ import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.setting.CFConfig;
import org.bukkit.Location;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
/**
* A scheduler implementation responsible for scheduling and managing tasks in a multi-threaded environment.