Add config
This commit is contained in:
1 parent
f28366aa98
commit
93c093e917
2 files changed
+72
No files matched your search
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of the Minecraft Smart Afk project.
|
||||
* Licensed under the MIT License. See the LICENSE file in the project root for full license information.
|
||||
*/
|
||||
|
||||
package de.codecrafter.smartAfk.utils;
|
||||
|
||||
import de.codecrafter.smartAfk.SmartAfk;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class AfkConfig {
|
||||
private final SmartAfk plugin;
|
||||
|
||||
// config values
|
||||
private boolean freezeAfkPlayers;
|
||||
private boolean cancelAfkOnMove;
|
||||
private boolean cancelAfkOnJump;
|
||||
|
||||
/**
|
||||
* Creates an instance of {@code TimerConfig} class.
|
||||
*
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
public AfkConfig(SmartAfk plugin) {
|
||||
this.plugin = plugin;
|
||||
this.load(plugin.getConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the config from the config file on the disk.
|
||||
*/
|
||||
public void reload() {
|
||||
plugin.reloadConfig();
|
||||
load(plugin.getConfig());
|
||||
plugin.getComponentLogger().info(Component.text("Timer config reloaded.", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the attributes of the class instance with the values from the config file.
|
||||
*
|
||||
* @param config The config object.
|
||||
*/
|
||||
private void load(FileConfiguration config) {
|
||||
this.freezeAfkPlayers = config.getBoolean("freeze-afk-players", true);
|
||||
this.cancelAfkOnJump = config.getBoolean("cancel-afk-on-jump", true);
|
||||
this.cancelAfkOnMove = config.getBoolean("cancel-afk-on-move", true);
|
||||
}
|
||||
|
||||
public boolean isFreezeAfkPlayers() {
|
||||
return freezeAfkPlayers;
|
||||
}
|
||||
|
||||
public boolean isCancelAfkOnJump() {
|
||||
return cancelAfkOnJump;
|
||||
}
|
||||
|
||||
public boolean isCancelAfkOnMove() {
|
||||
return cancelAfkOnMove;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# prevent afk players from moving
|
||||
freeze-afk-players: true
|
||||
|
||||
# cancel afk status if the player jumps
|
||||
# only active if 'freeze-afk-players' is true
|
||||
cancel-afk-on-jump: true
|
||||
|
||||
# cancel afk status if player moves more than 3 blocks
|
||||
# only active if 'freeze-afk-players' is false
|
||||
cancel-afk-on-move: true
|
||||
Reference in new issue
Block a user