From c9df6acb139cd7195d36586e0152f2cfca938cfe Mon Sep 17 00:00:00 2001 From: Nishikiyama <68656448+Nishikiyama@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:12:57 +0200 Subject: [PATCH] feat: possibility to set a default rank for new clans (#418) --- pom.xml | 8 ++++---- .../phaed/simpleclans/SimpleClans.java | 1 + .../conversation/CreateClanNamePrompt.java | 18 ++++++++++++------ .../simpleclans/managers/SettingsManager.java | 1 + src/main/resources/config.yml | 1 + 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 67ebd0a47..f3930cd78 100644 --- a/pom.xml +++ b/pom.xml @@ -202,7 +202,7 @@ org.bstats bstats-bukkit - 2.2.1 + 3.0.1 compile @@ -214,7 +214,7 @@ org.jetbrains annotations - 22.0.0 + 24.0.1 io.papermc @@ -230,7 +230,7 @@ com.github.cryptomorin XSeries - 8.3.0 + 9.2.0 com.sk89q.worldguard @@ -259,7 +259,7 @@ com.google.code.gson gson - 2.9.1 + 2.10.1 diff --git a/src/main/java/net/sacredlabyrinth/phaed/simpleclans/SimpleClans.java b/src/main/java/net/sacredlabyrinth/phaed/simpleclans/SimpleClans.java index 954e923af..e3b188055 100644 --- a/src/main/java/net/sacredlabyrinth/phaed/simpleclans/SimpleClans.java +++ b/src/main/java/net/sacredlabyrinth/phaed/simpleclans/SimpleClans.java @@ -176,6 +176,7 @@ private void startMetrics() { metrics.addCustomChart(new SimplePie("threads", () -> sm.is(PERFORMANCE_USE_THREADS) ? on : off)); metrics.addCustomChart(new SimplePie("bungeecord", () -> sm.is(PERFORMANCE_USE_BUNGEECORD) ? on : off)); metrics.addCustomChart(new SimplePie("discord_chat", () -> sm.is(DISCORDCHAT_ENABLE) ? on : off)); + metrics.addCustomChart(new SimplePie("default_rank", () -> sm.getString(CLAN_DEFAULT_RANK).isEmpty() ? off : on)); } private void startTasks() { diff --git a/src/main/java/net/sacredlabyrinth/phaed/simpleclans/conversation/CreateClanNamePrompt.java b/src/main/java/net/sacredlabyrinth/phaed/simpleclans/conversation/CreateClanNamePrompt.java index c4c99dc9b..89bcde717 100644 --- a/src/main/java/net/sacredlabyrinth/phaed/simpleclans/conversation/CreateClanNamePrompt.java +++ b/src/main/java/net/sacredlabyrinth/phaed/simpleclans/conversation/CreateClanNamePrompt.java @@ -4,6 +4,7 @@ import net.sacredlabyrinth.phaed.simpleclans.Clan; import net.sacredlabyrinth.phaed.simpleclans.SimpleClans; import net.sacredlabyrinth.phaed.simpleclans.events.PreCreateClanEvent; +import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager; import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils; import org.bukkit.Bukkit; import org.bukkit.conversations.ConversationContext; @@ -16,6 +17,7 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang; import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanTagPrompt.TAG_KEY; import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*; +import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.CLAN_DEFAULT_RANK; import static org.bukkit.ChatColor.AQUA; import static org.bukkit.ChatColor.RED; @@ -68,14 +70,18 @@ private void processClanCreation(@NotNull SimpleClans plugin, @NotNull Player pl Clan clan = plugin.getClanManager().getClan(tag); clan.addBb(player.getName(), lang("clan.created", name)); plugin.getStorageManager().updateClan(clan); + if (!plugin.getSettingsManager().getString(CLAN_DEFAULT_RANK).isEmpty()) { + clan.setDefaultRank(plugin.getSettingsManager().getString(CLAN_DEFAULT_RANK)); - if (plugin.getSettingsManager().is(REQUIRE_VERIFICATION)) { - boolean verified = !plugin.getSettingsManager().is(REQUIRE_VERIFICATION) - || plugin.getPermissionsManager().has(player, "simpleclans.mod.verify"); - if (!verified) { - ChatBlock.sendMessage(player, AQUA + - lang("get.your.clan.verified.to.access.advanced.features", player)); + if (plugin.getSettingsManager().is(REQUIRE_VERIFICATION)) { + boolean verified = !plugin.getSettingsManager().is(REQUIRE_VERIFICATION) + || plugin.getPermissionsManager().has(player, "simpleclans.mod.verify"); + + if (!verified) { + ChatBlock.sendMessage(player, AQUA + + lang("get.your.clan.verified.to.access.advanced.features", player)); + } } } } diff --git a/src/main/java/net/sacredlabyrinth/phaed/simpleclans/managers/SettingsManager.java b/src/main/java/net/sacredlabyrinth/phaed/simpleclans/managers/SettingsManager.java index b0fae5042..0c75c9147 100644 --- a/src/main/java/net/sacredlabyrinth/phaed/simpleclans/managers/SettingsManager.java +++ b/src/main/java/net/sacredlabyrinth/phaed/simpleclans/managers/SettingsManager.java @@ -450,6 +450,7 @@ public enum ConfigField { CLAN_PERCENTAGE_ONLINE_TO_DEMOTE("clan.percentage-online-to-demote", 100.0), CLAN_FF_ON_BY_DEFAULT("clan.ff-on-by-default", false), CLAN_MIN_TO_VERIFY("clan.min-to-verify", 1), + CLAN_DEFAULT_RANK("clan.default-rank", "recruit"), /* ================ > Tasks Settings diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 41e569833..eb88d3b30 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -167,6 +167,7 @@ clan: - treasurer: display-name: "&6Treasurer" permissions: [ bank.balance, bank.deposit, bank.withdraw ] + default-rank: "recruit" tasks: collect-upkeep: