Skip to content

Commit

Permalink
Add scoreboard injector
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Dec 21, 2023
1 parent 0a4728d commit 723541d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.nookure.mast.api.config.bukkit;

import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import java.util.List;

Expand All @@ -12,14 +13,18 @@ public boolean enabled() {
return enabled;
}

public final Scoreboard scoreboard = new Scoreboard();

@ConfigSerializable
public static final class Scoreboard {
@Setting
private String title = "<b><dark_aqua>Staff Mode</dark_aqua></b>";

public String title() {
return title;
}

@Setting
private List<String> lines = List.of(
"<b><yellow>|</yellow></b> <white>Rank:</white> <b><red>%vault_prefix%</red></b>",
"<b><yellow>|</yellow></b> <white>Vanished:</white> <green>True</green>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.google.inject.Injector;
import com.nookure.mast.api.addons.AddonManager;
import com.nookure.mast.api.addons.annotations.Addon;
import com.nookure.mast.api.config.ConfigurationContainer;
import com.nookure.mast.api.config.bukkit.ScoreboardConfig;
import com.nookure.mast.api.event.Channels;
import com.nookure.mast.api.event.EventManager;
import com.nookure.mast.webhook.DiscordWebhooks;
Expand Down Expand Up @@ -77,6 +79,7 @@
import org.simpleyaml.configuration.file.YamlFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.ArrayList;
Expand All @@ -101,6 +104,7 @@ public class MAStaff extends JavaPlugin implements MAStaffInstance<JavaPlugin> {
private final ArrayList<Listener> listeners = new ArrayList<>();
private boolean debug = false;
private Injector injector;
private ConfigurationContainer<ScoreboardConfig> scoreboardConfig;

@Override
public void onEnable() {
Expand Down Expand Up @@ -346,6 +350,7 @@ public void reload() {
AsyncThreadKt.stop();
logger.debug("Reloading Config...");
loadConfig();
scoreboardConfig.reload().join();
Messages.setMessages(ConfigLoader.getMessages().getConfig());
logger.debug("Loading Database...");
loadDatabase();
Expand Down Expand Up @@ -418,6 +423,11 @@ public void checkUpdates() {
@SuppressWarnings({"Deprecated", "deprecation"})
public void inject() {
getPLogger().debug("Injecting...");
try {
scoreboardConfig = ConfigurationContainer.load(getDataFolder().toPath(), ScoreboardConfig.class, "modules/scoreboard.yml");
} catch (IOException e) {
throw new RuntimeException(e);
}
injector = Guice.createInjector(new BukkitInjector());
StaticMembersInjector.injectStatics(injector, LegacyStaffPlayersManagers.class);
StaticMembersInjector.injectStatics(injector, LegacyUserDataManager.class);
Expand Down Expand Up @@ -491,4 +501,8 @@ public static MAStaff getPlugin() {
public Addon.AddonPlatform getPlatform() {
return Addon.AddonPlatform.BUKKIT;
}

public ConfigurationContainer<ScoreboardConfig> getScoreboardConfig() {
return scoreboardConfig;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nookure.mast.addon.ServerAddonManager;
import com.nookure.mast.api.addons.AddonManager;
import com.nookure.mast.api.config.bukkit.ScoreboardConfig;
import com.nookure.mast.api.event.PluginMessageManager;
import com.nookure.mast.api.manager.FreezeManager;
import com.nookure.mast.api.staff.StaffFeatureManager;
Expand Down Expand Up @@ -45,6 +46,7 @@ protected void configure() {
getScoreboardLibrary().ifPresent(scoreboardLibrary ->
bind(ScoreboardLibrary.class).toInstance(scoreboardLibrary)
);
bind(ScoreboardConfig.class).toInstance(MAStaff.getPlugin().getScoreboardConfig().get());
}

private static Optional<ScoreboardLibrary> getScoreboardLibrary() {
Expand Down

0 comments on commit 723541d

Please sign in to comment.