Drop support for all versions of MC < 1.17
- Only versions 1.17 and up are supported from now on.
This commit is contained in:
		@@ -5,7 +5,6 @@ import nl.pim16aap2.armoredElytra.handlers.CommandHandler;
 | 
				
			|||||||
import nl.pim16aap2.armoredElytra.handlers.EventHandlers;
 | 
					import nl.pim16aap2.armoredElytra.handlers.EventHandlers;
 | 
				
			||||||
import nl.pim16aap2.armoredElytra.handlers.FlyDurabilityHandler;
 | 
					import nl.pim16aap2.armoredElytra.handlers.FlyDurabilityHandler;
 | 
				
			||||||
import nl.pim16aap2.armoredElytra.handlers.ItemDropListener;
 | 
					import nl.pim16aap2.armoredElytra.handlers.ItemDropListener;
 | 
				
			||||||
import nl.pim16aap2.armoredElytra.handlers.LoginHandler;
 | 
					 | 
				
			||||||
import nl.pim16aap2.armoredElytra.handlers.NetheriteUpgradeListener;
 | 
					import nl.pim16aap2.armoredElytra.handlers.NetheriteUpgradeListener;
 | 
				
			||||||
import nl.pim16aap2.armoredElytra.handlers.SmithingTableCraftHandler;
 | 
					import nl.pim16aap2.armoredElytra.handlers.SmithingTableCraftHandler;
 | 
				
			||||||
import nl.pim16aap2.armoredElytra.handlers.Uninstaller;
 | 
					import nl.pim16aap2.armoredElytra.handlers.Uninstaller;
 | 
				
			||||||
@@ -30,10 +29,9 @@ import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			|||||||
import javax.annotation.Nullable;
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
import java.util.Collections;
 | 
					import java.util.Collections;
 | 
				
			||||||
import java.util.EnumMap;
 | 
					import java.util.EnumMap;
 | 
				
			||||||
import java.util.HashSet;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Objects;
 | 
				
			||||||
import java.util.logging.Level;
 | 
					import java.util.logging.Level;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ArmoredElytra extends JavaPlugin implements Listener
 | 
					public class ArmoredElytra extends JavaPlugin implements Listener
 | 
				
			||||||
