Skip to content

Commit

Permalink
feat: possibility to set a default rank for new clans (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishikiyama committed Feb 1, 2024
1 parent ad910e9 commit c9df6ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -214,7 +214,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
<version>24.0.1</version>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
Expand All @@ -230,7 +230,7 @@
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>8.3.0</version>
<version>9.2.0</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
Expand Down Expand Up @@ -259,7 +259,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
<version>2.10.1</version>
</dependency>

<!-- Test frameworks -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ clan:
- treasurer:
display-name: "&6Treasurer"
permissions: [ bank.balance, bank.deposit, bank.withdraw ]
default-rank: "recruit"

tasks:
collect-upkeep:
Expand Down

0 comments on commit c9df6ac

Please sign in to comment.