diff --git a/src/main/java/me/lrxh/practice/Practice.java b/src/main/java/me/lrxh/practice/Practice.java index 2ec2008..5dfc22f 100644 --- a/src/main/java/me/lrxh/practice/Practice.java +++ b/src/main/java/me/lrxh/practice/Practice.java @@ -33,6 +33,7 @@ import me.lrxh.practice.profile.KillEffects; import me.lrxh.practice.profile.Profile; import me.lrxh.practice.profile.ProfileListener; +import me.lrxh.practice.profile.Themes; import me.lrxh.practice.profile.hotbar.Hotbar; import me.lrxh.practice.queue.QueueListener; import me.lrxh.practice.queue.QueueThread; @@ -221,8 +222,11 @@ private void loadCommandCompletions() { private void registerPermissions() { PluginManager pluginManager = getServer().getPluginManager(); - for (KillEffects killEffects : KillEffects.values()) { - pluginManager.addPermission(new Permission("practice.killeffect." + killEffects.getDisplayName(), PermissionDefault.OP)); + for (KillEffects killEffect : KillEffects.values()) { + pluginManager.addPermission(new Permission("practice.killeffect." + killEffect.getDisplayName(), PermissionDefault.OP)); + } + for (Themes theme : Themes.values()) { + pluginManager.addPermission(new Permission("practice.theme." + theme.getName(), PermissionDefault.OP)); } Arrays.asList( "practice.admin.arena", diff --git a/src/main/java/me/lrxh/practice/commands/user/duels/DuelCommand.java b/src/main/java/me/lrxh/practice/commands/user/duels/DuelCommand.java index 1af690c..e1c4461 100644 --- a/src/main/java/me/lrxh/practice/commands/user/duels/DuelCommand.java +++ b/src/main/java/me/lrxh/practice/commands/user/duels/DuelCommand.java @@ -41,10 +41,10 @@ public void execute(Player sender, String targetName) { return; } - if (sender.getUniqueId().equals(target.getUniqueId())) { - sender.sendMessage(CC.RED + "You cannot duel yourself."); - return; - } +// if (sender.getUniqueId().equals(target.getUniqueId())) { +// sender.sendMessage(CC.RED + "You cannot duel yourself."); +// return; +// } Profile senderProfile = Profile.getByUuid(sender.getUniqueId()); Profile targetProfile = Profile.getByUuid(target.getUniqueId()); diff --git a/src/main/java/me/lrxh/practice/duel/menu/DuelSelectArenaMenu.java b/src/main/java/me/lrxh/practice/duel/menu/DuelSelectArenaMenu.java index 9ee7e27..d7c4188 100644 --- a/src/main/java/me/lrxh/practice/duel/menu/DuelSelectArenaMenu.java +++ b/src/main/java/me/lrxh/practice/duel/menu/DuelSelectArenaMenu.java @@ -5,6 +5,7 @@ import me.lrxh.practice.arena.Arena; import me.lrxh.practice.arena.ArenaType; import me.lrxh.practice.profile.Profile; +import me.lrxh.practice.util.InventoryUtil; import me.lrxh.practice.util.ItemBuilder; import me.lrxh.practice.util.menu.Button; import me.lrxh.practice.util.menu.Menu; @@ -18,6 +19,7 @@ import java.util.Map; public class DuelSelectArenaMenu extends Menu { + Map buttons = new HashMap<>(); @Override public String getTitle(Player player) { @@ -26,7 +28,7 @@ public String getTitle(Player player) { @Override public int getSize() { - return Practice.getInstance().getMenusConfig().getInteger("DUEL.ARENA-SELECTOR.SIZE"); + return InventoryUtil.getMenuSize(buttons.size(), true); } @Override @@ -38,7 +40,6 @@ public Filters getFilter() { public Map getButtons(Player player) { Profile profile = Profile.getByUuid(player.getUniqueId()); - Map buttons = new HashMap<>(); int i = 10; for (Arena arena : Arena.getArenas()) { diff --git a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java index f2ae625..85e67f6 100644 --- a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java +++ b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java @@ -53,7 +53,7 @@ public Map getButtons(Player player) { buttons.put(i++, new SelectKitButton(queue)); } } -// buttons.put(4, new SelectQueueButton(ranked)); + //buttons.put(4, new SelectQueueButton(ranked)); return buttons; } @@ -97,6 +97,7 @@ public ItemStack getButtonItem(Player player) { configLore.forEach(line -> { line = line.replaceAll("", String.valueOf(Match.getInFightsCount(queue))); line = line.replaceAll("", String.valueOf(queue.getQueuing())); + line = line.replaceAll("", queue.getKit().getName()); line = replaceLeaderboardPlaceholders(line, queue); if (!line.contains("") || !queue.getKit().getDescription().equalsIgnoreCase("none")) { line = line.replaceAll("", queue.getKit().getDescription()); diff --git a/src/main/java/me/lrxh/practice/setting/SettingsMenu.java b/src/main/java/me/lrxh/practice/setting/SettingsMenu.java index 1696ef5..bca2904 100644 --- a/src/main/java/me/lrxh/practice/setting/SettingsMenu.java +++ b/src/main/java/me/lrxh/practice/setting/SettingsMenu.java @@ -245,7 +245,7 @@ public void clicked(Player player, ClickType clickType) { break; } case THEME: { - if (!player.hasPermission("practice.options.theme.selector")) { + if (!player.hasPermission("practice.theme." + profile.getOptions().theme().getName())) { player.sendMessage(CC.translate("&cYou don't have permission to use the theme selector")); break; } diff --git a/src/main/java/me/lrxh/practice/util/InventoryUtil.java b/src/main/java/me/lrxh/practice/util/InventoryUtil.java index 261b7df..c287d72 100644 --- a/src/main/java/me/lrxh/practice/util/InventoryUtil.java +++ b/src/main/java/me/lrxh/practice/util/InventoryUtil.java @@ -36,6 +36,17 @@ public static String serializeInventory(ItemStack[] source) { return builder.toString(); } + public static int getMenuSize(int numberOfItems, boolean filling) { + int slotsPerRow = 9; + int rows = (int) Math.ceil((double) numberOfItems / slotsPerRow); + rows = Math.max(rows, 1); + if(filling){ + return rows * slotsPerRow + 18; + }else{ + return rows * slotsPerRow; + } + } + public static ItemStack[] deserializeInventory(String source) { List items = new ArrayList<>(); String[] split = source.split(";");