Skip to content

Commit

Permalink
Added Update Notifications Toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
beanbeanjuice committed Jun 4, 2024
1 parent 3c760ac commit 26fef50
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ BOT-TOKEN: "TOKEN_HERE"
CHANNEL-ID: "GLOBAL_CHANNEL_ID"

bot-activity:
# Valid Types: PLAYING, STREAMING, LISTENING, WATCHING, COMPETING
type: "COMPETING"
text: "SimpleProxyChat by beanbeanjuice"
# Valid Types: PLAYING, STREAMING, LISTENING, WATCHING, COMPETING
type: "COMPETING"
text: "SimpleProxyChat by beanbeanjuice"

# The amount of seconds to check if a server is online/offline.
# Smaller numbers can cause errors. Beware.
Expand All @@ -102,9 +102,9 @@ server-update-interval: 3
# It MUST be the same name you have in your bungee/velocity config.
# Simply set it to disabled: disabled to disable it.
aliases:
ServerInConfigExample: ServerAliasExample
hub: Hub1
smp: smp1
ServerInConfigExample: ServerAliasExample
hub: Hub1
smp: smp1

# Whether to use the permission system.
# Some permissions (denoted with ➕) are always active even if this is false.
Expand Down Expand Up @@ -134,18 +134,20 @@ use-fake-messages: true
# Format: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
# Timezone: https://www.joda.org/joda-time/timezones.html
timestamp:
# If your server is prone to getting off-sync on the time you can use an API.
# WARNING: Using the API will make messages somewhat longer to send.
# Additionally, the maximum accuracy will only be up to 1 minute, rather than seconds.
use-api: false
format: "hh:mm a"
timezone: "America/Los_Angeles"
# If your server is prone to getting off-sync on the time you can use an API.
# WARNING: Using the API will make messages somewhat longer to send.
# Additionally, the maximum accuracy will only be up to 1 minute, rather than seconds.
use-api: false
format: "hh:mm a"
timezone: "America/Los_Angeles"

# True if you will be using the helper plugin.
use-helper: false

update-notifications: true

# DO NOT TOUCH THIS
file-version: 10
file-version: 11
```
**messages.yml**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ private void startUpdateChecker() {
config,
currentVersion,
(message) -> {
if (!config.getAsBoolean(ConfigDataKey.UPDATE_NOTIFICATIONS)) return;

this.getLogger().info(Helper.sanitize(message));

Component minimessage = MiniMessage.miniMessage().deserialize(config.getAsString(ConfigDataKey.PLUGIN_PREFIX) + message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ private void startUpdateChecker() {
config,
currentVersion,
(message) -> {
if (!config.getAsBoolean(ConfigDataKey.UPDATE_NOTIFICATIONS)) return;
this.getLogger().info(Helper.sanitize(message));
this.proxyServer.getAllPlayers()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public HashMap<String, String> getAsStringMap(ConfigDataKey key) {

private void readConfig() throws IOException {
// config.yml
config.put(ConfigDataKey.USE_HELPER, Boolean.valueOf(yamlConfig.getString("use-helper")));
config.put(ConfigDataKey.USE_DISCORD, Boolean.valueOf(yamlConfig.getString("use-discord")));
config.put(ConfigDataKey.BOT_TOKEN, yamlConfig.getString("BOT-TOKEN"));
config.put(ConfigDataKey.CHANNEL_ID, yamlConfig.getString("CHANNEL-ID"));
Expand All @@ -106,6 +105,8 @@ private void readConfig() throws IOException {
config.put(ConfigDataKey.TIMESTAMP_USE_API, yamlConfig.getBoolean("timestamp.use-api"));
config.put(ConfigDataKey.TIMESTAMP_FORMAT, yamlConfig.getString("timestamp.format"));
config.put(ConfigDataKey.TIMESTAMP_TIMEZONE, yamlConfig.getString("timestamp.timezone"));
config.put(ConfigDataKey.USE_HELPER, Boolean.valueOf(yamlConfig.getString("use-helper")));
config.put(ConfigDataKey.UPDATE_NOTIFICATIONS, Boolean.valueOf(yamlConfig.getString("update-notifications")));

// Checking timezone.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public enum ConfigDataKey {
// CONFIG
USE_HELPER,
USE_DISCORD,
BOT_TOKEN,
CHANNEL_ID,
Expand All @@ -17,6 +16,8 @@ public enum ConfigDataKey {
TIMESTAMP_USE_API,
TIMESTAMP_FORMAT,
TIMESTAMP_TIMEZONE,
USE_HELPER,
UPDATE_NOTIFICATIONS,

// MESSAGES
PLUGIN_PREFIX,
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ timestamp:
# True if you will be using the helper plugin.
use-helper: false

update-notifications: true

# DO NOT TOUCH THIS
file-version: 10
file-version: 11

0 comments on commit 26fef50

Please sign in to comment.