diff --git a/src/main/java/space/yurisi/universecorev2/menu/MainMenu.java b/src/main/java/space/yurisi/universecorev2/menu/MainMenu.java index eb2ce9d6..4f7e52da 100644 --- a/src/main/java/space/yurisi/universecorev2/menu/MainMenu.java +++ b/src/main/java/space/yurisi/universecorev2/menu/MainMenu.java @@ -14,6 +14,7 @@ import space.yurisi.universecorev2.exception.CustomNameNotFoundException; import space.yurisi.universecorev2.exception.MoneyNotFoundException; import space.yurisi.universecorev2.exception.UserNotFoundException; +import space.yurisi.universecorev2.menu.menu_item.main_menu.LaunchNavigationItem; import space.yurisi.universecorev2.subplugins.universeeconomy.UniverseEconomyAPI; import space.yurisi.universecorev2.utils.Message; import space.yurisi.universecorev2.utils.TimeHelper; @@ -50,18 +51,6 @@ public void sendMenu(Player player) { .setDisplayName("ガチャ") .setLegacyLore(List.of("§6ガチャを引くことができます")), "/gacha"); - Item executeWiki = new CommandItem(new ItemBuilder(Material.MAP) - .setDisplayName("Wiki") - .setLegacyLore(List.of("§6公式WikiへのURLを表示します")), - "/wiki"); - Item executeWeb = new CommandItem(new ItemBuilder(Material.RECOVERY_COMPASS) - .setDisplayName("UniverseWeb") - .setLegacyLore(List.of("§6ランキングなどのオンラインサービスである UniverseWeb へのURLを表示します")), - "/web"); - // TODO: Add execute /money command - Item executeMoney = new SimpleItem(new ItemBuilder(Material.GOLD_INGOT) - .setDisplayName("銀行 (未実装)") - .setLegacyLore(List.of("§6お金を管理します"))); Item executeTrash = new CommandItem(new ItemBuilder(Material.LAVA_BUCKET) .setDisplayName("ゴミ箱") .setLegacyLore(List.of("§6ゴミ箱を開きます。取り扱い注意!")), @@ -74,13 +63,17 @@ public void sendMenu(Player player) { .setDisplayName("プレイヤーヘッド") .setLegacyLore(List.of("§6他のプレイヤーのヘッドを購入します")), "/head"); + Item executeAmmo = new CommandItem(new ItemBuilder(Material.IRON_NUGGET) + .setDisplayName("弾薬") + .setLegacyLore(List.of("§6弾薬を購入・クラフトします")), + "/ammo"); Gui gui = Gui.normal() .setStructure( - "= # # # i # # # #", - "# + a m t g y + #", - "# + w u n s h + #", - "# # # # # # # # #" + "# # # i # = # # #", + "# + a m t o y + #", + "# + + n s h + + #", + "# # # # l # # # #" ) .addIngredient('#', border) .addIngredient('+', inMenuBorder) @@ -89,16 +82,15 @@ public void sendMenu(Player player) { .addIngredient('a', executeGacha) .addIngredient('m', executeMywarp) .addIngredient('t', executeTpp) - .addIngredient('g', executeMoney) .addIngredient('y', executeMarket) - .addIngredient('w', executeWiki) - .addIngredient('u', executeWeb) .addIngredient('n', executeTag) .addIngredient('s', executeTrash) .addIngredient('h', executeHead) + .addIngredient('o', executeAmmo) + .addIngredient('l', new LaunchNavigationItem()) .build(); - xyz.xenondevs.invui.window.Window window = Window.single() + Window window = Window.single() .setViewer(player) .setGui(gui) .setTitle("メインメニュー") @@ -141,9 +133,12 @@ private Item createPlayerInfoHead(Player player) { } String greetingWithName = switch (TimeHelper.checkTime()) { + case LATE_NIGHT -> "§e遅くまでお疲れ様です、 §r" + player.getName(); + case EARLY_MORNING -> "§f朝早くからお疲れ様です、 §r" + player.getName(); case MORNING -> "§bおはようございます、 §r" + player.getName(); - case AFTERNOON -> "§6こんにちは、 §r" + player.getName(); - case EVENING -> "§9こんばんは、 §r" + player.getName(); + case AFTERNOON -> "§aこんにちは、 §r" + player.getName(); + case EVENING -> "§6夜ご飯は何を食べるんですか? §r" + player.getName(); + case NIGHT -> "§9こんばんは、 §r" + player.getName(); }; List playerinfo = List.of( diff --git a/src/main/java/space/yurisi/universecorev2/menu/menu_item/main_menu/LaunchNavigationItem.java b/src/main/java/space/yurisi/universecorev2/menu/menu_item/main_menu/LaunchNavigationItem.java new file mode 100644 index 00000000..14ebd7a7 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/menu/menu_item/main_menu/LaunchNavigationItem.java @@ -0,0 +1,33 @@ +package space.yurisi.universecorev2.menu.menu_item.main_menu; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.menu.MainMenu; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.AbstractItem; + +import java.util.List; + +public class LaunchNavigationItem extends AbstractItem { + + @Override + public ItemProvider getItemProvider() { + return new ItemBuilder(Material.MAP) + .setDisplayName("関連リンク") + .setLegacyLore(List.of("§6関連リンクを表示します")); + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { + Bukkit.getServer().dispatchCommand(player, "web"); + Bukkit.getServer().dispatchCommand(player, "wiki"); + Bukkit.getServer().dispatchCommand(player, "discord"); + // メニューを閉じる + player.closeInventory(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/UniverseGuns.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/UniverseGuns.java index eae74866..df9bdaa1 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/UniverseGuns.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/UniverseGuns.java @@ -4,6 +4,7 @@ import space.yurisi.universecorev2.UniverseCoreV2API; import space.yurisi.universecorev2.database.DatabaseManager; import space.yurisi.universecorev2.subplugins.SubPlugin; +import space.yurisi.universecorev2.subplugins.universeguns.core.GunCommand; import space.yurisi.universecorev2.subplugins.universeguns.event.GunEvent; import space.yurisi.universecorev2.subplugins.universeguns.connector.UniverseCoreAPIConnector; @@ -16,6 +17,7 @@ public void onEnable(UniverseCoreV2 core) { DatabaseManager manager = UniverseCoreV2API.getInstance().getDatabaseManager(); this.connector = new UniverseCoreAPIConnector(manager); core.getServer().getPluginManager().registerEvents(new GunEvent(core, connector), core); + core.getCommand("ammo").setExecutor(new GunCommand(connector)); } public void onDisable() { @@ -31,4 +33,4 @@ public String getName() { public String getVersion() { return "1.0.1"; } -} \ No newline at end of file +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/GunCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/GunCommand.java new file mode 100644 index 00000000..4f23c5fd --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/GunCommand.java @@ -0,0 +1,32 @@ +package space.yurisi.universecorev2.subplugins.universeguns.core; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.subplugins.universeguns.connector.UniverseCoreAPIConnector; +import space.yurisi.universecorev2.subplugins.universeguns.menu.AmmoManagerInventoryMenu; +import space.yurisi.universecorev2.utils.Message; + +public class GunCommand implements CommandExecutor { + + private final UniverseCoreAPIConnector connector; + + public GunCommand(UniverseCoreAPIConnector connector) { + this.connector = connector; + } + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { + if (!(sender instanceof Player player)) { + return false; + } + + AmmoManagerInventoryMenu ammoManagerInventoryMenu = new AmmoManagerInventoryMenu(connector); + ammoManagerInventoryMenu.sendMenu(player); + + Message.sendSuccessMessage(player, "[武器AI]", "弾薬管理メニューを開きました"); + return true; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/utils/TimeHelper.java b/src/main/java/space/yurisi/universecorev2/utils/TimeHelper.java index b7d561b7..4a647cf4 100644 --- a/src/main/java/space/yurisi/universecorev2/utils/TimeHelper.java +++ b/src/main/java/space/yurisi/universecorev2/utils/TimeHelper.java @@ -6,19 +6,25 @@ public class TimeHelper { /** - * 現在時刻をチェックし、その時間帯を返します。 + * 現在時間をチェックし、その時間帯を表すTimeType列挙型を返します。 * - * @return TimeType 時間帯 -- MORNING: 朝, AFTERNOON: 昼, EVENING: 夜 + * @return TimeType 時間帯 */ public static TimeType checkTime() { LocalTime now = LocalTime.now(); - if (now.isBefore(LocalTime.NOON)) { + if (now.isBefore(LocalTime.of(5, 0))) { + return TimeType.LATE_NIGHT; + } else if (now.isBefore(LocalTime.of(8, 0))) { + return TimeType.EARLY_MORNING; + } else if (now.isBefore(LocalTime.of(10, 0))) { return TimeType.MORNING; - } else if (now.isBefore(LocalTime.of(18, 0))) { + } else if (now.isBefore(LocalTime.of(16, 0))) { return TimeType.AFTERNOON; - } else { + } else if (now.isBefore(LocalTime.of(20, 0))) { return TimeType.EVENING; + } else { + return TimeType.NIGHT; } } diff --git a/src/main/java/space/yurisi/universecorev2/utils/time_type/TimeType.java b/src/main/java/space/yurisi/universecorev2/utils/time_type/TimeType.java index 730d0c37..bbcdea7c 100644 --- a/src/main/java/space/yurisi/universecorev2/utils/time_type/TimeType.java +++ b/src/main/java/space/yurisi/universecorev2/utils/time_type/TimeType.java @@ -1,7 +1,10 @@ package space.yurisi.universecorev2.utils.time_type; public enum TimeType { + LATE_NIGHT, + EARLY_MORNING, MORNING, AFTERNOON, - EVENING + EVENING, + NIGHT } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 44698b6e..fdb6a45c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -96,6 +96,10 @@ commands: unlock: description: コンテナ等の保護を解除します + ## UniverseGuns + ammo: + description: 弾薬管理メニューを開く + ## PlayerHead head: description: プレイヤーヘッドを購入します(WIP)