mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Add update channel config
This commit is contained in:
parent
d01f91edc9
commit
7cb27ffb15
@ -38,7 +38,7 @@
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>PluginLib</artifactId>
|
||||
<version>1.0.24-SNAPSHOT</version>
|
||||
<version>1.0.25-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- BadRabbit -->
|
||||
<dependency>
|
||||
|
@ -200,10 +200,12 @@ InventoryManagement:
|
||||
Enabled: true
|
||||
|
||||
Misc:
|
||||
# Enables/Disables the auto-update function of the plugin.
|
||||
AutoUpdate: true
|
||||
AutoUpdate:
|
||||
# When auto update is disabled you still can use the build in update function manually with /backpack update
|
||||
Enabled: true
|
||||
Channel: ${updateChannel}
|
||||
# Enable this option if you are using a BungeeCord setup!
|
||||
UseBungeeCord: false
|
||||
|
||||
# Config file version. Don't touch it!
|
||||
Version: 28
|
||||
Version: 29
|
@ -38,7 +38,7 @@
|
||||
|
||||
public class Config extends Configuration implements DatabaseConnectionConfiguration
|
||||
{
|
||||
private static final int CONFIG_VERSION = 28, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
||||
private static final int CONFIG_VERSION = 29, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
||||
|
||||
public Config(JavaPlugin plugin)
|
||||
{
|
||||
@ -64,7 +64,10 @@ protected void doUpgrade(@NotNull YamlFileManager oldConfig)
|
||||
{
|
||||
Map<String, String> remappedKeys = new HashMap<>();
|
||||
if(oldConfig.getVersion() <= 23) remappedKeys.put("ItemFilter.Materials", "ItemFilter.Blacklist");
|
||||
doUpgrade(oldConfig, remappedKeys);
|
||||
if(oldConfig.getVersion() <= 28) remappedKeys.put("Misc.AutoUpdate.Enabled", "Misc.AutoUpdate");
|
||||
Collection<String> keysToKeep = oldConfig.getYamlE().getKeysFiltered("Database\\.SQL\\.(MaxLifetime|IdleTimeout)");
|
||||
keysToKeep.addAll(oldConfig.getYamlE().getKeysFiltered("Database\\.Tables\\.Fields\\..+"));
|
||||
doUpgrade(oldConfig, remappedKeys, keysToKeep);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,15 +188,28 @@ public ShrinkApproach getShrinkApproach()
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getAutoUpdate()
|
||||
//region Misc getters
|
||||
public boolean useUpdater()
|
||||
{
|
||||
return getConfigE().getBoolean("Misc.AutoUpdate", true);
|
||||
return getConfigE().getBoolean("Misc.AutoUpdate.Enabled", getConfigE().getBoolean("Misc.AutoUpdate", true));
|
||||
}
|
||||
|
||||
public String getUpdateChannel()
|
||||
{
|
||||
String channel = getConfigE().getString("Misc.AutoUpdate.Channel", "Release");
|
||||
if("Release".equals(channel) || "Master".equals(channel) || "Dev".equals(channel))
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
else logger.info("Unknown update Channel: " + channel);
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isBungeeCordModeEnabled()
|
||||
{
|
||||
return getConfigE().getBoolean("Misc.UseBungeeCord", false);
|
||||
}
|
||||
//endregion
|
||||
|
||||
public long getCommandCooldown()
|
||||
{
|
||||
|
@ -19,5 +19,5 @@
|
||||
|
||||
public class MagicValues
|
||||
{
|
||||
public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.24-SNAPSHOT";
|
||||
public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.25-SNAPSHOT";
|
||||
}
|
@ -137,7 +137,7 @@ public void onEnable()
|
||||
lang = new Language(this);
|
||||
load();
|
||||
|
||||
if(config.getAutoUpdate()) updater.update();
|
||||
if(config.useUpdater()) updater.update();
|
||||
getLogger().info(StringUtils.getPluginEnabledMessage(getDescription().getName()));
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public void onEnable()
|
||||
public void onDisable()
|
||||
{
|
||||
if(config == null) return;
|
||||
if(config.getAutoUpdate()) updater.update();
|
||||
if(config.useUpdater()) updater.update();
|
||||
unload();
|
||||
updater.waitForAsyncOperation(); // Wait for an update to finish
|
||||
getLogger().info(StringUtils.getPluginDisabledMessage(getDescription().getName()));
|
||||
@ -159,6 +159,7 @@ public void update(final @Nullable UpdateResponseCallback updateResponseCallback
|
||||
|
||||
private void load()
|
||||
{
|
||||
updater.setChannel(config.getUpdateChannel());
|
||||
lang.load(config);
|
||||
database = Database.getDatabase(this);
|
||||
if(database == null)
|
||||
|
Loading…
Reference in New Issue
Block a user