Refactor logging by replacing custom Logger with SLF4J and adapt all usages
This commit is contained in:
parent
c66b30ff90
commit
ab162b5094
|
|
@ -39,7 +39,12 @@ tasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
|
compileOnly("com.alttd.cosmos:cosmos-api:1.21.7-R0.1-SNAPSHOT") {
|
||||||
isChanging = true
|
isChanging = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implementation("org.slf4j:slf4j-api:2.0.17")
|
||||||
|
|
||||||
|
compileOnly("org.projectlombok:lombok:1.18.38")
|
||||||
|
annotationProcessor("org.projectlombok:lombok:1.18.38")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import com.alttd.playerutils.config.Config;
|
||||||
import com.alttd.playerutils.config.KeyStorage;
|
import com.alttd.playerutils.config.KeyStorage;
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.event_listeners.*;
|
import com.alttd.playerutils.event_listeners.*;
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
@ -16,12 +15,10 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public final class PlayerUtils extends JavaPlugin {
|
public final class PlayerUtils extends JavaPlugin {
|
||||||
|
|
||||||
private Logger logger;
|
|
||||||
private PlayerUtilsCommand playerUtilsCommand;
|
private PlayerUtilsCommand playerUtilsCommand;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.logger = new Logger(getLogger());
|
|
||||||
registerCommands();
|
registerCommands();
|
||||||
registerEvents();
|
registerEvents();
|
||||||
reloadConfigs();
|
reloadConfigs();
|
||||||
|
|
@ -34,30 +31,30 @@ public final class PlayerUtils extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
playerUtilsCommand = new PlayerUtilsCommand(this, logger);
|
playerUtilsCommand = new PlayerUtilsCommand(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
pluginManager.registerEvents(new XpBottleEvent(this, logger), this);
|
pluginManager.registerEvents(new XpBottleEvent(this), this);
|
||||||
pluginManager.registerEvents(new TeleportEvent(), this);
|
pluginManager.registerEvents(new TeleportEvent(), this);
|
||||||
pluginManager.registerEvents(new GoatHornEvent(logger), this);
|
pluginManager.registerEvents(new GoatHornEvent(), this);
|
||||||
pluginManager.registerEvents(new LimitArmorStands(this, logger), this);
|
pluginManager.registerEvents(new LimitArmorStands(this), this);
|
||||||
pluginManager.registerEvents(new BlockBlockUseEvent(logger), this);
|
pluginManager.registerEvents(new BlockBlockUseEvent(), this);
|
||||||
|
|
||||||
RotateBlockEvent rotateBlockEvent = new RotateBlockEvent(logger);
|
RotateBlockEvent rotateBlockEvent = new RotateBlockEvent();
|
||||||
pluginManager.registerEvents(rotateBlockEvent, this);
|
pluginManager.registerEvents(rotateBlockEvent, this);
|
||||||
playerUtilsCommand.addSubCommand(new RotateBlock(rotateBlockEvent));
|
playerUtilsCommand.addSubCommand(new RotateBlock(rotateBlockEvent));
|
||||||
|
|
||||||
GhastSpeedEvent ghastSpeedEvent = new GhastSpeedEvent(logger);
|
GhastSpeedEvent ghastSpeedEvent = new GhastSpeedEvent();
|
||||||
pluginManager.registerEvents(ghastSpeedEvent, this);
|
pluginManager.registerEvents(ghastSpeedEvent, this);
|
||||||
playerUtilsCommand.addSubCommand(new GhastSpeed(logger, ghastSpeedEvent));
|
playerUtilsCommand.addSubCommand(new GhastSpeed(ghastSpeedEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadConfigs() {
|
public void reloadConfigs() {
|
||||||
Config.reload(logger);
|
Config.reload();
|
||||||
Messages.reload(logger);
|
Messages.reload();
|
||||||
KeyStorage.reload(logger);
|
KeyStorage.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSchedulers() {
|
private void registerSchedulers() {
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,26 @@ package com.alttd.playerutils.commands;
|
||||||
import com.alttd.playerutils.PlayerUtils;
|
import com.alttd.playerutils.PlayerUtils;
|
||||||
import com.alttd.playerutils.commands.playerutils_subcommands.*;
|
import com.alttd.playerutils.commands.playerutils_subcommands.*;
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.event_listeners.RotateBlockEvent;
|
import lombok.Getter;
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j @Getter
|
||||||
public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
||||||
private final List<SubCommand> subCommands;
|
private final List<SubCommand> subCommands;
|
||||||
|
|
||||||
public PlayerUtilsCommand(PlayerUtils playerUtils, Logger logger) {
|
public PlayerUtilsCommand(PlayerUtils playerUtils) {
|
||||||
PluginCommand command = playerUtils.getCommand("playerutils");
|
PluginCommand command = playerUtils.getCommand("playerutils");
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
subCommands = null;
|
subCommands = null;
|
||||||
logger.severe("Unable to find playerutils command.");
|
log.error("Unable to find playerutils command.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
command.setExecutor(this);
|
command.setExecutor(this);
|
||||||
|
|
@ -30,11 +30,11 @@ public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
||||||
command.setAliases(List.of("pu"));
|
command.setAliases(List.of("pu"));
|
||||||
|
|
||||||
subCommands = new ArrayList<>(List.of(
|
subCommands = new ArrayList<>(List.of(
|
||||||
new Glow(logger),
|
new Glow(),
|
||||||
new XPCheque(playerUtils),
|
new XPCheque(playerUtils),
|
||||||
new XPCalc(),
|
new XPCalc(),
|
||||||
new Reload(playerUtils),
|
new Reload(playerUtils),
|
||||||
new Key(logger))
|
new Key())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,10 +85,6 @@ public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SubCommand> getSubCommands() {
|
|
||||||
return subCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SubCommand getSubCommand(String cmdName) {
|
private SubCommand getSubCommand(String cmdName) {
|
||||||
return subCommands.stream()
|
return subCommands.stream()
|
||||||
.filter(subCommand -> subCommand.getName().equals(cmdName))
|
.filter(subCommand -> subCommand.getName().equals(cmdName))
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import com.alttd.playerutils.commands.argument_parser.GhastSpeedParser;
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.data_objects.GHAST_SPEED;
|
import com.alttd.playerutils.data_objects.GHAST_SPEED;
|
||||||
import com.alttd.playerutils.event_listeners.GhastSpeedEvent;
|
import com.alttd.playerutils.event_listeners.GhastSpeedEvent;
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
|
|
@ -20,11 +19,9 @@ public class GhastSpeed extends SubCommand {
|
||||||
private final static GhastSpeedParser GHAST_SPEED_PARSER = new GhastSpeedParser();
|
private final static GhastSpeedParser GHAST_SPEED_PARSER = new GhastSpeedParser();
|
||||||
private final static int GHAST_SPEED_ARG = 1;
|
private final static int GHAST_SPEED_ARG = 1;
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
private final GhastSpeedEvent ghastSpeedEvent;
|
private final GhastSpeedEvent ghastSpeedEvent;
|
||||||
|
|
||||||
public GhastSpeed(Logger logger, GhastSpeedEvent ghastSpeedEvent) {
|
public GhastSpeed(GhastSpeedEvent ghastSpeedEvent) {
|
||||||
this.logger = logger;
|
|
||||||
this.ghastSpeedEvent = ghastSpeedEvent;
|
this.ghastSpeedEvent = ghastSpeedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.alttd.playerutils.commands.playerutils_subcommands;
|
||||||
|
|
||||||
import com.alttd.playerutils.commands.SubCommand;
|
import com.alttd.playerutils.commands.SubCommand;
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
|
@ -19,13 +19,7 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Glow extends SubCommand {
|
@Slf4j public class Glow extends SubCommand {
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
public Glow(Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
|
|
@ -106,7 +100,7 @@ public class Glow extends SubCommand {
|
||||||
private void turnOnGlow(CommandSender commandSender, Player player, Team team, DyeColor dyeColor, boolean otherPlayer) {
|
private void turnOnGlow(CommandSender commandSender, Player player, Team team, DyeColor dyeColor, boolean otherPlayer) {
|
||||||
if (team.getScoreboard() == null) {
|
if (team.getScoreboard() == null) {
|
||||||
commandSender.sendRichMessage(Messages.GLOW.UNABLE_TO_GET_SCOREBOARD);
|
commandSender.sendRichMessage(Messages.GLOW.UNABLE_TO_GET_SCOREBOARD);
|
||||||
logger.warning("Unable to get scoreboard for team");
|
log.warn("Unable to get scoreboard for team");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import com.alttd.playerutils.commands.SubCommand;
|
||||||
import com.alttd.playerutils.config.Config;
|
import com.alttd.playerutils.config.Config;
|
||||||
import com.alttd.playerutils.config.KeyStorage;
|
import com.alttd.playerutils.config.KeyStorage;
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -15,13 +15,7 @@ import org.bukkit.entity.Player;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Key extends SubCommand {
|
@Slf4j public class Key extends SubCommand {
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
public Key(Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
|
|
@ -52,7 +46,7 @@ public class Key extends SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
crateMap.addTo(uuid, 1);
|
crateMap.addTo(uuid, 1);
|
||||||
logger.info(String.format("Gave %s one key for %s", player.getName(), crate));
|
log.info("Gave {} one key for {}", player.getName(), crate);
|
||||||
commandSender.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("crate give v %s 1 %s", crate, player.getName()));
|
commandSender.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("crate give v %s 1 %s", crate, player.getName()));
|
||||||
if (keys + 1 == totalKeys) {
|
if (keys + 1 == totalKeys) {
|
||||||
commandSender.sendRichMessage(Messages.KEY.GAVE_FINAL_KEY, TagResolver.resolver(
|
commandSender.sendRichMessage(Messages.KEY.GAVE_FINAL_KEY, TagResolver.resolver(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.alttd.playerutils.config;
|
package com.alttd.playerutils.config;
|
||||||
|
|
||||||
import com.alttd.playerutils.PlayerUtils;
|
import com.alttd.playerutils.PlayerUtils;
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
@ -19,19 +19,16 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "SameParameterValue"})
|
@Slf4j @SuppressWarnings({"unused", "SameParameterValue"})
|
||||||
abstract class AbstractConfig {
|
abstract class AbstractConfig {
|
||||||
File file;
|
File file;
|
||||||
YamlConfiguration yaml;
|
YamlConfiguration yaml;
|
||||||
private static Logger logger = null;
|
|
||||||
|
|
||||||
AbstractConfig(PlayerUtils playerUtils, String filename, Logger logger) {
|
AbstractConfig(PlayerUtils playerUtils, String filename) {
|
||||||
AbstractConfig.logger = logger;
|
|
||||||
init(new File(playerUtils.getDataFolder(), filename), filename);
|
init(new File(playerUtils.getDataFolder(), filename), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractConfig(File file, String filename, Logger logger) {
|
AbstractConfig(File file, String filename) {
|
||||||
AbstractConfig.logger = logger;
|
|
||||||
init(new File(file.getPath() + File.separator + filename), filename);
|
init(new File(file.getPath() + File.separator + filename), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,10 +38,9 @@ abstract class AbstractConfig {
|
||||||
try {
|
try {
|
||||||
yaml.load(file);
|
yaml.load(file);
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
} catch (InvalidConfigurationException ex) {
|
} catch (InvalidConfigurationException e) {
|
||||||
if (logger != null)
|
log.error("Could not load {}, please correct your syntax errors", filename, e);
|
||||||
logger.severe(String.format("Could not load %s, please correct your syntax errors", filename));
|
throw new RuntimeException(e);
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
}
|
||||||
yaml.options().copyDefaults(true);
|
yaml.options().copyDefaults(true);
|
||||||
}
|
}
|
||||||
|
|
@ -59,10 +55,8 @@ abstract class AbstractConfig {
|
||||||
method.invoke(instance);
|
method.invoke(instance);
|
||||||
} catch (InvocationTargetException ex) {
|
} catch (InvocationTargetException ex) {
|
||||||
throw new RuntimeException(ex.getCause());
|
throw new RuntimeException(ex.getCause());
|
||||||
} catch (Exception ex) {
|
} catch (Exception e) {
|
||||||
if (logger != null)
|
log.error("Error invoking {}.", method, e);
|
||||||
logger.severe("Error invoking %.", method.toString());
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,10 +69,8 @@ abstract class AbstractConfig {
|
||||||
private void save() {
|
private void save() {
|
||||||
try {
|
try {
|
||||||
yaml.save(file);
|
yaml.save(file);
|
||||||
} catch (IOException ex) {
|
} catch (IOException e) {
|
||||||
if (logger != null)
|
log.error("Could not save {}.", file.toString(), e);
|
||||||
logger.severe("Could not save %.", file.toString());
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,4 +142,4 @@ abstract class AbstractConfig {
|
||||||
ConfigurationSection getConfigurationSection(String path) {
|
ConfigurationSection getConfigurationSection(String path) {
|
||||||
return yaml.getConfigurationSection(path);
|
return yaml.getConfigurationSection(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,28 @@
|
||||||
package com.alttd.playerutils.config;
|
package com.alttd.playerutils.config;
|
||||||
|
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Config extends AbstractConfig{
|
@Slf4j public class Config extends AbstractConfig{
|
||||||
|
|
||||||
static Config config;
|
static Config config;
|
||||||
private Logger logger;
|
|
||||||
|
|
||||||
Config(Logger logger) {
|
Config() {
|
||||||
super(
|
super(
|
||||||
new File(File.separator
|
new File(File.separator
|
||||||
+ "mnt" + File.separator
|
+ "mnt" + File.separator
|
||||||
+ "configs" + File.separator
|
+ "configs" + File.separator
|
||||||
+ "PlayerUtils"),
|
+ "PlayerUtils"),
|
||||||
"config.yml", logger);
|
"config.yml");
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(Logger logger) {
|
public static void reload() {
|
||||||
logger.info("Reloading config");
|
log.info("Reloading config");
|
||||||
config = new Config(logger);
|
config = new Config();
|
||||||
config.readConfig(Config.class, null);
|
config.readConfig(Config.class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +47,7 @@ public class Config extends AbstractConfig{
|
||||||
CRATES.clear();
|
CRATES.clear();
|
||||||
ConfigurationSection configurationSection = config.getConfigurationSection(prefix.substring(0, prefix.length() - 1));
|
ConfigurationSection configurationSection = config.getConfigurationSection(prefix.substring(0, prefix.length() - 1));
|
||||||
if (configurationSection == null) {
|
if (configurationSection == null) {
|
||||||
config.logger.warning("No keys configured, adding default");
|
log.warn("No keys configured, adding default");
|
||||||
config.set(prefix, "dailyvotecrate", 0);
|
config.set(prefix, "dailyvotecrate", 0);
|
||||||
config.set(prefix, "weeklyvotecrate", 0);
|
config.set(prefix, "weeklyvotecrate", 0);
|
||||||
config.set(prefix, "questcrate", 0);
|
config.set(prefix, "questcrate", 0);
|
||||||
|
|
@ -73,7 +70,7 @@ public class Config extends AbstractConfig{
|
||||||
LIMIT.clear();
|
LIMIT.clear();
|
||||||
ConfigurationSection configurationSection = config.getConfigurationSection(prefix.substring(0, prefix.length() - 1));
|
ConfigurationSection configurationSection = config.getConfigurationSection(prefix.substring(0, prefix.length() - 1));
|
||||||
if (configurationSection == null) {
|
if (configurationSection == null) {
|
||||||
config.logger.warning("No limits configured, adding default");
|
log.warn("No limits configured, adding default");
|
||||||
config.set(prefix, "default", 10);
|
config.set(prefix, "default", 10);
|
||||||
}
|
}
|
||||||
Set<String> limits = configurationSection.getKeys(false);
|
Set<String> limits = configurationSection.getKeys(false);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.alttd.playerutils.config;
|
package com.alttd.playerutils.config;
|
||||||
|
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -9,24 +9,23 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class KeyStorage extends AbstractConfig {
|
public class KeyStorage extends AbstractConfig {
|
||||||
|
|
||||||
static KeyStorage config;
|
static KeyStorage config;
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
public KeyStorage(Logger logger) {
|
public KeyStorage() {
|
||||||
super(
|
super(
|
||||||
new File(File.separator
|
new File(File.separator
|
||||||
+ "mnt" + File.separator
|
+ "mnt" + File.separator
|
||||||
+ "configs" + File.separator
|
+ "configs" + File.separator
|
||||||
+ "PlayerUtils"),
|
+ "PlayerUtils"),
|
||||||
"key_storage.yml", logger);
|
"key_storage.yml");
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(Logger logger) {
|
public static void reload() {
|
||||||
logger.info("Reloading key storage");
|
log.info("Reloading key storage");
|
||||||
config = new KeyStorage(logger);
|
config = new KeyStorage();
|
||||||
config.readConfig(KeyStorage.class, null);
|
config.readConfig(KeyStorage.class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,13 +42,13 @@ public class KeyStorage extends AbstractConfig {
|
||||||
Object2IntOpenHashMap<UUID> count = new Object2IntOpenHashMap<>();
|
Object2IntOpenHashMap<UUID> count = new Object2IntOpenHashMap<>();
|
||||||
ConfigurationSection configurationSection = config.getConfigurationSection(prefix + crate);
|
ConfigurationSection configurationSection = config.getConfigurationSection(prefix + crate);
|
||||||
if (configurationSection == null) {
|
if (configurationSection == null) {
|
||||||
config.logger.info(String.format("No section yet for crate %s", crate));
|
log.info("No section yet for crate {}", crate);
|
||||||
KEYS.put(crate, count);
|
KEYS.put(crate, count);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<UUID> uuids = configurationSection.getKeys(false).stream().map(UUID::fromString).toList();
|
List<UUID> uuids = configurationSection.getKeys(false).stream().map(UUID::fromString).toList();
|
||||||
if (uuids.isEmpty()) {
|
if (uuids.isEmpty()) {
|
||||||
config.logger.info(String.format("No keys yet for crate %s", crate));
|
log.info("No keys yet for crate {}", crate);
|
||||||
KEYS.put(crate, count);
|
KEYS.put(crate, count);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +61,7 @@ public class KeyStorage extends AbstractConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static void save() {
|
public synchronized static void save() {
|
||||||
config.logger.info("Saving KeyStorage");
|
log.info("Saving KeyStorage");
|
||||||
KEYS.keySet()
|
KEYS.keySet()
|
||||||
.forEach(crate -> KEYS.get(crate)
|
.forEach(crate -> KEYS.get(crate)
|
||||||
.forEach((uuid, keys) -> config.set(prefix + crate + ".", uuid.toString(), keys)));
|
.forEach((uuid, keys) -> config.set(prefix + crate + ".", uuid.toString(), keys)));
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,22 @@
|
||||||
package com.alttd.playerutils.config;
|
package com.alttd.playerutils.config;
|
||||||
|
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Messages extends AbstractConfig {
|
public class Messages extends AbstractConfig {
|
||||||
static Messages config;
|
static Messages config;
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
Messages(Logger logger) {
|
Messages() {
|
||||||
super(
|
super(
|
||||||
new File(File.separator
|
new File(File.separator
|
||||||
+ "mnt" + File.separator
|
+ "mnt" + File.separator
|
||||||
+ "configs" + File.separator
|
+ "configs" + File.separator
|
||||||
+ "PlayerUtils"),
|
+ "PlayerUtils"),
|
||||||
"messages.yml", logger);
|
"messages.yml");
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(Logger logger) {
|
public static void reload() {
|
||||||
config = new Messages(logger);
|
config = new Messages();
|
||||||
config.readConfig(Messages.class, null);
|
config.readConfig(Messages.class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
package com.alttd.playerutils.event_listeners;
|
package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import com.destroystokyo.paper.MaterialTags;
|
import com.destroystokyo.paper.MaterialTags;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Tag;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
@ -15,12 +13,6 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class BlockBlockUseEvent implements Listener {
|
public class BlockBlockUseEvent implements Listener {
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
public BlockBlockUseEvent(Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockCanBuildEvent event) {
|
public void onBlockPlace(BlockCanBuildEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.alttd.playerutils.event_listeners;
|
package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
import com.alttd.playerutils.data_objects.GHAST_SPEED;
|
import com.alttd.playerutils.data_objects.GHAST_SPEED;
|
||||||
import com.alttd.playerutils.util.Logger;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
@ -19,12 +18,10 @@ import java.util.UUID;
|
||||||
public class GhastSpeedEvent implements Listener {
|
public class GhastSpeedEvent implements Listener {
|
||||||
|
|
||||||
private static final org.slf4j.Logger log = LoggerFactory.getLogger(GhastSpeedEvent.class);
|
private static final org.slf4j.Logger log = LoggerFactory.getLogger(GhastSpeedEvent.class);
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
private final HashMap<UUID, GHAST_SPEED> lastSetSpeed = new HashMap<>();
|
private final HashMap<UUID, GHAST_SPEED> lastSetSpeed = new HashMap<>();
|
||||||
|
|
||||||
public GhastSpeedEvent(Logger logger) {
|
public GhastSpeedEvent() {
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.alttd.playerutils.event_listeners;
|
package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
@ -11,13 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class GoatHornEvent implements Listener {
|
@Slf4j public class GoatHornEvent implements Listener {
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
public GoatHornEvent(Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
|
@ -41,11 +35,10 @@ public class GoatHornEvent implements Listener {
|
||||||
|
|
||||||
|
|
||||||
if (player.getLocation().distance(spawn) > 250) {
|
if (player.getLocation().distance(spawn) > 250) {
|
||||||
logger.info(String.format("Player %s with uuid %s used a goat horn", player.getName(), player.getUniqueId()));
|
log.info("Player {} with uuid {} used a goat horn", player.getName(), player.getUniqueId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
log.info("Player {} with uuid {} used a goat horn in spawn", player.getName(), player.getUniqueId());
|
||||||
logger.info(String.format("Player %s with uuid %s used a goat horn in spawn", player.getName(), player.getUniqueId()));
|
|
||||||
|
|
||||||
player.setCooldown(Material.GOAT_HORN, (int) TimeUnit.MINUTES.toSeconds(5) * 20);
|
player.setCooldown(Material.GOAT_HORN, (int) TimeUnit.MINUTES.toSeconds(5) * 20);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
import com.alttd.playerutils.PlayerUtils;
|
import com.alttd.playerutils.PlayerUtils;
|
||||||
import com.alttd.playerutils.config.Config;
|
import com.alttd.playerutils.config.Config;
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
|
@ -24,14 +24,12 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class LimitArmorStands implements Listener {
|
@Slf4j public class LimitArmorStands implements Listener {
|
||||||
|
|
||||||
private final PlayerUtils playerUtils;
|
private final PlayerUtils playerUtils;
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
public LimitArmorStands(PlayerUtils playerUtils, Logger logger) {
|
public LimitArmorStands(PlayerUtils playerUtils) {
|
||||||
this.playerUtils = playerUtils;
|
this.playerUtils = playerUtils;
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
|
@ -89,7 +87,7 @@ public class LimitArmorStands implements Listener {
|
||||||
NamespacedKey namespacedKey = NamespacedKey.fromString("armor_stand_count", playerUtils);
|
NamespacedKey namespacedKey = NamespacedKey.fromString("armor_stand_count", playerUtils);
|
||||||
if (namespacedKey == null) {
|
if (namespacedKey == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
logger.warning("Unable to retrieve name spaced key for armor stand count.");
|
log.warn("Unable to retrieve name spaced key for armor stand count.");
|
||||||
player.sendRichMessage("<red>Something went wrong while checking the armor stand count. " +
|
player.sendRichMessage("<red>Something went wrong while checking the armor stand count. " +
|
||||||
"You will not be able to place this until this is fixed. Please contact a staff member</red>");
|
"You will not be able to place this until this is fixed. Please contact a staff member</red>");
|
||||||
return;
|
return;
|
||||||
|
|
@ -101,7 +99,7 @@ public class LimitArmorStands implements Listener {
|
||||||
Integer armorStandCount = persistentDataContainer.get(namespacedKey, PersistentDataType.INTEGER);
|
Integer armorStandCount = persistentDataContainer.get(namespacedKey, PersistentDataType.INTEGER);
|
||||||
if (armorStandCount == null) {
|
if (armorStandCount == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
logger.warning("Unable to retrieve armor stand count.");
|
log.warn("Unable to retrieve armor stand count.");
|
||||||
player.sendRichMessage("<red>Something went wrong while checking the armor stand count. " +
|
player.sendRichMessage("<red>Something went wrong while checking the armor stand count. " +
|
||||||
"You will not be able to place this until this is fixed. Please contact a staff member</red>");
|
"You will not be able to place this until this is fixed. Please contact a staff member</red>");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.alttd.playerutils.event_listeners;
|
package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.Axis;
|
import org.bukkit.Axis;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
@ -21,17 +21,12 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class RotateBlockEvent implements Listener {
|
public class RotateBlockEvent implements Listener {
|
||||||
|
|
||||||
private final HashSet<UUID> rotateEnabled = new HashSet<>();
|
private final HashSet<UUID> rotateEnabled = new HashSet<>();
|
||||||
private final Logger logger;
|
|
||||||
private static final List<BlockFace> VALID_FOUR_STATES = List.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
private static final List<BlockFace> VALID_FOUR_STATES = List.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
||||||
|
|
||||||
public RotateBlockEvent(Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public synchronized boolean toggleRotate(UUID uuid) {
|
public synchronized boolean toggleRotate(UUID uuid) {
|
||||||
if (rotateEnabled.contains(uuid)) {
|
if (rotateEnabled.contains(uuid)) {
|
||||||
rotateEnabled.remove(uuid);
|
rotateEnabled.remove(uuid);
|
||||||
|
|
@ -61,7 +56,8 @@ public class RotateBlockEvent implements Listener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
logger.debug(String.format("Material %s with action %s", type, event.getAction().isLeftClick() ? "left click" : "right click"));
|
log.debug("Material {} with action {}", type, event.getAction().isLeftClick() ? "left " +
|
||||||
|
"click" : "right click");
|
||||||
if (type.equals(Material.IRON_TRAPDOOR) && event.getAction().isLeftClick()) {
|
if (type.equals(Material.IRON_TRAPDOOR) && event.getAction().isLeftClick()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
toggleTrapDoor(block, player);
|
toggleTrapDoor(block, player);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class VanillaPetTameEvent implements Listener {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityTame(EntityTameEvent event) {
|
||||||
|
UUID uniqueId = event.getOwner().getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ package com.alttd.playerutils.event_listeners;
|
||||||
|
|
||||||
import com.alttd.playerutils.PlayerUtils;
|
import com.alttd.playerutils.PlayerUtils;
|
||||||
import com.alttd.playerutils.config.Messages;
|
import com.alttd.playerutils.config.Messages;
|
||||||
import com.alttd.playerutils.util.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
|
@ -25,15 +25,13 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class XpBottleEvent implements Listener {
|
@Slf4j public class XpBottleEvent implements Listener {
|
||||||
|
|
||||||
private final PlayerUtils playerUtils;
|
private final PlayerUtils playerUtils;
|
||||||
private final Logger logger;
|
|
||||||
private final MiniMessage miniMessage = MiniMessage.miniMessage();
|
private final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
|
|
||||||
public XpBottleEvent(PlayerUtils playerUtils, Logger logger) {
|
public XpBottleEvent(PlayerUtils playerUtils) {
|
||||||
this.playerUtils = playerUtils;
|
this.playerUtils = playerUtils;
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
@ -42,7 +40,7 @@ public class XpBottleEvent implements Listener {
|
||||||
PersistentDataContainer persistentDataContainer = item.getItemMeta().getPersistentDataContainer();
|
PersistentDataContainer persistentDataContainer = item.getItemMeta().getPersistentDataContainer();
|
||||||
NamespacedKey customXp = NamespacedKey.fromString("custom_xp", playerUtils);
|
NamespacedKey customXp = NamespacedKey.fromString("custom_xp", playerUtils);
|
||||||
if (customXp == null) {
|
if (customXp == null) {
|
||||||
logger.warning("Unable to retrieve name spaced key.");
|
log.warn("Unable to retrieve name spaced key.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer integer = persistentDataContainer.get(customXp, PersistentDataType.INTEGER);
|
Integer integer = persistentDataContainer.get(customXp, PersistentDataType.INTEGER);
|
||||||
|
|
@ -83,7 +81,7 @@ public class XpBottleEvent implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<CookingRecipe<?>, Integer> entry : recipesUsed.entrySet()) {
|
for (Map.Entry<CookingRecipe<?>, Integer> entry : recipesUsed.entrySet()) {
|
||||||
exp += entry.getKey().getExperience() * entry.getValue();
|
exp += (int) (entry.getKey().getExperience() * entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<ItemStack> optionalItemStack = getExpBottleItem(player, exp);
|
Optional<ItemStack> optionalItemStack = getExpBottleItem(player, exp);
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
package com.alttd.playerutils.util;
|
|
||||||
|
|
||||||
import com.alttd.playerutils.config.Config;
|
|
||||||
|
|
||||||
public class Logger {
|
|
||||||
|
|
||||||
private final java.util.logging.Logger logger;
|
|
||||||
static private final String RESET = "\u001B[0m";
|
|
||||||
static private final String GREEN = "\u001B[32m";
|
|
||||||
static private final String TEAL = "\u001B[36m";
|
|
||||||
|
|
||||||
public Logger(java.util.logging.Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void debug(String debug, String... variables) {
|
|
||||||
if (!Config.SETTINGS.DEBUG)
|
|
||||||
return;
|
|
||||||
logger.info(TEAL + replace(debug, variables) + RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void info(String info, String... variables) {
|
|
||||||
logger.info(GREEN + replace(info, variables) + RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void warning(String warning, String... variables) {
|
|
||||||
if (!Config.SETTINGS.WARNINGS)
|
|
||||||
return;
|
|
||||||
logger.warning(replace(warning, variables));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void severe(String severe, String... variables) {
|
|
||||||
logger.severe(replace(severe, variables));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String replace(String text, String... variables) {
|
|
||||||
for (String variable : variables) {
|
|
||||||
text = text.replaceFirst("%", variable);
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user