Lower the amount of github rate limit calls
This commit is contained in:
parent
02a3602a28
commit
348ef9e25d
@ -271,6 +271,12 @@ public class DisguiseConfig {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static boolean viewSelfDisguisesDefault;
|
private static boolean viewSelfDisguisesDefault;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private static String lastGithubUpdateETag;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private static String lastPluginUpdateVersion;
|
||||||
|
|
||||||
public static boolean isArmorstandsName() {
|
public static boolean isArmorstandsName() {
|
||||||
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
||||||
@ -308,9 +314,8 @@ public class DisguiseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void doUpdaterTask() {
|
private static void doUpdaterTask() {
|
||||||
boolean startTask = isAutoUpdate() || isNotifyUpdate() || "1592".equals(
|
boolean startTask = isAutoUpdate() || isNotifyUpdate() ||
|
||||||
(LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() :
|
"1592".equals((LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() : LibsPremium.getPaidInformation()).getUserID());
|
||||||
LibsPremium.getPaidInformation()).getUserID());
|
|
||||||
|
|
||||||
// Don't ever run the auto updater on a custom build..
|
// Don't ever run the auto updater on a custom build..
|
||||||
if (!LibsDisguises.getInstance().isNumberedBuild()) {
|
if (!LibsDisguises.getInstance().isNumberedBuild()) {
|
||||||
@ -402,9 +407,10 @@ public class DisguiseConfig {
|
|||||||
usingReleaseBuild = configuration.getBoolean("ReleaseBuild", isUsingReleaseBuild());
|
usingReleaseBuild = configuration.getBoolean("ReleaseBuild", isUsingReleaseBuild());
|
||||||
lastUpdateRequest = configuration.getLong("LastUpdateRequest", 0L);
|
lastUpdateRequest = configuration.getLong("LastUpdateRequest", 0L);
|
||||||
hittingRateLimit = configuration.getBoolean("HittingRateLimit", false);
|
hittingRateLimit = configuration.getBoolean("HittingRateLimit", false);
|
||||||
|
lastGithubUpdateETag = configuration.getString("LastGithubETag", null);
|
||||||
|
lastPluginUpdateVersion = configuration.getString("LastPluginVersion", null);
|
||||||
|
|
||||||
if (!configuration.contains("Bisect-Hosted") || !configuration.contains("Server-IP") ||
|
if (!configuration.contains("Bisect-Hosted") || !configuration.contains("Server-IP") || !configuration.contains("ReleaseBuild")) {
|
||||||
!configuration.contains("ReleaseBuild")) {
|
|
||||||
saveInternalConfig();
|
saveInternalConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,12 +418,11 @@ public class DisguiseConfig {
|
|||||||
public static void saveInternalConfig() {
|
public static void saveInternalConfig() {
|
||||||
File internalFile = new File(LibsDisguises.getInstance().getDataFolder(), "internal.yml");
|
File internalFile = new File(LibsDisguises.getInstance().getDataFolder(), "internal.yml");
|
||||||
|
|
||||||
String internalConfig =
|
String internalConfig = ReflectionManager.getResourceAsString(LibsDisguises.getInstance().getFile(), "internal.yml");
|
||||||
ReflectionManager.getResourceAsString(LibsDisguises.getInstance().getFile(), "internal.yml");
|
|
||||||
|
|
||||||
// Bisect hosted, server ip, release builds
|
// Bisect hosted, server ip, release builds
|
||||||
for (Object s : new Object[]{isBisectHosted(), getSavedServerIp(), isUsingReleaseBuild(),
|
for (Object s : new Object[]{isBisectHosted(), getSavedServerIp(), isUsingReleaseBuild(), getLastUpdateRequest(), isHittingRateLimit(),
|
||||||
getLastUpdateRequest(), isHittingRateLimit()}) {
|
getLastGithubUpdateETag(), getLastPluginUpdateVersion()}) {
|
||||||
internalConfig = internalConfig.replaceFirst("%data%", "" + s);
|
internalConfig = internalConfig.replaceFirst("%data%", "" + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,8 +505,7 @@ public class DisguiseConfig {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HashMap.SimpleEntry(entry.getKey(),
|
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), target, entry.getValue()));
|
||||||
DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), target, entry.getValue()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entry<DisguisePerm, Disguise> getCustomDisguise(CommandSender invoker, Entity target, String disguise)
|
public static Entry<DisguisePerm, Disguise> getCustomDisguise(CommandSender invoker, Entity target, String disguise)
|
||||||
@ -558,8 +562,7 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
public static void saveDefaultConfig() {
|
public static void saveDefaultConfig() {
|
||||||
DisguiseUtilities.getLogger().info("Config is out of date! Now updating it!");
|
DisguiseUtilities.getLogger().info("Config is out of date! Now updating it!");
|
||||||
String[] string =
|
String[] string = ReflectionManager.getResourceAsString(LibsDisguises.getInstance().getFile(), "config.yml").split("\n");
|
||||||
ReflectionManager.getResourceAsString(LibsDisguises.getInstance().getFile(), "config.yml").split("\n");
|
|
||||||
FileConfiguration savedConfig = LibsDisguises.getInstance().getConfig();
|
FileConfiguration savedConfig = LibsDisguises.getInstance().getConfig();
|
||||||
|
|
||||||
StringBuilder section = new StringBuilder();
|
StringBuilder section = new StringBuilder();
|
||||||
@ -594,8 +597,7 @@ public class DisguiseConfig {
|
|||||||
Object val = savedConfig.get(key);
|
Object val = savedConfig.get(key);
|
||||||
|
|
||||||
if (savedConfig.isString(key) && !rawVal.equals("true") && !rawVal.equals("false")) {
|
if (savedConfig.isString(key) && !rawVal.equals("true") && !rawVal.equals("false")) {
|
||||||
val = "'" + StringEscapeUtils.escapeJava(val.toString().replace(ChatColor.COLOR_CHAR + "", "&")) +
|
val = "'" + StringEscapeUtils.escapeJava(val.toString().replace(ChatColor.COLOR_CHAR + "", "&")) + "'";
|
||||||
"'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string[i] = rawKey + ": " + val;
|
string[i] = rawKey + ": " + val;
|
||||||
@ -641,8 +643,7 @@ public class DisguiseConfig {
|
|||||||
explain.createNewFile();
|
explain.createNewFile();
|
||||||
|
|
||||||
try (PrintWriter out = new PrintWriter(explain)) {
|
try (PrintWriter out = new PrintWriter(explain)) {
|
||||||
out.println("This folder is used to store .png files for uploading with the /savedisguise or " +
|
out.println("This folder is used to store .png files for uploading with the /savedisguise or " + "/grabskin " + "commands");
|
||||||
"/grabskin " + "commands");
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -663,10 +664,8 @@ public class DisguiseConfig {
|
|||||||
setDisablePvP(config.getBoolean("DisablePvP"));
|
setDisablePvP(config.getBoolean("DisablePvP"));
|
||||||
setDisablePvE(config.getBoolean("DisablePvE"));
|
setDisablePvE(config.getBoolean("DisablePvE"));
|
||||||
setPvPTimer(config.getDouble("PvPTimer"));
|
setPvPTimer(config.getDouble("PvPTimer"));
|
||||||
setDisguiseBlownWhenAttacked(
|
setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacked")));
|
||||||
config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacked")));
|
setDisguiseBlownWhenAttacking(config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking")));
|
||||||
setDisguiseBlownWhenAttacking(
|
|
||||||
config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking")));
|
|
||||||
setDisguiseCloneExpire(config.getInt("DisguiseCloneExpire"));
|
setDisguiseCloneExpire(config.getInt("DisguiseCloneExpire"));
|
||||||
setDisguiseEntityExpire(config.getInt("DisguiseEntityExpire"));
|
setDisguiseEntityExpire(config.getInt("DisguiseEntityExpire"));
|
||||||
setDynamicExpiry(config.getBoolean("DynamicExpiry"));
|
setDynamicExpiry(config.getBoolean("DynamicExpiry"));
|
||||||
@ -728,49 +727,42 @@ public class DisguiseConfig {
|
|||||||
try {
|
try {
|
||||||
setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase(Locale.ENGLISH)));
|
setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase(Locale.ENGLISH)));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning(
|
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames");
|
||||||
"Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase(Locale.ENGLISH)));
|
setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase(Locale.ENGLISH)));
|
||||||
|
|
||||||
if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) {
|
if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) {
|
||||||
DisguiseUtilities.getLogger().warning(
|
DisguiseUtilities.getLogger()
|
||||||
"BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " +
|
.warning("BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + "ACTION_BAR");
|
||||||
"ACTION_BAR");
|
|
||||||
|
|
||||||
setNotifyBar(NotifyBar.ACTION_BAR);
|
setNotifyBar(NotifyBar.ACTION_BAR);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("NotifyBar") + "' to a valid option for NotifyBar");
|
||||||
.warning("Cannot parse '" + config.getString("NotifyBar") + "' to a valid option for NotifyBar");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setBossBarColor(BarColor.valueOf(config.getString("BossBarColor").toUpperCase(Locale.ENGLISH)));
|
setBossBarColor(BarColor.valueOf(config.getString("BossBarColor").toUpperCase(Locale.ENGLISH)));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning(
|
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("BossBarColor") + "' to a valid option for BossBarColor");
|
||||||
"Cannot parse '" + config.getString("BossBarColor") + "' to a valid option for BossBarColor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setBossBarStyle(BarStyle.valueOf(config.getString("BossBarStyle").toUpperCase(Locale.ENGLISH)));
|
setBossBarStyle(BarStyle.valueOf(config.getString("BossBarStyle").toUpperCase(Locale.ENGLISH)));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning(
|
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("BossBarStyle") + "' to a valid option for BossBarStyle");
|
||||||
"Cannot parse '" + config.getString("BossBarStyle") + "' to a valid option for BossBarStyle");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase(Locale.ENGLISH)));
|
setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase(Locale.ENGLISH)));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning(
|
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch");
|
||||||
"Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name())
|
String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name()).toUpperCase(Locale.ENGLISH);
|
||||||
.toUpperCase(Locale.ENGLISH);
|
|
||||||
|
|
||||||
if (!option.endsWith("_SCOREBOARD")) {
|
if (!option.endsWith("_SCOREBOARD")) {
|
||||||
option += "_SCOREBOARD";
|
option += "_SCOREBOARD";
|
||||||
@ -778,15 +770,15 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
pushingOption = DisguisePushing.valueOf(option);
|
pushingOption = DisguisePushing.valueOf(option);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("SelfDisguisesScoreboard") +
|
DisguiseUtilities.getLogger()
|
||||||
"' to a valid option for SelfDisguisesScoreboard");
|
.warning("Cannot parse '" + config.getString("SelfDisguisesScoreboard") + "' to a valid option for SelfDisguisesScoreboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionDefault commandVisibility = PermissionDefault.getByName(config.getString("Permissions.SeeCommands"));
|
PermissionDefault commandVisibility = PermissionDefault.getByName(config.getString("Permissions.SeeCommands"));
|
||||||
|
|
||||||
if (commandVisibility == null) {
|
if (commandVisibility == null) {
|
||||||
DisguiseUtilities.getLogger().warning("Invalid option '" + config.getString("Permissions.SeeCommands") +
|
DisguiseUtilities.getLogger()
|
||||||
"' for Permissions.SeeCommands when loading config!");
|
.warning("Invalid option '" + config.getString("Permissions.SeeCommands") + "' for Permissions.SeeCommands when loading config!");
|
||||||
} else {
|
} else {
|
||||||
setCommandVisibility(commandVisibility);
|
setCommandVisibility(commandVisibility);
|
||||||
}
|
}
|
||||||
@ -815,9 +807,7 @@ public class DisguiseConfig {
|
|||||||
if (config.contains("VerboseConfig")) {
|
if (config.contains("VerboseConfig")) {
|
||||||
verbose = config.getBoolean("VerboseConfig");
|
verbose = config.getBoolean("VerboseConfig");
|
||||||
} else {
|
} else {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().info("As 'VerboseConfig' hasn't been set, it is assumed true. Set it in your config to remove " + "these messages!");
|
||||||
.info("As 'VerboseConfig' hasn't been set, it is assumed true. Set it in your config to remove " +
|
|
||||||
"these messages!");
|
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,9 +817,8 @@ public class DisguiseConfig {
|
|||||||
ArrayList<String> returns = doOutput(config, changed, verbose);
|
ArrayList<String> returns = doOutput(config, changed, verbose);
|
||||||
|
|
||||||
if (!returns.isEmpty()) {
|
if (!returns.isEmpty()) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().info("This is not an error! Now outputting " + (verbose ? "missing " : "") +
|
||||||
.info("This is not an error! Now outputting " + (verbose ? "missing " : "") +
|
(changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values");
|
||||||
(changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values");
|
|
||||||
|
|
||||||
for (String v : returns) {
|
for (String v : returns) {
|
||||||
DisguiseUtilities.getLogger().info(v);
|
DisguiseUtilities.getLogger().info(v);
|
||||||
@ -852,10 +841,8 @@ public class DisguiseConfig {
|
|||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
DisguiseUtilities.getLogger().info("Config has been auto-updated!");
|
DisguiseUtilities.getLogger().info("Config has been auto-updated!");
|
||||||
} else if (!verbose) {
|
} else if (!verbose) {
|
||||||
DisguiseUtilities.getLogger().warning("Your config is missing " + missingConfigs +
|
DisguiseUtilities.getLogger().warning("Your config is missing " + missingConfigs + " options! Please consider regenerating your config!");
|
||||||
" options! Please consider regenerating your config!");
|
DisguiseUtilities.getLogger().info("You can also add the missing entries yourself! Try '/libsdisguises config'");
|
||||||
DisguiseUtilities.getLogger()
|
|
||||||
.info("You can also add the missing entries yourself! Try '/libsdisguises config'");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DisguiseUtilities.getLogger().info("Config is up to date!");
|
DisguiseUtilities.getLogger().info("Config is up to date!");
|
||||||
@ -904,8 +891,7 @@ public class DisguiseConfig {
|
|||||||
boolean living = section.getString("Type", "LIVING").equalsIgnoreCase("LIVING");
|
boolean living = section.getString("Type", "LIVING").equalsIgnoreCase("LIVING");
|
||||||
String type = section.getString("Type");
|
String type = section.getString("Type");
|
||||||
String mod = section.getString("Mod");
|
String mod = section.getString("Mod");
|
||||||
String[] version =
|
String[] version = mod == null || !section.contains("Version") ? null : section.getString("Version").split(",");
|
||||||
mod == null || !section.contains("Version") ? null : section.getString("Version").split(",");
|
|
||||||
String requireMessage = mod == null ? null : section.getString("Required");
|
String requireMessage = mod == null ? null : section.getString("Required");
|
||||||
|
|
||||||
if (section.contains("Channels")) {
|
if (section.contains("Channels")) {
|
||||||
@ -926,17 +912,14 @@ public class DisguiseConfig {
|
|||||||
ModdedEntity entity = new ModdedEntity(null, name, living, mod, version, requireMessage, 0);
|
ModdedEntity entity = new ModdedEntity(null, name, living, mod, version, requireMessage, 0);
|
||||||
|
|
||||||
if (ModdedManager.getModdedEntity(name) != null) {
|
if (ModdedManager.getModdedEntity(name) != null) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().info("Modded entity " + name + " has already been " + (register ? "registered" : "added"));
|
||||||
.info("Modded entity " + name + " has already been " + (register ? "registered" : "added"));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModdedManager.registerModdedEntity(
|
ModdedManager
|
||||||
new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)),
|
.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity, register);
|
||||||
entity, register);
|
|
||||||
|
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().info("Modded entity " + name + " has been " + (register ? "registered" : "added"));
|
||||||
.info("Modded entity " + name + " has been " + (register ? "registered" : "added"));
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().severe("Error while trying to register modded entity " + name);
|
DisguiseUtilities.getLogger().severe("Error while trying to register modded entity " + name);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -946,8 +929,7 @@ public class DisguiseConfig {
|
|||||||
new ModdedManager(channels);
|
new ModdedManager(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> doOutput(ConfigurationSection config, boolean informChangedUnknown,
|
public static ArrayList<String> doOutput(ConfigurationSection config, boolean informChangedUnknown, boolean informMissing) {
|
||||||
boolean informMissing) {
|
|
||||||
HashMap<String, Object> configs = new HashMap<>();
|
HashMap<String, Object> configs = new HashMap<>();
|
||||||
ConfigurationSection defaultSection = config.getDefaultSection();
|
ConfigurationSection defaultSection = config.getDefaultSection();
|
||||||
ArrayList<String> returns = new ArrayList<>();
|
ArrayList<String> returns = new ArrayList<>();
|
||||||
@ -1013,8 +995,8 @@ public class DisguiseConfig {
|
|||||||
String toParse = section.getString(key);
|
String toParse = section.getString(key);
|
||||||
|
|
||||||
if (!NmsVersion.v1_13.isSupported() && key.equals("libraryaddict")) {
|
if (!NmsVersion.v1_13.isSupported() && key.equals("libraryaddict")) {
|
||||||
toParse = toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET",
|
toParse =
|
||||||
"GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET");
|
toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET", "GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1040,8 +1022,7 @@ public class DisguiseConfig {
|
|||||||
DisguiseUtilities.getLogger().warning("Failed to load " + failedCustomDisguises + " custom disguises");
|
DisguiseUtilities.getLogger().warning("Failed to load " + failedCustomDisguises + " custom disguises");
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseUtilities.getLogger().info("Loaded " + customDisguises.size() + " custom disguise" +
|
DisguiseUtilities.getLogger().info("Loaded " + customDisguises.size() + " custom disguise" + (customDisguises.size() == 1 ? "" : "s"));
|
||||||
(customDisguises.size() == 1 ? "" : "s"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addCustomDisguise(String disguiseName, String toParse) throws DisguiseParseException {
|
public static void addCustomDisguise(String disguiseName, String toParse) throws DisguiseParseException {
|
||||||
@ -1065,8 +1046,7 @@ public class DisguiseConfig {
|
|||||||
|
|
||||||
DisguiseUtilities.getLogger().info("Loaded custom disguise " + disguiseName);
|
DisguiseUtilities.getLogger().info("Loaded custom disguise " + disguiseName);
|
||||||
} catch (DisguiseParseException e) {
|
} catch (DisguiseParseException e) {
|
||||||
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName,
|
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, (e.getMessage() == null ? "" : ": " + e.getMessage()));
|
||||||
(e.getMessage() == null ? "" : ": " + e.getMessage()));
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, "");
|
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, "");
|
||||||
|
@ -17,6 +17,7 @@ import java.net.URL;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,6 +59,10 @@ public class LDGithub {
|
|||||||
private UpdateChecker checker;
|
private UpdateChecker checker;
|
||||||
|
|
||||||
private String[] getBadUsers() {
|
private String[] getBadUsers() {
|
||||||
|
if (!LibsPremium.isPremium() || (LibsPremium.isBisectHosted() && (LibsPremium.getPaidInformation() == null || LibsPremium.getUserID().contains("%")))) {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
// List of bad users that need to redownload Libs Disguises
|
// List of bad users that need to redownload Libs Disguises
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -73,8 +78,7 @@ public class LDGithub {
|
|||||||
// Get the input stream, what we receive
|
// Get the input stream, what we receive
|
||||||
try (InputStream input = con.getInputStream()) {
|
try (InputStream input = con.getInputStream()) {
|
||||||
// Read it to string
|
// Read it to string
|
||||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines()
|
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||||
.collect(Collectors.joining("\n"));
|
|
||||||
|
|
||||||
map = new Gson().fromJson(json, HashMap.class);
|
map = new Gson().fromJson(json, HashMap.class);
|
||||||
}
|
}
|
||||||
@ -96,12 +100,10 @@ public class LDGithub {
|
|||||||
|
|
||||||
for (String s : users) {
|
for (String s : users) {
|
||||||
if (LibsPremium.getPaidInformation() != null &&
|
if (LibsPremium.getPaidInformation() != null &&
|
||||||
(s.equals(LibsPremium.getPaidInformation().getDownloadID()) ||
|
(s.equals(LibsPremium.getPaidInformation().getDownloadID()) || s.equals(LibsPremium.getPaidInformation().getUserID()))) {
|
||||||
s.equals(LibsPremium.getPaidInformation().getUserID()))) {
|
|
||||||
LibsDisguises.getInstance().unregisterCommands(true);
|
LibsDisguises.getInstance().unregisterCommands(true);
|
||||||
} else {
|
} else {
|
||||||
if (LibsPremium.getUserID() == null ||
|
if (LibsPremium.getUserID() == null || (!s.equals(LibsPremium.getUserID()) && !s.equals(LibsPremium.getDownloadID()))) {
|
||||||
(!s.equals(LibsPremium.getUserID()) && !s.equals(LibsPremium.getDownloadID()))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +111,8 @@ public class LDGithub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ourVersion = LibsDisguises.getInstance().getDescription().getVersion();
|
||||||
|
|
||||||
if (!getChecker().isGoSilent()) {
|
if (!getChecker().isGoSilent()) {
|
||||||
DisguiseUtilities.getLogger().info("Now looking for update on Github..");
|
DisguiseUtilities.getLogger().info("Now looking for update on Github..");
|
||||||
}
|
}
|
||||||
@ -120,19 +124,27 @@ public class LDGithub {
|
|||||||
con.setRequestProperty("User-Agent", "libraryaddict/LibsDisguises");
|
con.setRequestProperty("User-Agent", "libraryaddict/LibsDisguises");
|
||||||
con.setRequestProperty("Accept", "application/vnd.github.v3+json");
|
con.setRequestProperty("Accept", "application/vnd.github.v3+json");
|
||||||
|
|
||||||
|
// We believe we're on the latest version and know what the last etag was
|
||||||
|
if (Objects.equals(ourVersion, DisguiseConfig.getLastPluginUpdateVersion()) && DisguiseConfig.getLastGithubUpdateETag() != null) {
|
||||||
|
con.setRequestProperty("If-None-Match", DisguiseConfig.getLastGithubUpdateETag());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (con.getResponseCode() == 304) {
|
||||||
|
// Its the same as the last one we checked
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
GithubData gitData;
|
GithubData gitData;
|
||||||
|
|
||||||
// Get the input stream, what we receive
|
// Get the input stream, what we receive
|
||||||
try (InputStream input = con.getInputStream()) {
|
try (InputStream input = con.getInputStream()) {
|
||||||
// Read it to string
|
// Read it to string
|
||||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines()
|
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||||
.collect(Collectors.joining("\n"));
|
|
||||||
|
|
||||||
gitData = new Gson().fromJson(json, GithubData.class);
|
gitData = new Gson().fromJson(json, GithubData.class);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
try (InputStream error = con.getErrorStream()) {
|
try (InputStream error = con.getErrorStream()) {
|
||||||
String line = new BufferedReader(new InputStreamReader(error, StandardCharsets.UTF_8)).lines()
|
String line = new BufferedReader(new InputStreamReader(error, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||||
.collect(Collectors.joining("\n"));
|
|
||||||
|
|
||||||
DisguiseUtilities.getLogger().severe("Error with Github! " + line);
|
DisguiseUtilities.getLogger().severe("Error with Github! " + line);
|
||||||
|
|
||||||
@ -164,8 +176,15 @@ public class LDGithub {
|
|||||||
throw new IllegalStateException("Download url is missing");
|
throw new IllegalStateException("Download url is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GithubUpdate(gitData.getTag_name().replace("v", ""), gitData.getBody().split("(\\r|\\n)+"),
|
GithubUpdate update = new GithubUpdate(gitData.getTag_name().replace("v", ""), gitData.getBody().split("(\\r|\\n)+"), download);
|
||||||
download);
|
|
||||||
|
if (Objects.equals(update.getVersion(), ourVersion)) {
|
||||||
|
DisguiseConfig.setLastGithubUpdateETag(con.getHeaderField("ETag"));
|
||||||
|
DisguiseConfig.setLastPluginUpdateVersion(ourVersion);
|
||||||
|
DisguiseConfig.saveInternalConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return update;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DisguiseUtilities.getLogger().warning("Failed to check for a release on Github");
|
DisguiseUtilities.getLogger().warning("Failed to check for a release on Github");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -9,3 +9,5 @@ ReleaseBuild: %data%
|
|||||||
# Make sure the plugin aint spamming update requests
|
# Make sure the plugin aint spamming update requests
|
||||||
LastUpdateCheck: %data%
|
LastUpdateCheck: %data%
|
||||||
HittingRateLimit: %data%
|
HittingRateLimit: %data%
|
||||||
|
LastGithubETag: %data%
|
||||||
|
LastPluginVersion: %data%
|
Loading…
Reference in New Issue
Block a user