Implement toggling value update message

This commit is contained in:
ChronosX88 2021-08-04 00:42:22 +03:00
parent 97d4187af3
commit 7a2868a165
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
2 changed files with 15 additions and 12 deletions

View File

@ -12,22 +12,24 @@ public class ValueUpdates {
Placeholders plh = new Placeholders();
public void announceValue() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(OreMarket.main(), () -> {
for (String key : Objects.requireNonNull(OreMarket.main().getGuiConfig().getConfigurationSection("items")).getKeys(false)) {
ConfigurationSection keySection = Objects.requireNonNull(OreMarket.main().getGuiConfig().getConfigurationSection("items")).getConfigurationSection(key);
String message = OreMarket.main().getConfig().getString("valuemessage.format");
if(OreMarket.main().getConfig().getBoolean("valuemessage.enabled")) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(OreMarket.main(), () -> {
for (String key : Objects.requireNonNull(OreMarket.main().getGuiConfig().getConfigurationSection("items")).getKeys(false)) {
ConfigurationSection keySection = Objects.requireNonNull(OreMarket.main().getGuiConfig().getConfigurationSection("items")).getConfigurationSection(key);
String message = OreMarket.main().getConfig().getString("valuemessage.format");
assert keySection != null;
assert message != null;
assert keySection != null;
assert message != null;
for (Player player: Bukkit.getOnlinePlayers()) {
if (keySection.getBoolean("hide")) {
return;
for (Player player: Bukkit.getOnlinePlayers()) {
if (keySection.getBoolean("hide")) {
return;
}
player.sendMessage(plh.format(message, player, keySection));
}
player.sendMessage(plh.format(message, player, keySection));
}
}
}, 0L, (OreMarket.main().getConfig().getInt("valuemessage.time")* 20L*60));
}, 0L, (OreMarket.main().getConfig().getInt("valuemessage.time")* 20L*60));
}
}
}

View File

@ -5,6 +5,7 @@
prefix: '&bOreMarket '
valuemessage:
enabled: true
# Time (in minutes) to send this message
time: 5
# The below will look like: (These values are just examples)