diff --git a/build.gradle.kts b/build.gradle.kts index 854300b3..1204ce50 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ repositories { } dependencies { - implementation("plugily.projects:MiniGamesBox-Classic:1.3.13") { isTransitive = false } + implementation("plugily.projects:MiniGamesBox-Classic:1.3.14") { isTransitive = false } compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") compileOnly("org.jetbrains:annotations:24.0.1") @@ -25,7 +25,7 @@ dependencies { } group = "plugily.projects" -version = "2.0.12" +version = "2.0.12-SNAPSHOT2" description = "MurderMystery" java { diff --git a/src/main/java/plugily/projects/murdermystery/arena/special/SpecialBlockEvents.java b/src/main/java/plugily/projects/murdermystery/arena/special/SpecialBlockEvents.java index bbde79e5..10e24821 100644 --- a/src/main/java/plugily/projects/murdermystery/arena/special/SpecialBlockEvents.java +++ b/src/main/java/plugily/projects/murdermystery/arena/special/SpecialBlockEvents.java @@ -29,7 +29,6 @@ import plugily.projects.minigamesbox.api.arena.IArenaState; import plugily.projects.minigamesbox.api.user.IUser; import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder; -import plugily.projects.minigamesbox.classic.user.User; import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder; import plugily.projects.minigamesbox.classic.utils.helper.ItemUtils; import plugily.projects.minigamesbox.classic.utils.misc.complement.ComplementAccessor; @@ -124,7 +123,7 @@ private void onCauldronClick(PlayerInteractEvent event) { item.setPickupDelay(10000); Bukkit.getScheduler().runTaskLater(plugin, item::remove, 20); user.adjustStatistic("LOCAL_GOLD", -1); - ItemPosition.addItem(user, ItemPosition.GOLD_INGOTS, new ItemStack(Material.GOLD_INGOT, -1)); + ItemPosition.removeItem(user, new ItemStack(Material.GOLD_INGOT, 1)); ItemPosition.setItem(user, ItemPosition.POTION, new ItemBuilder(XMaterial.POTION.parseItem()).name(MysteryPotionRegistry.getRandomPotion().getName()).build()); } @@ -145,8 +144,8 @@ private void onPrayerClick(PlayerInteractEvent event) { new MessageBuilder("IN_GAME_MESSAGES_ARENA_PLAYING_SPECIAL_BLOCKS_PRAY_CHAT").asKey().player(event.getPlayer()).sendPlayer(); user.adjustStatistic("LOCAL_PRAISES", 1); VersionUtils.sendParticles("FIREWORKS_SPARK", event.getPlayer(), event.getClickedBlock().getLocation(), 10); - user.adjustStatistic("LOCAL_GOLD", 1); - ItemPosition.addItem(user, ItemPosition.GOLD_INGOTS, new ItemStack(Material.GOLD_INGOT, -1)); + user.adjustStatistic("LOCAL_GOLD", -1); + ItemPosition.removeItem(user, new ItemStack(Material.GOLD_INGOT, 1)); } private void onPrayLeverClick(PlayerInteractEvent event) { diff --git a/src/main/java/plugily/projects/murdermystery/arena/states/StartingState.java b/src/main/java/plugily/projects/murdermystery/arena/states/StartingState.java index 080e8626..fc6b382e 100644 --- a/src/main/java/plugily/projects/murdermystery/arena/states/StartingState.java +++ b/src/main/java/plugily/projects/murdermystery/arena/states/StartingState.java @@ -18,6 +18,7 @@ package plugily.projects.murdermystery.arena.states; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -27,7 +28,6 @@ import plugily.projects.minigamesbox.classic.arena.states.PluginStartingState; import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder; import plugily.projects.minigamesbox.classic.handlers.language.TitleBuilder; -import plugily.projects.minigamesbox.classic.user.User; import plugily.projects.minigamesbox.classic.utils.version.VersionUtils; import plugily.projects.murdermystery.arena.Arena; import plugily.projects.murdermystery.arena.ArenaUtils; @@ -116,8 +116,10 @@ private void addRole(Arena arena, Role role, Set playersToSet) { } else if(role == Role.DETECTIVE) { arena.getDetectiveList().add(userPlayer); userPlayer.getInventory().setHeldItemSlot(0); - ItemPosition.setItem(user, ItemPosition.BOW, new ItemStack(Material.BOW, 1)); - ItemPosition.setItem(user, ItemPosition.INFINITE_ARROWS, new ItemStack(Material.ARROW, getPlugin().getConfig().getInt("Bow.Amount.Arrows.Detective", 3))); + Bukkit.getScheduler().runTaskLater(arena.getPlugin(), () -> { + ItemPosition.setItem(user, ItemPosition.BOW, new ItemStack(Material.BOW, 1)); + ItemPosition.setItem(user, ItemPosition.INFINITE_ARROWS, new ItemStack(Material.ARROW, getPlugin().getConfig().getInt("Bow.Amount.Arrows.Detective", 3))); + }, 20); } } } diff --git a/src/main/java/plugily/projects/murdermystery/utils/ItemPosition.java b/src/main/java/plugily/projects/murdermystery/utils/ItemPosition.java index 2b18e18e..599d501b 100644 --- a/src/main/java/plugily/projects/murdermystery/utils/ItemPosition.java +++ b/src/main/java/plugily/projects/murdermystery/utils/ItemPosition.java @@ -21,7 +21,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import plugily.projects.minigamesbox.api.user.IUser; -import plugily.projects.minigamesbox.classic.user.User; import plugily.projects.murdermystery.arena.role.Role; /** @@ -46,15 +45,15 @@ public enum ItemPosition { * Adds target item to specified hotbar position sorta different for each role. * Item will be added if there is already set or will be set when no item is set in the position. * - * @param user player to add item to + * @param user player to add item to * @param itemPosition position of item to set/add * @param itemStack itemstack to be added at itemPostion or set at itemPosition */ public static void addItem(IUser user, ItemPosition itemPosition, ItemStack itemStack) { int itemPos = Role.isRole(Role.MURDERER, user) ? itemPosition.getMurdererItemPosition() - : itemPosition.getOtherRolesItemPosition(); + : itemPosition.getOtherRolesItemPosition(); - if (itemPos < 0) { + if(itemPos < 0) { return; } @@ -73,18 +72,23 @@ public static void addItem(IUser user, ItemPosition itemPosition, ItemStack item * Sets target item in specified hotbar position sorta different for each role. * If item there is already set it will be incremented by itemStack amount if possible. * - * @param user player to set item to + * @param user player to set item to * @param itemPosition position of item to set * @param itemStack itemstack to set at itemPosition */ public static void setItem(IUser user, ItemPosition itemPosition, ItemStack itemStack) { - if(itemPosition.getMurdererItemPosition() >= 0 && Role.isRole(Role.MURDERER, user)) { + if(Role.isRole(Role.MURDERER, user)) { user.getPlayer().getInventory().setItem(itemPosition.getMurdererItemPosition(), itemStack); - } else if (itemPosition.getOtherRolesItemPosition() >= 0) { + } else { user.getPlayer().getInventory().setItem(itemPosition.getOtherRolesItemPosition(), itemStack); } } + public static void removeItem(IUser user, ItemStack itemStack) { + user.getPlayer().getInventory().removeItem(itemStack); + } + + public int getMurdererItemPosition() { return murdererItemPosition; }