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:
parent
9f9c5b7980
commit
28522ccbf6
@ -5,7 +5,6 @@ import nl.pim16aap2.armoredElytra.handlers.CommandHandler;
|
||||
import nl.pim16aap2.armoredElytra.handlers.EventHandlers;
|
||||
import nl.pim16aap2.armoredElytra.handlers.FlyDurabilityHandler;
|
||||
import nl.pim16aap2.armoredElytra.handlers.ItemDropListener;
|
||||
import nl.pim16aap2.armoredElytra.handlers.LoginHandler;
|
||||
import nl.pim16aap2.armoredElytra.handlers.NetheriteUpgradeListener;
|
||||
import nl.pim16aap2.armoredElytra.handlers.SmithingTableCraftHandler;
|
||||
import nl.pim16aap2.armoredElytra.handlers.Uninstaller;
|
||||
@ -30,10 +29,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
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]);
|
||||
|
||||
private static ArmoredElytra INSTANCE;
|
||||
private final Set<Enchantment> allowedEnchantments = new HashSet<>();
|
||||
private Messages messages;
|
||||
private ConfigLoader config;
|
||||
|
||||
@ -50,34 +47,23 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
private UpdateManager updateManager;
|
||||
|
||||
private NBTEditor nbtEditor;
|
||||
private DurabilityManager durabilityManager;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
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!");
|
||||
setEnabled(false);
|
||||
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();
|
||||
|
||||
config = new ConfigLoader(this);
|
||||
|
||||
durabilityManager = new DurabilityManager(nbtEditor, config);
|
||||
DurabilityManager durabilityManager = new DurabilityManager(nbtEditor, config);
|
||||
|
||||
messages = new Messages(this);
|
||||
readMessages();
|
||||
@ -99,7 +85,8 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
"seeing higher user numbers helps me stay motivated!");
|
||||
|
||||
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.
|
||||
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()
|
||||
{
|
||||
return minecraftVersion;
|
||||
|
@ -137,13 +137,13 @@ public class ConfigLoader
|
||||
};
|
||||
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."
|
||||
};
|
||||
String[] allowUpgradeToNetheriteComment =
|
||||
{
|
||||
"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."
|
||||
};
|
||||
String[] allowRenamingComment =
|
||||
@ -189,28 +189,13 @@ public class ConfigLoader
|
||||
throw new IllegalStateException("Incorrect repair counts array size! Expected size " +
|
||||
armorTierCount + " but got size " + repairCounts.length);
|
||||
|
||||
|
||||
final boolean smithingTableAllowed = plugin.getMinecraftVersion().isNewerThan(MinecraftVersion.v1_15);
|
||||
craftingInSmithingTable = addNewConfigOption(config, "craftingInSmithingTable", smithingTableAllowed,
|
||||
craftingInSmithingTable = addNewConfigOption(config, "craftingInSmithingTable", true,
|
||||
craftingInSmithingTableComment);
|
||||
if (craftingInSmithingTable && !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.");
|
||||
craftingInSmithingTable = false;
|
||||
}
|
||||
allowUpgradeToNetherite = addNewConfigOption(config, "allowUpgradeToNetherite", smithingTableAllowed,
|
||||
allowUpgradeToNetherite = addNewConfigOption(config, "allowUpgradeToNetherite", true,
|
||||
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,
|
||||
enchantmentsComment);
|
||||
|
||||
allowedEnchantments = new LinkedHashSet<>();
|
||||
defaultAllowedEnchantments.forEach(
|
||||
fullKey ->
|
||||
@ -253,8 +238,7 @@ public class ConfigLoader
|
||||
|
||||
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<>(
|
||||
plugin, config, optionName, defaultValue, comment);
|
||||
ConfigOption<T> option = new ConfigOption<>(plugin, config, optionName, defaultValue, comment);
|
||||
configOptionsList.add(option);
|
||||
return option.getValue();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user