stuff
This commit is contained in:
@ -13,7 +13,6 @@ import cc.fascinated.motd.MotdManager;
|
|||||||
import cc.fascinated.placeholder.PlaceholderManager;
|
import cc.fascinated.placeholder.PlaceholderManager;
|
||||||
import cc.fascinated.playercolor.PlayerColorManager;
|
import cc.fascinated.playercolor.PlayerColorManager;
|
||||||
import cc.fascinated.staffchat.StaffChatManager;
|
import cc.fascinated.staffchat.StaffChatManager;
|
||||||
import cc.fascinated.staffchat.command.StaffChatCommand;
|
|
||||||
import cc.fascinated.utils.BuildData;
|
import cc.fascinated.utils.BuildData;
|
||||||
import cc.fascinated.vote.VoteManager;
|
import cc.fascinated.vote.VoteManager;
|
||||||
import cc.fascinated.worldsize.WorldSizeManager;
|
import cc.fascinated.worldsize.WorldSizeManager;
|
||||||
@ -26,15 +25,14 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class Aetheria extends JavaPlugin {
|
public class Aetheria extends JavaPlugin {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static final BuildData buildData = new BuildData();
|
||||||
/**
|
/**
|
||||||
* The instance of the plugin.
|
* The instance of the plugin.
|
||||||
*/
|
*/
|
||||||
public static Aetheria INSTANCE;
|
public static Aetheria INSTANCE;
|
||||||
|
|
||||||
public static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(2, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
|
public static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(2, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
|
||||||
|
|
||||||
@Getter private static final BuildData buildData = new BuildData();
|
|
||||||
|
|
||||||
public Aetheria() {
|
public Aetheria() {
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@Getter @Log4j2 @EqualsAndHashCode
|
|
||||||
|
@Getter
|
||||||
|
@Log4j2
|
||||||
|
@EqualsAndHashCode
|
||||||
public class Account {
|
public class Account {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +29,30 @@ public class Account {
|
|||||||
*/
|
*/
|
||||||
private static final String playerColorProfileId = "playerColorProfile";
|
private static final String playerColorProfileId = "playerColorProfile";
|
||||||
private static final String voteProfileId = "voteProfile";
|
private static final String voteProfileId = "voteProfile";
|
||||||
|
/**
|
||||||
|
* The UUID of the player.
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode.Exclude
|
||||||
|
private final UUID uuid;
|
||||||
|
/**
|
||||||
|
* The name of the player.
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
/**
|
||||||
|
* The file for this account.
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode.Exclude
|
||||||
|
private final File file;
|
||||||
|
/**
|
||||||
|
* The configuration for this account.
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode.Exclude
|
||||||
|
private final FileConfiguration config;
|
||||||
|
/**
|
||||||
|
* Account profiles.
|
||||||
|
*/
|
||||||
|
private final PlayerColorProfile playerColorProfile;
|
||||||
|
private final VoteProfile voteProfile;
|
||||||
/**
|
/**
|
||||||
* The last hashcode of the account. This is used to check if any changes
|
* The last hashcode of the account. This is used to check if any changes
|
||||||
* have been made to the account. If no changes have been made,
|
* have been made to the account. If no changes have been made,
|
||||||
@ -34,46 +60,15 @@ public class Account {
|
|||||||
*/
|
*/
|
||||||
@EqualsAndHashCode.Exclude
|
@EqualsAndHashCode.Exclude
|
||||||
private int lastHash;
|
private int lastHash;
|
||||||
|
|
||||||
/**
|
|
||||||
* The UUID of the player.
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode.Exclude
|
|
||||||
private final UUID uuid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the player.
|
|
||||||
*/
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The first time the player joined the server.
|
* The first time the player joined the server.
|
||||||
*/
|
*/
|
||||||
private long firstJoin;
|
private long firstJoin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last time the player logged in.
|
* The last time the player logged in.
|
||||||
*/
|
*/
|
||||||
private long lastLogin;
|
private long lastLogin;
|
||||||
|
|
||||||
/**
|
|
||||||
* The file for this account.
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode.Exclude
|
|
||||||
private final File file;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The configuration for this account.
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode.Exclude
|
|
||||||
private final FileConfiguration config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account profiles.
|
|
||||||
*/
|
|
||||||
private final PlayerColorProfile playerColorProfile;
|
|
||||||
private final VoteProfile voteProfile;
|
|
||||||
|
|
||||||
public Account(UUID uuid) {
|
public Account(UUID uuid) {
|
||||||
//log.info("Loading account for " + uuid);
|
//log.info("Loading account for " + uuid);
|
||||||
boolean newAccount = false;
|
boolean newAccount = false;
|
||||||
|
@ -27,8 +27,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Log4j2
|
@Log4j2
|
||||||
public class AccountManager extends Manager implements Listener {
|
public class AccountManager extends Manager implements Listener {
|
||||||
|
|
||||||
private final long SAVE_INTERVAL = 5; // in minutes
|
|
||||||
private static final Map<UUID, Account> ACCOUNTS = new HashMap<>();
|
private static final Map<UUID, Account> ACCOUNTS = new HashMap<>();
|
||||||
|
private final long SAVE_INTERVAL = 5; // in minutes
|
||||||
|
|
||||||
public AccountManager() {
|
public AccountManager() {
|
||||||
CommandManager.registerCommand(new SaveAccountsCommand());
|
CommandManager.registerCommand(new SaveAccountsCommand());
|
||||||
@ -46,11 +46,6 @@ public class AccountManager extends Manager implements Listener {
|
|||||||
}, SAVE_INTERVAL, SAVE_INTERVAL, TimeUnit.MINUTES);
|
}, SAVE_INTERVAL, SAVE_INTERVAL, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Priority getPriority() {
|
|
||||||
return Priority.LOWEST;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the account for the specified player.
|
* Gets the account for the specified player.
|
||||||
*
|
*
|
||||||
@ -61,16 +56,6 @@ public class AccountManager extends Manager implements Listener {
|
|||||||
return ACCOUNTS.get(uuid);
|
return ACCOUNTS.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if an account is already registered for the specified player.
|
|
||||||
*
|
|
||||||
* @param uuid the player's UUID
|
|
||||||
* @return true if the account is already registered, false otherwise
|
|
||||||
*/
|
|
||||||
private boolean isAccountLoaded(UUID uuid) {
|
|
||||||
return ACCOUNTS.containsKey(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an account for the specified player.
|
* Registers an account for the specified player.
|
||||||
*
|
*
|
||||||
@ -102,6 +87,21 @@ public class AccountManager extends Manager implements Listener {
|
|||||||
log.info("Saved {}/{} accounts. ({}ms)", saved, ACCOUNTS.size(), System.currentTimeMillis() - before);
|
log.info("Saved {}/{} accounts. ({}ms)", saved, ACCOUNTS.size(), System.currentTimeMillis() - before);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Priority getPriority() {
|
||||||
|
return Priority.LOWEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an account is already registered for the specified player.
|
||||||
|
*
|
||||||
|
* @param uuid the player's UUID
|
||||||
|
* @return true if the account is already registered, false otherwise
|
||||||
|
*/
|
||||||
|
private boolean isAccountLoaded(UUID uuid) {
|
||||||
|
return ACCOUNTS.containsKey(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onAsyncPlayerPreLoginEvent(AsyncPlayerPreLoginEvent event) {
|
public void onAsyncPlayerPreLoginEvent(AsyncPlayerPreLoginEvent event) {
|
||||||
UUID uuid = event.getUniqueId();
|
UUID uuid = event.getUniqueId();
|
||||||
|
@ -15,7 +15,8 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@RequiredArgsConstructor @Getter
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
enum BlockReason {
|
enum BlockReason {
|
||||||
DOMAIN("Domain was detected in the message."),
|
DOMAIN("Domain was detected in the message."),
|
||||||
DUPLICATE("Duplicate message was detected."),
|
DUPLICATE("Duplicate message was detected."),
|
||||||
|
@ -21,24 +21,29 @@ public enum Config {
|
|||||||
VERSION_WARNING_VERSION("version-warning.min-version"),
|
VERSION_WARNING_VERSION("version-warning.min-version"),
|
||||||
VERSION_WARNING_MESSAGE("version-warning.message");
|
VERSION_WARNING_MESSAGE("version-warning.message");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache of the config values.
|
||||||
|
*/
|
||||||
|
private static final HashMap<String, Object> cache = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* The path of the lang in the lang.yml file.
|
* The path of the lang in the lang.yml file.
|
||||||
*/
|
*/
|
||||||
private final String path;
|
private final String path;
|
||||||
|
/**
|
||||||
|
* The configuration.
|
||||||
|
*/
|
||||||
|
private final cc.fascinated.utils.io.Config config = new cc.fascinated.utils.io.Config(Aetheria.INSTANCE, "config.yml", null);
|
||||||
|
|
||||||
Config(String path) {
|
Config(String path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of the config values.
|
* Clear the cache.
|
||||||
*/
|
*/
|
||||||
private static final HashMap<String, Object> cache = new HashMap<>();
|
public static void clear() {
|
||||||
|
cache.clear();
|
||||||
/**
|
}
|
||||||
* The configuration.
|
|
||||||
*/
|
|
||||||
private final cc.fascinated.utils.io.Config config = new cc.fascinated.utils.io.Config(Aetheria.INSTANCE, "config.yml", null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets as an object.
|
* Gets as an object.
|
||||||
@ -76,11 +81,4 @@ public enum Config {
|
|||||||
public int getAsInt() {
|
public int getAsInt() {
|
||||||
return (int) get();
|
return (int) get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the cache.
|
|
||||||
*/
|
|
||||||
public static void clear() {
|
|
||||||
cache.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -42,24 +42,29 @@ public enum Lang {
|
|||||||
STAFF_CHAT_FORMAT("staff-chat.format"),
|
STAFF_CHAT_FORMAT("staff-chat.format"),
|
||||||
STAFF_CHAT_USAGE("staff-chat.usage");
|
STAFF_CHAT_USAGE("staff-chat.usage");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache of the lang values.
|
||||||
|
*/
|
||||||
|
private static final HashMap<String, Object> cache = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* The path of the lang in the lang.yml file.
|
* The path of the lang in the lang.yml file.
|
||||||
*/
|
*/
|
||||||
private final String path;
|
private final String path;
|
||||||
|
/**
|
||||||
|
* The lang configuration.
|
||||||
|
*/
|
||||||
|
private final Config langConfig = new Config(Aetheria.INSTANCE, "lang.yml", null);
|
||||||
|
|
||||||
Lang(String path) {
|
Lang(String path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of the lang values.
|
* Clear the cache.
|
||||||
*/
|
*/
|
||||||
private static final HashMap<String, Object> cache = new HashMap<>();
|
public static void clear() {
|
||||||
|
cache.clear();
|
||||||
/**
|
}
|
||||||
* The lang configuration.
|
|
||||||
*/
|
|
||||||
private final Config langConfig = new Config(Aetheria.INSTANCE, "lang.yml", null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets as an object.
|
* Gets as an object.
|
||||||
@ -93,11 +98,4 @@ public enum Lang {
|
|||||||
public List<String> getAsStringList() {
|
public List<String> getAsStringList() {
|
||||||
return (List<String>) get();
|
return (List<String>) get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the cache.
|
|
||||||
*/
|
|
||||||
public static void clear() {
|
|
||||||
cache.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,30 @@ public interface EventListener {
|
|||||||
return Priority.NORMAL;
|
return Priority.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void onAetheriaDisable() {}
|
default void onAetheriaDisable() {
|
||||||
default void onPlayerJoin(Account account, PlayerJoinEvent event) {}
|
}
|
||||||
default void onPlayerLogin(Account account, PlayerLoginEvent event) {}
|
|
||||||
default void onPlayerQuit(Account account, PlayerQuitEvent event) {}
|
default void onPlayerJoin(Account account, PlayerJoinEvent event) {
|
||||||
default void onAsyncChat(Account account, AsyncChatEvent event) {}
|
}
|
||||||
default void onCommandPreProcess(Account account, PlayerCommandPreprocessEvent event) {}
|
|
||||||
default void onServerListPing(ServerListPingEvent event) {}
|
default void onPlayerLogin(Account account, PlayerLoginEvent event) {
|
||||||
default void onEntityDeath(EntityDeathEvent event) {}
|
}
|
||||||
default void onVote(Account account, VotifierEvent event) {}
|
|
||||||
|
default void onPlayerQuit(Account account, PlayerQuitEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onAsyncChat(Account account, AsyncChatEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onCommandPreProcess(Account account, PlayerCommandPreprocessEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onServerListPing(ServerListPingEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onEntityDeath(EntityDeathEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onVote(Account account, VotifierEvent event) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cc.fascinated.metrics;
|
|||||||
|
|
||||||
import com.influxdb.client.write.Point;
|
import com.influxdb.client.write.Point;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public abstract class Metric {
|
public abstract class Metric {
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ import java.util.List;
|
|||||||
@Log4j2
|
@Log4j2
|
||||||
public class MetricManager extends Manager {
|
public class MetricManager extends Manager {
|
||||||
|
|
||||||
|
private static final List<Metric> metrics = new ArrayList<>();
|
||||||
private InfluxDBClient influxDB;
|
private InfluxDBClient influxDB;
|
||||||
private WriteApiBlocking writeApi;
|
private WriteApiBlocking writeApi;
|
||||||
private static final List<Metric> metrics = new ArrayList<>();
|
|
||||||
|
|
||||||
public MetricManager() {
|
public MetricManager() {
|
||||||
String url = Config.INFLUXDB_URL.getAsString();
|
String url = Config.INFLUXDB_URL.getAsString();
|
||||||
@ -71,6 +71,15 @@ public class MetricManager extends Manager {
|
|||||||
Bukkit.getScheduler().runTaskTimer(Aetheria.INSTANCE, (task) -> this.collectMetrics(), 30 * 20, 30 * 20);
|
Bukkit.getScheduler().runTaskTimer(Aetheria.INSTANCE, (task) -> this.collectMetrics(), 30 * 20, 30 * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a new metric
|
||||||
|
*
|
||||||
|
* @param metric the metric to register
|
||||||
|
*/
|
||||||
|
public static void registerMetric(Metric metric) {
|
||||||
|
metrics.add(metric);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect all metrics and write them to influx
|
* Collect all metrics and write them to influx
|
||||||
*/
|
*/
|
||||||
@ -101,15 +110,6 @@ public class MetricManager extends Manager {
|
|||||||
.forEach(entry -> log.warn("Metric {} took {}ms to collect", entry.getKey().getName(), System.currentTimeMillis() - entry.getValue()));
|
.forEach(entry -> log.warn("Metric {} took {}ms to collect", entry.getKey().getName(), System.currentTimeMillis() - entry.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a new metric
|
|
||||||
*
|
|
||||||
* @param metric the metric to register
|
|
||||||
*/
|
|
||||||
public static void registerMetric(Metric metric) {
|
|
||||||
metrics.add(metric);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAetheriaDisable() {
|
public void onAetheriaDisable() {
|
||||||
influxDB.close(); // close the connection
|
influxDB.close(); // close the connection
|
||||||
|
@ -19,7 +19,7 @@ public class CpuUsageMetric extends Metric {
|
|||||||
Bukkit.getAsyncScheduler().runAtFixedRate(Aetheria.INSTANCE, (task) -> {
|
Bukkit.getAsyncScheduler().runAtFixedRate(Aetheria.INSTANCE, (task) -> {
|
||||||
HardwareAbstractionLayer hardware = Oshi.SYSTEM_INFO.getHardware();
|
HardwareAbstractionLayer hardware = Oshi.SYSTEM_INFO.getHardware();
|
||||||
cpuLoad = hardware.getProcessor().getSystemCpuLoad(500) * 100; // get the CPU load in percentage
|
cpuLoad = hardware.getProcessor().getSystemCpuLoad(500) * 100; // get the CPU load in percentage
|
||||||
},0, 30, TimeUnit.SECONDS);
|
}, 0, 30, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,7 +9,9 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
@Getter @Setter @EqualsAndHashCode(callSuper = false)
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PlayerColorProfile extends Profile {
|
public class PlayerColorProfile extends Profile {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,8 +2,8 @@ package cc.fascinated.playercolor.command;
|
|||||||
|
|
||||||
import cc.fascinated.account.Account;
|
import cc.fascinated.account.Account;
|
||||||
import cc.fascinated.command.Command;
|
import cc.fascinated.command.Command;
|
||||||
import cc.fascinated.playercolor.PlayerColorProfile;
|
|
||||||
import cc.fascinated.playercolor.PlayerColorManager;
|
import cc.fascinated.playercolor.PlayerColorManager;
|
||||||
|
import cc.fascinated.playercolor.PlayerColorProfile;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class DiscordWebhook {
|
|||||||
private String username;
|
private String username;
|
||||||
private String avatarUrl;
|
private String avatarUrl;
|
||||||
private boolean tts;
|
private boolean tts;
|
||||||
private List<EmbedObject> embeds = new ArrayList<>();
|
private final List<EmbedObject> embeds = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new DiscordWebhook instance
|
* Constructs a new DiscordWebhook instance
|
||||||
@ -159,24 +159,44 @@ public class DiscordWebhook {
|
|||||||
private Thumbnail thumbnail;
|
private Thumbnail thumbnail;
|
||||||
private Image image;
|
private Image image;
|
||||||
private Author author;
|
private Author author;
|
||||||
private List<Field> fields = new ArrayList<>();
|
private final List<Field> fields = new ArrayList<>();
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbedObject setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbedObject setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbedObject setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbedObject setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Footer getFooter() {
|
public Footer getFooter() {
|
||||||
return footer;
|
return footer;
|
||||||
}
|
}
|
||||||
@ -185,10 +205,20 @@ public class DiscordWebhook {
|
|||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbedObject setThumbnail(String url) {
|
||||||
|
this.thumbnail = new Thumbnail(url);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbedObject setImage(String url) {
|
||||||
|
this.image = new Image(url);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Author getAuthor() {
|
public Author getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
@ -197,41 +227,11 @@ public class DiscordWebhook {
|
|||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmbedObject setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmbedObject setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmbedObject setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmbedObject setColor(Color color) {
|
|
||||||
this.color = color;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmbedObject setFooter(String text, String icon) {
|
public EmbedObject setFooter(String text, String icon) {
|
||||||
this.footer = new Footer(text, icon);
|
this.footer = new Footer(text, icon);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmbedObject setThumbnail(String url) {
|
|
||||||
this.thumbnail = new Thumbnail(url);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmbedObject setImage(String url) {
|
|
||||||
this.image = new Image(url);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmbedObject setAuthor(String name, String url, String icon) {
|
public EmbedObject setAuthor(String name, String url, String icon) {
|
||||||
this.author = new Author(name, url, icon);
|
this.author = new Author(name, url, icon);
|
||||||
return this;
|
return this;
|
||||||
@ -243,8 +243,8 @@ public class DiscordWebhook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Footer {
|
private class Footer {
|
||||||
private String text;
|
private final String text;
|
||||||
private String iconUrl;
|
private final String iconUrl;
|
||||||
|
|
||||||
private Footer(String text, String iconUrl) {
|
private Footer(String text, String iconUrl) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@ -261,7 +261,7 @@ public class DiscordWebhook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Thumbnail {
|
private class Thumbnail {
|
||||||
private String url;
|
private final String url;
|
||||||
|
|
||||||
private Thumbnail(String url) {
|
private Thumbnail(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
@ -273,7 +273,7 @@ public class DiscordWebhook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Image {
|
private class Image {
|
||||||
private String url;
|
private final String url;
|
||||||
|
|
||||||
private Image(String url) {
|
private Image(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
@ -285,9 +285,9 @@ public class DiscordWebhook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Author {
|
private class Author {
|
||||||
private String name;
|
private final String name;
|
||||||
private String url;
|
private final String url;
|
||||||
private String iconUrl;
|
private final String iconUrl;
|
||||||
|
|
||||||
private Author(String name, String url, String iconUrl) {
|
private Author(String name, String url, String iconUrl) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -309,9 +309,9 @@ public class DiscordWebhook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Field {
|
private class Field {
|
||||||
private String name;
|
private final String name;
|
||||||
private String value;
|
private final String value;
|
||||||
private boolean inline;
|
private final boolean inline;
|
||||||
|
|
||||||
private Field(String name, String value, boolean inline) {
|
private Field(String name, String value, boolean inline) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -361,7 +361,7 @@ public class DiscordWebhook {
|
|||||||
} else if (val instanceof Boolean) {
|
} else if (val instanceof Boolean) {
|
||||||
builder.append(val);
|
builder.append(val);
|
||||||
} else if (val instanceof JSONObject) {
|
} else if (val instanceof JSONObject) {
|
||||||
builder.append(val.toString());
|
builder.append(val);
|
||||||
} else if (val.getClass().isArray()) {
|
} else if (val.getClass().isArray()) {
|
||||||
builder.append("[");
|
builder.append("[");
|
||||||
int len = Array.getLength(val);
|
int len = Array.getLength(val);
|
||||||
|
@ -71,7 +71,7 @@ public final class TimeUtils {
|
|||||||
}
|
}
|
||||||
String formatted = time + (compact ? timeUnit.getSuffix() : " " + timeUnit.getDisplay()); // Append the time unit
|
String formatted = time + (compact ? timeUnit.getSuffix() : " " + timeUnit.getDisplay()); // Append the time unit
|
||||||
if (time != 1.0 && !compact) { // Pluralize the time unit
|
if (time != 1.0 && !compact) { // Pluralize the time unit
|
||||||
formatted+= "s";
|
formatted += "s";
|
||||||
}
|
}
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ public final class TimeUtils {
|
|||||||
String suffix = matcher.group(2); // The unit suffix
|
String suffix = matcher.group(2); // The unit suffix
|
||||||
WildTimeUnit timeUnit = WildTimeUnit.fromSuffix(suffix); // The time unit to add
|
WildTimeUnit timeUnit = WildTimeUnit.fromSuffix(suffix); // The time unit to add
|
||||||
if (timeUnit != null) { // Increment the total millis
|
if (timeUnit != null) { // Increment the total millis
|
||||||
millis+= amount * timeUnit.getMillis();
|
millis += amount * timeUnit.getMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return millis;
|
return millis;
|
||||||
@ -104,8 +104,10 @@ public final class TimeUtils {
|
|||||||
/**
|
/**
|
||||||
* Represents a unit of time.
|
* Represents a unit of time.
|
||||||
*/
|
*/
|
||||||
@NoArgsConstructor @AllArgsConstructor
|
@NoArgsConstructor
|
||||||
@Getter(AccessLevel.PRIVATE) @ToString
|
@AllArgsConstructor
|
||||||
|
@Getter(AccessLevel.PRIVATE)
|
||||||
|
@ToString
|
||||||
public enum WildTimeUnit {
|
public enum WildTimeUnit {
|
||||||
FIT,
|
FIT,
|
||||||
YEARS("Year", "y", TimeUnit.DAYS.toMillis(365L)),
|
YEARS("Year", "y", TimeUnit.DAYS.toMillis(365L)),
|
||||||
|
@ -6,7 +6,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
@Getter @EqualsAndHashCode(callSuper = false)
|
@Getter
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class VoteProfile extends Profile {
|
public class VoteProfile extends Profile {
|
||||||
|
|
||||||
private int totalVotes;
|
private int totalVotes;
|
||||||
|
Reference in New Issue
Block a user