it doesnt work

This commit is contained in:
Telesphoreo 2022-04-19 15:49:21 -05:00
parent 67a382695a
commit 730f7c5ea0
4 changed files with 53 additions and 42 deletions

View File

@ -21,13 +21,12 @@ import dev.plex.storage.player.MongoPlayerData;
import dev.plex.storage.player.SQLPlayerData; import dev.plex.storage.player.SQLPlayerData;
import dev.plex.storage.punishment.SQLNotes; import dev.plex.storage.punishment.SQLNotes;
import dev.plex.storage.punishment.SQLPunishment; import dev.plex.storage.punishment.SQLPunishment;
import dev.plex.util.BuildInfo;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import dev.plex.util.UpdateChecker; import dev.plex.util.UpdateChecker;
import dev.plex.world.CustomWorld; import dev.plex.world.CustomWorld;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
@ -40,7 +39,6 @@ import org.bukkit.plugin.java.JavaPlugin;
@Setter @Setter
public class Plex extends JavaPlugin public class Plex extends JavaPlugin
{ {
public static final BuildProperties build = new BuildProperties();
private static Plex plugin; private static Plex plugin;
public Config config; public Config config;
@ -51,6 +49,8 @@ public class Plex extends JavaPlugin
public File modulesFolder; public File modulesFolder;
private StorageType storageType = StorageType.SQLITE; private StorageType storageType = StorageType.SQLITE;
public static final BuildInfo build = new BuildInfo();
private SQLConnection sqlConnection; private SQLConnection sqlConnection;
private MongoConnection mongoConnection; private MongoConnection mongoConnection;
private RedisConnection redisConnection; private RedisConnection redisConnection;
@ -241,37 +241,6 @@ public class Plex extends JavaPlugin
}); });
} }
public static class BuildProperties
{
public String number;
public String author;
public String date;
public String head;
public void load(Plex plugin)
{
try
{
final Properties props;
try (InputStream in = plugin.getResource("build.properties"))
{
props = new Properties();
props.load(in);
}
number = props.getProperty("buildNumber", "unknown");
author = props.getProperty("buildAuthor", "unknown");
date = props.getProperty("buildDate", "unknown");
head = props.getProperty("buildHead", "unknown");
}
catch (Exception ex)
{
PlexLog.error("Could not load build properties! Did you compile with NetBeans/Maven?");
}
}
}
public boolean setupPermissions() public boolean setupPermissions()
{ {
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);

View File

@ -1,6 +1,5 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import dev.plex.Plex;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
@ -9,6 +8,7 @@ import dev.plex.command.source.RequiredCommandSource;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
import dev.plex.module.PlexModuleFile; import dev.plex.module.PlexModuleFile;
import dev.plex.rank.enums.Rank; import dev.plex.rank.enums.Rank;
import dev.plex.util.BuildInfo;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.Arrays; import java.util.Arrays;
@ -34,9 +34,9 @@ public class PlexCMD extends PlexCommand
if (args.length == 0) if (args.length == 0)
{ {
send(sender, mmString("<light_purple>Plex - A new freedom plugin.")); send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + Plex.build.number + " <light_purple>Git: <gold>" + Plex.build.head)); send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getHead()));
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh")); send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
send(sender, mmString("<light_purple>Built by: <gold>" + Plex.build.author + " <light_purple>on <gold>" + Plex.build.date)); send(sender, mmString("<light_purple>Built by: <gold>" + BuildInfo.getAuthor() + " <light_purple>on <gold>" + BuildInfo.getDate()));
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules.")); send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2); plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2);
return null; return null;

View File

@ -2,10 +2,12 @@ package dev.plex.listener.impl;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent; import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.util.PlexUtils;
import dev.plex.util.RandomUtil; import dev.plex.util.RandomUtil;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -20,16 +22,17 @@ public class ServerListener extends PlexListener
baseMotd = baseMotd.replace("%mcversion%", Bukkit.getBukkitVersion().split("-")[0]); baseMotd = baseMotd.replace("%mcversion%", Bukkit.getBukkitVersion().split("-")[0]);
if (plugin.config.getBoolean("server.colorize_motd")) if (plugin.config.getBoolean("server.colorize_motd"))
{ {
final StringBuilder motd = new StringBuilder(); AtomicReference<Component> motd = new AtomicReference<>(Component.empty());
for (final String word : baseMotd.split(" ")) for (final String word : baseMotd.split(" "))
{ {
motd.append(RandomUtil.getRandomColor()).append(word).append(" "); motd.get().append(Component.text(word).color(RandomUtil.getRandomColor()));
motd.get().append(Component.space());
} }
event.motd(LegacyComponentSerializer.legacyAmpersand().deserialize(motd.toString().trim())); event.motd(motd.get());
} }
else else
{ {
event.motd(LegacyComponentSerializer.legacyAmpersand().deserialize(baseMotd.trim())); event.motd(PlexUtils.mmDeserialize(baseMotd.trim()));
} }
if (plugin.config.contains("server.sample")) if (plugin.config.contains("server.sample"))
{ {

View File

@ -0,0 +1,39 @@
package dev.plex.util;
import dev.plex.Plex;
import java.io.InputStream;
import java.util.Properties;
import lombok.Getter;
public class BuildInfo
{
@Getter
public static String number;
@Getter
public static String author;
@Getter
public static String date;
@Getter
public static String head;
public void load(Plex plugin)
{
try
{
Properties props;
try (InputStream in = plugin.getResource("build.properties"))
{
props = new Properties();
props.load(in);
}
number = props.getProperty("buildNumber", "unknown");
author = props.getProperty("buildAuthor", "unknown");
date = props.getProperty("buildDate", "unknown");
head = props.getProperty("buildHead", "unknown");
}
catch (Exception ignored)
{
}
}
}