@@ -42,7 +40,6 @@ public class ArmoredElytra extends JavaPlugin implements Listener
 | 
				
			|||||||
        .get(Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]);
 | 
					        .get(Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static ArmoredElytra INSTANCE;
 | 
					    private static ArmoredElytra INSTANCE;
 | 
				
			||||||
    private final Set<Enchantment> allowedEnchantments = new HashSet<>();
 | 
					 | 
				
			||||||
    private Messages messages;
 | 
					    private Messages messages;
 | 
				
			||||||
    private ConfigLoader config;
 | 
					    private ConfigLoader config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,34 +47,23 @@ public class ArmoredElytra extends JavaPlugin implements Listener
 | 
				
			|||||||
    private UpdateManager updateManager;
 | 
					    private UpdateManager updateManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private NBTEditor nbtEditor;
 | 
					    private NBTEditor nbtEditor;
 | 
				
			||||||
    private DurabilityManager durabilityManager;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onEnable()
 | 
					    public void onEnable()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        INSTANCE = this;
 | 
					        INSTANCE = this;
 | 
				
			||||||
        if (minecraftVersion.isOlderThan(MinecraftVersion.v1_15))
 | 
					        if (minecraftVersion.isOlderThan(MinecraftVersion.v1_17))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            myLogger(Level.SEVERE, "Trying to run this plugin on an unsupported version... ABORT!");
 | 
					            myLogger(Level.SEVERE, "Trying to run this plugin on an unsupported version... ABORT!");
 | 
				
			||||||
            setEnabled(false);
 | 
					            setEnabled(false);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isBlacklistedVersion())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            myLogger(Level.SEVERE,
 | 
					 | 
				
			||||||
                     "You are trying to run this plugin on a blacklisted version of Spigot! Please update Spigot!");
 | 
					 | 
				
			||||||
            Bukkit.getPluginManager().registerEvents(
 | 
					 | 
				
			||||||
                new LoginHandler(this, ChatColor.RED +
 | 
					 | 
				
			||||||
                    "[ArmoredElytra] The plugin failed to start because you are running on a " +
 | 
					 | 
				
			||||||
                    "blacklisted version of Spiogt! Please update Spigot!"), this);
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        nbtEditor = new NBTEditor();
 | 
					        nbtEditor = new NBTEditor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        config = new ConfigLoader(this);
 | 
					        config = new ConfigLoader(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        durabilityManager = new DurabilityManager(nbtEditor, config);
 | 
					        DurabilityManager durabilityManager = new DurabilityManager(nbtEditor, config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        messages = new Messages(this);
 | 
					        messages = new Messages(this);
 | 
				
			||||||
        readMessages();
 | 
					        readMessages();
 | 
				
			||||||
@@ -99,7 +85,8 @@ public class ArmoredElytra extends JavaPlugin implements Listener
 | 
				
			|||||||
                         "seeing higher user numbers helps me stay motivated!");
 | 
					                         "seeing higher user numbers helps me stay motivated!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Bukkit.getPluginManager().registerEvents(new EventHandlers(this, nbtEditor, durabilityManager), this);
 | 
					        Bukkit.getPluginManager().registerEvents(new EventHandlers(this, nbtEditor, durabilityManager), this);
 | 
				
			||||||
        getCommand("ArmoredElytra").setExecutor(new CommandHandler(this, nbtEditor, durabilityManager));
 | 
					        Objects.requireNonNull(getCommand("ArmoredElytra"), "ArmoredElytra base command not found!")
 | 
				
			||||||
 | 
					               .setExecutor(new CommandHandler(this, nbtEditor, durabilityManager));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Load the plugin normally if not in uninstall mode.
 | 
					        // Load the plugin normally if not in uninstall mode.
 | 
				
			||||||
        if (!config.uninstallMode())
 | 
					        if (!config.uninstallMode())
 | 
				
			||||||
@@ -131,24 +118,6 @@ public class ArmoredElytra extends JavaPlugin implements Listener
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Checks if the current version is blacklisted.
 | 
					 | 
				
			||||||
     * <p>
 | 
					 | 
				
			||||||
     * This is needed for 1.16, as on the initial release there was a bug with NBT stuff that would crash clients when
 | 
					 | 
				
			||||||
     * they saw an Armored Elytra. When they obtained one using a command they wouldn't be able to rejoin the game again
 | 
					 | 
				
			||||||
     * until an NBTEditor was used to remove the item from their inventory.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return True if the current version is blacklisted.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public boolean isBlacklistedVersion()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (minecraftVersion != MinecraftVersion.v1_16)
 | 
					 | 
				
			||||||
            return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        String[] parts = Bukkit.getVersion().substring("git-Spigot-".length()).split("-");
 | 
					 | 
				
			||||||
        return parts.length > 0 && parts[0].equals("758abbe");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public MinecraftVersion getMinecraftVersion()
 | 
					    public MinecraftVersion getMinecraftVersion()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return minecraftVersion;
 | 
					        return minecraftVersion;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -137,13 +137,13 @@ public class ConfigLoader
 | 
				
			|||||||
            };
 | 
					            };
 | 
				
			||||||
        String[] craftingInSmithingTableComment =
 | 
					        String[] craftingInSmithingTableComment =
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                "This option only works on 1.16+! When enabled, armored elytra creation in anvils is disabled. ",
 | 
					                "When enabled, armored elytra creation in anvils is disabled. ",
 | 
				
			||||||
                "Instead, you will have to craft them in a smithy. Enchanting/repairing them still works via the anvil."
 | 
					                "Instead, you will have to craft them in a smithy. Enchanting/repairing them still works via the anvil."
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
        String[] allowUpgradeToNetheriteComment =
 | 
					        String[] allowUpgradeToNetheriteComment =
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                "Whether or not to allow upgrading diamond armored elytras to netherite ones is possible.",
 | 
					                "Whether or not to allow upgrading diamond armored elytras to netherite ones is possible.",
 | 
				
			||||||
                "When allowed (on 1.16+), you can combine a diamond one with a netherite ingot in a smithing table",
 | 
					                "When allowed, you can combine a diamond one with a netherite ingot in a smithing table",
 | 
				
			||||||
                "and you'll receive a netherite one."
 | 
					                "and you'll receive a netherite one."
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
        String[] allowRenamingComment =
 | 
					        String[] allowRenamingComment =
 | 
				
			||||||
