Add v3 update notification

This commit is contained in:
GeorgH93 2021-06-02 21:16:51 +02:00
parent 7247c5dcf4
commit 98736fa233
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 60 additions and 1 deletions

View File

@ -38,13 +38,17 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import lombok.Getter;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.stream.Collectors;
public class Config extends Configuration implements DatabaseConnectionConfiguration, IUnCacheStrategyConfig, ILanguageConfiguration
{
private static final int CONFIG_VERSION = 36, PRE_V2_VERSION = 20;
private static final int CONFIG_VERSION = 36, PRE_V2_VERSION = 20, PRE_V3_VERSION = 40;
@Getter private boolean updatedToV3 = false;
public Config(final @NotNull JavaPlugin plugin)
{
@ -101,6 +105,7 @@ protected void doUpgrade(@NotNull YamlFileManager oldConfig)
//keysToKeep.addAll(oldConfig.getYamlE().getKeysFiltered("Database\\.Tables\\.Fields\\..+"));
doUpgrade(oldConfig, remappedKeys, keysToKeep);
}
if(oldConfig.version().olderThan(new Version(PRE_V3_VERSION))) updatedToV3 = true;
}
//region getter

View File

@ -38,6 +38,7 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.*;
import at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker.NoDatabaseWorker;
import at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker.NoUpgradesFromV1;
import at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker.WelcomeToV3;
import at.pcgamingfreaks.StringUtils;
import at.pcgamingfreaks.Updater.UpdateResponseCallback;
import at.pcgamingfreaks.Version;
@ -231,6 +232,7 @@ private void load()
cooldownManager = new CooldownHandler(this);
if(configuration.isCommandCooldownSyncEnabled()) pluginManager.registerEvents(cooldownManager, this);
}
if(configuration.isUpdatedToV3()) pluginManager.registerEvents(new WelcomeToV3(this), this);
//endregion
if(configuration.isItemCollectorEnabled()) collector = new ItemsCollector(this);
worldBlacklist = configuration.getWorldBlacklist();

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker;
import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Bukkit.Message.MessageBuilder;
import at.pcgamingfreaks.Message.MessageColor;
import at.pcgamingfreaks.Message.MessageFormat;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import at.pcgamingfreaks.Minepacks.Bukkit.Permissions;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class WelcomeToV3 extends SpecialInfoBase
{
private List<Message> messages = new ArrayList<>();
public WelcomeToV3(final Minepacks plugin)
{
super(plugin, Permissions.RELOAD);
messages.add(new MessageBuilder().append(" ", MessageColor.AQUA, MessageFormat.UNDERLINE)
.append("[", MessageColor.DARK_GRAY).append("Minepacks v3." + plugin.getVersion().getMinor(), MessageColor.YELLOW).append("]", MessageColor.DARK_GRAY)
.append(" ", MessageColor.AQUA, MessageFormat.UNDERLINE).getMessage());
messages.add(new MessageBuilder("Minepacks has been updated to " + plugin.getVersion() + "!").appendNewLine()
.append("This update brings a lot of changes, so make sure to check the config file and update your language file.")
.getMessage());
}
@Override
protected void sendMessage(Player player)
{
messages.forEach(message -> message.send(player));
}
}