Prepare for v2.2 update

* Add warning when not using UUIDs
* Disable auto update if the used Minecraft version does not support UUIDs
This commit is contained in:
GeorgH93 2020-02-09 03:02:43 +01:00
parent 27c194c84b
commit 6b2aa5fde2
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
5 changed files with 62 additions and 11 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>Minepacks</artifactId>
<version>2.1.7</version>
<version>2.1.8</version>
<scm>
<connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>
@ -78,7 +78,7 @@
<dependency>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>PluginLib</artifactId>
<version>1.0.19-SNAPSHOT</version>
<version>1.0.20-SNAPSHOT</version>
</dependency>
<!-- BadRabbit -->
<dependency>

View File

@ -57,10 +57,7 @@ Database:
AutoCleanup:
# Defines the max amount of days backpacks will be stored. -1 to disable auto cleanup
MaxInactiveDays: -1
# If you would like to use UUIDs, it is recommended not to change this setting unless you know what you are doing!
# true: Should be used if your server is running Minecraft 1.7.5 or newer
# false: In offline mode or for minecraft version below 1.7.5
# If you are using BungeeCord please set this setting based on your BungeeCord's online mode!!!
# If you would like to use UUIDs. This option will be removed with the v2.2 update. It is not recommended to set this to false!
UseUUIDs: true
# Defines the storage format for UUIDs for compatibility with other plugins (shared tables)
# true: format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
@ -180,4 +177,4 @@ Misc:
UseBungeeCord: false
# Config file version. Don't touch it!
Version: 22
Version: 23

View File

@ -37,7 +37,7 @@
public class Config extends Configuration implements DatabaseConnectionConfiguration
{
private static final int CONFIG_VERSION = 22, UPGRADE_THRESHOLD = 22, PRE_V2_VERSION = 20;
private static final int CONFIG_VERSION = 23, UPGRADE_THRESHOLD = 23, PRE_V2_VERSION = 20;
public Config(JavaPlugin plugin)
{
@ -112,8 +112,8 @@ public String getDBFields(String sub, String def)
public boolean getUseUUIDs()
{
boolean uuid = getConfigE().getBoolean("Database.UseUUIDs", true);
if(!uuid) logger.warning(ConsoleColor.RED + "Disabling UUIDs is not recommended and can lead to unexpected behaviour. Please consider enabling UUIDs. The option will be removed at some point." + ConsoleColor.RESET);
boolean uuid = getConfigE().getBoolean("Database.UseUUIDs", true) && MCVersion.isUUIDsSupportAvailable();
if(!uuid) logger.severe(ConsoleColor.RED + "Disabling UUIDs is not recommended and can lead to unexpected behaviour. Please consider enabling UUIDs. The option will be removed with the v2.2 update." + ConsoleColor.RESET);
return uuid;
}
@ -176,7 +176,7 @@ public int getBackpackMaxSize()
public boolean getAutoUpdate()
{
return getConfigE().getBoolean("Misc.AutoUpdate", true);
return getConfigE().getBoolean("Misc.AutoUpdate", true) && MCVersion.isUUIDsSupportAvailable();
}
public boolean isBungeeCordModeEnabled()

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2020 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.Listener;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class NoUUIDWarning implements Listener
{
public NoUUIDWarning(){}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAdminJoin(PlayerJoinEvent event)
{
if(event.getPlayer().hasPermission("backpack.reload"))
{
final Player player = event.getPlayer();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Minepacks.getInstance(), () -> {
if(player.isOnline())
{
String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Minepacks" + ChatColor.DARK_GRAY + "] " + ChatColor.RED;
player.sendMessage(ChatColor.RED + "########## Warning ##########");
player.sendMessage(prefix + "With the upcoming v2.2 update the option to disable UUIDs will be removed.");
player.sendMessage(prefix + "If you are using BungeeCord or another proxy the plugin will not be able to autodetect if it should use online or offline mode UUIDs and you should set the 'UUID_Type' config option manually before updating to v2.2.");
player.sendMessage(prefix + "Please note that if you have many old players in your database already it is possible that some have already changed their name and will fail to convert to UUID. You will have to remove them manually from your database after converting to UUIDs. Not doing so will make the plugin try to convert them to UUIDs on every startup/reload.");
player.sendMessage(ChatColor.RED + "########## Warning ##########");
}
}, 40);
}
}
}

View File

@ -195,6 +195,7 @@ private void load()
}
if(config.isShulkerboxesDisable()) pluginManager.registerEvents(new DisableShulkerboxes(this), this);
if(config.isItemShortcutEnabled()) pluginManager.registerEvents(new ItemShortcut(this), this);
if(!config.getUseUUIDs() && config.getString("Database.UUID_Type", "auto").equalsIgnoreCase("auto") && MCVersion.isUUIDsSupportAvailable()) pluginManager.registerEvents(new NoUUIDWarning(), this);
//endregion
if(config.getFullInvCollect()) collector = new ItemsCollector(this);
worldBlacklist = config.getWorldBlacklist();