Skip to content

Commit

Permalink
feat: add updater disable/enable option in config
Browse files Browse the repository at this point in the history
  • Loading branch information
hank9999 committed Feb 16, 2024
1 parent 96952db commit 525868a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ public static String str(String path) {
public static Boolean bool(String path) {
return UseBlessingSkin.plugin.getConfig().getBoolean(path);
}

public static Boolean checkPath(String path) {
return UseBlessingSkin.plugin.getConfig().contains(path);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.hank9999.useblessingskin.bukkit;

import com.github.hank9999.useblessingskin.bukkit.Commands.BukkitCommand;
import com.github.hank9999.useblessingskin.bukkit.Libs.getConfig;
import com.github.hank9999.useblessingskin.bukkit.bStats.MetricsLite;

import com.github.hank9999.useblessingskin.bukkit.Update.Updater;
Expand Down Expand Up @@ -46,7 +47,9 @@ public void onEnable() {
getLogger().warning("An error occurred while enabling bStats Metrics!");
}

new Updater();
if (!getConfig.checkPath("update") || getConfig.bool("update")) {
new Updater();
}
}

Objects.requireNonNull(getServer().getPluginCommand("bskin")).setExecutor(new BukkitCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public static Boolean bool(String path) {
return UseBlessingSkin.configuration.getBoolean(path);
}

public static Boolean checkPath(String path) {
return UseBlessingSkin.configuration.contains(path);
}

public static Boolean reload() {
try {
UseBlessingSkin.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(UseBlessingSkin.instance.getDataFolder(), "config.yml"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.hank9999.useblessingskin.bungee;

import com.github.hank9999.useblessingskin.bungee.Libs.getConfig;
import com.github.hank9999.useblessingskin.bungee.Update.Updater;
import com.github.hank9999.useblessingskin.bungee.bStats.MetricsLite;
import net.md_5.bungee.api.ChatColor;
Expand Down Expand Up @@ -69,7 +70,9 @@ public void onEnable() {
getLogger().warning("An error occurred while enabling bStats Metrics!");
}

new Updater();
if (!getConfig.checkPath("update") || getConfig.bool("update")) {
new Updater();
}
}

getLogger().info("UseBlessingSkin Enable");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public boolean bool(String path) {
return configuration.node((Object[]) path.split("\\.")).getBoolean();
}

public boolean checkPath(String path) {
return configuration.node((Object[]) path.split("\\.")).isNull();
}

public boolean reloadConfig() {
return loadConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
componentLogger.warn("An error occurred while enabling bStats Metrics!");
}

if (configManager.bool("update")) {
if (!configManager.checkPath("update") || configManager.bool("update")) {
new Updater(server, plugin, componentLogger);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ url: 'https://example.com/'
mineskinapi: 'https://api.mineskin.org/generate/upload'
cdn: false
cache: false
update: true

message:
Support: '目前支持以下皮肤站'
Expand Down

0 comments on commit 525868a

Please sign in to comment.