This commit is contained in:
Paul Reilly 2023-02-16 20:28:38 -06:00
parent ea60be4c48
commit f53696aa9e
6 changed files with 56 additions and 10 deletions

View File

@ -11,7 +11,7 @@ public abstract class FreedomService implements Listener
protected final Server server; protected final Server server;
protected final Logger logger; protected final Logger logger;
public FreedomService() protected FreedomService()
{ {
plugin = TotalFreedomMod.getPlugin(); plugin = TotalFreedomMod.getPlugin();
server = plugin.getServer(); server = plugin.getServer();

View File

@ -236,6 +236,7 @@ public class TotalFreedomMod extends JavaPlugin
try try
{ {
final Properties props; final Properties props;
final String unknown = "unknown";
try (InputStream in = plugin.getResource("build.properties")) try (InputStream in = plugin.getResource("build.properties"))
{ {
@ -243,13 +244,12 @@ public class TotalFreedomMod extends JavaPlugin
props.load(in); props.load(in);
} }
author = props.getProperty("buildAuthor", "unknown"); author = props.getProperty("buildAuthor", unknown);
codename = props.getProperty("buildCodeName", "unknown"); codename = props.getProperty("buildCodeName", unknown);
version = props.getProperty("buildVersion", pluginVersion); version = props.getProperty("buildVersion", pluginVersion);
number = props.getProperty("buildNumber", "1"); number = props.getProperty("buildNumber", "1");
date = props.getProperty("buildDate", "unknown"); date = props.getProperty("buildDate", unknown);
// Need to do this or it will display ${git.commit.id.abbrev} head = props.getProperty("buildHead", unknown).replace("${git.commit.id.abbrev}", unknown);
head = props.getProperty("buildHead", "unknown").replace("${git.commit.id.abbrev}", "unknown");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -0,0 +1,44 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.essentialsx.discord.EssentialsDiscord;
import org.bukkit.plugin.Plugin;
public class EXDiscordBridge extends FreedomService
{
private EssentialsDiscord essentialsDiscord = null;
@Override
public void onStart()
{
// This is completely useless, but it's here to make sure the service is loaded.
}
@Override
public void onStop()
{
essentialsDiscord = null;
}
public EssentialsDiscord getEssentialsDiscord()
{
if (essentialsDiscord == null)
{
try
{
final Plugin xDiscord = server.getPluginManager().getPlugin("EssentialsXDiscord");
assert xDiscord != null;
if (xDiscord instanceof EssentialsDiscord e)
{
essentialsDiscord = e;
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return essentialsDiscord;
}
}

View File

@ -28,11 +28,13 @@ public class EssentialsBridge extends FreedomService
@Override @Override
public void onStart() public void onStart()
{ {
// This is completely useless, but it's here to make sure the service is loaded.
} }
@Override @Override
public void onStop() public void onStop()
{ {
essentialsPlugin = null;
} }
public Essentials getEssentialsPlugin() public Essentials getEssentialsPlugin()
@ -43,9 +45,9 @@ public class EssentialsBridge extends FreedomService
{ {
final Plugin essentials = server.getPluginManager().getPlugin("Essentials"); final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
assert essentials != null; assert essentials != null;
if (essentials instanceof Essentials) if (essentials instanceof Essentials e)
{ {
essentialsPlugin = (Essentials)essentials; essentialsPlugin = e;
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -32,7 +32,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!"; public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command."; public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command.";
public static final Timer timer = new Timer(); public static final Timer timer = new Timer();
public static final Map<CommandSender, FreedomCommand> COOLDOWN_TIMERS = new HashMap<>(); protected static final Map<CommandSender, FreedomCommand> COOLDOWN_TIMERS = new HashMap<>();
protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin(); protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
protected final Server server = plugin.getServer(); protected final Server server = plugin.getServer();
private final String name; private final String name;

View File

@ -121,7 +121,7 @@ public class DiscordToMinecraftListener extends ListenerAdapter
} }
} }
FLog.info(TextComponent.toLegacyText(components), true); FLog.info(BaseComponent.toLegacyText(components), true);
} }