@@ -189,28 +189,13 @@ public class ConfigLoader
 | 
				
			|||||||
            throw new IllegalStateException("Incorrect repair counts array size! Expected size " +
 | 
					            throw new IllegalStateException("Incorrect repair counts array size! Expected size " +
 | 
				
			||||||
                                                armorTierCount + " but got size " + repairCounts.length);
 | 
					                                                armorTierCount + " but got size " + repairCounts.length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        craftingInSmithingTable = addNewConfigOption(config, "craftingInSmithingTable", true,
 | 
				
			||||||
        final boolean smithingTableAllowed = plugin.getMinecraftVersion().isNewerThan(MinecraftVersion.v1_15);
 | 
					 | 
				
			||||||
        craftingInSmithingTable = addNewConfigOption(config, "craftingInSmithingTable", smithingTableAllowed,
 | 
					 | 
				
			||||||
                                                     craftingInSmithingTableComment);
 | 
					                                                     craftingInSmithingTableComment);
 | 
				
			||||||
        if (craftingInSmithingTable && !smithingTableAllowed)
 | 
					        allowUpgradeToNetherite = addNewConfigOption(config, "allowUpgradeToNetherite", true,
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Bukkit.getLogger().log(Level.WARNING, "You tried to enable crafting in smithing tables, " +
 | 
					 | 
				
			||||||
                "but this is only supported on 1.16+! Reverting to disabled.");
 | 
					 | 
				
			||||||
            craftingInSmithingTable = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        allowUpgradeToNetherite = addNewConfigOption(config, "allowUpgradeToNetherite", smithingTableAllowed,
 | 
					 | 
				
			||||||
                                                     allowUpgradeToNetheriteComment);
 | 
					                                                     allowUpgradeToNetheriteComment);
 | 
				
			||||||
        if (allowUpgradeToNetherite && !smithingTableAllowed)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Bukkit.getLogger().log(Level.WARNING, "You tried to enable crafting in smithing tables, " +
 | 
					 | 
				
			||||||
                "but this is only supported on 1.16+! Reverting to disabled.");
 | 
					 | 
				
			||||||
            allowUpgradeToNetherite = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        defaultAllowedEnchantments = addNewConfigOption(config, "allowedEnchantments", defaultAllowedEnchantments,
 | 
					        defaultAllowedEnchantments = addNewConfigOption(config, "allowedEnchantments", defaultAllowedEnchantments,
 | 
				
			||||||
                                                        enchantmentsComment);
 | 
					                                                        enchantmentsComment);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        allowedEnchantments = new LinkedHashSet<>();
 | 
					        allowedEnchantments = new LinkedHashSet<>();
 | 
				
			||||||
        defaultAllowedEnchantments.forEach(
 | 
					        defaultAllowedEnchantments.forEach(
 | 
				
			||||||
            fullKey ->
 | 
					            fullKey ->
 | 
				
			||||||
@@ -253,8 +238,7 @@ public class ConfigLoader
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private <T> T addNewConfigOption(FileConfiguration config, String optionName, T defaultValue, String[] comment)
 | 
					    private <T> T addNewConfigOption(FileConfiguration config, String optionName, T defaultValue, String[] comment)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        nl.pim16aap2.armoredElytra.util.ConfigOption<T> option = new nl.pim16aap2.armoredElytra.util.ConfigOption<>(
 | 
					        ConfigOption<T> option = new ConfigOption<>(plugin, config, optionName, defaultValue, comment);
 | 
				
			||||||
            plugin, config, optionName, defaultValue, comment);
 | 
					 | 
				
			||||||
        configOptionsList.add(option);
 | 
					        configOptionsList.add(option);
 | 
				
			||||||
        return option.getValue();
 | 
					        return option.getValue();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user