From 40f4b9b9ba5443828950e93f67a0950458d78d09 Mon Sep 17 00:00:00 2001 From: syoyu Date: Thu, 24 Oct 2024 21:10:13 +0900 Subject: [PATCH 01/36] achievement --- .../subplugins/SubPluginInitializer.java | 2 ++ .../subplugins/achievement/Achievement.java | 28 +++++++++++++++++ .../command/AchievementCommand.java | 21 +++++++++++++ .../achievement/menu/AchievementMenu.java | 30 +++++++++++++++++++ src/main/resources/plugin.yml | 3 ++ 5 files changed, 84 insertions(+) create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/command/AchievementCommand.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/SubPluginInitializer.java b/src/main/java/space/yurisi/universecorev2/subplugins/SubPluginInitializer.java index e56978f7..f59daa3b 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/SubPluginInitializer.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/SubPluginInitializer.java @@ -2,6 +2,7 @@ import org.bukkit.Bukkit; import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.subplugins.achievement.Achievement; import space.yurisi.universecorev2.subplugins.autocollect.AutoCollect; import space.yurisi.universecorev2.subplugins.birthdaycard.BirthdayCard; import space.yurisi.universecorev2.subplugins.blockcopystick.BlockCopyStick; @@ -86,6 +87,7 @@ private void registerPlugin() { this.subPlugins.add(new Elevator()); this.subPlugins.add(new BirthdayCard()); this.subPlugins.add(new AutoCollect()); + this.subPlugins.add(new Achievement()); } public void onEnable() { diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java new file mode 100644 index 00000000..86a90b00 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java @@ -0,0 +1,28 @@ +package space.yurisi.universecorev2.subplugins.achievement; + +import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.subplugins.SubPlugin; +import space.yurisi.universecorev2.subplugins.achievement.command.AchievementCommand; + +public final class Achievement implements SubPlugin { + + @Override + public void onEnable(UniverseCoreV2 core) { + core.getCommand("achievement").setExecutor(new AchievementCommand()); + } + + @Override + public void onDisable() { + //NOOP + } + + @Override + public String getName() { + return "Achievement"; + } + + @Override + public String getVersion() { + return "1.0.0"; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/command/AchievementCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/command/AchievementCommand.java new file mode 100644 index 00000000..62ac3f8e --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/command/AchievementCommand.java @@ -0,0 +1,21 @@ +package space.yurisi.universecorev2.subplugins.achievement.command; + +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.achievement.menu.AchievementMenu; + +public class AchievementCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { + if (commandSender instanceof Player player) { + AchievementMenu menu = new AchievementMenu(); + menu.sendMenu(player); + return true; + } + return false; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java new file mode 100644 index 00000000..a0a8a4a4 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -0,0 +1,30 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu; + +import org.bukkit.entity.Player; +import space.yurisi.universecorev2.menu.BaseMenu; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.gui.PagedGui; +import xyz.xenondevs.invui.gui.structure.Markers; +import xyz.xenondevs.invui.window.Window; + +public class AchievementMenu implements BaseMenu { + + @Override + public void sendMenu(Player player) { + Gui gui = PagedGui.items() + .setStructure( + "x x x x x x x x x", + "x x x x x x x x x", + "x x x x x x x x x") + .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) + .build(); + + Window window = Window.single() + .setViewer(player) + .setGui(gui) + .setTitle("Achievement") + .build(); + + window.open(); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 931bc8d5..3124d52b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -135,3 +135,6 @@ commands: birthday: description: お誕生日カードメニューを開きます + # Achievement + achievement: + description: 実績メニューを開きます \ No newline at end of file From 50683ed9d28505414af8f55f1b0a034be4eb7978 Mon Sep 17 00:00:00 2001 From: syoyu Date: Fri, 25 Oct 2024 00:16:15 +0900 Subject: [PATCH 02/36] =?UTF-8?q?=E8=8A=B1=E3=81=AE=E5=AE=9F=E7=B8=BE?= =?UTF-8?q?=E3=81=A0=E3=81=91=E4=BD=9C=E3=81=A3=E3=81=9F=EF=BC=88NewSpaceS?= =?UTF-8?q?erver=E3=81=A8=E3=81=BE=E3=81=A3=E3=81=9F=E3=81=8F=E4=B8=80?= =?UTF-8?q?=E7=B7=92=E3=81=AE=E3=82=84=E3=81=A4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/achievement/Achievement.java | 2 + .../achievement/data/AchievementData.java | 34 ++++++++++ .../data/AchievementDataManager.java | 65 +++++++++++++++++++ .../data/config/AchievementConfig.java | 40 ++++++++++++ .../achievement/menu/AchievementMenu.java | 11 ++++ .../menu/item/AchievementItem.java | 53 +++++++++++++++ .../subplugins/rankcounter/RankCounter.java | 2 + src/main/resources/subplugins/achievement.yml | 8 +++ 8 files changed, 215 insertions(+) create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java create mode 100644 src/main/resources/subplugins/achievement.yml diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java index 86a90b00..b24dde4f 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/Achievement.java @@ -3,11 +3,13 @@ import space.yurisi.universecorev2.UniverseCoreV2; import space.yurisi.universecorev2.subplugins.SubPlugin; import space.yurisi.universecorev2.subplugins.achievement.command.AchievementCommand; +import space.yurisi.universecorev2.subplugins.achievement.data.config.AchievementConfig; public final class Achievement implements SubPlugin { @Override public void onEnable(UniverseCoreV2 core) { + new AchievementConfig(core); core.getCommand("achievement").setExecutor(new AchievementCommand()); } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java new file mode 100644 index 00000000..097ba52a --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java @@ -0,0 +1,34 @@ +package space.yurisi.universecorev2.subplugins.achievement.data; + +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; + +public final class AchievementData { + + private final String stage; + private final String itemName; + private final ArrayList itemLore; + + private AchievementData(@NotNull String stage, @NotNull String itemName, @NotNull ArrayList itemLore){ + this.stage = stage; + this.itemName = itemName; + this.itemLore = itemLore; + } + + public static AchievementData createData(@NotNull String stage, @NotNull String ItemName, @NotNull ArrayList ItemLore){ + return new AchievementData(stage, ItemName, ItemLore); + } + + public String getStage() { + return stage; + } + + public String getItemName() { + return itemName; + } + + public ArrayList getItemLore() { + return itemLore; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java new file mode 100644 index 00000000..658c2d72 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -0,0 +1,65 @@ +package space.yurisi.universecorev2.subplugins.achievement.data; + +import org.bukkit.entity.Player; +import space.yurisi.universecorev2.UniverseCoreV2API; +import space.yurisi.universecorev2.database.models.User; +import space.yurisi.universecorev2.database.models.count.LifeCount; +import space.yurisi.universecorev2.database.repositories.count.CountRepository; +import space.yurisi.universecorev2.database.repositories.count.LifeCountRepository; +import space.yurisi.universecorev2.exception.CountNotFoundException; +import space.yurisi.universecorev2.exception.LifeCountNotFoundException; +import space.yurisi.universecorev2.exception.UserNotFoundException; +import space.yurisi.universecorev2.subplugins.achievement.data.config.AchievementConfig; +import space.yurisi.universecorev2.subplugins.rankcounter.manager.CounterModelManager; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class AchievementDataManager { + + public static final String Achievement_NORMAL = "normal"; + public static final String Achievement_SILVER = "silver"; + public static final String Achievement_GOLD = "gold"; + public static final String Name_GOLD = "§e"; + public static final String Name_SILVER = "§b"; + public static final String Name_NORMAL = "§f"; + + public static CounterModelManager manager = null; + + public static void setManager(CounterModelManager manager) { + AchievementDataManager.manager = manager; + } + + @Nullable + public static AchievementData getFlower(Player player) { + if(manager == null) return null; + LifeCount lifeCount = manager.get(player).getLifeCount(); + Long place = lifeCount.getFlower_place(); + List flower = AchievementConfig.getInstance().getFlower(); + Long goal; + String stage; + String Color; + if(place > flower.getLast()) { + goal = flower.getLast(); + stage = Achievement_GOLD; + Color = Name_GOLD; + }else if (place > flower.getFirst()) { + goal = flower.getLast(); + stage = Achievement_SILVER; + Color = Name_SILVER; + }else{ + goal = flower.getFirst(); + stage = Achievement_NORMAL; + Color = Name_NORMAL; + } + + return AchievementData.createData( + stage, + Color + "花を植えた数", + new ArrayList<>(List.of( + place + "/" + goal + )) + ); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java new file mode 100644 index 00000000..0d67b397 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java @@ -0,0 +1,40 @@ +package space.yurisi.universecorev2.subplugins.achievement.data.config; + +import org.bukkit.configuration.file.FileConfiguration; +import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.utils.ConfigReader; + +import java.util.List; + +public class AchievementConfig { + + private final UniverseCoreV2 core; + private static AchievementConfig instance; + + private FileConfiguration config = null; + + public AchievementConfig (UniverseCoreV2 core){ + this.core = core; + init(); + instance = this; + } + + public static AchievementConfig getInstance() { + return instance; + } + + private void init(){ + ConfigReader configReader = new ConfigReader(this.core, "subplugins/", "achievement.yml"); + configReader.saveDefaultConfig(); + if (this.config != null) { + configReader.reloadConfig(); + } + this.config = configReader.getConfig(); + } + + public List getFlower(){ + List flower = this.config.getLongList("flower"); + return List.of(flower.getFirst(), flower.getLast()); + } +} + diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index a0a8a4a4..14d76f91 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -2,21 +2,32 @@ import org.bukkit.entity.Player; import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; +import space.yurisi.universecorev2.subplugins.achievement.menu.item.AchievementItem; import xyz.xenondevs.invui.gui.Gui; import xyz.xenondevs.invui.gui.PagedGui; import xyz.xenondevs.invui.gui.structure.Markers; +import xyz.xenondevs.invui.item.Item; import xyz.xenondevs.invui.window.Window; +import java.util.List; + public class AchievementMenu implements BaseMenu { @Override public void sendMenu(Player player) { + List items = new java.util.ArrayList<>(List.of()); + if(AchievementDataManager.getFlower(player) != null) { + items.add(new AchievementItem(AchievementDataManager.getFlower(player))); + } + Gui gui = PagedGui.items() .setStructure( "x x x x x x x x x", "x x x x x x x x x", "x x x x x x x x x") .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) + .setContent(items) .build(); Window window = Window.single() diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java new file mode 100644 index 00000000..2bb86c8a --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java @@ -0,0 +1,53 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu.item; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.subplugins.achievement.data.AchievementData; +import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; +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 AchievementItem extends AbstractItem { + + private final AchievementData data; + + public AchievementItem(AchievementData data){ + this.data = data; + } + + @Override + public ItemProvider getItemProvider() { + Material material; + switch (data.getStage()){ + case AchievementDataManager.Achievement_GOLD: + material = Material.YELLOW_STAINED_GLASS_PANE; + break; + case AchievementDataManager.Achievement_SILVER: + material = Material.WHITE_STAINED_GLASS_PANE; + break; + case AchievementDataManager.Achievement_NORMAL: + material = Material.GLASS_PANE; + break; + default: + return new ItemBuilder(Material.RED_STAINED_GLASS_PANE); + } + ItemBuilder builder = new ItemBuilder(material) + .setDisplayName(data.getItemName()); + for(String lore: data.getItemLore()){ + builder.addLoreLines(lore); + } + return builder; + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { + + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/RankCounter.java b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/RankCounter.java index a4991aca..47b17c56 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/RankCounter.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/RankCounter.java @@ -2,6 +2,7 @@ import org.bukkit.plugin.java.JavaPlugin; import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; import space.yurisi.universecorev2.subplugins.rankcounter.manager.CounterModelManager; import space.yurisi.universecorev2.subplugins.rankcounter.manager.EventManager; import space.yurisi.universecorev2.subplugins.SubPlugin; @@ -13,6 +14,7 @@ public final class RankCounter implements SubPlugin { public void onEnable(UniverseCoreV2 core) { this.counterManager = new CounterModelManager(); new EventManager(core, getCounterManager()); + AchievementDataManager.setManager(getCounterManager()); } public CounterModelManager getCounterManager() { diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml new file mode 100644 index 00000000..5ce42931 --- /dev/null +++ b/src/main/resources/subplugins/achievement.yml @@ -0,0 +1,8 @@ +# コンフィグの書き方 +# achievement: +# - Long [Normal] +# - Long [Gold] + +flower: + - 25 + - 100 \ No newline at end of file From d0e72c9e84ff779e8bd4c5454105e1fefbec2da0 Mon Sep 17 00:00:00 2001 From: syoyu Date: Fri, 25 Oct 2024 00:17:28 +0900 Subject: [PATCH 03/36] =?UTF-8?q?=E3=82=AD=E3=83=81=E3=82=B2=E8=A7=A3?= =?UTF-8?q?=E6=94=BE=E3=82=AD=E3=83=A3=E3=83=B3=E3=83=9A=E3=83=BC=E3=83=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/subplugins/achievement.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml index 5ce42931..c1a0845b 100644 --- a/src/main/resources/subplugins/achievement.yml +++ b/src/main/resources/subplugins/achievement.yml @@ -1,7 +1,7 @@ # コンフィグの書き方 # achievement: -# - Long [Normal] -# - Long [Gold] +# - Normal [Long] +# - Gold [Long] flower: - 25 From f92c6ac4c45a3742ac1d02ee92c14dba5e757de4 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 00:44:22 +0900 Subject: [PATCH 04/36] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=88=86=E5=B2=90?= =?UTF-8?q?=E3=81=AE=E4=B8=AD=E3=81=AE=E8=A9=95=E4=BE=A1=E3=83=9F=E3=82=B9?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/AchievementDataManager.java | 51 ++++++++++++++----- .../data/config/AchievementConfig.java | 5 ++ .../achievement/menu/AchievementMenu.java | 5 +- .../menu/item/AchievementItem.java | 3 -- src/main/resources/subplugins/achievement.yml | 4 ++ 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java index 658c2d72..08990c8d 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -1,14 +1,7 @@ package space.yurisi.universecorev2.subplugins.achievement.data; import org.bukkit.entity.Player; -import space.yurisi.universecorev2.UniverseCoreV2API; -import space.yurisi.universecorev2.database.models.User; import space.yurisi.universecorev2.database.models.count.LifeCount; -import space.yurisi.universecorev2.database.repositories.count.CountRepository; -import space.yurisi.universecorev2.database.repositories.count.LifeCountRepository; -import space.yurisi.universecorev2.exception.CountNotFoundException; -import space.yurisi.universecorev2.exception.LifeCountNotFoundException; -import space.yurisi.universecorev2.exception.UserNotFoundException; import space.yurisi.universecorev2.subplugins.achievement.data.config.AchievementConfig; import space.yurisi.universecorev2.subplugins.rankcounter.manager.CounterModelManager; @@ -39,27 +32,57 @@ public static AchievementData getFlower(Player player) { List flower = AchievementConfig.getInstance().getFlower(); Long goal; String stage; - String Color; - if(place > flower.getLast()) { + String color; + if(place >= flower.getLast()) { goal = flower.getLast(); stage = Achievement_GOLD; - Color = Name_GOLD; - }else if (place > flower.getFirst()) { + color = Name_GOLD; + }else if (place >= flower.getFirst()) { goal = flower.getLast(); stage = Achievement_SILVER; - Color = Name_SILVER; + color = Name_SILVER; }else{ goal = flower.getFirst(); stage = Achievement_NORMAL; - Color = Name_NORMAL; + color = Name_NORMAL; } return AchievementData.createData( stage, - Color + "花を植えた数", + color + "花を植えた数", new ArrayList<>(List.of( place + "/" + goal )) ); } + + public static AchievementData getBreak(Player player) { + if(manager == null) return null; + LifeCount lifeCount = manager.get(player).getLifeCount(); + Long breakCount = lifeCount.getBlock_break(); + List blockBreak = AchievementConfig.getInstance().getBreak(); + Long goal; + String stage; + String color; + if(breakCount >= blockBreak.getLast()) { + goal = blockBreak.getLast(); + stage = Achievement_GOLD; + color = Name_GOLD; + }else if (breakCount >= blockBreak.getFirst()) { + goal = blockBreak.getLast(); + stage = Achievement_SILVER; + color = Name_SILVER; + }else{ + goal = blockBreak.getFirst(); + stage = Achievement_NORMAL; + color = Name_NORMAL; + } + return AchievementData.createData( + stage, + color+"ブロック破壊数", + new ArrayList<>(List.of( + breakCount+"/"+goal + )) + ); + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java index 0d67b397..f490d33c 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java @@ -36,5 +36,10 @@ public List getFlower(){ List flower = this.config.getLongList("flower"); return List.of(flower.getFirst(), flower.getLast()); } + + public List getBreak(){ + List breakCount = this.config.getLongList("break"); + return List.of(breakCount.getFirst(), breakCount.getLast()); + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index 14d76f91..e7a8d545 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -17,9 +17,8 @@ public class AchievementMenu implements BaseMenu { @Override public void sendMenu(Player player) { List items = new java.util.ArrayList<>(List.of()); - if(AchievementDataManager.getFlower(player) != null) { - items.add(new AchievementItem(AchievementDataManager.getFlower(player))); - } + if(AchievementDataManager.getBreak(player) != null) {items.add(new AchievementItem(AchievementDataManager.getBreak(player)));} + if(AchievementDataManager.getFlower(player) != null) {items.add(new AchievementItem(AchievementDataManager.getFlower(player)));} Gui gui = PagedGui.items() .setStructure( diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java index 2bb86c8a..5d3d0003 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import space.yurisi.universecorev2.subplugins.achievement.data.AchievementData; import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; @@ -12,8 +11,6 @@ import xyz.xenondevs.invui.item.builder.ItemBuilder; import xyz.xenondevs.invui.item.impl.AbstractItem; -import java.util.List; - public class AchievementItem extends AbstractItem { private final AchievementData data; diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml index c1a0845b..2da2545a 100644 --- a/src/main/resources/subplugins/achievement.yml +++ b/src/main/resources/subplugins/achievement.yml @@ -3,6 +3,10 @@ # - Normal [Long] # - Gold [Long] +break: + - 100000 + - 1000000 + flower: - 25 - 100 \ No newline at end of file From 30753292ded05bf2fc04d1096479a73ceabae473 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 02:03:29 +0900 Subject: [PATCH 05/36] =?UTF-8?q?AchievementDataManager=E3=81=AE=E4=B8=AD?= =?UTF-8?q?=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AB=E3=81=84=E3=81=A1=E3=81=84?= =?UTF-8?q?=E3=81=A1=E3=81=AA=E3=81=A3=E3=81=8C=E3=81=9F=E3=82=89=E3=81=97?= =?UTF-8?q?=E3=81=84=E6=9D=A1=E4=BB=B6=E5=88=86=E5=B2=90=E3=82=92=E6=9B=B8?= =?UTF-8?q?=E3=81=8F=E3=81=AE=E3=81=AF=E3=81=8D=E3=82=82=E9=81=8E=E3=81=8E?= =?UTF-8?q?=E3=82=8B=EF=BC=81=EF=BC=81=EF=BC=81=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achievement/data/AchievementData.java | 5 +- .../data/AchievementDataManager.java | 78 ++++++++++--------- .../achievement/data/AchievementStatus.java | 38 +++++++++ .../data/config/AchievementConfig.java | 5 ++ .../achievement/menu/AchievementMenu.java | 13 +++- src/main/resources/subplugins/achievement.yml | 6 +- 6 files changed, 103 insertions(+), 42 deletions(-) create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementStatus.java diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java index 097ba52a..2ee6a0a4 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java @@ -16,18 +16,21 @@ private AchievementData(@NotNull String stage, @NotNull String itemName, @NotNul this.itemLore = itemLore; } - public static AchievementData createData(@NotNull String stage, @NotNull String ItemName, @NotNull ArrayList ItemLore){ + public static AchievementData create(@NotNull String stage, @NotNull String ItemName, @NotNull ArrayList ItemLore){ return new AchievementData(stage, ItemName, ItemLore); } + @NotNull public String getStage() { return stage; } + @NotNull public String getItemName() { return itemName; } + @NotNull public ArrayList getItemLore() { return itemLore; } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java index 08990c8d..7244232c 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -24,64 +24,70 @@ public static void setManager(CounterModelManager manager) { AchievementDataManager.manager = manager; } - @Nullable - public static AchievementData getFlower(Player player) { - if(manager == null) return null; - LifeCount lifeCount = manager.get(player).getLifeCount(); - Long place = lifeCount.getFlower_place(); - List flower = AchievementConfig.getInstance().getFlower(); - Long goal; + private static AchievementStatus getStatus(Long now, List conf){ String stage; String color; - if(place >= flower.getLast()) { - goal = flower.getLast(); + if(now >= conf.getLast()){ stage = Achievement_GOLD; color = Name_GOLD; - }else if (place >= flower.getFirst()) { - goal = flower.getLast(); + }else if(now >= conf.getFirst()){ stage = Achievement_SILVER; color = Name_SILVER; }else{ - goal = flower.getFirst(); stage = Achievement_NORMAL; color = Name_NORMAL; } - - return AchievementData.createData( + return AchievementStatus.create( + now >= conf.getLast(), + (now >= conf.getFirst() ? conf.getLast():conf.getFirst()), stage, - color + "花を植えた数", + color + ); + } + + @Nullable + public static AchievementData getFlower(Player player) { + if(manager == null) return null; + LifeCount lifeCount = manager.get(player).getLifeCount(); + Long place = lifeCount.getFlower_place(); + List flower = AchievementConfig.getInstance().getFlower(); + AchievementStatus status = getStatus(place, flower); + return AchievementData.create( + status.getStage(), + status.getColor() + "花を植えた数", new ArrayList<>(List.of( - place + "/" + goal + (status.isAchieved() ? "":"Next: ")+place + "/" + status.getGoal() )) ); } + @Nullable public static AchievementData getBreak(Player player) { if(manager == null) return null; LifeCount lifeCount = manager.get(player).getLifeCount(); Long breakCount = lifeCount.getBlock_break(); List blockBreak = AchievementConfig.getInstance().getBreak(); - Long goal; - String stage; - String color; - if(breakCount >= blockBreak.getLast()) { - goal = blockBreak.getLast(); - stage = Achievement_GOLD; - color = Name_GOLD; - }else if (breakCount >= blockBreak.getFirst()) { - goal = blockBreak.getLast(); - stage = Achievement_SILVER; - color = Name_SILVER; - }else{ - goal = blockBreak.getFirst(); - stage = Achievement_NORMAL; - color = Name_NORMAL; - } - return AchievementData.createData( - stage, - color+"ブロック破壊数", + AchievementStatus status = getStatus(breakCount, blockBreak); + return AchievementData.create( + status.getStage(), + status.getColor()+"ブロック破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+breakCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getPlace(Player player){ + if(manager == null) return null; + LifeCount lifeCount = manager.get(player).getLifeCount(); + Long placeCount = lifeCount.getBlock_place(); + List place = AchievementConfig.getInstance().getPlace(); + AchievementStatus status = getStatus(placeCount, place); + return AchievementData.create( + status.getStage(), + status.getColor()+"ブロック設置数", new ArrayList<>(List.of( - breakCount+"/"+goal + (status.isAchieved() ? "":"Next: ")+placeCount+"/"+status.getGoal() )) ); } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementStatus.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementStatus.java new file mode 100644 index 00000000..7d646656 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementStatus.java @@ -0,0 +1,38 @@ +package space.yurisi.universecorev2.subplugins.achievement.data; + +import org.jetbrains.annotations.NotNull; + +public final class AchievementStatus { + + private final boolean isAchieved; + private final Long goal; + private final String stage; + private final String color; + + private AchievementStatus(boolean isAchieved, @NotNull Long goal, @NotNull String stage, @NotNull String color) { + this.isAchieved = isAchieved; + this.goal = goal; + this.stage = stage; + this.color = color; + } + + public static AchievementStatus create(boolean isAchieved, @NotNull Long goal, @NotNull String stage, @NotNull String color) { + return new AchievementStatus(isAchieved, goal, stage, color); + } + + public boolean isAchieved() { + return isAchieved; + } + + public Long getGoal() { + return goal; + } + + public String getStage() { + return stage; + } + + public String getColor() { + return color; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java index f490d33c..9c0d405d 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java @@ -41,5 +41,10 @@ public List getBreak(){ List breakCount = this.config.getLongList("break"); return List.of(breakCount.getFirst(), breakCount.getLast()); } + + public List getPlace(){ + List place = this.config.getLongList("place"); + return List.of(place.getFirst(), place.getLast()); + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index e7a8d545..8127ff6c 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -16,9 +16,6 @@ public class AchievementMenu implements BaseMenu { @Override public void sendMenu(Player player) { - List items = new java.util.ArrayList<>(List.of()); - if(AchievementDataManager.getBreak(player) != null) {items.add(new AchievementItem(AchievementDataManager.getBreak(player)));} - if(AchievementDataManager.getFlower(player) != null) {items.add(new AchievementItem(AchievementDataManager.getFlower(player)));} Gui gui = PagedGui.items() .setStructure( @@ -26,7 +23,7 @@ public void sendMenu(Player player) { "x x x x x x x x x", "x x x x x x x x x") .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) - .setContent(items) + .setContent(getItems(player)) .build(); Window window = Window.single() @@ -37,4 +34,12 @@ public void sendMenu(Player player) { window.open(); } + + public List getItems(Player player) { + List items = new java.util.ArrayList<>(List.of()); + if(AchievementDataManager.getBreak(player) != null) {items.add(new AchievementItem(AchievementDataManager.getBreak(player)));} + if(AchievementDataManager.getPlace(player) != null) {items.add(new AchievementItem(AchievementDataManager.getPlace(player)));} + if(AchievementDataManager.getFlower(player) != null) {items.add(new AchievementItem(AchievementDataManager.getFlower(player)));} + return items; + } } diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml index 2da2545a..1be014d1 100644 --- a/src/main/resources/subplugins/achievement.yml +++ b/src/main/resources/subplugins/achievement.yml @@ -1,12 +1,16 @@ # コンフィグの書き方 # achievement: -# - Normal [Long] +# - Silver [Long] # - Gold [Long] break: - 100000 - 1000000 +place: + - 50000 + - 250000 + flower: - 25 - 100 \ No newline at end of file From 916cb29b098fc2257aa2f3a7d1d39cfc630b612b Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 02:14:15 +0900 Subject: [PATCH 06/36] =?UTF-8?q?=E3=81=93=E3=82=8C=E3=81=A710^-12?= =?UTF-8?q?=E7=A7=92=E3=81=8F=E3=82=89=E3=81=84=E5=87=A6=E7=90=86=E3=81=8C?= =?UTF-8?q?=E9=80=9F=E3=81=8F=E3=81=AA=E3=82=8B=E3=82=93=E3=81=98=E3=82=83?= =?UTF-8?q?=E3=81=AA=E3=81=84=E7=9F=A5=E3=82=89=E3=82=93=E3=81=91=E3=81=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achievement/data/AchievementDataManager.java | 4 ++++ .../subplugins/achievement/menu/AchievementMenu.java | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java index 7244232c..0e7c1e7e 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -24,6 +24,10 @@ public static void setManager(CounterModelManager manager) { AchievementDataManager.manager = manager; } + public static boolean canGetManager(){ + return manager != null; + } + private static AchievementStatus getStatus(Long now, List conf){ String stage; String color; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index 8127ff6c..9f4dffed 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -37,9 +37,11 @@ public void sendMenu(Player player) { public List getItems(Player player) { List items = new java.util.ArrayList<>(List.of()); - if(AchievementDataManager.getBreak(player) != null) {items.add(new AchievementItem(AchievementDataManager.getBreak(player)));} - if(AchievementDataManager.getPlace(player) != null) {items.add(new AchievementItem(AchievementDataManager.getPlace(player)));} - if(AchievementDataManager.getFlower(player) != null) {items.add(new AchievementItem(AchievementDataManager.getFlower(player)));} + if(AchievementDataManager.canGetManager()){ + items.add(new AchievementItem(AchievementDataManager.getBreak(player))); + items.add(new AchievementItem(AchievementDataManager.getPlace(player))); + items.add(new AchievementItem(AchievementDataManager.getFlower(player))); + } return items; } } From 5b2d7a34e7c2f06459de96081452bac5eaf381ec Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 02:40:49 +0900 Subject: [PATCH 07/36] =?UTF-8?q?=E3=82=B3=E3=83=9F=E3=83=83=E3=83=88?= =?UTF-8?q?=E6=96=87=E3=81=AF=E3=81=9D=E3=81=AE=E4=BA=BA=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E3=81=AE=E5=BF=83=E3=82=92=E6=98=A0=E3=81=97=E5=87=BA=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/achievement/menu/item/AchievementItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java index 5d3d0003..e02a7948 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java @@ -45,6 +45,6 @@ public ItemProvider getItemProvider() { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { - + //クリックで実績解除報酬をプレゼント!とかあったらいいなと思った午前2時 } } From 364a550c35c120dce444135bde8edfa3b02c7897 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 04:14:00 +0900 Subject: [PATCH 08/36] =?UTF-8?q?=E9=89=B1=E7=9F=B3=E3=81=AF=E5=A4=9A?= =?UTF-8?q?=E5=88=86=E3=81=8A=EF=BD=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/AchievementDataManager.java | 146 ++++++++++++++++++ .../data/config/AchievementConfig.java | 45 ++++++ .../achievement/menu/AchievementMenu.java | 19 ++- .../rankcounter/event/OreCountEvents.java | 5 + src/main/resources/subplugins/achievement.yml | 36 +++++ 5 files changed, 249 insertions(+), 2 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java index 0e7c1e7e..a5a7b65b 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -2,6 +2,7 @@ import org.bukkit.entity.Player; import space.yurisi.universecorev2.database.models.count.LifeCount; +import space.yurisi.universecorev2.database.models.count.OreCount; import space.yurisi.universecorev2.subplugins.achievement.data.config.AchievementConfig; import space.yurisi.universecorev2.subplugins.rankcounter.manager.CounterModelManager; @@ -95,4 +96,149 @@ public static AchievementData getPlace(Player player){ )) ); } + + public static AchievementData getCoal(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long coalCount = oreCount.getCoal_ore(); + List coal = AchievementConfig.getInstance().getCoal(); + AchievementStatus status = getStatus(coalCount, coal); + return AchievementData.create( + status.getStage(), + status.getColor()+"石炭:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+coalCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getIron(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long ironCount = oreCount.getIron_ore(); + List iron = AchievementConfig.getInstance().getIron(); + AchievementStatus status = getStatus(ironCount, iron); + return AchievementData.create( + status.getStage(), + status.getColor()+"鉄:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+ironCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getGold(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long goldCount = oreCount.getGold_ore(); + List gold = AchievementConfig.getInstance().getGold(); + AchievementStatus status = getStatus(goldCount, gold); + return AchievementData.create( + status.getStage(), + status.getColor()+"金:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+goldCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getLapis(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long lapisCount = oreCount.getLapis_ore(); + List lapis = AchievementConfig.getInstance().getLapis(); + AchievementStatus status = getStatus(lapisCount, lapis); + return AchievementData.create( + status.getStage(), + status.getColor()+"ラピス:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+lapisCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getRedStone(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long redStoneCount = oreCount.getRedstone_ore(); + List redStone = AchievementConfig.getInstance().getRedStone(); + AchievementStatus status = getStatus(redStoneCount, redStone); + return AchievementData.create( + status.getStage(), + status.getColor()+"赤石:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+redStoneCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getEmerald(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long emeraldCount = oreCount.getEmerald_ore(); + List emerald = AchievementConfig.getInstance().getEmerald(); + AchievementStatus status = getStatus(emeraldCount, emerald); + return AchievementData.create( + status.getStage(), + status.getColor()+"エメラルド:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+emeraldCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getDiamond(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long diamondCount = oreCount.getDiamond_ore(); + List diamond = AchievementConfig.getInstance().getDiamond(); + AchievementStatus status = getStatus(diamondCount, diamond); + return AchievementData.create( + status.getStage(), + status.getColor()+"ダイヤ:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+diamondCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getCopper(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long copperCount = oreCount.getCopper_ore(); + List copper = AchievementConfig.getInstance().getCopper(); + AchievementStatus status = getStatus(copperCount, copper); + return AchievementData.create( + status.getStage(), + status.getColor()+"銅:原石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+copperCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getOre(Player player){ + if(manager == null) return null; + OreCount oreCount = manager.get(player).getOreCount(); + Long oreSum = ( + oreCount.getCoal_ore() + + oreCount.getIron_ore() + + oreCount.getGold_ore() + + oreCount.getLapis_ore() + + oreCount.getRedstone_ore() + + oreCount.getEmerald_ore() + + oreCount.getDiamond_ore() + + oreCount.getCopper_ore() + ); + + List ore = AchievementConfig.getInstance().getOre(); + AchievementStatus status = getStatus(oreSum, ore); + return AchievementData.create( + status.getStage(), + status.getColor()+"鉱石破壊数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+oreSum+"/"+status.getGoal() + )) + ); + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java index 9c0d405d..49252770 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java @@ -46,5 +46,50 @@ public List getPlace(){ List place = this.config.getLongList("place"); return List.of(place.getFirst(), place.getLast()); } + + public List getCoal(){ + List coal = this.config.getLongList("coal"); + return List.of(coal.getFirst(), coal.getLast()); + } + + public List getIron(){ + List iron = this.config.getLongList("iron"); + return List.of(iron.getFirst(), iron.getLast()); + } + + public List getGold(){ + List gold = this.config.getLongList("gold"); + return List.of(gold.getFirst(), gold.getLast()); + } + + public List getLapis(){ + List lap = this.config.getLongList("lapis"); + return List.of(lap.getFirst(), lap.getLast()); + } + + public List getRedStone(){ + List redStone = this.config.getLongList("redstone"); + return List.of(redStone.getFirst(), redStone.getLast()); + } + + public List getEmerald(){ + List emerald = this.config.getLongList("emerald"); + return List.of(emerald.getFirst(), emerald.getLast()); + } + + public List getDiamond(){ + List diamond = this.config.getLongList("diamond"); + return List.of(diamond.getFirst(), diamond.getLast()); + } + + public List getCopper(){ + List copper = this.config.getLongList("copper"); + return List.of(copper.getFirst(), copper.getLast()); + } + + public List getOre(){ + List ore = this.config.getLongList("ore"); + return List.of(ore.getFirst(), ore.getLast()); + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index 9f4dffed..df1d9e3a 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -1,5 +1,6 @@ package space.yurisi.universecorev2.subplugins.achievement.menu; +import org.bukkit.Material; import org.bukkit.entity.Player; import space.yurisi.universecorev2.menu.BaseMenu; import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; @@ -8,6 +9,8 @@ import xyz.xenondevs.invui.gui.PagedGui; import xyz.xenondevs.invui.gui.structure.Markers; import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; import xyz.xenondevs.invui.window.Window; import java.util.List; @@ -16,13 +19,14 @@ public class AchievementMenu implements BaseMenu { @Override public void sendMenu(Player player) { - + Item border = new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("§r")); Gui gui = PagedGui.items() .setStructure( - "x x x x x x x x x", + "x x x b b b b b b", "x x x x x x x x x", "x x x x x x x x x") .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) + .addIngredient('b', border) .setContent(getItems(player)) .build(); @@ -38,9 +42,20 @@ public void sendMenu(Player player) { public List getItems(Player player) { List items = new java.util.ArrayList<>(List.of()); if(AchievementDataManager.canGetManager()){ + //1st row items.add(new AchievementItem(AchievementDataManager.getBreak(player))); items.add(new AchievementItem(AchievementDataManager.getPlace(player))); items.add(new AchievementItem(AchievementDataManager.getFlower(player))); + //2nd row + items.add(new AchievementItem(AchievementDataManager.getOre(player))); + items.add(new AchievementItem(AchievementDataManager.getCoal(player))); + items.add(new AchievementItem(AchievementDataManager.getCopper(player))); + items.add(new AchievementItem(AchievementDataManager.getIron(player))); + items.add(new AchievementItem(AchievementDataManager.getGold(player))); + items.add(new AchievementItem(AchievementDataManager.getRedStone(player))); + items.add(new AchievementItem(AchievementDataManager.getLapis(player))); + items.add(new AchievementItem(AchievementDataManager.getEmerald(player))); + items.add(new AchievementItem(AchievementDataManager.getDiamond(player))); } return items; } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java index f71cc55f..0ab8ca25 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java @@ -1,6 +1,7 @@ package space.yurisi.universecorev2.subplugins.rankcounter.event; import org.bukkit.GameMode; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -26,6 +27,10 @@ public void onBreak(BlockBreakEvent event) { return; } + if (player.getInventory().getItemInMainHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { + return; + } + switch (event.getBlock().getType()) { case COAL_ORE, DEEPSLATE_COAL_ORE -> oreCount.setCoal_ore(oreCount.getCoal_ore() + 1); case LAPIS_ORE, DEEPSLATE_LAPIS_ORE -> oreCount.setLapis_ore(oreCount.getLapis_ore() + 1); diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml index 1be014d1..60c78474 100644 --- a/src/main/resources/subplugins/achievement.yml +++ b/src/main/resources/subplugins/achievement.yml @@ -11,6 +11,42 @@ place: - 50000 - 250000 +ore: + - 10000 + - 50000 + +coal: + - 1000 + - 5000 + +copper: + - 1000 + - 5000 + +iron: + - 500 + - 1000 + +gold: + - 100 + - 500 + +redstone: + - 1000 + - 7000 + +lapis: + - 50 + - 500 + +emerald: + - 10 + - 50 + +diamond: + - 50 + - 250 + flower: - 25 - 100 \ No newline at end of file From 5b437062a0ef4bbece184ae0e6ec34e58e7c9493 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 23:18:39 +0900 Subject: [PATCH 09/36] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=82=B9=E3=83=90=E3=83=BC=E3=82=92=E4=BD=9C=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=BF=E3=81=9F&=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achievement/data/AchievementData.java | 30 +++- .../data/AchievementDataManager.java | 132 +++++++++++++++++- .../data/config/AchievementConfig.java | 25 ++++ .../achievement/menu/AchievementMenu.java | 49 ++++--- .../achievement/menu/ProgressMenu.java | 66 +++++++++ .../menu/item/AchievementHomeItem.java | 23 +++ .../menu/item/AchievementItem.java | 18 +-- .../menu/item/ProgressBarItem.java | 42 ++++++ .../menu/item/ProgressDownItem.java | 19 +++ .../menu/item/ProgressMenuItem.java | 68 +++++++++ .../achievement/menu/item/ProgressUpItem.java | 19 +++ .../rankcounter/event/OreCountEvents.java | 4 - src/main/resources/subplugins/achievement.yml | 26 +++- 13 files changed, 473 insertions(+), 48 deletions(-) create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementHomeItem.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressDownItem.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressUpItem.java diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java index 2ee6a0a4..133a85b9 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementData.java @@ -1,5 +1,6 @@ package space.yurisi.universecorev2.subplugins.achievement.data; +import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -9,15 +10,36 @@ public final class AchievementData { private final String stage; private final String itemName; private final ArrayList itemLore; - - private AchievementData(@NotNull String stage, @NotNull String itemName, @NotNull ArrayList itemLore){ + private final Long currentGoal; + private final Long currentCount; + private final Material material; + + private AchievementData(@NotNull Material material, @NotNull Long currentCount, @NotNull Long currentGoal, @NotNull String stage, @NotNull String itemName, @NotNull ArrayList itemLore){ + this.material = material; + this.currentCount = currentCount; + this.currentGoal = currentGoal; this.stage = stage; this.itemName = itemName; this.itemLore = itemLore; } - public static AchievementData create(@NotNull String stage, @NotNull String ItemName, @NotNull ArrayList ItemLore){ - return new AchievementData(stage, ItemName, ItemLore); + public static AchievementData create(@NotNull Material material, @NotNull Long currentCount, @NotNull Long currentGoal, @NotNull String stage, @NotNull String ItemName, @NotNull ArrayList ItemLore){ + return new AchievementData(material, currentCount, currentGoal, stage, ItemName, ItemLore); + } + + @NotNull + public Material getMaterial() { + return material; + } + + @NotNull + public Long getCurrentCount() { + return currentCount; + } + + @NotNull + public Long getCurrentGoal() { + return currentGoal; } @NotNull diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java index a5a7b65b..20aabb32 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -1,12 +1,14 @@ package space.yurisi.universecorev2.subplugins.achievement.data; +import org.bukkit.Material; import org.bukkit.entity.Player; +import space.yurisi.universecorev2.database.models.count.KillDeathCount; import space.yurisi.universecorev2.database.models.count.LifeCount; import space.yurisi.universecorev2.database.models.count.OreCount; +import space.yurisi.universecorev2.database.models.count.PlayerCount; import space.yurisi.universecorev2.subplugins.achievement.data.config.AchievementConfig; import space.yurisi.universecorev2.subplugins.rankcounter.manager.CounterModelManager; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; @@ -50,7 +52,6 @@ private static AchievementStatus getStatus(Long now, List conf){ ); } - @Nullable public static AchievementData getFlower(Player player) { if(manager == null) return null; LifeCount lifeCount = manager.get(player).getLifeCount(); @@ -58,6 +59,9 @@ public static AchievementData getFlower(Player player) { List flower = AchievementConfig.getInstance().getFlower(); AchievementStatus status = getStatus(place, flower); return AchievementData.create( + Material.POPPY, + place, + status.getGoal(), status.getStage(), status.getColor() + "花を植えた数", new ArrayList<>(List.of( @@ -66,7 +70,6 @@ public static AchievementData getFlower(Player player) { ); } - @Nullable public static AchievementData getBreak(Player player) { if(manager == null) return null; LifeCount lifeCount = manager.get(player).getLifeCount(); @@ -74,6 +77,9 @@ public static AchievementData getBreak(Player player) { List blockBreak = AchievementConfig.getInstance().getBreak(); AchievementStatus status = getStatus(breakCount, blockBreak); return AchievementData.create( + Material.IRON_PICKAXE, + breakCount, + status.getGoal(), status.getStage(), status.getColor()+"ブロック破壊数", new ArrayList<>(List.of( @@ -89,6 +95,9 @@ public static AchievementData getPlace(Player player){ List place = AchievementConfig.getInstance().getPlace(); AchievementStatus status = getStatus(placeCount, place); return AchievementData.create( + Material.OAK_PLANKS, + placeCount, + status.getGoal(), status.getStage(), status.getColor()+"ブロック設置数", new ArrayList<>(List.of( @@ -97,6 +106,96 @@ public static AchievementData getPlace(Player player){ ); } + public static AchievementData getFishing(Player player){ + if(manager == null) return null; + LifeCount lifeCount = manager.get(player).getLifeCount(); + Long fishingCount = lifeCount.getFishing(); + List fishing = AchievementConfig.getInstance().getFishing(); + AchievementStatus status = getStatus(fishingCount, fishing); + return AchievementData.create( + Material.FISHING_ROD, + fishingCount, + status.getGoal(), + status.getStage(), + status.getColor()+"釣りをした回数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+fishingCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getGacha(Player player){ + if(manager == null) return null; + LifeCount lifeCount = manager.get(player).getLifeCount(); + Long gachaCount = lifeCount.getGacha(); + List gacha = AchievementConfig.getInstance().getGacha(); + AchievementStatus status = getStatus(gachaCount, gacha); + return AchievementData.create( + Material.PAPER, + gachaCount, + status.getGoal(), + status.getStage(), + status.getColor()+"ガチャを引いた回数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+gachaCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getKill(Player player){ + if(manager == null) return null; + KillDeathCount killDeathCount = manager.get(player).getKillDeathCount(); + Long killCount = killDeathCount.getPlayer_kill(); + List kill = AchievementConfig.getInstance().getKill(); + AchievementStatus status = getStatus(killCount, kill); + return AchievementData.create( + Material.IRON_SWORD, + killCount, + status.getGoal(), + status.getStage(), + status.getColor()+"キルした回数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+killCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getLogin(Player player){ + if(manager == null) return null; + PlayerCount playerCount = manager.get(player).getPlayerCount(); + Long loginCount = playerCount.getLogin(); + List login = AchievementConfig.getInstance().getLogin(); + AchievementStatus status = getStatus(loginCount, login); + return AchievementData.create( + Material.LANTERN, + loginCount, + status.getGoal(), + status.getStage(), + status.getColor()+"サーバーログイン日数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+loginCount+"/"+status.getGoal() + )) + ); + } + + public static AchievementData getConsecutiveLogin(Player player){ + if(manager == null) return null; + PlayerCount playerCount = manager.get(player).getPlayerCount(); + Long loginCount = playerCount.getConsecutive_login(); + List login = AchievementConfig.getInstance().getConsecutiveLogin(); + AchievementStatus status = getStatus(loginCount, login); + return AchievementData.create( + Material.SOUL_LANTERN, + loginCount, + status.getGoal(), + status.getStage(), + status.getColor()+"サーバー連続ログイン日数", + new ArrayList<>(List.of( + (status.isAchieved() ? "":"Next: ")+loginCount+"/"+status.getGoal() + )) + ); + } + public static AchievementData getCoal(Player player){ if(manager == null) return null; OreCount oreCount = manager.get(player).getOreCount(); @@ -104,6 +203,9 @@ public static AchievementData getCoal(Player player){ List coal = AchievementConfig.getInstance().getCoal(); AchievementStatus status = getStatus(coalCount, coal); return AchievementData.create( + Material.COAL_ORE, + coalCount, + status.getGoal(), status.getStage(), status.getColor()+"石炭:原石破壊数", new ArrayList<>(List.of( @@ -119,6 +221,9 @@ public static AchievementData getIron(Player player){ List iron = AchievementConfig.getInstance().getIron(); AchievementStatus status = getStatus(ironCount, iron); return AchievementData.create( + Material.IRON_ORE, + ironCount, + status.getGoal(), status.getStage(), status.getColor()+"鉄:原石破壊数", new ArrayList<>(List.of( @@ -134,6 +239,9 @@ public static AchievementData getGold(Player player){ List gold = AchievementConfig.getInstance().getGold(); AchievementStatus status = getStatus(goldCount, gold); return AchievementData.create( + Material.GOLD_ORE, + goldCount, + status.getGoal(), status.getStage(), status.getColor()+"金:原石破壊数", new ArrayList<>(List.of( @@ -149,6 +257,9 @@ public static AchievementData getLapis(Player player){ List lapis = AchievementConfig.getInstance().getLapis(); AchievementStatus status = getStatus(lapisCount, lapis); return AchievementData.create( + Material.LAPIS_ORE, + lapisCount, + status.getGoal(), status.getStage(), status.getColor()+"ラピス:原石破壊数", new ArrayList<>(List.of( @@ -164,6 +275,9 @@ public static AchievementData getRedStone(Player player){ List redStone = AchievementConfig.getInstance().getRedStone(); AchievementStatus status = getStatus(redStoneCount, redStone); return AchievementData.create( + Material.REDSTONE_ORE, + redStoneCount, + status.getGoal(), status.getStage(), status.getColor()+"赤石:原石破壊数", new ArrayList<>(List.of( @@ -179,6 +293,9 @@ public static AchievementData getEmerald(Player player){ List emerald = AchievementConfig.getInstance().getEmerald(); AchievementStatus status = getStatus(emeraldCount, emerald); return AchievementData.create( + Material.EMERALD_ORE, + emeraldCount, + status.getGoal(), status.getStage(), status.getColor()+"エメラルド:原石破壊数", new ArrayList<>(List.of( @@ -194,6 +311,9 @@ public static AchievementData getDiamond(Player player){ List diamond = AchievementConfig.getInstance().getDiamond(); AchievementStatus status = getStatus(diamondCount, diamond); return AchievementData.create( + Material.DIAMOND_ORE, + diamondCount, + status.getGoal(), status.getStage(), status.getColor()+"ダイヤ:原石破壊数", new ArrayList<>(List.of( @@ -209,6 +329,9 @@ public static AchievementData getCopper(Player player){ List copper = AchievementConfig.getInstance().getCopper(); AchievementStatus status = getStatus(copperCount, copper); return AchievementData.create( + Material.COPPER_ORE, + copperCount, + status.getGoal(), status.getStage(), status.getColor()+"銅:原石破壊数", new ArrayList<>(List.of( @@ -234,6 +357,9 @@ public static AchievementData getOre(Player player){ List ore = AchievementConfig.getInstance().getOre(); AchievementStatus status = getStatus(oreSum, ore); return AchievementData.create( + Material.STONE, + oreSum, + status.getGoal(), status.getStage(), status.getColor()+"鉱石破壊数", new ArrayList<>(List.of( diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java index 49252770..dd9948c7 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/config/AchievementConfig.java @@ -91,5 +91,30 @@ public List getOre(){ List ore = this.config.getLongList("ore"); return List.of(ore.getFirst(), ore.getLast()); } + + public List getFishing(){ + List fishing = this.config.getLongList("fishing"); + return List.of(fishing.getFirst(), fishing.getLast()); + } + + public List getGacha(){ + List gacha = this.config.getLongList("gacha"); + return List.of(gacha.getFirst(), gacha.getLast()); + } + + public List getKill(){ + List kill = this.config.getLongList("kill"); + return List.of(kill.getFirst(), kill.getLast()); + } + + public List getLogin(){ + List login = this.config.getLongList("login"); + return List.of(login.getFirst(), login.getLast()); + } + + public List getConsecutiveLogin(){ + List consecutiveLogin = this.config.getLongList("consecutive_login"); + return List.of(consecutiveLogin.getFirst(), consecutiveLogin.getLast()); + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index df1d9e3a..2fdbf018 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -5,6 +5,7 @@ import space.yurisi.universecorev2.menu.BaseMenu; import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; import space.yurisi.universecorev2.subplugins.achievement.menu.item.AchievementItem; +import space.yurisi.universecorev2.subplugins.achievement.menu.item.ProgressMenuItem; import xyz.xenondevs.invui.gui.Gui; import xyz.xenondevs.invui.gui.PagedGui; import xyz.xenondevs.invui.gui.structure.Markers; @@ -22,10 +23,14 @@ public void sendMenu(Player player) { Item border = new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("§r")); Gui gui = PagedGui.items() .setStructure( - "x x x b b b b b b", - "x x x x x x x x x", - "x x x x x x x x x") + "1 x x x x x x b b", + "2 x x x x x x x x", + "3 x x x b b b b b" + ) .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) + .addIngredient('1', new ProgressMenuItem(1)) + .addIngredient('2', new ProgressMenuItem(2)) + .addIngredient('3', new ProgressMenuItem(3)) .addIngredient('b', border) .setContent(getItems(player)) .build(); @@ -41,22 +46,28 @@ public void sendMenu(Player player) { public List getItems(Player player) { List items = new java.util.ArrayList<>(List.of()); - if(AchievementDataManager.canGetManager()){ - //1st row - items.add(new AchievementItem(AchievementDataManager.getBreak(player))); - items.add(new AchievementItem(AchievementDataManager.getPlace(player))); - items.add(new AchievementItem(AchievementDataManager.getFlower(player))); - //2nd row - items.add(new AchievementItem(AchievementDataManager.getOre(player))); - items.add(new AchievementItem(AchievementDataManager.getCoal(player))); - items.add(new AchievementItem(AchievementDataManager.getCopper(player))); - items.add(new AchievementItem(AchievementDataManager.getIron(player))); - items.add(new AchievementItem(AchievementDataManager.getGold(player))); - items.add(new AchievementItem(AchievementDataManager.getRedStone(player))); - items.add(new AchievementItem(AchievementDataManager.getLapis(player))); - items.add(new AchievementItem(AchievementDataManager.getEmerald(player))); - items.add(new AchievementItem(AchievementDataManager.getDiamond(player))); - } + + //1st row + items.add(new AchievementItem(AchievementDataManager.getLogin(player))); + items.add(new AchievementItem(AchievementDataManager.getConsecutiveLogin(player))); + items.add(new AchievementItem(AchievementDataManager.getBreak(player))); + items.add(new AchievementItem(AchievementDataManager.getPlace(player))); + items.add(new AchievementItem(AchievementDataManager.getFlower(player))); + items.add(new AchievementItem(AchievementDataManager.getOre(player))); + //2nd row + items.add(new AchievementItem(AchievementDataManager.getCoal(player))); + items.add(new AchievementItem(AchievementDataManager.getCopper(player))); + items.add(new AchievementItem(AchievementDataManager.getIron(player))); + items.add(new AchievementItem(AchievementDataManager.getGold(player))); + items.add(new AchievementItem(AchievementDataManager.getRedStone(player))); + items.add(new AchievementItem(AchievementDataManager.getLapis(player))); + items.add(new AchievementItem(AchievementDataManager.getEmerald(player))); + items.add(new AchievementItem(AchievementDataManager.getDiamond(player))); + //3rd row + items.add(new AchievementItem(AchievementDataManager.getGacha(player))); + items.add(new AchievementItem(AchievementDataManager.getKill(player))); + items.add(new AchievementItem(AchievementDataManager.getFishing(player))); + return items; } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java new file mode 100644 index 00000000..7b5ad454 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java @@ -0,0 +1,66 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.achievement.data.AchievementData; +import space.yurisi.universecorev2.subplugins.achievement.menu.item.*; +import xyz.xenondevs.invui.gui.ScrollGui; +import xyz.xenondevs.invui.gui.structure.Markers; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +import java.util.List; + +public class ProgressMenu implements BaseMenu{ + + private final List dataList; + + public ProgressMenu(List dataList){ + this.dataList = dataList; + } + + @Override + public void sendMenu(Player player) { + Item border = new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("§r")); + ScrollGui.Builder<@NotNull Item> builder; + builder = ScrollGui.items() + .setStructure( + "x x x x x x x x u", + "x x x x x x x x b", + "x x x x x x x x h", + "x x x x x x x x b", + "x x x x x x x x d" + ) + .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) + .addIngredient('b', border) + .addIngredient('u', new ProgressUpItem()) + .addIngredient('d', new ProgressDownItem()) + .addIngredient('h', new AchievementHomeItem()); + + for(int i = 0; i < (this.dataList.size() * 8); i++){ + if(i % 8 == 0){ + builder = builder.addContent(new AchievementItem(this.dataList.get(i / 8))); + continue; + } + int j = i / 8; + AchievementData data = this.dataList.get(j); + Long currentCount = data.getCurrentCount(); + Long currentGoal = data.getCurrentGoal(); + int cell = (int) (currentGoal / 8); + int achievedCells = (int) (currentCount / cell); + builder = builder.addContent(new ProgressBarItem((i % 8) <= achievedCells, data.getStage(), data.getItemName())); + } + + Window window = Window.single() + .setViewer(player) + .setGui(builder.build()) + .setTitle("Achievement_Progress") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementHomeItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementHomeItem.java new file mode 100644 index 00000000..ec3da015 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementHomeItem.java @@ -0,0 +1,23 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu.item; + +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.subplugins.achievement.menu.AchievementMenu; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.AbstractItem; + +public class AchievementHomeItem extends AbstractItem { + @Override + public ItemProvider getItemProvider() { + return new ItemBuilder(Material.WHITE_STAINED_GLASS_PANE).setDisplayName("§d最初に戻る"); + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { + new AchievementMenu().sendMenu(player); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java index e02a7948..364e591f 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java @@ -6,7 +6,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.jetbrains.annotations.NotNull; import space.yurisi.universecorev2.subplugins.achievement.data.AchievementData; -import space.yurisi.universecorev2.subplugins.achievement.data.AchievementDataManager; import xyz.xenondevs.invui.item.ItemProvider; import xyz.xenondevs.invui.item.builder.ItemBuilder; import xyz.xenondevs.invui.item.impl.AbstractItem; @@ -21,21 +20,10 @@ public AchievementItem(AchievementData data){ @Override public ItemProvider getItemProvider() { - Material material; - switch (data.getStage()){ - case AchievementDataManager.Achievement_GOLD: - material = Material.YELLOW_STAINED_GLASS_PANE; - break; - case AchievementDataManager.Achievement_SILVER: - material = Material.WHITE_STAINED_GLASS_PANE; - break; - case AchievementDataManager.Achievement_NORMAL: - material = Material.GLASS_PANE; - break; - default: - return new ItemBuilder(Material.RED_STAINED_GLASS_PANE); + if(data == null) { + return new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE); } - ItemBuilder builder = new ItemBuilder(material) + ItemBuilder builder = new ItemBuilder(data.getMaterial()) .setDisplayName(data.getItemName()); for(String lore: data.getItemLore()){ builder.addLoreLines(lore); diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java new file mode 100644 index 00000000..0790fe28 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java @@ -0,0 +1,42 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu.item; + +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.subplugins.achievement.data.AchievementDataManager; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.AbstractItem; + +import java.util.Objects; + +public class ProgressBarItem extends AbstractItem { + + private final boolean isAchieved; + private final String stage; + private final String name; + + public ProgressBarItem(boolean isAchieved, String stage, String name) { + this.isAchieved = isAchieved; + this.stage = stage; + this.name = name; + } + + @Override + public ItemProvider getItemProvider() { + Material material; + if(Objects.equals(stage, AchievementDataManager.Achievement_NORMAL)){ + material = isAchieved ? Material.LIGHT_BLUE_STAINED_GLASS_PANE:Material.LIGHT_GRAY_STAINED_GLASS_PANE; + }else{ + material = isAchieved ? Material.BLUE_STAINED_GLASS_PANE:Material.LIGHT_BLUE_STAINED_GLASS_PANE; + } + return new ItemBuilder(material).setDisplayName(name); + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { + + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressDownItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressDownItem.java new file mode 100644 index 00000000..d12718a8 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressDownItem.java @@ -0,0 +1,19 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu.item; + +import org.bukkit.Material; +import xyz.xenondevs.invui.gui.ScrollGui; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.controlitem.ScrollItem; + +public class ProgressDownItem extends ScrollItem { + + public ProgressDownItem() { + super(1); + } + + @Override + public ItemProvider getItemProvider(ScrollGui scrollGui) { + return new ItemBuilder(Material.LIME_STAINED_GLASS_PANE).setDisplayName("§9下にスクロール"); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java new file mode 100644 index 00000000..5c32568a --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java @@ -0,0 +1,68 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu.item; + +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.subplugins.achievement.data.AchievementDataManager; +import space.yurisi.universecorev2.subplugins.achievement.menu.ProgressMenu; +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 ProgressMenuItem extends AbstractItem { + + private final Integer row; + + public ProgressMenuItem(Integer row) { + this.row = row; + } + + @Override + public ItemProvider getItemProvider() { + return new ItemBuilder(Material.LIME_STAINED_GLASS_PANE).setDisplayName("§a進行状況を表示"); + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { + if(!AchievementDataManager.canGetManager()) return; + ProgressMenu menu; + switch (row){ + case 1: + menu = new ProgressMenu(List.of( + AchievementDataManager.getLogin(player), + AchievementDataManager.getConsecutiveLogin(player), + AchievementDataManager.getBreak(player), + AchievementDataManager.getPlace(player), + AchievementDataManager.getFlower(player), + AchievementDataManager.getOre(player) + )); + menu.sendMenu(player); + break; + case 2: + menu = new ProgressMenu(List.of( + AchievementDataManager.getCoal(player), + AchievementDataManager.getCopper(player), + AchievementDataManager.getIron(player), + AchievementDataManager.getGold(player), + AchievementDataManager.getRedStone(player), + AchievementDataManager.getLapis(player), + AchievementDataManager.getEmerald(player), + AchievementDataManager.getDiamond(player) + )); + menu.sendMenu(player); + break; + case 3: + menu = new ProgressMenu(List.of( + AchievementDataManager.getGacha(player), + AchievementDataManager.getKill(player), + AchievementDataManager.getFishing(player) + )); + menu.sendMenu(player); + break; + } + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressUpItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressUpItem.java new file mode 100644 index 00000000..45c3b9b5 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressUpItem.java @@ -0,0 +1,19 @@ +package space.yurisi.universecorev2.subplugins.achievement.menu.item; + +import org.bukkit.Material; +import xyz.xenondevs.invui.gui.ScrollGui; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.controlitem.ScrollItem; + +public class ProgressUpItem extends ScrollItem { + + public ProgressUpItem(){ + super(-1); + } + + @Override + public ItemProvider getItemProvider(ScrollGui scrollGui) { + return new ItemBuilder(Material.RED_STAINED_GLASS_PANE).setDisplayName("§9上にスクロール"); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java index 0ab8ca25..89458eac 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java @@ -27,10 +27,6 @@ public void onBreak(BlockBreakEvent event) { return; } - if (player.getInventory().getItemInMainHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { - return; - } - switch (event.getBlock().getType()) { case COAL_ORE, DEEPSLATE_COAL_ORE -> oreCount.setCoal_ore(oreCount.getCoal_ore() + 1); case LAPIS_ORE, DEEPSLATE_LAPIS_ORE -> oreCount.setLapis_ore(oreCount.getLapis_ore() + 1); diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml index 60c78474..676beeda 100644 --- a/src/main/resources/subplugins/achievement.yml +++ b/src/main/resources/subplugins/achievement.yml @@ -3,6 +3,14 @@ # - Silver [Long] # - Gold [Long] +login: + - 10 + - 30 + +consecutive_login: + - 10 + - 30 + break: - 100000 - 1000000 @@ -11,6 +19,10 @@ place: - 50000 - 250000 +flower: + - 25 + - 100 + ore: - 10000 - 50000 @@ -47,6 +59,14 @@ diamond: - 50 - 250 -flower: - - 25 - - 100 \ No newline at end of file +fishing: + - 30 + - 100 + +gacha: + - 50 + - 250 + +kill: + - 250 + - 1000 \ No newline at end of file From 8a60260a9cf681fc7c2686a9a384e1e0df554bda Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 23:21:23 +0900 Subject: [PATCH 10/36] =?UTF-8?q?=E3=81=93=E3=81=AE=E3=81=BB=E3=81=86?= =?UTF-8?q?=E3=81=8C=E8=A6=AA=E5=88=87=E3=81=8B=E3=82=82=E3=81=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/achievement/menu/item/ProgressMenuItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java index 5c32568a..17820f13 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressMenuItem.java @@ -23,7 +23,7 @@ public ProgressMenuItem(Integer row) { @Override public ItemProvider getItemProvider() { - return new ItemBuilder(Material.LIME_STAINED_GLASS_PANE).setDisplayName("§a進行状況を表示"); + return new ItemBuilder(Material.LIME_STAINED_GLASS_PANE).setDisplayName("§a"+row+"列目: 進行状況を表示"); } @Override From 08f6f3385648865605bdee86b03fb82115a9d1b7 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 23:27:37 +0900 Subject: [PATCH 11/36] =?UTF-8?q?=E3=82=A4=E3=83=A9=E3=83=B3import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/rankcounter/event/OreCountEvents.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java index 89458eac..f71cc55f 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/rankcounter/event/OreCountEvents.java @@ -1,7 +1,6 @@ package space.yurisi.universecorev2.subplugins.rankcounter.event; import org.bukkit.GameMode; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; From 17c7f41356c823e68301ecb6e4af8b3cbb1b4bb1 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 23:42:06 +0900 Subject: [PATCH 12/36] =?UTF-8?q?=E6=94=B9=E8=A1=8C=E8=AD=A6=E5=AF=9F?= =?UTF-8?q?=E5=BB=83=E6=A5=AD=E3=81=97=E3=82=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/subplugins/achievement.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/subplugins/achievement.yml b/src/main/resources/subplugins/achievement.yml index 676beeda..f1426383 100644 --- a/src/main/resources/subplugins/achievement.yml +++ b/src/main/resources/subplugins/achievement.yml @@ -69,4 +69,4 @@ gacha: kill: - 250 - - 1000 \ No newline at end of file + - 1000 From 74b761c277c60e77a2890544290fec14322cd817 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 23:46:11 +0900 Subject: [PATCH 13/36] =?UTF-8?q?=E6=94=B9=E8=A1=8C=E8=AD=A6=E5=AF=9F?= =?UTF-8?q?=E5=BB=83=E6=A5=AD=E3=81=97=E3=82=8Dpart2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3124d52b..5daff58b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -137,4 +137,4 @@ commands: # Achievement achievement: - description: 実績メニューを開きます \ No newline at end of file + description: 実績メニューを開きます From 65ff05a3d9c15f392cf6e9acb4d914684e39f437 Mon Sep 17 00:00:00 2001 From: syoyu Date: Sun, 27 Oct 2024 23:59:18 +0900 Subject: [PATCH 14/36] =?UTF-8?q?displayName=E3=81=84=E3=82=89=E3=81=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/AchievementManagerUndefinedException.java | 7 +++++++ .../subplugins/achievement/menu/AchievementMenu.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java diff --git a/src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java b/src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java new file mode 100644 index 00000000..34b73d09 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java @@ -0,0 +1,7 @@ +package space.yurisi.universecorev2.exception; + +public class AchievementManagerUndefinedException extends RuntimeException { + public AchievementManagerUndefinedException(String message) { + super(message); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java index 2fdbf018..54628e50 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/AchievementMenu.java @@ -20,7 +20,7 @@ public class AchievementMenu implements BaseMenu { @Override public void sendMenu(Player player) { - Item border = new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("§r")); + Item border = new SimpleItem(new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE)); Gui gui = PagedGui.items() .setStructure( "1 x x x x x x b b", From 207c327cf4f2f19484382b49cfd6ce18127f3d63 Mon Sep 17 00:00:00 2001 From: syoyu Date: Mon, 28 Oct 2024 00:04:34 +0900 Subject: [PATCH 15/36] =?UTF-8?q?GUI=E3=81=AE=E6=A8=AA=E5=B9=858=E3=81=A0?= =?UTF-8?q?=E3=81=A8=E5=8B=98=E9=81=95=E3=81=84=E3=81=97=E3=81=A6=E3=81=9F?= =?UTF-8?q?=E3=81=91=E3=81=A9=EF=BC=97=E3=81=A0=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/achievement/menu/ProgressMenu.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java index 7b5ad454..59a191ed 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java @@ -50,9 +50,9 @@ public void sendMenu(Player player) { AchievementData data = this.dataList.get(j); Long currentCount = data.getCurrentCount(); Long currentGoal = data.getCurrentGoal(); - int cell = (int) (currentGoal / 8); + int cell = (int) (currentGoal / 7); int achievedCells = (int) (currentCount / cell); - builder = builder.addContent(new ProgressBarItem((i % 8) <= achievedCells, data.getStage(), data.getItemName())); + builder = builder.addContent(new ProgressBarItem((i % 7) <= achievedCells, data.getStage(), data.getItemName())); } Window window = Window.single() From 4344e36e71b872441fb613785cf35decc757cfc8 Mon Sep 17 00:00:00 2001 From: syoyu Date: Tue, 29 Oct 2024 00:18:34 +0900 Subject: [PATCH 16/36] =?UTF-8?q?=E3=81=AA=E3=81=9C=E3=81=AEexception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/AchievementManagerUndefinedException.java | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java diff --git a/src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java b/src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java deleted file mode 100644 index 34b73d09..00000000 --- a/src/main/java/space/yurisi/universecorev2/exception/AchievementManagerUndefinedException.java +++ /dev/null @@ -1,7 +0,0 @@ -package space.yurisi.universecorev2.exception; - -public class AchievementManagerUndefinedException extends RuntimeException { - public AchievementManagerUndefinedException(String message) { - super(message); - } -} From 8cb3c13798715d96658035e9d3054ba698e1f94d Mon Sep 17 00:00:00 2001 From: syoyu Date: Wed, 30 Oct 2024 00:04:47 +0900 Subject: [PATCH 17/36] Naosita --- .../subplugins/achievement/menu/item/AchievementItem.java | 8 ++++++-- .../subplugins/achievement/menu/item/ProgressBarItem.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java index 364e591f..7b6e20c0 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/AchievementItem.java @@ -21,7 +21,11 @@ public AchievementItem(AchievementData data){ @Override public ItemProvider getItemProvider() { if(data == null) { - return new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE); + return new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE) + .setDisplayName("§c§l§n読み込みエラー") + .addLoreLines( + "運営に連絡してください" + ); } ItemBuilder builder = new ItemBuilder(data.getMaterial()) .setDisplayName(data.getItemName()); @@ -33,6 +37,6 @@ public ItemProvider getItemProvider() { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent inventoryClickEvent) { - //クリックで実績解除報酬をプレゼント!とかあったらいいなと思った午前2時 + // TODO: 実績解除報酬を追加する } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java index 0790fe28..f705535f 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/item/ProgressBarItem.java @@ -28,9 +28,9 @@ public ProgressBarItem(boolean isAchieved, String stage, String name) { public ItemProvider getItemProvider() { Material material; if(Objects.equals(stage, AchievementDataManager.Achievement_NORMAL)){ - material = isAchieved ? Material.LIGHT_BLUE_STAINED_GLASS_PANE:Material.LIGHT_GRAY_STAINED_GLASS_PANE; + material = isAchieved ? Material.LIGHT_BLUE_STAINED_GLASS_PANE : Material.LIGHT_GRAY_STAINED_GLASS_PANE; }else{ - material = isAchieved ? Material.BLUE_STAINED_GLASS_PANE:Material.LIGHT_BLUE_STAINED_GLASS_PANE; + material = isAchieved ? Material.BLUE_STAINED_GLASS_PANE : Material.LIGHT_BLUE_STAINED_GLASS_PANE; } return new ItemBuilder(material).setDisplayName(name); } From 4832ee0d840a57a66764656d37483fa53b6eebf9 Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 31 Oct 2024 15:55:43 +0900 Subject: [PATCH 18/36] =?UTF-8?q?=E3=83=9B=E3=83=83=E3=83=88=E3=83=90?= =?UTF-8?q?=E3=83=BC=E6=89=80=E6=8C=81=E5=88=B6=E9=99=90=E3=81=AE=E8=A9=A6?= =?UTF-8?q?=E9=A8=93=E7=9A=84=E5=AE=9F=E8=A3=85&=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=90=E3=83=BC=E3=81=AE=E3=83=90?= =?UTF-8?q?=E3=82=B0=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yurisi/universecorev2/item/gun/F2.java | 1 + .../yurisi/universecorev2/item/gun/Gun.java | 16 ++ .../yurisi/universecorev2/item/gun/L96A1.java | 1 + .../yurisi/universecorev2/item/gun/M1911.java | 1 + .../yurisi/universecorev2/item/gun/M870.java | 1 + .../yurisi/universecorev2/item/gun/R4C.java | 1 + .../yurisi/universecorev2/item/gun/RPG.java | 1 + .../yurisi/universecorev2/item/gun/SMG11.java | 1 + .../universeguns/constants/GunType.java | 4 +- .../universeguns/event/GunEvent.java | 241 ++++++++++++++---- 10 files changed, 221 insertions(+), 47 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/F2.java b/src/main/java/space/yurisi/universecorev2/item/gun/F2.java index 7b43d00a..bdd8115e 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/F2.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/F2.java @@ -19,6 +19,7 @@ public F2() { ); this.type = GunType.AR; + this.equipmentType = GunType.PRIMARY; this.magazineSize = 30; this.burst = 2; this.reloadTime = 3500; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java index 59e9fc2a..e44f252b 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java @@ -20,6 +20,8 @@ public abstract class Gun extends CustomItem { protected GunType type; + protected GunType equipmentType; + protected int magazineSize; protected int burst; @@ -71,6 +73,10 @@ public GunType getType(){ return this.type; } + public GunType getEquipmentType(){ + return this.equipmentType; + } + public int getMagazineSize(){ return this.magazineSize; } @@ -184,8 +190,18 @@ public ItemStack getItem(){ category += "特殊系"; break; } + String equipmentCategory = "§7装備カテゴリ: "; + switch (equipmentType){ + case PRIMARY: + equipmentCategory += "プライマリ"; + break; + case SECONDARY: + equipmentCategory += "セカンダリ"; + break; + } List lore = List.of( Component.text(category), + Component.text(equipmentCategory), Component.text("§7マガジンサイズ: " + magazineSize), Component.text("§7リロード時間: " + (double)reloadTime/1000 + "s"), Component.text(flavorText) diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java index 7933af89..86836467 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java @@ -18,6 +18,7 @@ public L96A1() { ); this.type = GunType.SR; + this.equipmentType = GunType.PRIMARY; this.magazineSize = 5; this.burst = 0; this.reloadTime = 5000; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java b/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java index 145cf900..cbc0998d 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java @@ -19,6 +19,7 @@ public M1911(){ ); this.type = GunType.HG; + this.equipmentType = GunType.SECONDARY; this.magazineSize = 7; this.burst = 0; this.reloadTime = 800; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/M870.java b/src/main/java/space/yurisi/universecorev2/item/gun/M870.java index a677981e..4fad6ff9 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/M870.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/M870.java @@ -19,6 +19,7 @@ public M870() { ); this.type = GunType.SG; + this.equipmentType = GunType.PRIMARY; this.magazineSize = 7; this.burst = 0; this.reloadTime = 4000; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java b/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java index 0a9ea066..0cffe5f8 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java @@ -18,6 +18,7 @@ public R4C() { ); this.type = GunType.AR; + this.equipmentType = GunType.PRIMARY; this.magazineSize = 30; this.burst = 0; this.reloadTime = 2500; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java b/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java index b6bdf07a..287caa51 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java @@ -19,6 +19,7 @@ public RPG() { ); this.type = GunType.EX; + this.equipmentType = GunType.PRIMARY; this.magazineSize = 1; this.burst = 0; this.reloadTime = 10000; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java b/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java index c5503beb..c5feff1c 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java @@ -18,6 +18,7 @@ public SMG11() { ); this.type = GunType.SMG; + this.equipmentType = GunType.SECONDARY; this.magazineSize = 16; this.burst = 0; this.reloadTime = 800; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java index d577b32f..c2a8ffd3 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java @@ -8,7 +8,9 @@ public enum GunType { SG(30), HG(40), LMG(50), - EX(60); + EX(60), + PRIMARY(70), + SECONDARY(71); private int id; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index 1cb2ef3a..11ab9543 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -11,6 +11,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; @@ -40,10 +41,7 @@ import space.yurisi.universecorev2.subplugins.universeguns.menu.AmmoManagerInventoryMenu; import space.yurisi.universecorev2.utils.Message; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; +import java.util.*; public class GunEvent implements Listener { @@ -398,48 +396,7 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { ItemStack oldInHand = player.getInventory().getItem(event.getPreviousSlot()); if (oldInHand != null && oldInHand.hasItemMeta()) { - ItemMeta oldMeta = oldInHand.getItemMeta(); - PersistentDataContainer oldContainer = oldMeta.getPersistentDataContainer(); - NamespacedKey oldItemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - NamespacedKey gunSerialKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_SERIAL); - if (!Gun.isGun(oldInHand)) { - return; - } - - String oldHandItemID = oldContainer.get(oldItemKey, PersistentDataType.STRING); - String oldGunSerial = oldContainer.get(gunSerialKey, PersistentDataType.STRING); - CustomItem oldGunItem = UniverseItem.getItem(oldHandItemID); - - if (!(oldGunItem instanceof Gun oldGun)) { - return; - } - - if(!connector.isExistsAmmoData(player)){ - try { - connector.AmmoDataInit(player); - } catch (UserNotFoundException e) { - Message.sendErrorMessage(player, "[武器AI]", "ユーザーが見つかりませんでした。"); - } - } - - if (!GunStatusManager.isExists(oldGunSerial)) { - GunStatusManager.register(oldGunSerial, oldGun, connector); - } - - GunStatus oldGunStatus = GunStatusManager.get(oldGunSerial); - try { - oldGunStatus.updateAmmo(player, isZoom.contains(player)); - } catch (UserNotFoundException | AmmoNotFoundException e) { - throw new RuntimeException(e); - } - - if (reloadingTasks.containsKey(player)) { - taskCancel(reloadingTasks, player); - oldGunStatus.cancelReload(); - oldGunStatus.updateActionBar(player, false); - } - - + cancelOldGun(oldInHand, player); } ItemStack newInHand = player.getInventory().getItem(event.getNewSlot()); @@ -498,6 +455,49 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { } } + private void cancelOldGun(ItemStack oldInHand, Player player) { + ItemMeta oldMeta = oldInHand.getItemMeta(); + PersistentDataContainer oldContainer = oldMeta.getPersistentDataContainer(); + NamespacedKey oldItemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + NamespacedKey gunSerialKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_SERIAL); + if (!Gun.isGun(oldInHand)) { + return; + } + + String oldHandItemID = oldContainer.get(oldItemKey, PersistentDataType.STRING); + String oldGunSerial = oldContainer.get(gunSerialKey, PersistentDataType.STRING); + CustomItem oldGunItem = UniverseItem.getItem(oldHandItemID); + + if (!(oldGunItem instanceof Gun oldGun)) { + return; + } + + if(!connector.isExistsAmmoData(player)){ + try { + connector.AmmoDataInit(player); + } catch (UserNotFoundException e) { + Message.sendErrorMessage(player, "[武器AI]", "ユーザーが見つかりませんでした。"); + } + } + + if (!GunStatusManager.isExists(oldGunSerial)) { + GunStatusManager.register(oldGunSerial, oldGun, connector); + } + + GunStatus oldGunStatus = GunStatusManager.get(oldGunSerial); + try { + oldGunStatus.updateAmmo(player, isZoom.contains(player)); + } catch (UserNotFoundException | AmmoNotFoundException e) { + throw new RuntimeException(e); + } + + if (reloadingTasks.containsKey(player)) { + taskCancel(reloadingTasks, player); + oldGunStatus.cancelReload(); + oldGunStatus.updateActionBar(player, false); + } + } + @EventHandler public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { ItemStack offHandItem = event.getOffHandItem(); @@ -666,12 +666,161 @@ public void run() { @EventHandler public void onInventoryClick(InventoryClickEvent event) { if (event.getWhoClicked() instanceof Player player) { + ItemStack item = event.getCurrentItem(); + if (item == null || !item.hasItemMeta()) { + return; + } + if(!Gun.isGun(item)){ + return; + } + if (reloadingTasks.containsKey(player)) { event.setCancelled(true); + return; + } + + int destinationSlot = event.getRawSlot(); + if(destinationSlot == 40){ + // オフハンド + Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); + event.setCancelled(true); + return; + } + + if(destinationSlot > 8) { + return; + } + + boolean[] result = checkEquipmentLimit(player); + if(!result[0] && !result[1]){ + Message.sendWarningMessage(player, "[武器AI]", "これ以上武器を持つことはできません。"); + event.setCancelled(true); + return; + } + + ItemMeta meta = item.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + String clickedItemID = container.get(itemKey, PersistentDataType.STRING); + CustomItem clickedGunItem = UniverseItem.getItem(clickedItemID); + if(!(clickedGunItem instanceof Gun clickedGun)){ + return; + } + + if(clickedGun.getEquipmentType() == GunType.PRIMARY && !result[0]){ + Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); + event.setCancelled(true); + }else if(clickedGun.getEquipmentType() == GunType.SECONDARY && !result[1]){ + Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); + event.setCancelled(true); + } + } + } + + + @EventHandler(priority = EventPriority.LOW) + public void onPlayerPickupItem(EntityPickupItemEvent event) { + if (!(event.getEntity() instanceof Player player)) { + return; + } + ItemStack item = event.getItem().getItemStack(); + if (!item.hasItemMeta()) { + return; + } + if (!Gun.isGun(item)) { + return; + } + + ItemMeta meta = item.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + + String handItemID = container.get(itemKey, PersistentDataType.STRING); + CustomItem gunItem = UniverseItem.getItem(handItemID); + + if (!(gunItem instanceof Gun gun)) { + return; + } + + boolean[] result = checkEquipmentLimit(player); + if(result[0] && result[1]){ + return; + } + int emptySlot = -1; + ItemStack[] contents = player.getInventory().getContents(); + boolean isHotbarFull = Arrays.stream(contents, 0, 9).allMatch(Objects::isNull); + if (isHotbarFull) { + return; + } + + for (int i = 9; i < contents.length; i++) { + if (contents[i] == null) { + emptySlot = i; + break; + } + } + if(emptySlot == -1){ + if(!result[0] && gun.getEquipmentType() == GunType.PRIMARY) { + Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); + event.setCancelled(true); + }else if(!result[1] && gun.getEquipmentType() == GunType.SECONDARY){ + Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); + event.setCancelled(true); + } + } else { + if((!result[0] && gun.getEquipmentType() == GunType.PRIMARY) || (!result[1] && gun.getEquipmentType() == GunType.SECONDARY)) { + player.getInventory().setItem(emptySlot, item); + event.getItem().remove(); + event.setCancelled(true); } } } + private boolean[] checkEquipmentLimit(Player player){ + int primaryLimit = 1; + int secondaryLimit = 1; + int[] hotbarCount = scanHotbar(player); + boolean[] result = new boolean[2]; + // 超えてたらfalse + result[0] = hotbarCount[0] < primaryLimit; + result[1] = hotbarCount[1] < secondaryLimit; + return result; + } + + private int[] scanHotbar(Player player){ + int primaryCount = 0; + int secondaryCount = 0; + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + + for (ItemStack item : player.getInventory().getContents()) { + if (item == null || !item.hasItemMeta()) { + continue; + } + + ItemMeta meta = item.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + + if (!Gun.isGun(item)) { + continue; + } + + String handItemID = container.get(itemKey, PersistentDataType.STRING); + CustomItem gunItem = UniverseItem.getItem(handItemID); + + if (!(gunItem instanceof Gun gun)) { + continue; + } + + if (gun.getEquipmentType() == GunType.PRIMARY) { + primaryCount++; + } else if (gun.getEquipmentType() == GunType.SECONDARY) { + secondaryCount++; + } + } + + return new int[]{primaryCount, secondaryCount}; + } + @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { Player player = event.getPlayer(); From eb3f4a606fe0a7902d6dcf14083d29103eacfe17 Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 31 Oct 2024 16:21:01 +0900 Subject: [PATCH 19/36] =?UTF-8?q?=E3=82=BF=E3=82=AF=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=82=AB=E3=83=AB=E3=83=99=E3=82=B9=E3=83=88=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../item/gun/TacticalLeggings.java | 9 +++- .../universecorev2/item/gun/TacticalVest.java | 45 +++++++++++++++++++ .../universeguns/event/GunEvent.java | 18 +++++++- 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalLeggings.java b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalLeggings.java index 4e78b22f..11464838 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalLeggings.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalLeggings.java @@ -1,14 +1,16 @@ package space.yurisi.universecorev2.item.gun; import net.kyori.adventure.text.Component; +import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; import space.yurisi.universecorev2.item.CustomItem; -import java.awt.*; import java.util.List; +import java.util.Random; public class TacticalLeggings extends CustomItem { @@ -25,7 +27,7 @@ public TacticalLeggings() { @Override protected void registerItemFunction() { default_setting = (item) -> { - ItemMeta meta = item.getItemMeta(); + LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); if (meta != null) { meta.addEnchant(Enchantment.UNBREAKING, 4, true); List lore = List.of( @@ -33,6 +35,9 @@ protected void registerItemFunction() { Component.text("§7装備することでリロード速度が上昇する") ); meta.lore(lore); + Random random = new Random(); + Color colour = Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)); + meta.setColor(colour); item.setItemMeta(meta); } return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java new file mode 100644 index 00000000..38dad94b --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java @@ -0,0 +1,45 @@ +package space.yurisi.universecorev2.item.gun; + +import net.kyori.adventure.text.Component; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import space.yurisi.universecorev2.item.CustomItem; + +import java.util.List; +import java.util.Random; + +public class TacticalVest extends CustomItem { + + public static final String id = "tactical_vest"; + + public TacticalVest() { + super( + id, + "§dタクティカルベスト", + ItemStack.of(Material.LEATHER_CHESTPLATE) + ); + } + + @Override + protected void registerItemFunction() { + default_setting = (item) -> { + LeatherArmorMeta leatherMeta = (LeatherArmorMeta) item.getItemMeta(); + if (leatherMeta != null) { + leatherMeta.addEnchant(Enchantment.UNBREAKING, 4, true); + List lore = List.of( + Component.text("§7銃やマガジンを装備するアタッチメントのあるベスト"), + Component.text("§7リロード速度上昇とセカンダリの所持枠が§d1§7増加") + ); + leatherMeta.lore(lore); + Random random = new Random(); + Color colour = Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)); + leatherMeta.setColor(colour); + item.setItemMeta(leatherMeta); + } + return item; + }; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index 11ab9543..3486de8c 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -608,10 +608,15 @@ private void startReload(Player player, Gun gun, GunStatus gunStatus) { ItemMeta meta = leggings.getItemMeta(); PersistentDataContainer container = meta.getPersistentDataContainer(); NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + double reloadTimeCoefficient = 1.0; if (container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_leggings")) { - double newReloadTime = reloadTime * 0.7; - reloadTime = (int) newReloadTime; + reloadTimeCoefficient -= 0.3; } + if (container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")) { + reloadTimeCoefficient -= 0.1; + } + double newReloadTime = reloadTime * reloadTimeCoefficient; + reloadTime = (int) newReloadTime; } boolean result = gunStatus.startReload(reloadTime, player); @@ -779,6 +784,15 @@ public void onPlayerPickupItem(EntityPickupItemEvent event) { private boolean[] checkEquipmentLimit(Player player){ int primaryLimit = 1; int secondaryLimit = 1; + ItemStack chestplate = player.getInventory().getChestplate(); + if(chestplate != null && chestplate.hasItemMeta()){ + ItemMeta meta = chestplate.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + if(container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")){ + secondaryLimit = 2; + } + } int[] hotbarCount = scanHotbar(player); boolean[] result = new boolean[2]; // 超えてたらfalse From 96dac06af52833eeb1892cb3f11224bc1c63fcbc Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 31 Oct 2024 16:40:20 +0900 Subject: [PATCH 20/36] =?UTF-8?q?import=E5=91=A8=E3=82=8A=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/universeguns/command/GunCommand.java | 1 - .../universeguns/connector/UniverseCoreAPIConnector.java | 5 ----- .../subplugins/universeguns/event/GunEvent.java | 6 +++++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java index e176ac49..1cc770df 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java @@ -8,7 +8,6 @@ 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 { diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/connector/UniverseCoreAPIConnector.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/connector/UniverseCoreAPIConnector.java index c1c0f75d..aad9d467 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/connector/UniverseCoreAPIConnector.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/connector/UniverseCoreAPIConnector.java @@ -1,17 +1,12 @@ package space.yurisi.universecorev2.subplugins.universeguns.connector; -import org.bukkit.Location; import org.bukkit.entity.Player; import space.yurisi.universecorev2.database.DatabaseManager; -import space.yurisi.universecorev2.database.models.Ammo; -import space.yurisi.universecorev2.database.models.User; import space.yurisi.universecorev2.database.repositories.AmmoRepository; -import space.yurisi.universecorev2.database.repositories.MoneyRepository; import space.yurisi.universecorev2.database.repositories.UserRepository; import space.yurisi.universecorev2.exception.AmmoNotFoundException; import space.yurisi.universecorev2.exception.UserNotFoundException; import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; -import space.yurisi.universecorev2.utils.Message; public class UniverseCoreAPIConnector { diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index 3486de8c..f5345c96 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -41,7 +41,11 @@ import space.yurisi.universecorev2.subplugins.universeguns.menu.AmmoManagerInventoryMenu; import space.yurisi.universecorev2.utils.Message; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.Arrays; public class GunEvent implements Listener { From b0e68bda79911c22e6b537741a257e1e7cf398f7 Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 31 Oct 2024 17:07:56 +0900 Subject: [PATCH 21/36] =?UTF-8?q?isGun=E3=81=82=E3=81=9F=E3=82=8A=E3=82=92?= =?UTF-8?q?=E6=95=B4=E7=90=86=E3=81=97=E3=81=A6=E3=81=BF=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yurisi/universecorev2/item/gun/Gun.java | 12 +- .../universeguns/event/GunEvent.java | 106 ++++-------------- 2 files changed, 29 insertions(+), 89 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java index e44f252b..22d2dec4 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java @@ -11,6 +11,7 @@ import space.yurisi.universecorev2.UniverseCoreV2; import space.yurisi.universecorev2.constants.UniverseItemKeyString; import space.yurisi.universecorev2.item.CustomItem; +import space.yurisi.universecorev2.item.UniverseItem; import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; import java.util.List; @@ -209,7 +210,7 @@ public ItemStack getItem(){ return lore; } - public static boolean isGun(ItemStack itemStack){ + public static Gun getGun(ItemStack itemStack){ ItemMeta meta = itemStack.getItemMeta(); PersistentDataContainer container = meta.getPersistentDataContainer(); @@ -222,8 +223,13 @@ public static boolean isGun(ItemStack itemStack){ || !container.has(gunKey, PersistentDataType.BOOLEAN) || !container.has(gunSerialKey, PersistentDataType.STRING) ){ - return false; + return null; } - return true; + String itemID = container.get(itemKey, PersistentDataType.STRING); + CustomItem item = UniverseItem.getItem(itemID); + if((item instanceof Gun gun)){ + return gun; + } + return null; } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index f5345c96..3f6d6034 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -92,19 +92,13 @@ public void onPlayerInteract(PlayerInteractEvent event) { return; } - if (!Gun.isGun(itemInHand)) { + Gun gun = Gun.getGun(itemInHand); + if(gun == null){ return; } - String handItemID = container.get(itemKey, PersistentDataType.STRING); String gunSerial = container.get(gunSerialKey, PersistentDataType.STRING); - CustomItem gunItem = UniverseItem.getItem(handItemID); - - if (!(gunItem instanceof Gun gun)) { - return; - } - if (!GunStatusManager.isExists(gunSerial)) { GunStatusManager.register(gunSerial, gun, connector); } @@ -416,7 +410,8 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { NamespacedKey newItemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); NamespacedKey gunSerialKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_SERIAL); - if (!Gun.isGun(newInHand)) { + Gun gun = Gun.getGun(newInHand); + if (gun == null) { player.setWalkSpeed(0.2f); return; } @@ -462,19 +457,13 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { private void cancelOldGun(ItemStack oldInHand, Player player) { ItemMeta oldMeta = oldInHand.getItemMeta(); PersistentDataContainer oldContainer = oldMeta.getPersistentDataContainer(); - NamespacedKey oldItemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); NamespacedKey gunSerialKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_SERIAL); - if (!Gun.isGun(oldInHand)) { + Gun oldGun = Gun.getGun(oldInHand); + if (oldGun == null) { return; } - String oldHandItemID = oldContainer.get(oldItemKey, PersistentDataType.STRING); String oldGunSerial = oldContainer.get(gunSerialKey, PersistentDataType.STRING); - CustomItem oldGunItem = UniverseItem.getItem(oldHandItemID); - - if (!(oldGunItem instanceof Gun oldGun)) { - return; - } if(!connector.isExistsAmmoData(player)){ try { @@ -506,23 +495,14 @@ private void cancelOldGun(ItemStack oldInHand, Player player) { public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { ItemStack offHandItem = event.getOffHandItem(); if (offHandItem.hasItemMeta()) { - ItemMeta meta = offHandItem.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - NamespacedKey gunKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN); - if (!Gun.isGun(offHandItem)) { - return; - } - String handItemID = container.get(itemKey, PersistentDataType.STRING); - CustomItem gunItem = UniverseItem.getItem(handItemID); - if (!(gunItem instanceof Gun)) { + Gun gun = Gun.getGun(offHandItem); + if (gun == null) { return; } event.setCancelled(true); Message.sendWarningMessage(event.getPlayer(), "[武器AI]", "オフハンドに武器を持つことはできません。"); - } } @@ -567,23 +547,12 @@ public void onPlayerJump(PlayerMoveEvent event) { } ItemStack itemInHand = player.getInventory().getItemInMainHand(); - ItemMeta meta = itemInHand.getItemMeta(); if (!itemInHand.hasItemMeta()) { return; } - PersistentDataContainer container = meta.getPersistentDataContainer(); - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - NamespacedKey gunKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN); - - if (!Gun.isGun(itemInHand)) { - return; - } - - String handItemID = container.get(itemKey, PersistentDataType.STRING); - CustomItem gunItem = UniverseItem.getItem(handItemID); - - if (!(gunItem instanceof Gun gun)) { + Gun gun = Gun.getGun(itemInHand); + if (gun == null) { return; } @@ -679,7 +648,8 @@ public void onInventoryClick(InventoryClickEvent event) { if (item == null || !item.hasItemMeta()) { return; } - if(!Gun.isGun(item)){ + Gun gun = Gun.getGun(item); + if(gun == null){ return; } @@ -707,19 +677,10 @@ public void onInventoryClick(InventoryClickEvent event) { return; } - ItemMeta meta = item.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - String clickedItemID = container.get(itemKey, PersistentDataType.STRING); - CustomItem clickedGunItem = UniverseItem.getItem(clickedItemID); - if(!(clickedGunItem instanceof Gun clickedGun)){ - return; - } - - if(clickedGun.getEquipmentType() == GunType.PRIMARY && !result[0]){ + if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); event.setCancelled(true); - }else if(clickedGun.getEquipmentType() == GunType.SECONDARY && !result[1]){ + }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); event.setCancelled(true); } @@ -736,18 +697,8 @@ public void onPlayerPickupItem(EntityPickupItemEvent event) { if (!item.hasItemMeta()) { return; } - if (!Gun.isGun(item)) { - return; - } - - ItemMeta meta = item.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - - String handItemID = container.get(itemKey, PersistentDataType.STRING); - CustomItem gunItem = UniverseItem.getItem(handItemID); - - if (!(gunItem instanceof Gun gun)) { + Gun gun = Gun.getGun(item); + if (gun == null) { return; } @@ -808,24 +759,14 @@ private boolean[] checkEquipmentLimit(Player player){ private int[] scanHotbar(Player player){ int primaryCount = 0; int secondaryCount = 0; - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); for (ItemStack item : player.getInventory().getContents()) { if (item == null || !item.hasItemMeta()) { continue; } - ItemMeta meta = item.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); - - if (!Gun.isGun(item)) { - continue; - } - - String handItemID = container.get(itemKey, PersistentDataType.STRING); - CustomItem gunItem = UniverseItem.getItem(handItemID); - - if (!(gunItem instanceof Gun gun)) { + Gun gun = Gun.getGun(item); + if (gun == null) { continue; } @@ -848,17 +789,10 @@ public void onPlayerDropItem(PlayerDropItemEvent event) { return; } PersistentDataContainer container = meta.getPersistentDataContainer(); - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); NamespacedKey gunSerialKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_SERIAL); - if (!Gun.isGun(droppedItem)) { - return; - } - - String handItemID = container.get(itemKey, PersistentDataType.STRING); - CustomItem gunItem = UniverseItem.getItem(handItemID); - - if (!(gunItem instanceof Gun gun)) { + Gun gun = Gun.getGun(droppedItem); + if (gun == null) { return; } From 814cab764568e1cce26ae7ea67e4409f7c60b946 Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 31 Oct 2024 23:06:01 +0900 Subject: [PATCH 22/36] =?UTF-8?q?=E3=83=9B=E3=83=83=E3=83=88=E3=83=90?= =?UTF-8?q?=E3=83=BC=E5=88=B6=E9=99=90=E3=81=82=E3=81=8D=E3=82=89=E3=82=81?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../universecorev2/item/UniverseItem.java | 1 + .../universecorev2/item/gun/TacticalVest.java | 3 +- .../universeguns/event/GunEvent.java | 321 ++++++++++-------- 3 files changed, 182 insertions(+), 143 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java b/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java index 2ac59298..ae8af03e 100644 --- a/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java +++ b/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java @@ -52,6 +52,7 @@ public void register(){ items.put(M1911.id, new M1911()); items.put(MagazineBag.id, new MagazineBag()); items.put(TacticalLeggings.id, new TacticalLeggings()); + items.put(TacticalVest.id, new TacticalVest()); items.put(MainMenuBook.id, new MainMenuBook()); } diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java index 38dad94b..450fb1f8 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java @@ -31,7 +31,8 @@ protected void registerItemFunction() { leatherMeta.addEnchant(Enchantment.UNBREAKING, 4, true); List lore = List.of( Component.text("§7銃やマガジンを装備するアタッチメントのあるベスト"), - Component.text("§7リロード速度上昇とセカンダリの所持枠が§d1§7増加") +// Component.text("§7リロード速度上昇とセカンダリの所持枠が§d1§7増加") + Component.text("§7リロード速度上昇") ); leatherMeta.lore(lore); Random random = new Random(); diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index 3f6d6034..4bba8eca 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -264,7 +264,7 @@ public void onPlayerHit(EntityDamageByEntityEvent event) { isHandlingExplosion.set(true); try { snowball.getWorld().createExplosion(loc, radius, false, false, snowball); - snowball.getWorld().spawnParticle(Particle.EXPLOSION, loc, 1); + snowball.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, loc, 1); } finally { isHandlingExplosion.set(false); } @@ -339,7 +339,7 @@ public void onBlockHit(ProjectileHitEvent event) { try { snowball.getWorld().createExplosion(loc, radius, false, false, snowball); - snowball.getWorld().spawnParticle(Particle.EXPLOSION, loc, 1); + snowball.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, loc, 1); } finally { isHandlingExplosion.set(false); } @@ -583,10 +583,10 @@ private void startReload(Player player, Gun gun, GunStatus gunStatus) { NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); double reloadTimeCoefficient = 1.0; if (container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_leggings")) { - reloadTimeCoefficient -= 0.3; + reloadTimeCoefficient -= 0.2; } if (container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")) { - reloadTimeCoefficient -= 0.1; + reloadTimeCoefficient -= 0.3; } double newReloadTime = reloadTime * reloadTimeCoefficient; reloadTime = (int) newReloadTime; @@ -641,144 +641,181 @@ public void run() { } - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - if (event.getWhoClicked() instanceof Player player) { - ItemStack item = event.getCurrentItem(); - if (item == null || !item.hasItemMeta()) { - return; - } - Gun gun = Gun.getGun(item); - if(gun == null){ - return; - } - - if (reloadingTasks.containsKey(player)) { - event.setCancelled(true); - return; - } - - int destinationSlot = event.getRawSlot(); - if(destinationSlot == 40){ - // オフハンド - Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); - event.setCancelled(true); - return; - } - - if(destinationSlot > 8) { - return; - } - - boolean[] result = checkEquipmentLimit(player); - if(!result[0] && !result[1]){ - Message.sendWarningMessage(player, "[武器AI]", "これ以上武器を持つことはできません。"); - event.setCancelled(true); - return; - } - - if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ - Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); - event.setCancelled(true); - }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ - Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); - event.setCancelled(true); - } - } - } - - - @EventHandler(priority = EventPriority.LOW) - public void onPlayerPickupItem(EntityPickupItemEvent event) { - if (!(event.getEntity() instanceof Player player)) { - return; - } - ItemStack item = event.getItem().getItemStack(); - if (!item.hasItemMeta()) { - return; - } - Gun gun = Gun.getGun(item); - if (gun == null) { - return; - } - - boolean[] result = checkEquipmentLimit(player); - if(result[0] && result[1]){ - return; - } - int emptySlot = -1; - ItemStack[] contents = player.getInventory().getContents(); - boolean isHotbarFull = Arrays.stream(contents, 0, 9).allMatch(Objects::isNull); - if (isHotbarFull) { - return; - } - - for (int i = 9; i < contents.length; i++) { - if (contents[i] == null) { - emptySlot = i; - break; - } - } - if(emptySlot == -1){ - if(!result[0] && gun.getEquipmentType() == GunType.PRIMARY) { - Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); - event.setCancelled(true); - }else if(!result[1] && gun.getEquipmentType() == GunType.SECONDARY){ - Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); - event.setCancelled(true); - } - } else { - if((!result[0] && gun.getEquipmentType() == GunType.PRIMARY) || (!result[1] && gun.getEquipmentType() == GunType.SECONDARY)) { - player.getInventory().setItem(emptySlot, item); - event.getItem().remove(); - event.setCancelled(true); - } - } - } - - private boolean[] checkEquipmentLimit(Player player){ - int primaryLimit = 1; - int secondaryLimit = 1; - ItemStack chestplate = player.getInventory().getChestplate(); - if(chestplate != null && chestplate.hasItemMeta()){ - ItemMeta meta = chestplate.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); - NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - if(container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")){ - secondaryLimit = 2; - } - } - int[] hotbarCount = scanHotbar(player); - boolean[] result = new boolean[2]; - // 超えてたらfalse - result[0] = hotbarCount[0] < primaryLimit; - result[1] = hotbarCount[1] < secondaryLimit; - return result; - } - - private int[] scanHotbar(Player player){ - int primaryCount = 0; - int secondaryCount = 0; - - for (ItemStack item : player.getInventory().getContents()) { - if (item == null || !item.hasItemMeta()) { - continue; - } - - Gun gun = Gun.getGun(item); - if (gun == null) { - continue; - } - - if (gun.getEquipmentType() == GunType.PRIMARY) { - primaryCount++; - } else if (gun.getEquipmentType() == GunType.SECONDARY) { - secondaryCount++; - } - } - - return new int[]{primaryCount, secondaryCount}; - } +// @EventHandler +// public void onInventoryClick(InventoryClickEvent event) { +// if (event.getWhoClicked() instanceof Player player) { +// player.sendMessage("called"); +// int destinationSlot = event.getRawSlot(); +// int slot = event.getSlot(); +// ItemStack item = event.getCurrentItem(); +// if(item != null && item.hasItemMeta()){ +// Gun newGun = Gun.getGun(item); +// if(newGun != null){ +// player.getInventory().setItem(slot, null); +// return; +// } +// } +// +// ItemStack oldItem = event.getCursor(); +// if (!oldItem.hasItemMeta()) { +// return; +// } +// Gun gun = Gun.getGun(oldItem); +// if(gun == null){ +// return; +// } +// +// if (reloadingTasks.containsKey(player)) { +// event.setCancelled(true); +// return; +// } +// +// if(destinationSlot == 45){ +// // オフハンド +// Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); +// event.setCancelled(true); +// putGunToEmptySlot(player, oldItem); +// return; +// } +// if(destinationSlot <= 35) { +// return; +// } +// +// boolean[] result = checkEquipmentLimit(player); +// if(!result[0] && !result[1]){ +// event.setCancelled(true); +// Message.sendWarningMessage(player, "[武器AI]", "これ以上武器を持つことはできません。"); +// putGunToEmptySlot(player, oldItem); +// +// return; +// } +// +// if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ +// event.setCancelled(true); +// Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); +// putGunToEmptySlot(player, oldItem); +// }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ +// event.setCancelled(true); +// Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); +// putGunToEmptySlot(player, oldItem); +// } +// player.updateInventory(); +// } +// } +// +// private void putGunToEmptySlot(Player player, ItemStack item){ +// ItemStack[] contents = player.getInventory().getContents(); +// int emptySlot = -1; +// +// for (int i = 9; i < 36; i++) { +// if (contents[i] == null) { +// emptySlot = i; +// break; +// }else{ +// player.sendMessage(contents[i].toString()); +// } +// } +// if(emptySlot == -1){ +// player.getWorld().dropItemNaturally(player.getLocation(), item); +// return; +// } +// player.getInventory().setItem(emptySlot, item); +// } +// +// +// @EventHandler(priority = EventPriority.LOW) +// public void onPlayerPickupItem(EntityPickupItemEvent event) { +// if (!(event.getEntity() instanceof Player player)) { +// return; +// } +// ItemStack item = event.getItem().getItemStack(); +// if (!item.hasItemMeta()) { +// return; +// } +// Gun gun = Gun.getGun(item); +// if (gun == null) { +// return; +// } +// +// boolean[] result = checkEquipmentLimit(player); +// if(result[0] && result[1]){ +// return; +// } +// int emptySlot = -1; +// ItemStack[] contents = player.getInventory().getContents(); +// boolean isHotbarFull = Arrays.stream(contents, 0, 9).allMatch(Objects::isNull); +// if (isHotbarFull) { +// return; +// } +// +// for (int i = 9; i < 36; i++) { +// if (contents[i] == null) { +// emptySlot = i; +// break; +// } +// } +// if(emptySlot == -1){ +// if(!result[0] && gun.getEquipmentType() == GunType.PRIMARY) { +// Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); +// event.setCancelled(true); +// }else if(!result[1] && gun.getEquipmentType() == GunType.SECONDARY){ +// Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); +// event.setCancelled(true); +// } +// } else { +// if((!result[0] && gun.getEquipmentType() == GunType.PRIMARY) || (!result[1] && gun.getEquipmentType() == GunType.SECONDARY)) { +// player.getInventory().setItem(emptySlot, item); +// event.getItem().remove(); +// event.setCancelled(true); +// player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0F, 1.0F); +// } +// } +// } +// +// private boolean[] checkEquipmentLimit(Player player){ +// int primaryLimit = 1; +// int secondaryLimit = 1; +// ItemStack chestplate = player.getInventory().getChestplate(); +// if(chestplate != null && chestplate.hasItemMeta()){ +// ItemMeta meta = chestplate.getItemMeta(); +// PersistentDataContainer container = meta.getPersistentDataContainer(); +// NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); +// if(container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")){ +// secondaryLimit = 2; +// } +// } +// int[] hotbarCount = scanHotbar(player); +// boolean[] result = new boolean[2]; +// // 超えてたらfalse +// result[0] = hotbarCount[0] < primaryLimit; +// result[1] = hotbarCount[1] < secondaryLimit; +// return result; +// } +// +// private int[] scanHotbar(Player player){ +// int primaryCount = 0; +// int secondaryCount = 0; +// +// for (int i = 0; i < 9; i++) { +// ItemStack item = player.getInventory().getItem(i); +// if (item == null || !item.hasItemMeta()) { +// continue; +// } +// +// Gun gun = Gun.getGun(item); +// if (gun == null) { +// continue; +// } +// +// if (gun.getEquipmentType() == GunType.PRIMARY) { +// primaryCount++; +// } else if (gun.getEquipmentType() == GunType.SECONDARY) { +// secondaryCount++; +// } +// } +// +// return new int[]{primaryCount, secondaryCount}; +// } @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { From 55596535ef4611323d30692aff330340401d8086 Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 31 Oct 2024 23:15:01 +0900 Subject: [PATCH 23/36] =?UTF-8?q?=E3=82=BF=E3=82=AF=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=82=AB=E3=83=AB=E3=83=99=E3=82=B9=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../universeguns/event/GunEvent.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index 4bba8eca..8322e70a 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -11,9 +11,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.CraftingInventory; @@ -45,7 +43,6 @@ import java.util.HashMap; import java.util.List; import java.util.Objects; -import java.util.Arrays; public class GunEvent implements Listener { @@ -576,22 +573,29 @@ private void startReload(Player player, Gun gun, GunStatus gunStatus) { } try { int reloadTime = gun.getReloadTime(); + double reloadTimeCoefficient = 1.0; ItemStack leggings = player.getInventory().getLeggings(); if (leggings != null && leggings.hasItemMeta()) { - ItemMeta meta = leggings.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); + ItemMeta leggingsMeta = leggings.getItemMeta(); + PersistentDataContainer container = leggingsMeta.getPersistentDataContainer(); NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); - double reloadTimeCoefficient = 1.0; if (container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_leggings")) { reloadTimeCoefficient -= 0.2; } + } + ItemStack chestplate = player.getInventory().getChestplate(); + if (chestplate != null && chestplate.hasItemMeta()) { + ItemMeta chestplateMeta = chestplate.getItemMeta(); + PersistentDataContainer container = chestplateMeta.getPersistentDataContainer(); + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); if (container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")) { reloadTimeCoefficient -= 0.3; } - double newReloadTime = reloadTime * reloadTimeCoefficient; - reloadTime = (int) newReloadTime; } + double newReloadTime = reloadTime * reloadTimeCoefficient; + reloadTime = (int) newReloadTime; + boolean result = gunStatus.startReload(reloadTime, player); if (!result) { Message.sendWarningMessage(player, "[武器AI]", "弾薬を補充してください"); From 8672024d88b257a925c9cae0cd895096d2051158 Mon Sep 17 00:00:00 2001 From: meyason Date: Fri, 1 Nov 2024 12:13:50 +0900 Subject: [PATCH 24/36] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=83=AA=E6=93=8D=E4=BD=9C=E3=81=AF=E3=82=84=E3=82=81?= =?UTF-8?q?=E3=81=A6=E3=83=87=E3=83=90=E3=83=95=E3=81=8C=E5=85=A5=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yurisi/universecorev2/item/gun/Gun.java | 2 +- .../yurisi/universecorev2/item/gun/L96A1.java | 2 +- .../universecorev2/item/gun/TacticalVest.java | 4 +- .../universeguns/constants/GunType.java | 2 + .../universeguns/core/EquipmentLimit.java | 79 ++++++++ .../universeguns/event/GunEvent.java | 188 +----------------- 6 files changed, 94 insertions(+), 183 deletions(-) create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java index 22d2dec4..7aee2c63 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java @@ -178,7 +178,7 @@ public ItemStack getItem(){ case SG: category += "ショットガン"; break; - case SR: + case SR, SR_SEMI, SR_BOLT: category += "スナイパーライフル"; break; case HG: diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java index 86836467..5e3a2475 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java @@ -17,7 +17,7 @@ public L96A1() { ItemStack.of(Material.DIAMOND_HOE) ); - this.type = GunType.SR; + this.type = GunType.SR_SEMI; this.equipmentType = GunType.PRIMARY; this.magazineSize = 5; this.burst = 0; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java index 450fb1f8..1fd09a37 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/TacticalVest.java @@ -31,8 +31,8 @@ protected void registerItemFunction() { leatherMeta.addEnchant(Enchantment.UNBREAKING, 4, true); List lore = List.of( Component.text("§7銃やマガジンを装備するアタッチメントのあるベスト"), -// Component.text("§7リロード速度上昇とセカンダリの所持枠が§d1§7増加") - Component.text("§7リロード速度上昇") + Component.text("§7リロード速度上昇とセカンダリの所持枠が§d1§7増加") +// Component.text("§7リロード速度上昇") ); leatherMeta.lore(lore); Random random = new Random(); diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java index c2a8ffd3..88b07cea 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/GunType.java @@ -4,6 +4,8 @@ public enum GunType { AR(1), SR(10), + SR_BOLT(11), + SR_SEMI(12), SMG(20), SG(30), HG(40), diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java new file mode 100644 index 00000000..46d081ea --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java @@ -0,0 +1,79 @@ +package space.yurisi.universecorev2.subplugins.universeguns.core; + +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.potion.PotionEffectType; +import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.constants.UniverseItemKeyString; +import space.yurisi.universecorev2.item.gun.Gun; +import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; +import space.yurisi.universecorev2.utils.Message; + +import java.util.Objects; + +public class EquipmentLimit { + + private boolean[] checkEquipmentLimit(Player player){ + int primaryLimit = 1; + int secondaryLimit = 1; + ItemStack chestplate = player.getInventory().getChestplate(); + if(chestplate != null && chestplate.hasItemMeta()){ + ItemMeta meta = chestplate.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + if(container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")){ + secondaryLimit = 2; + } + } + int[] hotbarCount = scanHotbar(player); + boolean[] result = new boolean[2]; + // 超えてたらfalse + result[0] = hotbarCount[0] < primaryLimit; + result[1] = hotbarCount[1] < secondaryLimit; + return result; + } + + private int[] scanHotbar(Player player){ + int primaryCount = 0; + int secondaryCount = 0; + + for (int i = 0; i < 9; i++) { + ItemStack item = player.getInventory().getItem(i); + if (item == null || !item.hasItemMeta()) { + continue; + } + + Gun gun = Gun.getGun(item); + if (gun == null) { + continue; + } + + if (gun.getEquipmentType() == GunType.PRIMARY) { + primaryCount++; + } else if (gun.getEquipmentType() == GunType.SECONDARY) { + secondaryCount++; + } + } + + return new int[]{primaryCount, secondaryCount}; + } + + public boolean debuffEquipmentLimit(Player player){ + boolean[] result = checkEquipmentLimit(player); + if(!result[0]){ + Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); + } + if(!result[1]){ + Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); + } + if(!result[0] || !result[1]){ + player.addPotionEffect(PotionEffectType.SLOWNESS.createEffect(1000000, 5)); + return true; + } + return false; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index 8322e70a..ec69fa4a 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -34,6 +34,7 @@ import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; import space.yurisi.universecorev2.subplugins.universeguns.core.BulletData; import space.yurisi.universecorev2.subplugins.universeguns.core.DamageCalculator; +import space.yurisi.universecorev2.subplugins.universeguns.core.EquipmentLimit; import space.yurisi.universecorev2.subplugins.universeguns.core.GunStatus; import space.yurisi.universecorev2.subplugins.universeguns.manager.GunStatusManager; import space.yurisi.universecorev2.subplugins.universeguns.menu.AmmoManagerInventoryMenu; @@ -94,6 +95,10 @@ public void onPlayerInteract(PlayerInteractEvent event) { return; } + if(new EquipmentLimit().debuffEquipmentLimit(player)){ + return; + } + String gunSerial = container.get(gunSerialKey, PersistentDataType.STRING); if (!GunStatusManager.isExists(gunSerial)) { @@ -153,7 +158,7 @@ public void run() { } } - } else if (gun.getType().equals(GunType.SR)) { + } else if (gun.getType().equals(GunType.SR_BOLT) || gun.getType().equals(GunType.SR_SEMI) || gun.getType().equals(GunType.SR)) { if (!isZoom.contains(player)) { Message.sendWarningMessage(player, "[武器AI]", "狙撃時のみ発射できます。"); return; @@ -161,7 +166,7 @@ public void run() { gunStatus.shoot(); new SniperShot(player, gun, gunStatus); - if (Objects.equals(gun.getName(), "L96A1")) { + if (gun.getType().equals(GunType.SR_BOLT)) { new BukkitRunnable() { @Override public void run() { @@ -184,7 +189,7 @@ public void run() { new BukkitRunnable() { @Override public void run() { - if (Objects.equals(gun.getName(), "L96A1")) { + if (gun.getType().equals(GunType.SR_BOLT)) { player.playSound(player.getLocation(), Sound.BLOCK_COPPER_DOOR_CLOSE, 1.0F, 0.6F); } } @@ -412,6 +417,7 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { player.setWalkSpeed(0.2f); return; } + new EquipmentLimit().debuffEquipmentLimit(player); if(!connector.isExistsAmmoData(player)){ try { @@ -645,182 +651,6 @@ public void run() { } -// @EventHandler -// public void onInventoryClick(InventoryClickEvent event) { -// if (event.getWhoClicked() instanceof Player player) { -// player.sendMessage("called"); -// int destinationSlot = event.getRawSlot(); -// int slot = event.getSlot(); -// ItemStack item = event.getCurrentItem(); -// if(item != null && item.hasItemMeta()){ -// Gun newGun = Gun.getGun(item); -// if(newGun != null){ -// player.getInventory().setItem(slot, null); -// return; -// } -// } -// -// ItemStack oldItem = event.getCursor(); -// if (!oldItem.hasItemMeta()) { -// return; -// } -// Gun gun = Gun.getGun(oldItem); -// if(gun == null){ -// return; -// } -// -// if (reloadingTasks.containsKey(player)) { -// event.setCancelled(true); -// return; -// } -// -// if(destinationSlot == 45){ -// // オフハンド -// Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); -// event.setCancelled(true); -// putGunToEmptySlot(player, oldItem); -// return; -// } -// if(destinationSlot <= 35) { -// return; -// } -// -// boolean[] result = checkEquipmentLimit(player); -// if(!result[0] && !result[1]){ -// event.setCancelled(true); -// Message.sendWarningMessage(player, "[武器AI]", "これ以上武器を持つことはできません。"); -// putGunToEmptySlot(player, oldItem); -// -// return; -// } -// -// if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ -// event.setCancelled(true); -// Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); -// putGunToEmptySlot(player, oldItem); -// }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ -// event.setCancelled(true); -// Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); -// putGunToEmptySlot(player, oldItem); -// } -// player.updateInventory(); -// } -// } -// -// private void putGunToEmptySlot(Player player, ItemStack item){ -// ItemStack[] contents = player.getInventory().getContents(); -// int emptySlot = -1; -// -// for (int i = 9; i < 36; i++) { -// if (contents[i] == null) { -// emptySlot = i; -// break; -// }else{ -// player.sendMessage(contents[i].toString()); -// } -// } -// if(emptySlot == -1){ -// player.getWorld().dropItemNaturally(player.getLocation(), item); -// return; -// } -// player.getInventory().setItem(emptySlot, item); -// } -// -// -// @EventHandler(priority = EventPriority.LOW) -// public void onPlayerPickupItem(EntityPickupItemEvent event) { -// if (!(event.getEntity() instanceof Player player)) { -// return; -// } -// ItemStack item = event.getItem().getItemStack(); -// if (!item.hasItemMeta()) { -// return; -// } -// Gun gun = Gun.getGun(item); -// if (gun == null) { -// return; -// } -// -// boolean[] result = checkEquipmentLimit(player); -// if(result[0] && result[1]){ -// return; -// } -// int emptySlot = -1; -// ItemStack[] contents = player.getInventory().getContents(); -// boolean isHotbarFull = Arrays.stream(contents, 0, 9).allMatch(Objects::isNull); -// if (isHotbarFull) { -// return; -// } -// -// for (int i = 9; i < 36; i++) { -// if (contents[i] == null) { -// emptySlot = i; -// break; -// } -// } -// if(emptySlot == -1){ -// if(!result[0] && gun.getEquipmentType() == GunType.PRIMARY) { -// Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); -// event.setCancelled(true); -// }else if(!result[1] && gun.getEquipmentType() == GunType.SECONDARY){ -// Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); -// event.setCancelled(true); -// } -// } else { -// if((!result[0] && gun.getEquipmentType() == GunType.PRIMARY) || (!result[1] && gun.getEquipmentType() == GunType.SECONDARY)) { -// player.getInventory().setItem(emptySlot, item); -// event.getItem().remove(); -// event.setCancelled(true); -// player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0F, 1.0F); -// } -// } -// } -// -// private boolean[] checkEquipmentLimit(Player player){ -// int primaryLimit = 1; -// int secondaryLimit = 1; -// ItemStack chestplate = player.getInventory().getChestplate(); -// if(chestplate != null && chestplate.hasItemMeta()){ -// ItemMeta meta = chestplate.getItemMeta(); -// PersistentDataContainer container = meta.getPersistentDataContainer(); -// NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); -// if(container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")){ -// secondaryLimit = 2; -// } -// } -// int[] hotbarCount = scanHotbar(player); -// boolean[] result = new boolean[2]; -// // 超えてたらfalse -// result[0] = hotbarCount[0] < primaryLimit; -// result[1] = hotbarCount[1] < secondaryLimit; -// return result; -// } -// -// private int[] scanHotbar(Player player){ -// int primaryCount = 0; -// int secondaryCount = 0; -// -// for (int i = 0; i < 9; i++) { -// ItemStack item = player.getInventory().getItem(i); -// if (item == null || !item.hasItemMeta()) { -// continue; -// } -// -// Gun gun = Gun.getGun(item); -// if (gun == null) { -// continue; -// } -// -// if (gun.getEquipmentType() == GunType.PRIMARY) { -// primaryCount++; -// } else if (gun.getEquipmentType() == GunType.SECONDARY) { -// secondaryCount++; -// } -// } -// -// return new int[]{primaryCount, secondaryCount}; -// } - @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { Player player = event.getPlayer(); From 8867e506dfed34ecbeaef9e197e5ca5e2d2c8d35 Mon Sep 17 00:00:00 2001 From: meyason Date: Fri, 1 Nov 2024 12:21:11 +0900 Subject: [PATCH 25/36] =?UTF-8?q?=E9=8A=83=E6=92=83=E6=88=A6=E4=B8=AD?= =?UTF-8?q?=E3=81=AB=E5=BA=A7=E3=82=89=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/sitdown/event/EventListener.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/sitdown/event/EventListener.java b/src/main/java/space/yurisi/universecorev2/subplugins/sitdown/event/EventListener.java index fc683977..45dc41c7 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/sitdown/event/EventListener.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/sitdown/event/EventListener.java @@ -53,6 +53,10 @@ public void onInteract(PlayerInteractEvent event) { return; } + if (!player.getInventory().getItemInMainHand().getType().isAir()) { + return; + } + if (!block.getType().toString().contains("STAIRS")) { return; } From 8a9f2eaf1a71e07b674f4c2ff0a4dc79262d8e79 Mon Sep 17 00:00:00 2001 From: meyason Date: Fri, 1 Nov 2024 21:39:28 +0900 Subject: [PATCH 26/36] =?UTF-8?q?=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D&?= =?UTF-8?q?=E3=83=AD=E3=82=B1=E3=83=A9=E3=83=B3=E3=81=AE=E6=AD=BB=E4=BA=A1?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/player/DeathEvent.java | 2 +- ...yExplosionBasePlayerDeathEventMessage.java | 61 ++++++++++++- .../universeguns/core/EquipmentLimit.java | 31 ++++--- .../universeguns/event/GunEvent.java | 89 ++++++++++++++++++- 4 files changed, 167 insertions(+), 16 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/event/player/DeathEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/event/player/DeathEvent.java index 5ee2d9ef..bacf537c 100755 --- a/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/event/player/DeathEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/event/player/DeathEvent.java @@ -45,7 +45,7 @@ private BasePlayerDeathEventMessage getDeathMessageClass(Player player, @Nullabl case BLOCK_EXPLOSION: return new BlockExplosionBasePlayerDeathEventMessage(player); case ENTITY_EXPLOSION: - return new EntityExplosionBasePlayerDeathEventMessage(player); + return new EntityExplosionBasePlayerDeathEventMessage(player, killer); case VOID: return new VoidBasePlayerDeathEventMessage(player); case SUICIDE: diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/message/event/player_death/EntityExplosionBasePlayerDeathEventMessage.java b/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/message/event/player_death/EntityExplosionBasePlayerDeathEventMessage.java index da4a7116..273640d0 100755 --- a/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/message/event/player_death/EntityExplosionBasePlayerDeathEventMessage.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/changemessages/message/event/player_death/EntityExplosionBasePlayerDeathEventMessage.java @@ -1,19 +1,72 @@ package space.yurisi.universecorev2.subplugins.changemessages.message.event.player_death; import net.kyori.adventure.text.Component; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; public class EntityExplosionBasePlayerDeathEventMessage extends BasePlayerDeathEventMessage{ - public EntityExplosionBasePlayerDeathEventMessage(Player player){ - super(player); + public EntityExplosionBasePlayerDeathEventMessage(Player player, Player killer) { + super(player, killer); } @Override - protected void init(Player player) { + protected void init(Player player, Player killer) { + if (killer == null) { + EntityDamageEvent cause = player.getLastDamageCause(); + if (cause instanceof EntityDamageByEntityEvent e && e.getDamager() instanceof Projectile damager) { + if (damager.getShooter() instanceof Entity shooter) { + String item = getItemName((Player) shooter); + setMessages( + new Component[]{ + Component.text("§a§l[戦闘型AI] §c" + shooter.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- で爆破しました"), + Component.text("§a§l[戦闘型AI] §c" + shooter.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- で爆殺しました"), + Component.text("§a§l[戦闘型AI] §c" + shooter.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- で絶命させた!"), + Component.text("§a§l[戦闘型AI] §c" + shooter.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- で倒しました"), + + } + ); + } else { + setMessages( + new Component[]{ + Component.text("§a§l[死亡管理AI] §c" + player.getName() + "§a が死亡した") + } + ); + } + return; + + } + + setMessages( + new Component[]{ + Component.text("") + } + ); + return; + + } + + if (player.getName().equals(killer.getName())) { + setMessages( + new Component[]{ + Component.text("§a§l[死亡管理AI] §c" + player.getName() + "§a が 自分の放った矢で自爆した"), + Component.text("§a§l[死亡管理AI] §c" + player.getName() + "§a が 自分の放った弾で自爆した") + } + ); + return; + } + + String item = getItemName(killer); + setMessages( new Component[]{ - Component.text("") + Component.text("§a§l[戦闘型AI] §c" + killer.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- で爆殺しました"), + Component.text("§a§l[戦闘型AI] §c" + killer.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- でばらばらにしました"), + Component.text("§a§l[戦闘型AI] §c" + killer.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- の爆発によって生命活動が停止させた"), + Component.text("§a§l[戦闘型AI] §c" + killer.getName() + "§a が §b" + player.getName() + "§a を -§d" + item + "§a- の爆発で骨にした"), } ); } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java index 46d081ea..de8b2368 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java @@ -32,12 +32,12 @@ private boolean[] checkEquipmentLimit(Player player){ int[] hotbarCount = scanHotbar(player); boolean[] result = new boolean[2]; // 超えてたらfalse - result[0] = hotbarCount[0] < primaryLimit; - result[1] = hotbarCount[1] < secondaryLimit; + result[0] = hotbarCount[0] <= primaryLimit; + result[1] = hotbarCount[1] <= secondaryLimit; return result; } - private int[] scanHotbar(Player player){ + public int[] scanHotbar(Player player){ int primaryCount = 0; int secondaryCount = 0; @@ -64,16 +64,27 @@ private int[] scanHotbar(Player player){ public boolean debuffEquipmentLimit(Player player){ boolean[] result = checkEquipmentLimit(player); - if(!result[0]){ - Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); - } - if(!result[1]){ - Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); - } if(!result[0] || !result[1]){ - player.addPotionEffect(PotionEffectType.SLOWNESS.createEffect(1000000, 5)); + setEquipmentEffect(player, true); + if(!result[0]){ + Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); + } + if(!result[1]){ + Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); + } return true; } + setEquipmentEffect(player, false); return false; } + + public void setEquipmentEffect(Player player, Boolean isOver){ + if(isOver){ + player.addPotionEffect(PotionEffectType.SLOWNESS.createEffect(1000000, 10)); + player.addPotionEffect(PotionEffectType.BLINDNESS.createEffect(1000000, 10)); + }else{ + player.removePotionEffect(PotionEffectType.SLOWNESS); + player.removePotionEffect(PotionEffectType.BLINDNESS); + } + } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index ec69fa4a..f49b1747 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -11,7 +11,10 @@ import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.CraftingInventory; @@ -44,6 +47,7 @@ import java.util.HashMap; import java.util.List; import java.util.Objects; +import java.util.Arrays; public class GunEvent implements Listener { @@ -339,6 +343,7 @@ public void onBlockHit(ProjectileHitEvent event) { float radius = gun.getExplosionRadius(); isHandlingExplosion.set(true); try { + snowball.getWorld().createExplosion(loc, radius, false, false, snowball); snowball.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, loc, 1); @@ -400,6 +405,7 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { } ItemStack newInHand = player.getInventory().getItem(event.getNewSlot()); + new EquipmentLimit().debuffEquipmentLimit(player); if (newInHand == null) { player.setWalkSpeed(0.2f); } else { @@ -417,7 +423,6 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) { player.setWalkSpeed(0.2f); return; } - new EquipmentLimit().debuffEquipmentLimit(player); if(!connector.isExistsAmmoData(player)){ try { @@ -684,5 +689,87 @@ public void onPlayerDropItem(PlayerDropItemEvent event) { startReload(player, gun, gunStatus); } } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event){ + if(event.getWhoClicked() instanceof Player player){ + new EquipmentLimit().debuffEquipmentLimit(player); + int destinationSlot = event.getRawSlot(); + int slot = event.getSlot(); + ItemStack item = event.getCurrentItem(); + if(item != null && item.hasItemMeta()){ + Gun newGun = Gun.getGun(item); + if(newGun != null){ + player.getInventory().setItem(slot, null); + return; + } + } + + ItemStack oldItem = event.getCursor(); + if (!oldItem.hasItemMeta()) { + return; + } + Gun gun = Gun.getGun(oldItem); + if(gun == null){ + return; + } + + if (reloadingTasks.containsKey(player)) { + event.setCancelled(true); + return; + } + + if(destinationSlot == 45){ + // オフハンド + Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); + event.setCancelled(true); + player.getInventory().addItem(oldItem); + return; + } + if(destinationSlot <= 35) { + return; + } + + int primaryLimit = 1; + int secondaryLimit = 1; + ItemStack chestplate = player.getInventory().getChestplate(); + if(chestplate != null && chestplate.hasItemMeta()){ + ItemMeta meta = chestplate.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + if(container.has(itemKey, PersistentDataType.STRING) && Objects.equals(container.get(itemKey, PersistentDataType.STRING), "tactical_vest")){ + secondaryLimit = 2; + } + } + int[] hotbarCount = new EquipmentLimit().scanHotbar(player); + boolean[] result = new boolean[2]; + result[0] = hotbarCount[0] < primaryLimit; + result[1] = hotbarCount[1] < secondaryLimit; + + if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ + new EquipmentLimit().setEquipmentEffect(player, true); + }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ + new EquipmentLimit().setEquipmentEffect(player, true); + } + } + } + + + @EventHandler(priority = EventPriority.LOW) + public void onPlayerPickupItem(EntityPickupItemEvent event) { + if (!(event.getEntity() instanceof Player player)) { + return; + } + ItemStack item = event.getItem().getItemStack(); + if (!item.hasItemMeta()) { + return; + } + Gun gun = Gun.getGun(item); + if (gun == null) { + return; + } + + new EquipmentLimit().debuffEquipmentLimit(player); + } } From 9825b65838f9a003004da1c6fb97b688ac8763b6 Mon Sep 17 00:00:00 2001 From: meyason Date: Sat, 2 Nov 2024 01:22:05 +0900 Subject: [PATCH 27/36] =?UTF-8?q?inventory=E9=96=A2=E9=80=A3=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E5=AF=BE=E5=87=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/universeguns/event/GunEvent.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index f49b1747..c6f56ea0 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -15,6 +15,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.CraftingInventory; @@ -695,12 +696,11 @@ public void onInventoryClick(InventoryClickEvent event){ if(event.getWhoClicked() instanceof Player player){ new EquipmentLimit().debuffEquipmentLimit(player); int destinationSlot = event.getRawSlot(); - int slot = event.getSlot(); ItemStack item = event.getCurrentItem(); + if(item != null && item.hasItemMeta()){ Gun newGun = Gun.getGun(item); if(newGun != null){ - player.getInventory().setItem(slot, null); return; } } @@ -719,14 +719,15 @@ public void onInventoryClick(InventoryClickEvent event){ return; } - if(destinationSlot == 45){ + if(event.getInventory().getType().equals(InventoryType.CRAFTING) && destinationSlot == 45){ // オフハンド Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); event.setCancelled(true); player.getInventory().addItem(oldItem); return; } - if(destinationSlot <= 35) { + + if(!event.getSlotType().equals(InventoryType.SlotType.QUICKBAR)){ return; } @@ -748,8 +749,10 @@ public void onInventoryClick(InventoryClickEvent event){ if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ new EquipmentLimit().setEquipmentEffect(player, true); + Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ new EquipmentLimit().setEquipmentEffect(player, true); + Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); } } } From c2943a9885a31031a82fb8d2a5cd8e02880030b9 Mon Sep 17 00:00:00 2001 From: meyason Date: Sat, 2 Nov 2024 01:44:19 +0900 Subject: [PATCH 28/36] =?UTF-8?q?=E7=9C=9F=E7=B4=85=E3=81=A1=E3=82=83?= =?UTF-8?q?=E3=82=93=E3=81=8B=E3=82=8F=E3=81=84=E3=81=84=E3=81=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../universecorev2/database/repositories/AmmoRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/database/repositories/AmmoRepository.java b/src/main/java/space/yurisi/universecorev2/database/repositories/AmmoRepository.java index 7e5b91b4..e021d11f 100644 --- a/src/main/java/space/yurisi/universecorev2/database/repositories/AmmoRepository.java +++ b/src/main/java/space/yurisi/universecorev2/database/repositories/AmmoRepository.java @@ -115,7 +115,7 @@ public Long getAmmoFromUserId(Long user_id, GunType gunType) throws AmmoNotFound case SG -> { return ammo.getSg(); } - case SR -> { + case SR, SR_BOLT, SR_SEMI -> { return ammo.getSr(); } case LMG -> { @@ -152,7 +152,7 @@ public void updateAmmo(Long user_id, Long newAmmo, GunType gunType) throws AmmoN case SMG -> ammo.setSmg(newAmmo); case AR -> ammo.setAr(newAmmo); case SG -> ammo.setSg(newAmmo); - case SR -> ammo.setSr(newAmmo); + case SR, SR_BOLT, SR_SEMI -> ammo.setSr(newAmmo); case LMG -> ammo.setLmg(newAmmo); case EX -> ammo.setEx(newAmmo); } From e97ab0b900852d0fdd297d941cf0e701c2cfd66e Mon Sep 17 00:00:00 2001 From: meyason Date: Mon, 4 Nov 2024 13:23:16 +0900 Subject: [PATCH 29/36] =?UTF-8?q?=E3=82=A8=E3=83=B3=E3=83=80=E3=83=BC?= =?UTF-8?q?=E3=83=9E=E3=83=B3=E3=81=AE=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF?= =?UTF-8?q?=E8=A8=AD=E7=BD=AE=E3=82=92=E3=82=AD=E3=83=A3=E3=83=B3=E3=82=BB?= =?UTF-8?q?=E3=83=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/entity/ChangeBlockEvent.java | 16 ++++++++++++++++ .../yurisi/universecorev2/item/gun/L96A1.java | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/main/java/space/yurisi/universecorev2/event/entity/ChangeBlockEvent.java diff --git a/src/main/java/space/yurisi/universecorev2/event/entity/ChangeBlockEvent.java b/src/main/java/space/yurisi/universecorev2/event/entity/ChangeBlockEvent.java new file mode 100644 index 00000000..c2c2c659 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/event/entity/ChangeBlockEvent.java @@ -0,0 +1,16 @@ +package space.yurisi.universecorev2.event.entity; + +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityChangeBlockEvent; + +public class ChangeBlockEvent implements Listener { + + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) { + if(event.getEntity().getType() == EntityType.ENDERMAN) { + event.setCancelled(true); + } + } +} diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java index 5e3a2475..8edb2052 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java @@ -17,7 +17,7 @@ public L96A1() { ItemStack.of(Material.DIAMOND_HOE) ); - this.type = GunType.SR_SEMI; + this.type = GunType.SR_BOLT; this.equipmentType = GunType.PRIMARY; this.magazineSize = 5; this.burst = 0; From e2a5b192ca36890e2225628e810c68c1db8c56b5 Mon Sep 17 00:00:00 2001 From: meyason Date: Mon, 4 Nov 2024 18:44:36 +0900 Subject: [PATCH 30/36] =?UTF-8?q?=E9=8A=83=E3=83=81=E3=82=B1=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=83=BB=E9=8A=83=E3=82=B7=E3=83=A7=E3=83=83=E3=83=97?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../universecorev2/command/giveuCommand.java | 20 ++++- .../constants/UniverseItemKeyString.java | 1 + .../universecorev2/item/UniverseItem.java | 43 ++++++++-- .../yurisi/universecorev2/item/gun/F2.java | 4 +- .../yurisi/universecorev2/item/gun/Gun.java | 29 +++++-- .../yurisi/universecorev2/item/gun/L96A1.java | 4 +- .../yurisi/universecorev2/item/gun/M1911.java | 4 +- .../yurisi/universecorev2/item/gun/M870.java | 4 +- .../yurisi/universecorev2/item/gun/R4C.java | 4 +- .../yurisi/universecorev2/item/gun/RPG.java | 4 +- .../yurisi/universecorev2/item/gun/SMG11.java | 4 +- .../universecorev2/item/ticket/GunTicket.java | 37 ++++++++ .../gacha/core/event/EventGacha.java | 2 +- .../repaircream/command/repairCommand.java | 2 +- .../subplugins/universeguns/UniverseGuns.java | 8 +- .../universeguns/command/GunCommand.java | 3 +- .../command/KillGunShopClerkCommand.java | 50 +++++++++++ .../command/SpawnGunShopClerkCommand.java | 47 ++++++++++ .../universeguns/constants/ShopType.java | 24 ++++++ .../universeguns/core/PurchaseGun.java | 46 ++++++++++ .../universeguns/entity/GunShopClerk.java | 86 +++++++++++++++++++ .../universeguns/event/EntityInteract.java | 64 ++++++++++++++ .../universeguns/event/GunEvent.java | 4 +- .../AmmoManagerInventoryMenu.java | 6 +- .../menu/{ => ammo_menu}/item/AmmoItem.java | 4 +- .../item/AssaultRifleAmmoItem.java | 2 +- .../item/ExplosiveAmmoItem.java | 2 +- .../{ => ammo_menu}/item/HandGunAmmoItem.java | 2 +- .../item/LightMachineGunAmmoItem.java | 2 +- .../{ => ammo_menu}/item/ShotGunAmmoItem.java | 2 +- .../item/SniperRifleAmmoItem.java | 2 +- .../item/SubMachineGunAmmoItem.java | 6 +- .../menu/shop_menu/AssultRifleShopMenu.java | 41 +++++++++ .../menu/shop_menu/ExplosiveShopMenu.java | 39 +++++++++ .../menu/shop_menu/HandGunShopMenu.java | 39 +++++++++ .../shop_menu/LightMachineGunShopMenu.java | 37 ++++++++ .../menu/shop_menu/ShotGunShopMenu.java | 39 +++++++++ .../menu/shop_menu/SniperRifleShopMenu.java | 39 +++++++++ .../menu/shop_menu/SubMachineGunShopMenu.java | 39 +++++++++ .../menu/shop_menu/item/GunShopMenuItem.java | 49 +++++++++++ src/main/resources/plugin.yml | 4 + 41 files changed, 799 insertions(+), 49 deletions(-) create mode 100644 src/main/java/space/yurisi/universecorev2/item/ticket/GunTicket.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/KillGunShopClerkCommand.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/SpawnGunShopClerkCommand.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/ShopType.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/entity/GunShopClerk.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/EntityInteract.java rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/AmmoManagerInventoryMenu.java (97%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/AmmoItem.java (99%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/AssaultRifleAmmoItem.java (98%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/ExplosiveAmmoItem.java (98%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/HandGunAmmoItem.java (98%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/LightMachineGunAmmoItem.java (98%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/ShotGunAmmoItem.java (98%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/SniperRifleAmmoItem.java (98%) rename src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/{ => ammo_menu}/item/SubMachineGunAmmoItem.java (86%) create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/AssultRifleShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ExplosiveShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/HandGunShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/LightMachineGunShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ShotGunShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SniperRifleShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SubMachineGunShopMenu.java create mode 100644 src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/item/GunShopMenuItem.java diff --git a/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java b/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java index 6f686e8a..d3b719c3 100644 --- a/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java +++ b/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java @@ -14,6 +14,7 @@ import space.yurisi.universecorev2.item.LevellingCustomItem; import space.yurisi.universecorev2.item.UniverseItem; import space.yurisi.universecorev2.item.ticket.GachaTicket; +import space.yurisi.universecorev2.item.ticket.GunTicket; import space.yurisi.universecorev2.utils.Message; import java.util.ArrayList; @@ -36,7 +37,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command §6-- Give Universe Item Help -- §7/giveu add [レベル] [アイテム数] : 指定されたIDのアイテムをインベントリに追加します §7/giveu list : 入手可能なアイテムのリストを表示します - §7/giveu ticket [枚数] : チケットを指定した枚数分インベントリに追加します + §7/giveu ticket gacha/gun [枚数] : ガチャや銃のチケットを指定した枚数分インベントリに追加します §7/giveu help : このヘルプを表示します """.split("\n"); @@ -98,13 +99,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "ticket": int amount; - if (args.length < 2) { + if (args.length < 3) { + Message.sendErrorMessage(player, "[管理AI]", "チケットの種類をgachaかgunで指定してください。"); Message.sendErrorMessage(player, "[管理AI]", "枚数を指定してください。"); return false; } try { - amount = Integer.parseInt(args[1]); + amount = Integer.parseInt(args[2]); } catch (NumberFormatException e) { Message.sendErrorMessage(player, "[管理AI]", "枚数は数値で指定してください。"); return false; @@ -115,7 +117,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return false; } - ItemStack ticket = UniverseItem.getItem(GachaTicket.id).getItem(); + String ticketType = args[1]; + ItemStack ticket; + if(ticketType.equalsIgnoreCase("gacha")){ + ticket = UniverseItem.getItem(GachaTicket.id).getItem(); + } else if(ticketType.equalsIgnoreCase("gun")) { + ticket = UniverseItem.getItem(GunTicket.id).getItem(); + } else { + Message.sendErrorMessage(player, "[管理AI]", "チケットの種類をgachaかgunで指定してください。"); + return false; + } + for (int i = 1; i <= amount; i++) { player.getInventory().addItem(ticket); } diff --git a/src/main/java/space/yurisi/universecorev2/constants/UniverseItemKeyString.java b/src/main/java/space/yurisi/universecorev2/constants/UniverseItemKeyString.java index 0930d2fe..a8cacc86 100644 --- a/src/main/java/space/yurisi/universecorev2/constants/UniverseItemKeyString.java +++ b/src/main/java/space/yurisi/universecorev2/constants/UniverseItemKeyString.java @@ -5,6 +5,7 @@ public class UniverseItemKeyString { public static final String ITEM_NAME = "item_name"; public static final String LEVEL = "level"; public static final String GACHA_TICKET = "gacha_ticket"; + public static final String GUN_TICKET = "gun_ticket"; public static final String FISH = "fish"; public static final String FISH_SIZE = "fish_size"; public static final String GUN = "gun"; diff --git a/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java b/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java index ae8af03e..14df1645 100644 --- a/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java +++ b/src/main/java/space/yurisi/universecorev2/item/UniverseItem.java @@ -17,6 +17,7 @@ import space.yurisi.universecorev2.item.solar_system.*; import space.yurisi.universecorev2.item.stick.BlockCopyStick; import space.yurisi.universecorev2.item.ticket.GachaTicket; +import space.yurisi.universecorev2.item.ticket.GunTicket; import space.yurisi.universecorev2.menu.MainMenu; import java.util.HashMap; @@ -39,6 +40,7 @@ public void register(){ items.put(SolarSystemLeggings.id, new SolarSystemLeggings()); items.put(SolarSystemBoots.id, new SolarSystemBoots()); items.put(GachaTicket.id, new GachaTicket()); + items.put(GunTicket.id, new GunTicket()); items.put(RepairCream.id, new RepairCream()); items.put(BlockCopyStick.id, new BlockCopyStick()); items.put(FishingRod.id, new FishingRod()); @@ -91,9 +93,11 @@ public static Boolean isLevelingItem(ItemStack itemStack){ } - public static Boolean removeItem(Player player, String item_name){ + public static Boolean removeItem(Player player, String item_name, int amount){ PlayerInventory inventory = player.getInventory(); NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); + int remainingAmount = amount; + int totalAmount = 0; for (ItemStack item : inventory.getContents()) { if (item != null && item.hasItemMeta()) { @@ -104,12 +108,41 @@ public static Boolean removeItem(Player player, String item_name){ String isGachaTicket = container.get(itemKey, PersistentDataType.STRING); if (Objects.equals(isGachaTicket, item_name)) { - if (item.getAmount() > 1) { - item.setAmount(item.getAmount() - 1); + totalAmount += item.getAmount(); + if(totalAmount >= amount){ + break; + } + } + } + } + } + + if (totalAmount < amount) { + return false; + } + + for (ItemStack item : inventory.getContents()) { + if (item != null && item.hasItemMeta()) { + ItemMeta meta = item.getItemMeta(); + PersistentDataContainer container = meta.getPersistentDataContainer(); + + if (container.has(itemKey, PersistentDataType.STRING)) { + String isGachaTicket = container.get(itemKey, PersistentDataType.STRING); + + if (Objects.equals(isGachaTicket, item_name)) { + int itemAmount = item.getAmount(); + if (itemAmount <= remainingAmount) { + remainingAmount -= itemAmount; + player.sendMessage(remainingAmount + " " + item_name); + item.setAmount(0); } else { - inventory.remove(item); + item.setAmount(itemAmount - remainingAmount); + remainingAmount = 0; + } + + if (remainingAmount == 0) { + return true; } - return true; } } } diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/F2.java b/src/main/java/space/yurisi/universecorev2/item/gun/F2.java index bdd8115e..b508858a 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/F2.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/F2.java @@ -39,6 +39,8 @@ public F2() { this.volumeSound = 5.0F; this.pitchSound = 0.8F; this.flavorText = "§7フランスで開発された3点バースト式のアサルトライフル。高いレートと命中精度が特徴"; + this.textureNumber = 5; + this.price = 4; } @Override @@ -46,7 +48,7 @@ protected void registerItemFunction(){ default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(5); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java index 7aee2c63..da8e72fd 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/Gun.java @@ -66,6 +66,10 @@ public abstract class Gun extends CustomItem { protected String flavorText; + protected int textureNumber; + + protected int price; + public Gun(String id, String name, ItemStack baseItem) { super(id, name, baseItem); } @@ -151,6 +155,18 @@ public float getPitchSound(){ return pitchSound; } + public String getFlavorText(){ + return flavorText; + } + + public int getTextureNumber(){ + return textureNumber; + } + + public int getPrice(){ + return price; + } + @Override public ItemStack getItem(){ ItemStack item = getBaseItem().clone(); @@ -160,14 +176,14 @@ public ItemStack getItem(){ container.set(new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN), PersistentDataType.BOOLEAN, true); container.set(new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_SERIAL), PersistentDataType.STRING, UUID.randomUUID().toString()); meta.displayName(Component.text(name)); - List lore = getComponents(); + List lore = getGunComponents(); meta.lore(lore); item.setItemMeta(meta); return default_setting.apply(item); } - private @NotNull List getComponents() { - String category = "§7カテゴリ: "; + public @NotNull List getGunComponents() { + String category = "§7カテゴリ: §b"; switch (type){ case AR: category += "アサルトライフル"; @@ -191,7 +207,7 @@ public ItemStack getItem(){ category += "特殊系"; break; } - String equipmentCategory = "§7装備カテゴリ: "; + String equipmentCategory = "§7装備カテゴリ: §b"; switch (equipmentType){ case PRIMARY: equipmentCategory += "プライマリ"; @@ -203,9 +219,8 @@ public ItemStack getItem(){ List lore = List.of( Component.text(category), Component.text(equipmentCategory), - Component.text("§7マガジンサイズ: " + magazineSize), - Component.text("§7リロード時間: " + (double)reloadTime/1000 + "s"), - Component.text(flavorText) + Component.text("§7マガジンサイズ: §b" + magazineSize), + Component.text("§7リロード時間: §b" + (double)reloadTime/1000 + "§7秒") ); return lore; } diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java index 5e3a2475..d64ac717 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java @@ -38,6 +38,8 @@ public L96A1() { this.volumeSound = 10.0F; this.pitchSound = 0.8F; this.flavorText = "§7イギリスで使用される軍用ボルトアクション式スナイパーライフル"; + this.textureNumber = 2; + this.price = 10; } @Override @@ -45,7 +47,7 @@ protected void registerItemFunction(){ default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(2); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java b/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java index cbc0998d..eea1c1ae 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/M1911.java @@ -39,6 +39,8 @@ public M1911(){ this.volumeSound = 5.0F; this.pitchSound = 2.0F; this.flavorText = "§7アメリカで開発された自動拳銃。第一次世界大戦時代に生まれ、現在でも多くの国で使用されている"; + this.textureNumber = 7; + this.price = 1; } @Override @@ -46,7 +48,7 @@ protected void registerItemFunction(){ default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(7); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/M870.java b/src/main/java/space/yurisi/universecorev2/item/gun/M870.java index 4fad6ff9..a737a121 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/M870.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/M870.java @@ -39,6 +39,8 @@ public M870() { this.volumeSound = 5.0F; this.pitchSound = 0.6F; this.flavorText = "§7ポンプアクション式ショットガン。有効射程が長いが連射速度は遅い"; + this.textureNumber = 6; + this.price = 5; } @Override @@ -46,7 +48,7 @@ protected void registerItemFunction(){ default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(6); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java b/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java index 0cffe5f8..a4810731 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/R4C.java @@ -38,6 +38,8 @@ public R4C() { this.volumeSound = 4.0F; this.pitchSound = 1.8F; this.flavorText = "§7威力は低いものの高い連射速度でレインボーな特殊部隊に愛用されている"; + this.textureNumber = 1; + this.price = 5; } @@ -46,7 +48,7 @@ protected void registerItemFunction() { default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(1); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java b/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java index 287caa51..9186db26 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/RPG.java @@ -39,6 +39,8 @@ public RPG() { this.volumeSound = 10.0F; this.pitchSound = 0.5F; this.flavorText = "§7ロケットランチャーの代名詞。爆風で広範囲にダメージを与える"; + this.textureNumber = 3; + this.price = 10; } @Override @@ -46,7 +48,7 @@ protected void registerItemFunction(){ default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(3); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java b/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java index c5feff1c..11f30315 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/SMG11.java @@ -38,6 +38,8 @@ public SMG11() { this.volumeSound = 3.0F; this.pitchSound = 0.8F; this.flavorText = "§7随一の連射速度と軽量さが特徴のサブマシンガン。覗かないとまともに当たらない"; + this.textureNumber = 4; + this.price = 2; } @Override @@ -45,7 +47,7 @@ protected void registerItemFunction(){ default_setting = (item) -> { ItemMeta meta = item.getItemMeta(); if (meta != null) { - meta.setCustomModelData(4); + meta.setCustomModelData(textureNumber); } item.setItemMeta(meta); return item; diff --git a/src/main/java/space/yurisi/universecorev2/item/ticket/GunTicket.java b/src/main/java/space/yurisi/universecorev2/item/ticket/GunTicket.java new file mode 100644 index 00000000..c73195aa --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/item/ticket/GunTicket.java @@ -0,0 +1,37 @@ +package space.yurisi.universecorev2.item.ticket; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; +import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.constants.UniverseItemKeyString; +import space.yurisi.universecorev2.item.CustomItem; + +public class GunTicket extends CustomItem { + + public static final String id = "gun_ticket"; + + public GunTicket() { + super( + id, + "§e§l銃チケット", + ItemStack.of(Material.PAPER) + ); + } + + @Override + protected void registerItemFunction() { + default_setting = (item) -> { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + PersistentDataContainer container = meta.getPersistentDataContainer(); + container.set(new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.GUN_TICKET), PersistentDataType.BOOLEAN, true); + item.setItemMeta(meta); + } + return item; + }; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/gacha/core/event/EventGacha.java b/src/main/java/space/yurisi/universecorev2/subplugins/gacha/core/event/EventGacha.java index df8d6286..985a5bd0 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/gacha/core/event/EventGacha.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/gacha/core/event/EventGacha.java @@ -44,7 +44,7 @@ public EventGacha(Player player) { } public void turn() { - Boolean ticket = UniverseItem.removeItem(player, "gacha_ticket"); + Boolean ticket = UniverseItem.removeItem(player, "gacha_ticket", 1); if (player.getInventory().firstEmpty() == -1) { Message.sendErrorMessage(player, "[ガチャAI]", "インベントリがいっぱいです。(スタックが余ってる場合も一度しまって下さい。)"); diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/repaircream/command/repairCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/repaircream/command/repairCommand.java index 5c392f93..09c0b6d4 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/repaircream/command/repairCommand.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/repaircream/command/repairCommand.java @@ -39,7 +39,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return false; } - Boolean ticket = UniverseItem.removeItem(player, "repair_cream"); + Boolean ticket = UniverseItem.removeItem(player, "repair_cream", 1); if (!ticket) { Message.sendErrorMessage(player, "[修復AI]", "修復クリームが足りません。"); 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 61ce4f79..9be53d37 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/UniverseGuns.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/UniverseGuns.java @@ -4,7 +4,8 @@ import space.yurisi.universecorev2.UniverseCoreV2API; import space.yurisi.universecorev2.database.DatabaseManager; import space.yurisi.universecorev2.subplugins.SubPlugin; -import space.yurisi.universecorev2.subplugins.universeguns.command.GunCommand; +import space.yurisi.universecorev2.subplugins.universeguns.command.*; +import space.yurisi.universecorev2.subplugins.universeguns.event.EntityInteract; import space.yurisi.universecorev2.subplugins.universeguns.event.GunEvent; import space.yurisi.universecorev2.subplugins.universeguns.connector.UniverseCoreAPIConnector; @@ -17,7 +18,10 @@ 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.getServer().getPluginManager().registerEvents(new EntityInteract(), core); core.getCommand("ammo").setExecutor(new GunCommand(connector)); + core.getCommand("spawnGunClerk").setExecutor(new SpawnGunShopClerkCommand()); + core.getCommand("killGunClerk").setExecutor(new KillGunShopClerkCommand()); } public void onDisable() { @@ -31,6 +35,6 @@ public String getName() { @Override public String getVersion() { - return "1.0.1"; + return "1.1.1"; } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java index 1cc770df..7276f944 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/GunCommand.java @@ -7,7 +7,7 @@ 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.subplugins.universeguns.menu.ammo_menu.AmmoManagerInventoryMenu; public class GunCommand implements CommandExecutor { @@ -27,7 +27,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command AmmoManagerInventoryMenu ammoManagerInventoryMenu = new AmmoManagerInventoryMenu(connector); ammoManagerInventoryMenu.sendMenu(player); -// Message.sendSuccessMessage(player, "[武器AI]", "弾薬管理メニューを開きました"); return true; } } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/KillGunShopClerkCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/KillGunShopClerkCommand.java new file mode 100644 index 00000000..6d0bfb31 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/KillGunShopClerkCommand.java @@ -0,0 +1,50 @@ +package space.yurisi.universecorev2.subplugins.universeguns.command; + +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.api.LuckPermsWrapper; +import space.yurisi.universecorev2.subplugins.universeguns.constants.ShopType; +import space.yurisi.universecorev2.subplugins.universeguns.entity.GunShopClerk; +import space.yurisi.universecorev2.utils.Message; + +public class KillGunShopClerkCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if(!(sender instanceof Player player)) { + return false; + } + + if (!LuckPermsWrapper.isUserInAdminOrDevGroup(player)) { + Message.sendErrorMessage(player, "[管理AI]", "このコマンドを実行する権限がありません。"); + return false; + } + + if(args == null || args.length < 1) { + Message.sendErrorMessage(player, "[武器AI]", "ショップの種類を指定してください。"); + Message.sendErrorMessage(player, "[武器AI]", "hg | smg | sg"); + Message.sendErrorMessage(player, "[武器AI]", "ar | sr"); + Message.sendErrorMessage(player, "[武器AI]", "lmg | ex | armor"); + return false; + } + + String strShopType = args[0]; + for(ShopType shopType : ShopType.values()) { + if(shopType.getName().equals(strShopType)) { + if(GunShopClerk.killClerk(player.getLocation(), shopType)) { + Message.sendSuccessMessage(player, "[武器AI]", "指定されたショップの店員を削除しました。"); + }else{ + Message.sendWarningMessage(player, "[武器AI]", "指定されたショップの店員が見つかりませんでした。"); + } + return true; + } + } + + Message.sendWarningMessage(player, "[武器AI]", "指定されたショップが見つかりませんでした。"); + + return false; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/SpawnGunShopClerkCommand.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/SpawnGunShopClerkCommand.java new file mode 100644 index 00000000..18ba607e --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/command/SpawnGunShopClerkCommand.java @@ -0,0 +1,47 @@ +package space.yurisi.universecorev2.subplugins.universeguns.command; + +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.api.LuckPermsWrapper; +import space.yurisi.universecorev2.subplugins.universeguns.constants.ShopType; +import space.yurisi.universecorev2.subplugins.universeguns.entity.GunShopClerk; +import space.yurisi.universecorev2.utils.Message; + +public class SpawnGunShopClerkCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if(!(sender instanceof Player player)) { + return false; + } + + if (!LuckPermsWrapper.isUserInAdminOrDevGroup(player)) { + Message.sendErrorMessage(player, "[管理AI]", "このコマンドを実行する権限がありません。"); + return false; + } + + if(args == null || args.length < 1) { + Message.sendErrorMessage(player, "[武器AI]", "ショップの種類を指定してください。"); + Message.sendErrorMessage(player, "[武器AI]", "hg | smg | sg"); + Message.sendErrorMessage(player, "[武器AI]", "ar | sr"); + Message.sendErrorMessage(player, "[武器AI]", "lmg | ex | armor"); + return false; + } + + String strShopType = args[0]; + for(ShopType shopType : ShopType.values()) { + if(shopType.getName().equals(strShopType)) { + GunShopClerk gunShopClerk = new GunShopClerk(); + gunShopClerk.spawnClerk(player.getLocation(), shopType); + return true; + } + } + + Message.sendWarningMessage(player, "[武器AI]", "指定されたショップが見つかりませんでした。"); + + return false; + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/ShopType.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/ShopType.java new file mode 100644 index 00000000..98b3331d --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/constants/ShopType.java @@ -0,0 +1,24 @@ +package space.yurisi.universecorev2.subplugins.universeguns.constants; + +public enum ShopType { + + HGShop("hg"), + SMGShop("smg"), + SGShop("sg"), + ARShop("ar"), + SRShop("sr"), + LMGShop("lmg"), + EXShop("ex"), + EQUIPMENTShop("armor"); + + private String name; + + ShopType(String name){ + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java new file mode 100644 index 00000000..4421ff31 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java @@ -0,0 +1,46 @@ +package space.yurisi.universecorev2.subplugins.universeguns.core; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import space.yurisi.universecorev2.item.CustomItem; +import space.yurisi.universecorev2.item.UniverseItem; +import space.yurisi.universecorev2.item.gun.Gun; +import space.yurisi.universecorev2.subplugins.receivebox.ReceiveBoxAPI; +import space.yurisi.universecorev2.utils.Message; + +import java.util.Date; + +public class PurchaseGun { + + public static void executePurchase(Player player, Gun gun) { + Boolean canPurchase = UniverseItem.removeItem(player, "gun_ticket", gun.getPrice()); + + if(!canPurchase) { + Message.sendWarningMessage(player, "[武器AI]", "チケットが足りません。"); + player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); + return; + } + + CustomItem item = UniverseItem.getItem(gun.getId()); + if(item == null) { + player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); + Message.sendErrorMessage(player, "[武器AI]", "アイテムが見つかりませんでした。運営にお問い合わせください。"); + return; + } + Inventory inventory = player.getInventory(); + ItemStack itemStack = item.getItem(); + + if(inventory.firstEmpty() == -1) { + player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_YES, 1, 1); + Message.sendWarningMessage(player, "[武器AI]", "インベントリがいっぱいなので、受け取りboxに送りました。"); + Date expireDate = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 7); + ReceiveBoxAPI.AddReceiveItem(itemStack, player.getUniqueId(), expireDate, "購入した武器"); + return; + } + + inventory.addItem(itemStack); + player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_CELEBRATE, 1, 1); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/entity/GunShopClerk.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/entity/GunShopClerk.java new file mode 100644 index 00000000..2258a069 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/entity/GunShopClerk.java @@ -0,0 +1,86 @@ +package space.yurisi.universecorev2.subplugins.universeguns.entity; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.World; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; +import org.bukkit.persistence.PersistentDataType; +import space.yurisi.universecorev2.UniverseCoreV2; +import space.yurisi.universecorev2.subplugins.universeguns.constants.ShopType; + + +public class GunShopClerk { + + public void spawnClerk(Location location, ShopType shopType) { + // Thanks to Charindo + World world = location.getWorld(); + Villager villager = (Villager) world.spawnEntity(location, EntityType.VILLAGER); + villager.setCustomName(getDisplayName(shopType)); + villager.setCustomNameVisible(true); + villager.getEquipment().setItemInMainHand(new ItemStack(Material.AIR)); + villager.getEquipment().setItemInOffHand(new ItemStack(Material.AIR)); + villager.getEquipment().setHelmet(new ItemStack(Material.AIR)); + villager.getEquipment().setChestplate(new ItemStack(Material.AIR)); + villager.getEquipment().setLeggings(new ItemStack(Material.AIR)); + villager.getEquipment().setBoots(new ItemStack(Material.AIR)); + villager.getPersistentDataContainer().set(new NamespacedKey(UniverseCoreV2.getInstance(), shopType.getName()), + PersistentDataType.STRING, shopType.getName()); + villager.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.0D); + villager.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(0.0D); + villager.setCollidable(false); + villager.setSilent(true); + villager.setInvulnerable(true); + } + + public static ShopType getShopType(Entity entity) { + if(entity instanceof Villager villager) { + for(ShopType shopType : ShopType.values()) { + if(villager.getPersistentDataContainer().has(new NamespacedKey(UniverseCoreV2.getInstance(), shopType.getName()), PersistentDataType.STRING)) { + return shopType; + } + } + } + return null; + } + + public static boolean killClerk(Location location, ShopType shopType) { + for(Entity entity : location.getWorld().getNearbyEntities(location, 5, 5, 5)) { + if(entity instanceof Villager villager) { + if(villager.getPersistentDataContainer().has(new NamespacedKey(UniverseCoreV2.getInstance(), shopType.getName()), PersistentDataType.STRING)) { + villager.remove(); + return true; + } + } + } + return false; + } + + private String getDisplayName(ShopType shopType) { + switch (shopType){ + case HGShop: + return "ハンドガン"; + case SMGShop: + return "サブマシンガン"; + case SGShop: + return "ショットガン"; + case ARShop: + return "アサルトライフル"; + case SRShop: + return "スナイパーライフル"; + case LMGShop: + return "ライトマシンガン"; + case EXShop: + return "特殊武器"; + case EQUIPMENTShop: + return "装具類"; + default: + return null; + } + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/EntityInteract.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/EntityInteract.java new file mode 100644 index 00000000..b42cb407 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/EntityInteract.java @@ -0,0 +1,64 @@ +package space.yurisi.universecorev2.subplugins.universeguns.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import space.yurisi.universecorev2.subplugins.universeguns.constants.ShopType; +import space.yurisi.universecorev2.subplugins.universeguns.entity.GunShopClerk; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.*; + +public class EntityInteract implements Listener{ + + @EventHandler + public void onEntityInteract(PlayerInteractEntityEvent event) { + ShopType shopType = GunShopClerk.getShopType(event.getRightClicked()); + if(shopType == null) { + return; + } + Player player = event.getPlayer(); + event.setCancelled(true); + + switch (shopType) { + case HGShop: + HandGunShopMenu handGunShopMenu = new HandGunShopMenu(); + handGunShopMenu.sendMenu(player); + break; + case SMGShop: + SubMachineGunShopMenu subMachineGunShopMenu = new SubMachineGunShopMenu(); + subMachineGunShopMenu.sendMenu(player); + break; + case SGShop: + ShotGunShopMenu shotGunShopMenu = new ShotGunShopMenu(); + shotGunShopMenu.sendMenu(player); + break; + case ARShop: + AssultRifleShopMenu assultRifleShopMenu = new AssultRifleShopMenu(); + assultRifleShopMenu.sendMenu(player); + break; + case SRShop: + SniperRifleShopMenu sniperRifleShopMenu = new SniperRifleShopMenu(); + sniperRifleShopMenu.sendMenu(player); + break; + case LMGShop: + break; + case EXShop: + ExplosiveShopMenu explosiveShopMenu = new ExplosiveShopMenu(); + explosiveShopMenu.sendMenu(player); + break; + case EQUIPMENTShop: + break; + } + } + + @EventHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + if (event.getDamager() instanceof Player) { + ShopType shopType = GunShopClerk.getShopType(event.getEntity()); + if(shopType != null) { + event.setCancelled(true); + } + } + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index c6f56ea0..13fc1ab0 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -14,7 +14,6 @@ import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.*; @@ -41,14 +40,13 @@ import space.yurisi.universecorev2.subplugins.universeguns.core.EquipmentLimit; import space.yurisi.universecorev2.subplugins.universeguns.core.GunStatus; import space.yurisi.universecorev2.subplugins.universeguns.manager.GunStatusManager; -import space.yurisi.universecorev2.subplugins.universeguns.menu.AmmoManagerInventoryMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.AmmoManagerInventoryMenu; import space.yurisi.universecorev2.utils.Message; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Objects; -import java.util.Arrays; public class GunEvent implements Listener { diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/AmmoManagerInventoryMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/AmmoManagerInventoryMenu.java similarity index 97% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/AmmoManagerInventoryMenu.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/AmmoManagerInventoryMenu.java index 4eb44a6a..755d042b 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/AmmoManagerInventoryMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/AmmoManagerInventoryMenu.java @@ -1,14 +1,12 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import space.yurisi.universecorev2.exception.AmmoNotFoundException; import space.yurisi.universecorev2.exception.UserNotFoundException; import space.yurisi.universecorev2.menu.BaseMenu; import space.yurisi.universecorev2.subplugins.universeguns.connector.UniverseCoreAPIConnector; -import space.yurisi.universecorev2.subplugins.universeguns.menu.item.*; +import space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item.*; import space.yurisi.universecorev2.utils.Message; import xyz.xenondevs.invui.gui.Gui; import xyz.xenondevs.invui.item.Item; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/AmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/AmmoItem.java similarity index 99% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/AmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/AmmoItem.java index 66124945..e36b8227 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/AmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/AmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.Sound; @@ -15,7 +15,7 @@ import space.yurisi.universecorev2.subplugins.universeeconomy.exception.ParameterException; import space.yurisi.universecorev2.subplugins.universeguns.connector.UniverseCoreAPIConnector; import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; -import space.yurisi.universecorev2.subplugins.universeguns.menu.AmmoManagerInventoryMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.AmmoManagerInventoryMenu; import space.yurisi.universecorev2.utils.Message; import xyz.xenondevs.invui.item.ItemProvider; import xyz.xenondevs.invui.item.builder.ItemBuilder; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/AssaultRifleAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/AssaultRifleAmmoItem.java similarity index 98% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/AssaultRifleAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/AssaultRifleAmmoItem.java index 0009a620..d4454fa3 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/AssaultRifleAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/AssaultRifleAmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/ExplosiveAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/ExplosiveAmmoItem.java similarity index 98% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/ExplosiveAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/ExplosiveAmmoItem.java index 18342727..ed6aa447 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/ExplosiveAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/ExplosiveAmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/HandGunAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/HandGunAmmoItem.java similarity index 98% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/HandGunAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/HandGunAmmoItem.java index 7c32cbc8..ca0a9feb 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/HandGunAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/HandGunAmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/LightMachineGunAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/LightMachineGunAmmoItem.java similarity index 98% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/LightMachineGunAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/LightMachineGunAmmoItem.java index b8babe92..bad5d96b 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/LightMachineGunAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/LightMachineGunAmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/ShotGunAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/ShotGunAmmoItem.java similarity index 98% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/ShotGunAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/ShotGunAmmoItem.java index ff8ca6d5..c5e1917c 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/ShotGunAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/ShotGunAmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/SniperRifleAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/SniperRifleAmmoItem.java similarity index 98% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/SniperRifleAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/SniperRifleAmmoItem.java index ab6809ea..1c4417cd 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/SniperRifleAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/SniperRifleAmmoItem.java @@ -1,4 +1,4 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/SubMachineGunAmmoItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/SubMachineGunAmmoItem.java similarity index 86% rename from src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/SubMachineGunAmmoItem.java rename to src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/SubMachineGunAmmoItem.java index 610b3ba7..d7c9f897 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/item/SubMachineGunAmmoItem.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/ammo_menu/item/SubMachineGunAmmoItem.java @@ -1,15 +1,11 @@ -package space.yurisi.universecorev2.subplugins.universeguns.menu.item; +package space.yurisi.universecorev2.subplugins.universeguns.menu.ammo_menu.item; 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.exception.AmmoNotFoundException; import space.yurisi.universecorev2.exception.UserNotFoundException; import space.yurisi.universecorev2.subplugins.universeguns.connector.UniverseCoreAPIConnector; import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; -import space.yurisi.universecorev2.utils.Message; public class SubMachineGunAmmoItem extends AmmoItem { diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/AssultRifleShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/AssultRifleShopMenu.java new file mode 100644 index 00000000..5ebb0eb1 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/AssultRifleShopMenu.java @@ -0,0 +1,41 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class AssultRifleShopMenu implements BaseMenu { + + public AssultRifleShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "a b # # # # # # #") + .addIngredient('#', border) + + .addIngredient('a', new GunShopMenuItem(new R4C())) + .addIngredient('b', new GunShopMenuItem(new F2())); + + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("アサルトライフル") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ExplosiveShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ExplosiveShopMenu.java new file mode 100644 index 00000000..c2085119 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ExplosiveShopMenu.java @@ -0,0 +1,39 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class ExplosiveShopMenu implements BaseMenu{ + + public ExplosiveShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "a # # # # # # # #") + .addIngredient('#', border) + + .addIngredient('a', new GunShopMenuItem(new RPG())); + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("特殊武器") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/HandGunShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/HandGunShopMenu.java new file mode 100644 index 00000000..54d5e84a --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/HandGunShopMenu.java @@ -0,0 +1,39 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class HandGunShopMenu implements BaseMenu { + + public HandGunShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "a # # # # # # # #") + .addIngredient('#', border) + + .addIngredient('a', new GunShopMenuItem(new M1911())); + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("ハンドガン") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/LightMachineGunShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/LightMachineGunShopMenu.java new file mode 100644 index 00000000..d8c51528 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/LightMachineGunShopMenu.java @@ -0,0 +1,37 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class LightMachineGunShopMenu implements BaseMenu{ + + public LightMachineGunShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "# # # # # # # # #") + .addIngredient('#', border); + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("軽機関銃") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ShotGunShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ShotGunShopMenu.java new file mode 100644 index 00000000..cabc5f9e --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/ShotGunShopMenu.java @@ -0,0 +1,39 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class ShotGunShopMenu implements BaseMenu{ + + public ShotGunShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "a # # # # # # # #") + .addIngredient('#', border) + + .addIngredient('a', new GunShopMenuItem(new M870())); + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("ショットガン") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SniperRifleShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SniperRifleShopMenu.java new file mode 100644 index 00000000..d86a42eb --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SniperRifleShopMenu.java @@ -0,0 +1,39 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class SniperRifleShopMenu implements BaseMenu{ + + public SniperRifleShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "a # # # # # # # #") + .addIngredient('#', border) + + .addIngredient('a', new GunShopMenuItem(new L96A1())); + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("スナイパーライフル") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SubMachineGunShopMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SubMachineGunShopMenu.java new file mode 100644 index 00000000..1b7842f5 --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/SubMachineGunShopMenu.java @@ -0,0 +1,39 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.*; +import space.yurisi.universecorev2.menu.BaseMenu; +import space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item.GunShopMenuItem; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.Window; + +public class SubMachineGunShopMenu implements BaseMenu { + + public SubMachineGunShopMenu() { + } + + public void sendMenu(Player player) { + + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + + Gui.Builder.@NotNull Normal gui = Gui.normal() + .setStructure( + "a # # # # # # # #") + .addIngredient('#', border) + + .addIngredient('a', new GunShopMenuItem(new SMG11())); + + xyz.xenondevs.invui.window.Window window = Window.single() + .setViewer(player) + .setGui(gui.build()) + .setTitle("サブマシンガン") + .build(); + + window.open(); + } +} diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/item/GunShopMenuItem.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/item/GunShopMenuItem.java new file mode 100644 index 00000000..be281e3d --- /dev/null +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/menu/shop_menu/item/GunShopMenuItem.java @@ -0,0 +1,49 @@ +package space.yurisi.universecorev2.subplugins.universeguns.menu.shop_menu.item; + +import net.kyori.adventure.text.Component; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import space.yurisi.universecorev2.item.gun.Gun; +import space.yurisi.universecorev2.subplugins.universeguns.core.PurchaseGun; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.AbstractItem; + +import java.util.ArrayList; +import java.util.List; + +public class GunShopMenuItem extends AbstractItem { + + private final Gun gun; + + public GunShopMenuItem(Gun gun) { + this.gun = gun; + } + + @Override + public ItemProvider getItemProvider() { + ItemStack itemStack = new ItemStack(Material.DIAMOND_HOE); + ItemMeta itemMeta = itemStack.getItemMeta(); + if(itemMeta != null) { + itemMeta.setCustomModelData(gun.getTextureNumber()); + itemMeta.setDisplayName(gun.getName()); + List lore = new ArrayList<>(gun.getGunComponents()); + lore.add(Component.text(gun.getFlavorText())); + lore.add(Component.text("§7値段: §b" + gun.getPrice() + "§7枚")); + lore.add(Component.text("§7クリックで購入")); + itemMeta.lore(lore); + itemStack.setItemMeta(itemMeta); + } + return new ItemBuilder(itemStack); + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { + PurchaseGun.executePurchase(player, gun); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 931bc8d5..6bc7a3a6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -99,6 +99,10 @@ commands: ## UniverseGuns ammo: description: 弾薬管理メニューを開く + spawnGunClerk: + description: 銃ショップの店員召喚 + killGunClerk: + description: 半径5ブロック以内の指定したショップの店員を排除します ## PlayerHead head: From da4350a715b497c3c405605da00264e2f3ae7ae1 Mon Sep 17 00:00:00 2001 From: meyason Date: Mon, 4 Nov 2024 19:06:52 +0900 Subject: [PATCH 31/36] kyo ha sityu- --- src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java index d64ac717..470fc8a4 100644 --- a/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java +++ b/src/main/java/space/yurisi/universecorev2/item/gun/L96A1.java @@ -17,7 +17,7 @@ public L96A1() { ItemStack.of(Material.DIAMOND_HOE) ); - this.type = GunType.SR_SEMI; + this.type = GunType.SR_BOLT; this.equipmentType = GunType.PRIMARY; this.magazineSize = 5; this.burst = 0; From 8b27b9e4a383236c45342701a195a4b67444b5c8 Mon Sep 17 00:00:00 2001 From: meyason Date: Mon, 4 Nov 2024 20:16:50 +0900 Subject: [PATCH 32/36] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E5=9B=9E?= =?UTF-8?q?=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/universeguns/core/EquipmentLimit.java | 8 +++++++- .../subplugins/universeguns/event/GunEvent.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java index de8b2368..85ea6e98 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java @@ -43,7 +43,13 @@ public int[] scanHotbar(Player player){ for (int i = 0; i < 9; i++) { ItemStack item = player.getInventory().getItem(i); - if (item == null || !item.hasItemMeta()) { + if(item == null){ + continue; + } + if(item.getType().isAir()){ + continue; + } + if (!item.hasItemMeta()) { continue; } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index c6f56ea0..86e614c3 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -79,10 +79,10 @@ public void onPlayerInteract(PlayerInteractEvent event) { return; } ItemStack itemInHand = player.getInventory().getItemInMainHand(); - ItemMeta meta = itemInHand.getItemMeta(); if (!itemInHand.hasItemMeta()) { return; } + ItemMeta meta = itemInHand.getItemMeta(); PersistentDataContainer container = meta.getPersistentDataContainer(); NamespacedKey itemKey = new NamespacedKey(UniverseCoreV2.getInstance(), UniverseItemKeyString.ITEM_NAME); From a95e042d864420505f59ac36aa8343306a75e891 Mon Sep 17 00:00:00 2001 From: meyason Date: Mon, 4 Nov 2024 20:41:33 +0900 Subject: [PATCH 33/36] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../universecorev2/command/giveuCommand.java | 29 ++++++++++--------- .../universeguns/core/PurchaseGun.java | 4 ++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java b/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java index d3b719c3..77d72beb 100644 --- a/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java +++ b/src/main/java/space/yurisi/universecorev2/command/giveuCommand.java @@ -37,7 +37,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command §6-- Give Universe Item Help -- §7/giveu add [レベル] [アイテム数] : 指定されたIDのアイテムをインベントリに追加します §7/giveu list : 入手可能なアイテムのリストを表示します - §7/giveu ticket gacha/gun [枚数] : ガチャや銃のチケットを指定した枚数分インベントリに追加します + §7/giveu ticket [枚数] : ガチャや銃のチケットを指定した枚数分インベントリに追加します §7/giveu help : このヘルプを表示します """.split("\n"); @@ -99,22 +99,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "ticket": int amount; - if (args.length < 3) { + if (args.length < 2) { Message.sendErrorMessage(player, "[管理AI]", "チケットの種類をgachaかgunで指定してください。"); - Message.sendErrorMessage(player, "[管理AI]", "枚数を指定してください。"); - return false; - } - - try { - amount = Integer.parseInt(args[2]); - } catch (NumberFormatException e) { - Message.sendErrorMessage(player, "[管理AI]", "枚数は数値で指定してください。"); return false; } - if (player.getInventory().firstEmpty() == -amount) { - Message.sendErrorMessage(player, "[管理AI]", "インベントリに空きがありません。"); - return false; + if(args.length < 3){ + Message.sendErrorMessage(player, "[管理AI]", "枚数を指定してください。"); } String ticketType = args[1]; @@ -128,6 +119,18 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return false; } + try { + amount = Integer.parseInt(args[2]); + } catch (NumberFormatException e) { + Message.sendErrorMessage(player, "[管理AI]", "枚数は数値で指定してください。"); + return false; + } + + if (player.getInventory().firstEmpty() == -amount) { + Message.sendErrorMessage(player, "[管理AI]", "インベントリに空きがありません。"); + return false; + } + for (int i = 1; i <= amount; i++) { player.getInventory().addItem(ticket); } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java index 4421ff31..0fe0c3e4 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/PurchaseGun.java @@ -34,13 +34,15 @@ public static void executePurchase(Player player, Gun gun) { if(inventory.firstEmpty() == -1) { player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_YES, 1, 1); - Message.sendWarningMessage(player, "[武器AI]", "インベントリがいっぱいなので、受け取りboxに送りました。"); + Message.sendSuccessMessage(player, "[武器AI]", "インベントリがいっぱいなので、受け取りboxに送りました。"); + Message.sendSuccessMessage(player, "[武器AI]", "受け取りboxは /receive で確認できます。"); Date expireDate = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 7); ReceiveBoxAPI.AddReceiveItem(itemStack, player.getUniqueId(), expireDate, "購入した武器"); return; } inventory.addItem(itemStack); + Message.sendSuccessMessage(player, "[武器AI]", gun.getName() + "を購入しました。"); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_CELEBRATE, 1, 1); } } From 0d548f708782f3481bf32eba8130d626267115b7 Mon Sep 17 00:00:00 2001 From: syoyu Date: Mon, 4 Nov 2024 21:48:14 +0900 Subject: [PATCH 34/36] =?UTF-8?q?=E9=A0=86=E7=95=AA=E7=9B=B4=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/achievement/data/AchievementDataManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java index 20aabb32..7ee2de17 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/data/AchievementDataManager.java @@ -17,9 +17,9 @@ public class AchievementDataManager { public static final String Achievement_NORMAL = "normal"; public static final String Achievement_SILVER = "silver"; public static final String Achievement_GOLD = "gold"; - public static final String Name_GOLD = "§e"; - public static final String Name_SILVER = "§b"; public static final String Name_NORMAL = "§f"; + public static final String Name_SILVER = "§b"; + public static final String Name_GOLD = "§e"; public static CounterModelManager manager = null; From 8028fdbb3cb50ef1c56c399a504951c26573f613 Mon Sep 17 00:00:00 2001 From: syoyu Date: Mon, 4 Nov 2024 22:25:27 +0900 Subject: [PATCH 35/36] =?UTF-8?q?=E3=81=A1=E3=82=83=E3=82=93=E3=81=A8?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D=E3=81=97=E3=81=9F=EF=BC=9F?= =?UTF-8?q?=E3=83=9E=E3=82=B8=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/achievement/menu/ProgressMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java index 59a191ed..fdecdbb4 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/achievement/menu/ProgressMenu.java @@ -52,7 +52,7 @@ public void sendMenu(Player player) { Long currentGoal = data.getCurrentGoal(); int cell = (int) (currentGoal / 7); int achievedCells = (int) (currentCount / cell); - builder = builder.addContent(new ProgressBarItem((i % 7) <= achievedCells, data.getStage(), data.getItemName())); + builder = builder.addContent(new ProgressBarItem((i % 8) <= achievedCells, data.getStage(), data.getItemName())); } Window window = Window.single() From ab45feb69ed736feb9e8ce3604f856d3d367f968 Mon Sep 17 00:00:00 2001 From: meyason Date: Thu, 7 Nov 2024 23:22:00 +0900 Subject: [PATCH 36/36] =?UTF-8?q?=E8=89=B2=E3=80=85warning=E3=83=A1?= =?UTF-8?q?=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92ActionBar=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=BF=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subplugins/universeguns/core/EquipmentLimit.java | 6 ++++-- .../subplugins/universeguns/event/GunEvent.java | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java index 85ea6e98..4c9ba126 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/core/EquipmentLimit.java @@ -13,6 +13,8 @@ import space.yurisi.universecorev2.subplugins.universeguns.constants.GunType; import space.yurisi.universecorev2.utils.Message; +import net.kyori.adventure.text.Component; + import java.util.Objects; public class EquipmentLimit { @@ -73,10 +75,10 @@ public boolean debuffEquipmentLimit(Player player){ if(!result[0] || !result[1]){ setEquipmentEffect(player, true); if(!result[0]){ - Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); + player.sendActionBar(Component.text("§6プライマリの所持制限を超えています。")); } if(!result[1]){ - Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); + player.sendActionBar(Component.text("§6セカンダリの所持制限を超えています。")); } return true; } diff --git a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java index eab5a089..4f6b55e8 100644 --- a/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java +++ b/src/main/java/space/yurisi/universecorev2/subplugins/universeguns/event/GunEvent.java @@ -1,5 +1,6 @@ package space.yurisi.universecorev2.subplugins.universeguns.event; +import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.Sound; @@ -509,7 +510,7 @@ public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { } event.setCancelled(true); - Message.sendWarningMessage(event.getPlayer(), "[武器AI]", "オフハンドに武器を持つことはできません。"); + event.getPlayer().sendActionBar(Component.text("§6オフハンドに武器を持つことはできません。")); } } @@ -608,7 +609,7 @@ private void startReload(Player player, Gun gun, GunStatus gunStatus) { boolean result = gunStatus.startReload(reloadTime, player); if (!result) { - Message.sendWarningMessage(player, "[武器AI]", "弾薬を補充してください"); + player.sendActionBar(Component.text("§6弾薬を補充してください")); return; } player.getWorld().playSound(player.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 1.0F, 1.0F); @@ -719,7 +720,7 @@ public void onInventoryClick(InventoryClickEvent event){ if(event.getInventory().getType().equals(InventoryType.CRAFTING) && destinationSlot == 45){ // オフハンド - Message.sendWarningMessage(player, "[武器AI]", "オフハンドに武器を持つことはできません。"); + player.sendActionBar(Component.text("§6オフハンドに武器を持つことはできません。")); event.setCancelled(true); player.getInventory().addItem(oldItem); return; @@ -747,10 +748,10 @@ public void onInventoryClick(InventoryClickEvent event){ if(gun.getEquipmentType() == GunType.PRIMARY && !result[0]){ new EquipmentLimit().setEquipmentEffect(player, true); - Message.sendWarningMessage(player, "[武器AI]", "プライマリの所持制限を超えています。"); + player.sendActionBar(Component.text("§6プライマリの所持制限を超えています。")); }else if(gun.getEquipmentType() == GunType.SECONDARY && !result[1]){ new EquipmentLimit().setEquipmentEffect(player, true); - Message.sendWarningMessage(player, "[武器AI]", "セカンダリの所持制限を超えています。"); + player.sendActionBar(Component.text("§6セカンダリの所持制限を超えています。")); } } }