From 2f944d970cfccabe26567bc76a6e9c3ad5ca24e7 Mon Sep 17 00:00:00 2001 From: EriolEandur Date: Wed, 18 Sep 2024 23:08:54 +0200 Subject: [PATCH] version 2.9.14-snapshot-1 added multi-version support for RPs --- pom.xml | 11 ++ .../serverResoucePack/RpCommand.java | 11 +- .../serverResoucePack/RpListener.java | 11 +- .../serverResoucePack/RpManager.java | 149 ++++++++++++++---- .../serverResoucePack/RpPlayerData.java | 12 +- .../serverResoucePack/RpReleaseUtil.java | 70 ++------ .../com/mcmiddleearth/util/ResourceUtil.java | 66 ++++++++ src/main/resources/config.yml | 5 +- src/main/resources/protocolVersions.yml | 34 ++++ 9 files changed, 275 insertions(+), 94 deletions(-) create mode 100644 src/main/java/com/mcmiddleearth/util/ResourceUtil.java create mode 100644 src/main/resources/protocolVersions.yml diff --git a/pom.xml b/pom.xml index b15cd4b..17a2492 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ plugin.yml config.yml + protocolVersions.yml items.json @@ -48,6 +49,10 @@ dmulloy2-repo https://repo.dmulloy2.net/repository/public/ + + viaversion-repo + https://repo.viaversion.com + @@ -103,6 +108,12 @@ + + com.viaversion + viaversion-api + [5.0.0,6.0.0) + provided + MCME-Architect \ No newline at end of file diff --git a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpCommand.java b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpCommand.java index a674161..c7aeeb7 100644 --- a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpCommand.java +++ b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpCommand.java @@ -60,17 +60,17 @@ public boolean onCommand(CommandSender cs, Command cmd, String c, String[] args) } if(args.length>0 && args[0].equalsIgnoreCase("server") && PluginData.hasPermission(cs, Permission.RESOURCE_PACK_ADMIN)) { - if(args.length>2) { - RpReleaseUtil.setServerResourcePack(cs, args[1], args[2], success -> { + if(args.length>3) { + RpReleaseUtil.setServerResourcePack(cs, args[1], args[2], args[3], success -> { if (success) { PluginData.getMessageUtil().sendInfoMessage(cs, "Server resource pack " + args[1] - + " set to version: " + args[2]); + + " set to version: " + args[2] + " for MC: "+ args[3]); } else { PluginData.getMessageUtil().sendErrorMessage(cs, "Error while setting server resource pack!"); } }); } else { - PluginData.getMessageUtil().sendErrorMessage(cs, "Command syntax: /rp server "); + PluginData.getMessageUtil().sendErrorMessage(cs, "Command syntax: /rp server "); } return true; } @@ -84,7 +84,8 @@ public boolean onCommand(CommandSender cs, Command cmd, String c, String[] args) @Override public void run() { String rpName = RpManager.matchRpName(args[1]); - if(RpManager.refreshSHA(cs, rpName)) { + boolean allVersions = args.length > 2 && args[2].equals("all"); + if(RpManager.refreshSHA(cs, rpName, allVersions)) { PluginData.getMessageUtil().sendInfoMessage(cs, "SHA recalculated for rp: "+rpName); } else { PluginData.getMessageUtil().sendErrorMessage(cs, "Error while recalculating SHA for rp: "+args[1]); diff --git a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpListener.java b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpListener.java index 9f557a1..0867c2d 100644 --- a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpListener.java +++ b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpListener.java @@ -25,6 +25,7 @@ import com.mcmiddleearth.connect.log.Log; import com.mcmiddleearth.pluginutil.message.FancyMessage; import com.mcmiddleearth.pluginutil.message.MessageType; +import com.viaversion.viaversion.api.Via; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -66,17 +67,18 @@ public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) { @EventHandler public void onPlayerConnect(PlayerConnectEvent event) { Player player = event.getPlayer(); -Logger.getGlobal().info("PlayerConnectEvent: "+player.getName()+" "+ event.getReason().name()); +/*Logger.getGlobal().info("PlayerConnectEvent: "+player.getName()+" "+ event.getReason().name()); int version = player.getProtocolVersion(); String snapshot = ""; if(version > 0x40000000) { snapshot = "Snapshot "; version = version - 0x40000000; } -Logger.getGlobal().info("Protocol Version: "+snapshot + version); +Logger.getGlobal().info("Bukkit Protocol Version: "+snapshot + version); +Logger.getGlobal().info("ViaVersion Protocol Version: "+Via.getAPI().getPlayerProtocolVersion(player.getUniqueId()).getVersion()); Logger.getGlobal().info("Sodium client: "+RpManager.isSodiumClient(player)); Logger.getGlobal().info("Incomming plugin channels:"); -Bukkit.getMessenger().getIncomingChannels().forEach(channel->Logger.getGlobal().info(channel)); +Bukkit.getMessenger().getIncomingChannels().forEach(channel->Logger.getGlobal().info(channel));*/ if(event.getReason().equals(PlayerConnectEvent.ConnectReason.JOIN_PROXY)) { new BukkitRunnable() { int counter = 11; @@ -84,6 +86,7 @@ public void onPlayerConnect(PlayerConnectEvent event) { public void run() { if(RpManager.hasPlayerDataLoaded(player) || counter==0) { RpPlayerData data = RpManager.getPlayerData(player); + data.setProtocolVersion(Via.getAPI().getPlayerProtocolVersion(player.getUniqueId()).getVersion()); if(RpManager.isSodiumClient(player)) { data.setClient("sodium"); } @@ -126,7 +129,7 @@ public void run() { Logger.getLogger(ArchitectPlugin.class.getName()).log(Level.WARNING,"Could not get player rp settings from the database"); } } - }.runTaskTimer(ArchitectPlugin.getPluginInstance(),0,20); + }.runTaskTimer(ArchitectPlugin.getPluginInstance(),30,20); } } diff --git a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpManager.java b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpManager.java index 2a7ac1a..28ac4bb 100644 --- a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpManager.java +++ b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpManager.java @@ -26,7 +26,9 @@ import com.mcmiddleearth.architect.ArchitectPlugin; import com.mcmiddleearth.architect.PluginData; import com.mcmiddleearth.architect.serverResoucePack.RegionEditConversation.RegionEditConversationFactory; +import com.mcmiddleearth.connect.log.Log; import com.mcmiddleearth.util.DevUtil; +import com.mcmiddleearth.util.ResourceUtil; import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.configuration.ConfigurationSection; @@ -46,6 +48,7 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; /** * @@ -55,21 +58,36 @@ public class RpManager { private static final File playerFile = new File(ArchitectPlugin.getPluginInstance().getDataFolder(),"/playerRpData.dat"); private static final File regionFolder = new File(ArchitectPlugin.getPluginInstance().getDataFolder(),"regions"); - + + private static final File versionFile = new File(ArchitectPlugin.getPluginInstance().getDataFolder(), "protocolVersions.yml"); + private static final Map protocolVersions = new HashMap<>(); + private static final String rpDatabaseConfig = "rpSettingsDatabase"; - + private static final Map regions = new HashMap<>(); - + private static final Map playerRpData = new HashMap<>(); private static final Map sodiumClients = new HashMap<>(); - + private static final RpDatabaseConnector dbConnector = new RpDatabaseConnector(ArchitectPlugin.getPluginInstance().getConfig().getConfigurationSection(rpDatabaseConfig)); private static final RegionEditConversationFactory regionEditConversationFactory = new RegionEditConversationFactory(ArchitectPlugin.getPluginInstance()); public static void init() { + if(!versionFile.exists()) { + ResourceUtil.saveResourceToFile(versionFile.getName(),versionFile); + } + YamlConfiguration versionConfig = new YamlConfiguration(); + try { + versionConfig.load(versionFile); + for(String version: versionConfig.getKeys(false)) { + protocolVersions.put(version, versionConfig.getInt(version)); + } + } catch (IOException | InvalidConfigurationException e) { + e.printStackTrace(); + } if(!regionFolder.exists()) { regionFolder.mkdir(); } @@ -145,6 +163,7 @@ public static RpPlayerData getPlayerData(Player player) { RpPlayerData data = playerRpData.get(player.getUniqueId()); if(data == null) { data = new RpPlayerData(); + data.setProtocolVersion(player.getProtocolVersion()); playerRpData.put(player.getUniqueId(), data); } return data; @@ -261,6 +280,32 @@ private static ConfigurationSection searchInVariantSection(ConfigurationSection if (variantSection != null) { if (variantSection.contains("url")) { return variantSection; + } else { + String versionResult = "0.1"; + int protocolResult = 0; + String versionMin = "unknown"; + int protocolMin = Integer.MAX_VALUE; + for(String version: variantSection.getKeys(false)) { +//Logger.getGlobal().info("Version: "+version); + Integer protocolVersion = protocolVersions.get(version); + if(protocolVersion==null) { + return null; + } +//Logger.getGlobal().info("Protocol: "+protocolVersion); + if(protocolResult < protocolVersion && protocolVersion <= data.getProtocolVersion()) { + versionResult = version; + protocolResult = protocolVersion; + } + if(protocolMin > protocolVersion) { + protocolMin = protocolVersion; + versionMin = version; + } + } + if(protocolResult > 0) { + return variantSection.getConfigurationSection(versionResult); + } else { + return variantSection.getConfigurationSection(versionMin); + } } } return null; @@ -306,7 +351,7 @@ public static boolean setRp(String rpName, Player player, boolean force) { return false; } - public static byte[] getSHAForUrl(String url) { + /*public static byte[] getSHAForUrl(String url) { for(String rpName: getRpConfig().getKeys(false)) { ConfigurationSection clientSection = getRpConfig().getConfigurationSection(rpName); for (String clientName : clientSection.getKeys(false)) { @@ -323,7 +368,7 @@ public static byte[] getSHAForUrl(String url) { } } return new byte[20]; - } + }*/ public static String getRpForUrl(String url) { for(String rpName: getRpConfig().getKeys(false)) { @@ -338,8 +383,17 @@ public static String getRpForUrl(String url) { for (String varKey : pxSection.getKeys(false)) { //Logger.getGlobal().info("Variant: "+varKey); ConfigurationSection varSection = pxSection.getConfigurationSection(varKey); - if (varSection.getString("url").equals(url)) { - return rpName; + if (varSection.contains("url")) { + if(varSection.getString("url").equals(url)) { + return rpName; + } + } else { + for(String versionKey: varSection.getKeys(false)) { + ConfigurationSection versionSection = varSection.getConfigurationSection(versionKey); + if (versionSection.getString("url").equals(url)) { + return rpName; + } + } } } } @@ -356,39 +410,60 @@ public static ConfigurationSection getRpConfig() { return ArchitectPlugin.getPluginInstance().getConfig().getConfigurationSection("ServerResourcePacks"); } - public static boolean refreshSHA(CommandSender cs, String rp) { + public static boolean refreshSHA(CommandSender cs, String rp, boolean allVersions) { ConfigurationSection config = getRpConfig().getConfigurationSection(rp); if(config!=null) { for(String clientKey: config.getKeys(false)) { +//Logger.getGlobal().info("ClientKey: "+clientKey); ConfigurationSection clientSection = config.getConfigurationSection(clientKey); for(String resolutionKey: clientSection.getKeys(false)) { +//Logger.getGlobal().info("ResolutionKey: "+resolutionKey); ConfigurationSection resolutionSection = clientSection.getConfigurationSection(resolutionKey); for (String variantKey : resolutionSection.getKeys(false)) { +//Logger.getGlobal().info("VariantKey: "+variantKey); try { ConfigurationSection variantSection = resolutionSection.getConfigurationSection(variantKey); - URL url = new URL(variantSection.getString("url")); - InputStream fis = url.openStream(); - MessageDigest sha1 = MessageDigest.getInstance("SHA1"); - - byte[] data = new byte[1024]; - int read = 0; - long time = System.currentTimeMillis(); - while ((read = fis.read(data)) != -1) { - sha1.update(data, 0, read); - if (System.currentTimeMillis() - time > 5000) { - time = System.currentTimeMillis(); - PluginData.getMessageUtil().sendInfoMessage(cs, "calculating ..."); + List sections = new LinkedList<>(); + if (variantSection.contains("url")) { +//Logger.getGlobal().info("DirectURL: "+variantSection.getString("url")); + sections.add(variantSection); + } else { + if (allVersions) { +//Logger.getGlobal().info("All versions"); + sections.addAll(variantSection.getKeys(false).stream() + .map(variantSection::getConfigurationSection).collect(Collectors.toSet())); + } else { +//Logger.getGlobal().info("Latest versions"); + sections.add(variantSection + .getConfigurationSection(getLatestVersion(variantSection.getKeys(false)))); } } - byte[] hashBytes = sha1.digest(); - StringBuilder sb = new StringBuilder(); - for (byte b : hashBytes) { - sb.append(String.format("%02x", b)); +//for(ConfigurationSection section: sections) Logger.getGlobal().info("URL: "+section.getString("url")); + for (ConfigurationSection section : sections) { + URL url = new URL(section.getString("url")); + InputStream fis = url.openStream(); + MessageDigest sha1 = MessageDigest.getInstance("SHA1"); + + byte[] data = new byte[1024]; + int read = 0; + long time = System.currentTimeMillis(); + while ((read = fis.read(data)) != -1) { + sha1.update(data, 0, read); + if (System.currentTimeMillis() - time > 5000) { + time = System.currentTimeMillis(); + PluginData.getMessageUtil().sendInfoMessage(cs, "calculating ..."); + } + } + byte[] hashBytes = sha1.digest(); + StringBuilder sb = new StringBuilder(); + for (byte b : hashBytes) { + sb.append(String.format("%02x", b)); + } + String hashString = sb.toString(); + section.set("sha", hashString); + ArchitectPlugin.getPluginInstance().saveConfig(); } - String hashString = sb.toString(); - variantSection.set("sha", hashString); - ArchitectPlugin.getPluginInstance().saveConfig(); - } catch (IOException | NoSuchAlgorithmException ex) { + } catch(IOException | NoSuchAlgorithmException ex){ Logger.getLogger(RpManager.class.getName()).log(Level.SEVERE, null, ex); return false; } @@ -399,6 +474,22 @@ public static boolean refreshSHA(CommandSender cs, String rp) { } return false; } + + private static String getLatestVersion(Collection versions) { + int latestProtocol = 0; + String latestVersion = ""; + for(String version : versions) { +//protocolVersions.forEach((key, protocol) -> Logger.getGlobal().info(key+" "+protocol)); +//Logger.getGlobal().info("getLatestVersion: version "+ version+ " protcolVersions: "+protocolVersions.size()); + int protocolVersion = protocolVersions.get(version); + if(protocolVersion > latestProtocol) { + latestProtocol = protocolVersion; + latestVersion = version; + } + } +//Logger.getGlobal().info("LatestVersion: "+latestVersion); + return latestVersion; + } public static String getResolutionKey(int px) { return px+"px"; diff --git a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpPlayerData.java b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpPlayerData.java index 77a239b..f1cb38d 100644 --- a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpPlayerData.java +++ b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpPlayerData.java @@ -27,7 +27,7 @@ public class RpPlayerData implements Serializable { private final long serialVerionsUID = 1; - + private boolean autoRp = true; private String variant = "light"; private String client = "vanilla"; @@ -37,6 +37,8 @@ public class RpPlayerData implements Serializable { private transient PlayerResourcePackStatusEvent.Status currentRpStatus = PlayerResourcePackStatusEvent.Status.DECLINED; + private transient int protocolVersion; + public boolean isAutoRp() { return autoRp; } @@ -92,4 +94,12 @@ public PlayerResourcePackStatusEvent.Status getCurrentRpStatus() { public void setCurrentRpStatus(PlayerResourcePackStatusEvent.Status currentRpStatus) { this.currentRpStatus = currentRpStatus; } + + public void setProtocolVersion(int protocolVersion) { + this.protocolVersion = protocolVersion; + } + + public int getProtocolVersion() { + return protocolVersion; + } } diff --git a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpReleaseUtil.java b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpReleaseUtil.java index ad79f97..dae4b61 100644 --- a/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpReleaseUtil.java +++ b/src/main/java/com/mcmiddleearth/architect/serverResoucePack/RpReleaseUtil.java @@ -51,9 +51,10 @@ public static void releaseResourcePack(String rpName, String version, String tit }); } - public static void setServerResourcePack(CommandSender cs, String rpName, String version, + public static void setServerResourcePack(CommandSender cs, String rpName, String version, String requiredMcVersion, Consumer callback) { String finalRpName = RpManager.matchRpName(rpName); + requiredMcVersion = requiredMcVersion.replace('.','_'); ConfigurationSection rpConfig = RpManager.getRpConfig(); rpConfig = rpConfig.getConfigurationSection(finalRpName); if(rpConfig ==null) { @@ -61,66 +62,29 @@ public static void setServerResourcePack(CommandSender cs, String rpName, String } else { String download = "https://github.com/" + getGitHubOwner(finalRpName) + "/" + getGitHubRepo(finalRpName) + "/releases/download/"; if (rpConfig.contains("sodium")) { - rpConfig.set("vanilla.16px.light.url", download + version + "/"+finalRpName+"-Vanilla.zip"); - rpConfig.set("vanilla.16px.footprints.url", download + version + "/"+finalRpName+"-Vanilla-Footprints.zip"); - rpConfig.set("sodium.16px.light.url", download + version + "/"+finalRpName+"-Sodium.zip"); - rpConfig.set("sodium.16px.footprints.url", download + version + "/"+finalRpName+"-Sodium-Footprints.zip"); + updateSection(rpConfig, "vanilla.16px.light",requiredMcVersion, download + version + "/"+finalRpName+"-Vanilla.zip"); + updateSection(rpConfig, "vanilla.16px.footprints",requiredMcVersion, download + version + "/"+finalRpName+"-Vanilla-Footprints.zip"); + updateSection(rpConfig, "sodium.16px.light",requiredMcVersion, download + version + "/"+finalRpName+"-Sodium.zip"); + updateSection(rpConfig, "sodium.16px.footprints",requiredMcVersion, download + version + "/"+finalRpName+"-Sodium-Footprints.zip"); } else { - rpConfig.set("vanilla.16px.light.url", download + version + "/"+finalRpName+".zip"); - rpConfig.set("vanilla.16px.footprints.url", download + version + "/"+finalRpName+"-Footprints.zip"); + updateSection(rpConfig, "vanilla.16px.light",requiredMcVersion, download + version + "/"+finalRpName+".zip"); + updateSection(rpConfig, "vanilla.16px.footprints",requiredMcVersion, download + version + "/"+finalRpName+"-Footprints.zip"); } ArchitectPlugin.getPluginInstance().saveConfig(); - //ArchitectPlugin.getPluginInstance().loadData(); probably not needed Bukkit.getScheduler().runTaskAsynchronously(ArchitectPlugin.getPluginInstance(), () -> { - callback.accept(RpManager.refreshSHA(cs, finalRpName)); + callback.accept(RpManager.refreshSHA(cs, finalRpName, false)); }); } - /*if(rpName.equalsIgnoreCase("human")) { - ConfigurationSection rpConfig = RpManager.getRpConfig(); - ConfigurationSection humanConfig = rpConfig.getConfigurationSection("Human"); - if(humanConfig !=null) { - String download = "https://github.com/"+getGitHubOwner("Human")+"/"+getGitHubRepo("Human")+"/releases/download/"; - humanConfig.set("vanilla.16px.light.url", download + version + "/Human-Vanilla.zip"); - humanConfig.set("vanilla.16px.footprints.url", download + version + "/Human-Vanilla-Footprints.zip"); - humanConfig.set("sodium.16px.light.url", download + version + "/Human-Sodium.zip"); - humanConfig.set("sodium.16px.footprints.url", download + version + "/Human-Sodium-Footprints.zip"); - ArchitectPlugin.getPluginInstance().saveConfig(); - //ArchitectPlugin.getPluginInstance().loadData(); probably not needed - Bukkit.getScheduler().runTaskAsynchronously(ArchitectPlugin.getPluginInstance(), () -> { - callback.accept(RpManager.refreshSHA(cs, "Human")); - }); - } - } else if(rpName.equalsIgnoreCase("Dwarf")) { - ConfigurationSection rpConfig = RpManager.getRpConfig(); - ConfigurationSection humanConfig = rpConfig.getConfigurationSection("Dwarf"); - if(humanConfig !=null) { - String download = "https://github.com/"+getGitHubOwner("Dwarf")+"/"+getGitHubRepo("Dwarf")+"/releases/download/"; - humanConfig.set("vanilla.16px.light.url", download + version + "/Dwarven.zip"); - humanConfig.set("vanilla.16px.footprints.url", download + version + "/Dwarven-footprints.zip"); - ArchitectPlugin.getPluginInstance().saveConfig(); - //ArchitectPlugin.getPluginInstance().loadData(); probably not needed - Bukkit.getScheduler().runTaskAsynchronously(ArchitectPlugin.getPluginInstance(), () -> { - callback.accept(RpManager.refreshSHA(cs, "Dwarf")); - }); - } - } else if(rpName.equalsIgnoreCase("Rohan")) { - ConfigurationSection rpConfig = RpManager.getRpConfig(); - ConfigurationSection humanConfig = rpConfig.getConfigurationSection("Rohan"); - if(humanConfig !=null) { - String download = "https://github.com/"+getGitHubOwner("Rohan")+"/"+getGitHubRepo("Rohan")+"/releases/download/"; - humanConfig.set("vanilla.16px.light.url", download + version + "/Rohan.zip"); - humanConfig.set("vanilla.16px.footprints.url", download + version + "/Rohan-footprints.zip"); - ArchitectPlugin.getPluginInstance().saveConfig(); - //ArchitectPlugin.getPluginInstance().loadData(); probably not needed - Bukkit.getScheduler().runTaskAsynchronously(ArchitectPlugin.getPluginInstance(), () -> { - callback.accept(RpManager.refreshSHA(cs, "Rohan")); - }); - } - } else { - callback.accept(false); - }*/ } + private static void updateSection(ConfigurationSection rpConfig, String path, String requiredMcVersion, String url) { + ConfigurationSection section = rpConfig.getConfigurationSection(path); + if(section.contains("url")) { + section.set("url", null); + section.set("sha", null); + } + rpConfig.set(path+"."+requiredMcVersion+".url", url); + } private static String getGitHubOwner(String rpName) { return ArchitectPlugin.getPluginInstance().getConfig().getString("gitHubRpReleases."+rpName+".owner"); } diff --git a/src/main/java/com/mcmiddleearth/util/ResourceUtil.java b/src/main/java/com/mcmiddleearth/util/ResourceUtil.java new file mode 100644 index 0000000..b7fade0 --- /dev/null +++ b/src/main/java/com/mcmiddleearth/util/ResourceUtil.java @@ -0,0 +1,66 @@ +package com.mcmiddleearth.util; + +import com.mcmiddleearth.architect.ArchitectPlugin; + +import java.io.*; +import java.util.logging.Logger; + +public class ResourceUtil { + + public static void saveResourceToFile(String resource, File file) { + InputStream inputStream = ArchitectPlugin.class.getResourceAsStream("/" + resource); + if (!file.exists()) { + if (inputStream == null) { + Logger.getGlobal().severe("resource " + resource + " not found in plugin jar"); + } else { + try { + if (file.createNewFile()) { + InputStreamReader in = new InputStreamReader(inputStream); + + try { + FileWriter fw = new FileWriter(file); + + try { + char[] buf = new char[1024]; + int read = 1; + + while(read > 0) { + read = in.read(buf); + if (read > 0) { + fw.write(buf, 0, read); + } + } + + fw.flush(); + } catch (Throwable var10) { + try { + fw.close(); + } catch (Throwable var9) { + var10.addSuppressed(var9); + } + + throw var10; + } + + fw.close(); + } catch (Throwable var11) { + try { + in.close(); + } catch (Throwable var8) { + var11.addSuppressed(var8); + } + + throw var11; + } + + in.close(); + } + } catch (IOException var12) { + Logger.getGlobal().severe("IOException: " + var12.getLocalizedMessage()); + } + } + } + + } + +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7ce14bd..d0d9f3f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,8 +3,9 @@ ServerResourcePacks: vanilla: 16px: light: - url: https://github.com/MCME/RP-Human/releases/download/v3.0.4/Human.zip - sha: 7f838c761529237eaf1d9cdc8cd4c439d9cb0770 + 1_18_1: + url: https://github.com/MCME/RP-Human/releases/download/v3.0.4/Human.zip + sha: 7f838c761529237eaf1d9cdc8cd4c439d9cb0770 rpSettingsDatabase: user: xxx password: xxx diff --git a/src/main/resources/protocolVersions.yml b/src/main/resources/protocolVersions.yml new file mode 100644 index 0000000..75f45e3 --- /dev/null +++ b/src/main/resources/protocolVersions.yml @@ -0,0 +1,34 @@ +'1_21_1': 767 +'1_21_2': 767 +'1_20_6': 766 +'1_20_5': 766 +'1_20_4': 765 +'1_20_3': 765 +'1_20_2': 764 +'1_20_1': 763 +'1_20': 763 +'1_19_4': 762 +'1_19_3': 761 +'1_19_2': 760 +'1_19_1': 760 +'1_18_2': 758 +'1_18_1': 757 +'1_18': 757 +'1_17_1': 756 +'1_17': 755 +'1_16_4': 754 +'1_16_3': 753 +'1_16_2': 751 +'1_16:1': 736 +'1_16': 735 +'1_15_2': 578 +'1_15_1': 575 +'1_15': 573 +'1_14_4': 498 +'1_14_3': 490 +'1_14_2': 485 +'1_14_1': 480 +'1_14': 477 +'1_13_2': 404 +'1_13_1': 401 +'1_13': 393 \ No newline at end of file