Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
<version>26.1-R0.1-SNAPSHOT-build2096-tfmc-822e034c64c8</version>
<scope>provided</scope>
</dependency>
<!-- Optional at runtime: the rank writer no-ops when LuckPerms is absent. -->
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.plugins</groupId>
<artifactId>tlibs</artifactId>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/net/tfminecraft/tfmcweb/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -62,8 +63,26 @@ public final class Cache {
public static boolean drinksMetaDefaultAllowMessage = false;
public static List<MetaGroupDefinition> drinksMetaGroups = MetaGroupDefinition.emptyList();

/** Master switch for /patreon and the rank writer. */
public static boolean patreonEnabled = false;
/** When true with {@link #patreonEnabled}, this server writes LuckPerms ranks. */
public static boolean patreonApplyRanks = false;
public static int patreonPollSeconds = 60;
public static int patreonReconcileMinutes = 30;
/** Tier key → LuckPerms group. Only these groups are ever added or removed. */
public static Map<String, String> patreonGroups = Map.copyOf(patreonGroupDefaults());

private Cache() {}

/** Mutable noble/gilded/ascended → same-name group map. */
public static Map<String, String> patreonGroupDefaults() {
Map<String, String> groups = new LinkedHashMap<>();
groups.put("noble", "noble");
groups.put("gilded", "gilded");
groups.put("ascended", "ascended");
return groups;
}

/** One LP-gated cooldown row from token-cooldowns.groups. */
public static final class TokenCooldownGroup {
public final String permission;
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/net/tfminecraft/tfmcweb/TFMCWeb.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import net.tfminecraft.tfmcweb.loaders.ConfigLoader;
import net.tfminecraft.tfmcweb.entitlements.PlayerMetaSyncService;
import net.tfminecraft.tfmcweb.managers.LinkDiscordCommand;
import net.tfminecraft.tfmcweb.managers.PatreonCommand;
import net.tfminecraft.tfmcweb.managers.PluginNoticePoller;
import net.tfminecraft.tfmcweb.managers.TokenCommand;
import net.tfminecraft.tfmcweb.managers.UnlinkDiscordCommand;
import net.tfminecraft.tfmcweb.managers.WarningCommand;
import net.tfminecraft.tfmcweb.managers.WebCommand;
import net.tfminecraft.tfmcweb.patreon.PatreonRankWriter;

public class TFMCWeb extends JavaPlugin {

Expand All @@ -27,6 +29,7 @@ public class TFMCWeb extends JavaPlugin {
private final LinkCache linkCache = new LinkCache();
private DiscordGateService gateService;
private PluginNoticePoller noticePoller;
private PatreonRankWriter rankWriter;

@Override
public void onEnable() {
Expand All @@ -46,6 +49,8 @@ public void onEnable() {

noticePoller = new PluginNoticePoller(this, linkCache, gateService);
noticePoller.start();
rankWriter = new PatreonRankWriter(this);
rankWriter.refresh();

if (getCommand("linkdiscord") != null) {
getCommand("linkdiscord").setExecutor(new LinkDiscordCommand(this, linkCache, gateService));
Expand All @@ -60,7 +65,7 @@ public void onEnable() {
getLogger().severe("Command unlinkdiscord missing from plugin.yml");
}
if (getCommand("web") != null) {
WebCommand web = new WebCommand(this, linkCache, gateService);
WebCommand web = new WebCommand(this, linkCache, gateService, rankWriter);
getCommand("web").setExecutor(web);
getCommand("web").setTabCompleter(web);
} else {
Expand All @@ -78,6 +83,13 @@ public void onEnable() {
} else {
getLogger().severe("Command warning missing from plugin.yml");
}
if (getCommand("patreon") != null) {
PatreonCommand patreon = new PatreonCommand(this);
getCommand("patreon").setExecutor(patreon);
getCommand("patreon").setTabCompleter(patreon);
} else {
getLogger().severe("Command patreon missing from plugin.yml");
}

Bukkit.getPluginManager().registerEvents(
new PlayerJoinListener(this, gateService),
Expand All @@ -99,6 +111,9 @@ public void onDisable() {
if (noticePoller != null) {
noticePoller.stop();
}
if (rankWriter != null) {
rankWriter.stop();
}
}

public LinkCache getLinkCache() {
Expand All @@ -111,6 +126,9 @@ public DiscordGateService getGateService() {

public void reloadLocalConfig() {
configLoader.load(new File(getDataFolder(), "config.yml"));
if (rankWriter != null) {
rankWriter.refresh();
}
PlayerMetaSyncService.pushAllOnlineAsync();
}

Expand Down
Loading