Update to 1.21.6
This commit is contained in:
parent
66276fbf47
commit
064191f19b
|
|
@ -12,7 +12,7 @@ apply<JavaLibraryPlugin>()
|
|||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ tasks {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.alttd:Galaxy-API:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT")
|
||||
compileOnly("de.keyle:mypet:3.11-SNAPSHOT")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import com.alttd.afkdectector.config.Messages;
|
|||
import com.alttd.afkdectector.config.MessagesConfig;
|
||||
import com.alttd.afkdectector.trackers.AutoJoinTracker;
|
||||
import com.alttd.afkdectector.trackers.SuspiciousKickTracker;
|
||||
import com.alttd.afkdectector.util.Logger;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
|
@ -26,8 +25,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.ScoreboardManager;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -186,7 +183,7 @@ public class AFKDetector extends JavaPlugin implements Listener {
|
|||
Config.reload();
|
||||
MessagesConfig.reload();
|
||||
if (sender != null) {
|
||||
sender.sendMiniMessage("<green>Configuration reloaded", null);
|
||||
sender.sendRichMessage("<green>Configuration reloaded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class MessageTimer extends BukkitRunnable {
|
|||
miniMessage.deserialize(Messages.COUNT_DOWN_TITLE_2.getMessage()));
|
||||
//Title.Times.of(Config.FADEIN, Config.STAY, Config.STAY);
|
||||
player.showTitle(title);
|
||||
player.sendMessage(miniMessage.deserialize(Messages.COUNT_DOWN_MESSAGE.getMessage()));
|
||||
player.sendRichMessage(Messages.COUNT_DOWN_MESSAGE.getMessage());
|
||||
}
|
||||
repeats = repeats - 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,172 @@
|
|||
package com.alttd.afkdectector.config;
|
||||
|
||||
import com.alttd.afkdectector.AFKDetector;
|
||||
import com.alttd.galaxy.configuration.AbstractConfiguration;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.yaml.NodeStyle;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Config extends AbstractConfiguration {
|
||||
public class Config {
|
||||
|
||||
private Config() {
|
||||
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + AFKDetector.getInstance().getName()), "config");
|
||||
}
|
||||
public static File CONFIG_PATH;
|
||||
public static final Pattern PATH_PATTERN = Pattern.compile("\\.");
|
||||
private static final String HEADER = "";
|
||||
|
||||
private static File CONFIG_FILE;
|
||||
public static ConfigurationNode config;
|
||||
public static YamlConfigurationLoader configLoader;
|
||||
|
||||
static Config config;
|
||||
static int version;
|
||||
static boolean verbose;
|
||||
|
||||
public static void reload() {
|
||||
config = new Config();
|
||||
CONFIG_PATH = new File(Bukkit.sharedConfigurationFile(), "AFKDetector");
|
||||
CONFIG_FILE = new File(CONFIG_PATH, "config.yml");
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
config.set("config-version", 1);
|
||||
configLoader = YamlConfigurationLoader.builder()
|
||||
.file(CONFIG_FILE)
|
||||
.nodeStyle(NodeStyle.BLOCK)
|
||||
.build();
|
||||
if (!CONFIG_FILE.getParentFile().exists()) {
|
||||
if(!CONFIG_FILE.getParentFile().mkdirs()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!CONFIG_FILE.exists()) {
|
||||
try {
|
||||
if(!CONFIG_FILE.createNewFile()) {
|
||||
return;
|
||||
}
|
||||
} catch (IOException error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
config.readConfig(Config.class, null);
|
||||
try {
|
||||
config = configLoader.load(ConfigurationOptions.defaults().header(HEADER).shouldCopyDefaults(false));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
verbose = getBoolean("verbose", true);
|
||||
version = getInt("config-version", 1);
|
||||
|
||||
readConfig(Config.class, null);
|
||||
try {
|
||||
configLoader.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void readConfig(Class<?> clazz, Object instance) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (Modifier.isPrivate(method.getModifiers())) {
|
||||
if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
method.invoke(instance);
|
||||
} catch (InvocationTargetException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
configLoader.save(config);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveConfig() {
|
||||
try {
|
||||
configLoader.save(config);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Object[] splitPath(String key) {
|
||||
return PATH_PATTERN.split(key);
|
||||
}
|
||||
|
||||
static void set(String path, Object def) {
|
||||
if(config.node(splitPath(path)).virtual()) {
|
||||
try {
|
||||
config.node(splitPath(path)).set(def);
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setString(String path, String def) {
|
||||
try {
|
||||
if(config.node(splitPath(path)).virtual())
|
||||
config.node(splitPath(path)).set(io.leangen.geantyref.TypeToken.get(String.class), def);
|
||||
} catch(SerializationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean getBoolean(String path, boolean def) {
|
||||
set(path, def);
|
||||
return config.node(splitPath(path)).getBoolean(def);
|
||||
}
|
||||
|
||||
private static double getDouble(String path, double def) {
|
||||
set(path, def);
|
||||
return config.node(splitPath(path)).getDouble(def);
|
||||
}
|
||||
|
||||
private static int getInt(String path, int def) {
|
||||
set(path, def);
|
||||
return config.node(splitPath(path)).getInt(def);
|
||||
}
|
||||
|
||||
private static String getString(String path, String def) {
|
||||
setString(path, def);
|
||||
return config.node(splitPath(path)).getString(def);
|
||||
}
|
||||
|
||||
private static Long getLong(String path, Long def) {
|
||||
set(path, def);
|
||||
return config.node(splitPath(path)).getLong(def);
|
||||
}
|
||||
|
||||
private static <T> List<String> getList(String path, T def) {
|
||||
try {
|
||||
set(path, def);
|
||||
return config.node(splitPath(path)).getList(TypeToken.get(String.class));
|
||||
} catch(SerializationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
protected static ConfigurationNode getNode(String path) {
|
||||
return config.node(splitPath(path));
|
||||
}
|
||||
|
||||
public static boolean DEBUG_MODE = false;
|
||||
public static int MAX_DUPLICATE_HISTORY = 5;
|
||||
|
||||
private static void settings() {
|
||||
DEBUG_MODE = config.getBoolean("debug-mode", DEBUG_MODE);
|
||||
MAX_DUPLICATE_HISTORY = config.getInt("max-duplicate-history", MAX_DUPLICATE_HISTORY);
|
||||
DEBUG_MODE = getBoolean("debug-mode", DEBUG_MODE);
|
||||
MAX_DUPLICATE_HISTORY = getInt("max-duplicate-history", MAX_DUPLICATE_HISTORY);
|
||||
}
|
||||
|
||||
public static boolean SLEEP_IGNORE = false;
|
||||
|
|
@ -47,17 +183,17 @@ public class Config extends AbstractConfiguration {
|
|||
public static int MAX_REJOIN_FOR_TRACKING = 30;
|
||||
|
||||
private static void playerSettings() {
|
||||
SLEEP_IGNORE = config.getBoolean("player.sleep", SLEEP_IGNORE);
|
||||
RADIUS = config.getInt("player.radius", RADIUS);
|
||||
WARNING_TIME = config.getInt("player.warning-time", WARNING_TIME);
|
||||
TOGGLE_TIME = config.getInt("player.toggle-time", TOGGLE_TIME);
|
||||
DEFAULT_AFK_TIME = config.getInt("player.afk-time", 5);
|
||||
MAX_AFK_TIME = config.getInt("player.maxafk-time", 5);
|
||||
SERVER_FULL = config.getBoolean("player.serverfull", false);
|
||||
COMMAND_COOL_DOWN = config.getInt("player.commandcooldown", COMMAND_COOL_DOWN);
|
||||
AFK_TOGGLE_MESSAGES = config.getBoolean("player.afk-toggle-messages", AFK_TOGGLE_MESSAGES);
|
||||
NOTIFY_STAFF_ON_AFK_KICK = config.getBoolean("player.notify-staff-on-afk-kick", NOTIFY_STAFF_ON_AFK_KICK);
|
||||
MAX_REJOIN_FOR_TRACKING = config.getInt("tracking.max-seconds-for-tracking", MAX_REJOIN_FOR_TRACKING);
|
||||
SLEEP_IGNORE = getBoolean("player.sleep", SLEEP_IGNORE);
|
||||
RADIUS = getInt("player.radius", RADIUS);
|
||||
WARNING_TIME = getInt("player.warning-time", WARNING_TIME);
|
||||
TOGGLE_TIME = getInt("player.toggle-time", TOGGLE_TIME);
|
||||
DEFAULT_AFK_TIME = getInt("player.afk-time", 5);
|
||||
MAX_AFK_TIME = getInt("player.maxafk-time", 5);
|
||||
SERVER_FULL = getBoolean("player.serverfull", false);
|
||||
COMMAND_COOL_DOWN = getInt("player.commandcooldown", COMMAND_COOL_DOWN);
|
||||
AFK_TOGGLE_MESSAGES = getBoolean("player.afk-toggle-messages", AFK_TOGGLE_MESSAGES);
|
||||
NOTIFY_STAFF_ON_AFK_KICK = getBoolean("player.notify-staff-on-afk-kick", NOTIFY_STAFF_ON_AFK_KICK);
|
||||
MAX_REJOIN_FOR_TRACKING = getInt("tracking.max-seconds-for-tracking", MAX_REJOIN_FOR_TRACKING);
|
||||
}
|
||||
|
||||
public static boolean COUNT_DOWN_ENABLED = false;
|
||||
|
|
@ -69,21 +205,21 @@ public class Config extends AbstractConfiguration {
|
|||
public static String KICK_COMMAND = "kickfrombungee %player% &cYou have been afk for %afktime% minutes.";
|
||||
|
||||
private static void countdownSettings() {
|
||||
COUNT_DOWN_ENABLED = config.getBoolean("countdown.enabled", COUNT_DOWN_ENABLED);
|
||||
FADEIN = config.getInt("countdown.fadein", FADEIN);
|
||||
STAY = config.getInt("countdown.stay", STAY);
|
||||
FADEOUT = config.getInt("countdown.fadeout", FADEOUT);
|
||||
MESSAGE_DELAY = config.getInt("countdown.message-delay", MESSAGE_DELAY);
|
||||
MESSAGE_REPEATS = config.getInt("countdown.message-repeats", MESSAGE_REPEATS);
|
||||
KICK_COMMAND = config.getString("countdown.kick-command", KICK_COMMAND);
|
||||
COUNT_DOWN_ENABLED = getBoolean("countdown.enabled", COUNT_DOWN_ENABLED);
|
||||
FADEIN = getInt("countdown.fadein", FADEIN);
|
||||
STAY = getInt("countdown.stay", STAY);
|
||||
FADEOUT = getInt("countdown.fadeout", FADEOUT);
|
||||
MESSAGE_DELAY = getInt("countdown.message-delay", MESSAGE_DELAY);
|
||||
MESSAGE_REPEATS = getInt("countdown.message-repeats", MESSAGE_REPEATS);
|
||||
KICK_COMMAND = getString("countdown.kick-command", KICK_COMMAND);
|
||||
}
|
||||
|
||||
public static boolean CHAT_WILL_CANCEL = true;
|
||||
public static boolean COMMAND_WILL_CANCEL = true;
|
||||
|
||||
private static void eventSettings() {
|
||||
CHAT_WILL_CANCEL = config.getBoolean("events.chat", CHAT_WILL_CANCEL);
|
||||
COMMAND_WILL_CANCEL = config.getBoolean("events.commands", COMMAND_WILL_CANCEL);
|
||||
CHAT_WILL_CANCEL = getBoolean("events.chat", CHAT_WILL_CANCEL);
|
||||
COMMAND_WILL_CANCEL = getBoolean("events.commands", COMMAND_WILL_CANCEL);
|
||||
}
|
||||
|
||||
public static int SPAWN_MAX_X = 250;
|
||||
|
|
@ -93,11 +229,11 @@ public class Config extends AbstractConfiguration {
|
|||
public static int EXTRA_MIN_IN_SPAWN = 10;
|
||||
|
||||
private static void spawnSettings() {
|
||||
SPAWN_MAX_X = config.getInt("spawn.max-x", SPAWN_MAX_X);
|
||||
SPAWN_MIN_X = config.getInt("spawn.min-x", SPAWN_MIN_X);
|
||||
SPAWN_MAX_Z = config.getInt("spawn.max-z", SPAWN_MAX_Z);
|
||||
SPAWN_MIN_Z = config.getInt("spawn.min-z", SPAWN_MIN_Z);
|
||||
EXTRA_MIN_IN_SPAWN = config.getInt("spawn.extra-time", EXTRA_MIN_IN_SPAWN);
|
||||
SPAWN_MAX_X = getInt("spawn.max-x", SPAWN_MAX_X);
|
||||
SPAWN_MIN_X = getInt("spawn.min-x", SPAWN_MIN_X);
|
||||
SPAWN_MAX_Z = getInt("spawn.max-z", SPAWN_MAX_Z);
|
||||
SPAWN_MIN_Z = getInt("spawn.min-z", SPAWN_MIN_Z);
|
||||
EXTRA_MIN_IN_SPAWN = getInt("spawn.extra-time", EXTRA_MIN_IN_SPAWN);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,100 @@
|
|||
package com.alttd.afkdectector.config;
|
||||
|
||||
import com.alttd.afkdectector.AFKDetector;
|
||||
import com.alttd.galaxy.configuration.AbstractConfiguration;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.yaml.NodeStyle;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class MessagesConfig extends AbstractConfiguration {
|
||||
private MessagesConfig() {
|
||||
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + AFKDetector.getInstance().getName()), "messages");
|
||||
}
|
||||
public class MessagesConfig {
|
||||
|
||||
private static final String HEADER = "";
|
||||
|
||||
private static File CONFIG_FILE;
|
||||
public static ConfigurationNode config;
|
||||
public static YamlConfigurationLoader configLoader;
|
||||
|
||||
static MessagesConfig config;
|
||||
static int version;
|
||||
|
||||
public static void reload() {
|
||||
config = new MessagesConfig();
|
||||
CONFIG_FILE = new File(Config.CONFIG_PATH, "messages.yml");
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
config.set("config-version", 1);
|
||||
configLoader = YamlConfigurationLoader.builder()
|
||||
.file(CONFIG_FILE)
|
||||
.nodeStyle(NodeStyle.BLOCK)
|
||||
.build();
|
||||
if (!CONFIG_FILE.getParentFile().exists()) {
|
||||
if(!CONFIG_FILE.getParentFile().mkdirs()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!CONFIG_FILE.exists()) {
|
||||
try {
|
||||
if(!CONFIG_FILE.createNewFile()) {
|
||||
return;
|
||||
}
|
||||
} catch (IOException error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
config.readConfig(MessagesConfig.class, null);
|
||||
try {
|
||||
config = configLoader.load(ConfigurationOptions.defaults().header(HEADER).shouldCopyDefaults(false));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Config.readConfig(MessagesConfig.class, null);
|
||||
try {
|
||||
configLoader.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean DEBUG_MODE = false;
|
||||
public static void saveConfig() {
|
||||
try {
|
||||
configLoader.save(config);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void settings() {
|
||||
DEBUG_MODE = config.getBoolean("debug-mode", DEBUG_MODE);
|
||||
private static Object[] splitPath(String key) {
|
||||
return Config.PATH_PATTERN.split(key);
|
||||
}
|
||||
|
||||
private static void set(String path, Object def) {
|
||||
if(config.node(splitPath(path)).virtual()) {
|
||||
try {
|
||||
config.node(splitPath(path)).set(def);
|
||||
} catch (SerializationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setString(String path, String def) {
|
||||
try {
|
||||
if(config.node(splitPath(path)).virtual())
|
||||
config.node(splitPath(path)).set(io.leangen.geantyref.TypeToken.get(String.class), def);
|
||||
} catch(SerializationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getString(String path, String def) {
|
||||
setString(path, def);
|
||||
return config.node(splitPath(path)).getString(def);
|
||||
}
|
||||
|
||||
private static void loadMessages() {
|
||||
for (Messages message : Messages.values()) {
|
||||
message.setMessage(config.getString(message.getKey(), message.getMessage()));
|
||||
message.setMessage(getString(message.getKey(), message.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
main: com.alttd.afkdectector.AFKDetector
|
||||
name: AFKDetector
|
||||
version: ${projectVersion}
|
||||
api-version: 1.18
|
||||
api-version: 1.21
|
||||
author: Destro174
|
||||
softdepend:
|
||||
- MyPet
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user