github is broken

This commit is contained in:
NEZNAMY committed 2020-01-17 22:16:16 +01:00
1 parent 82e340146f
commit 207e976103
16 files changed
+74 -64

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
name: TAB
main: me.neznamy.tab.platforms.bungee.Main
version: 2.6.3-pre5
version: 2.6.3
author: NEZNAMY
@@ -480,7 +480,7 @@ public class Main extends JavaPlugin implements Listener, MainClass{
int cooldown = entry.getValue();
Placeholders.serverPlaceholders.add(new ServerPlaceholder(placeholder, cooldown, "PlaceholderAPI[" + entry.getKey() + " - " + cooldown + "]") {
public String get() {
return PluginHooks.PlaceholderAPI_setPlaceholders(null, placeholder, new String[] {placeholder}, false);
return PluginHooks.PlaceholderAPI_setPlaceholders(null, placeholder);
}
});
}
@@ -492,7 +492,7 @@ public class Main extends JavaPlugin implements Listener, MainClass{
int cooldown = entry.getValue();
Placeholders.playerPlaceholders.add(new PlayerPlaceholder(placeholder, cooldown, "PlaceholderAPI[" + entry.getKey() + " - " + cooldown + "]") {
public String get(ITabPlayer p) {
return PluginHooks.PlaceholderAPI_setPlaceholders(p, placeholder, new String[] {placeholder}, false);
return PluginHooks.PlaceholderAPI_setPlaceholders(p, placeholder);
}
});
}
@@ -543,7 +543,7 @@ public class Main extends JavaPlugin implements Listener, MainClass{
return packet.toNMS(protocolVersion);
}
public void loadConfig() throws Exception {
Configs.config = new ConfigurationFile("bukkitconfig.yml", "config.yml", Configs.configComments);
Configs.config = new ConfigurationFile("bukkitconfig.yml", "config.yml", Configs.configComments, true);
boolean changeNameTag = Configs.config.getBoolean("change-nametag-prefix-suffix", true);
NameTag16.refresh = NameTagX.refresh = (Configs.config.getInt("nametag-refresh-interval-ticks", 20)*50);
Playerlist.refresh = (Configs.config.getInt("tablist-refresh-interval-ticks", 20)*50);
@@ -583,7 +583,7 @@ public class Main extends JavaPlugin implements Listener, MainClass{
Configs.noAfk = Configs.config.getString("placeholders.afk-no", "");
Configs.yesAfk = Configs.config.getString("placeholders.afk-yes", " &4*&4&lAFK&4*&r");
Configs.removeStrings = Configs.config.getStringList("placeholders.remove-strings", Arrays.asList("[] ", "< > "));
Configs.advancedconfig = new ConfigurationFile("advancedconfig.yml", Configs.advancedconfigComments);
Configs.advancedconfig = new ConfigurationFile("advancedconfig.yml", Configs.advancedconfigComments, true);
PerWorldPlayerlist.enabled = Configs.advancedconfig.getBoolean("per-world-playerlist", false);
PerWorldPlayerlist.allowBypass = Configs.advancedconfig.getBoolean("allow-pwp-bypass-permission", false);
PerWorldPlayerlist.ignoredWorlds = Configs.advancedconfig.getList("ignore-pwp-in-worlds", Arrays.asList("ignoredworld", "spawn"));
@@ -272,7 +272,7 @@ public class Main extends Plugin implements Listener, MainClass{
return packet.toBungee(protocolVersion);
}
public void loadConfig() throws Exception {
Configs.config = new ConfigurationFile("bungeeconfig.yml", "config.yml", Configs.configComments);
Configs.config = new ConfigurationFile("bungeeconfig.yml", "config.yml", Configs.configComments, true);
TabObjective.rawValue = Configs.config.getString("tablist-objective-value", "%ping%");
TabObjective.type = (TabObjective.rawValue.length() == 0) ? TabObjectiveType.NONE : TabObjectiveType.CUSTOM;
BelowName.enable = Configs.config.getBoolean("belowname.enabled", true);
@@ -328,7 +328,7 @@ public class Main implements MainClass{
return packet.toVelocity(protocolVersion);
}
public void loadConfig() throws Exception {
Configs.config = new ConfigurationFile("bungeeconfig.yml", "config.yml", Configs.configComments);
Configs.config = new ConfigurationFile("bungeeconfig.yml", "config.yml", Configs.configComments, true);
TabObjective.rawValue = Configs.config.getString("tablist-objective-value", "%ping%");
TabObjective.type = (TabObjective.rawValue.length() == 0) ? TabObjectiveType.NONE : TabObjectiveType.CUSTOM;
BelowName.enable = Configs.config.getBoolean("belowname.enabled", true);
+2 -2
View File
@@ -19,12 +19,12 @@ public class Premium {
public static Map<String, Double> staticLines = new HashMap<String, Double>();
public static boolean is() {
return false;
return true;
}
@SuppressWarnings("unchecked")
public static void loadPremiumConfig() throws Exception {
premiumconfig = new ConfigurationFile("premiumconfig.yml", new HashMap<String, List<String>>());
premiumconfig = new ConfigurationFile("premiumconfig.yml", new HashMap<String, List<String>>(), true);
String type = premiumconfig.getString("sorting-type", "GROUPS");
try {
sortingType = SortingType.valueOf(type.toUpperCase());
+6 -4
View File
@@ -11,6 +11,7 @@ import java.util.Map;
import me.neznamy.tab.premium.Premium;
import me.neznamy.tab.shared.BossBar.BossBarLine;
import me.neznamy.tab.shared.placeholders.Placeholders;
public class Configs {
@@ -127,6 +128,7 @@ public class Configs {
errorFile.delete();
}
}
Placeholders.usedPAPIPlaceholders = new ArrayList<String>();
loadConfig();
SECRET_relational_placeholders_refresh = getSecretOption("relational-placeholders-refresh", 30);
SECRET_NTX_space = getSecretOption("ntx-space", 0.22F);
@@ -189,7 +191,7 @@ public class Configs {
disabledBelowname = config.getStringList("disable-features-in-"+Shared.separatorType+"s.belowname", Arrays.asList("disabled" + Shared.separatorType));
}
public static void loadAnimations() throws Exception {
animation = new ConfigurationFile("animations.yml", animationComments);
animation = new ConfigurationFile("animations.yml", animationComments, true);
animations = new ArrayList<Animation>();
if (animation.getConfigurationSection("animations") != null) {
for (String s : animation.getConfigurationSection("animations").keySet())
@@ -198,7 +200,7 @@ public class Configs {
}
@SuppressWarnings("unchecked")
public static void loadBossbar() throws Exception {
bossbar = new ConfigurationFile("bossbar.yml", bossbarComments);
bossbar = new ConfigurationFile("bossbar.yml", bossbarComments, true);
if (bossbar.get("enabled") != null) {
Shared.startupWarn("You are using old bossbar config, please make a backup of the file and delete it to get new file.");
return;
@@ -237,13 +239,13 @@ public class Configs {
if (BossBar.remember_toggle_choice) {
File file = new File("plugins" + System.getProperty("file.separator") + "TAB" + System.getProperty("file.separator") + "playerdata.yml");
if (!file.exists()) file.createNewFile();
playerdata = new ConfigurationFile("playerdata.yml", new HashMap<String, List<String>>());
playerdata = new ConfigurationFile("playerdata.yml", new HashMap<String, List<String>>(), false);
BossBar.bossbar_off_players = playerdata.getStringList("bossbar-off");
}
if (BossBar.bossbar_off_players == null) BossBar.bossbar_off_players = new ArrayList<String>();
}
public static void loadTranslation() throws Exception {
translation = new ConfigurationFile("translation.yml", new HashMap<String, List<String>>());
translation = new ConfigurationFile("translation.yml", new HashMap<String, List<String>>(), false);
no_perm = translation.getString("no_permission", "&cI'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
unlimited_nametag_mode_not_enabled = translation.getString("unlimited_nametag_mode_not_enabled", "&c[TAB] Warning! To make these work, you need to enable unlimited-nametag-prefix-suffix-mode in config !");
data_removed = translation.getString("data_removed", "&3[TAB] All data has been successfully removed from %category% &e%value%");
@@ -21,6 +21,11 @@ import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.parser.ParserException;
import org.yaml.snakeyaml.scanner.ScannerException;
import me.neznamy.tab.shared.placeholders.Constant;
import me.neznamy.tab.shared.placeholders.Placeholder;
import me.neznamy.tab.shared.placeholders.Placeholders;
import me.neznamy.tab.shared.placeholders.PlayerPlaceholder;
@SuppressWarnings("unchecked")
public class ConfigurationFile{
@@ -31,7 +36,7 @@ public class ConfigurationFile{
private HashMap<String, List<String>> comments;
private Map<String, Object> values;
public ConfigurationFile(String source, String destination, HashMap<String, List<String>> comments) throws Exception{
public ConfigurationFile(String source, String destination, HashMap<String, List<String>> comments, boolean usesPAPI) throws Exception{
FileInputStream input = null;
try {
this.comments = comments;
@@ -46,6 +51,10 @@ public class ConfigurationFile{
if (values == null) values = new HashMap<String, Object>();
input.close();
if (!hasComments()) fixComments();
if (usesPAPI) {
registerPAPIPlaceholders(values.toString());
registerPAPIPlaceholders("%" + values.toString());
}
} catch (Exception e) {
input.close();
Shared.startupWarn("File " + destination + " has broken formatting.");
@@ -60,8 +69,28 @@ public class ConfigurationFile{
throw e;
}
}
public ConfigurationFile(String sourceAndDestination, HashMap<String, List<String>> comments) throws Exception{
this(sourceAndDestination, sourceAndDestination, comments);
public ConfigurationFile(String sourceAndDestination, HashMap<String, List<String>> comments, boolean usesPAPI) throws Exception{
this(sourceAndDestination, sourceAndDestination, comments, usesPAPI);
}
private static void registerPAPIPlaceholders(String string) {
main:
for (String placeholder : Property.detectPlaceholderAPIPlaceholders(string)) {
if (!placeholder.contains("_")) continue;
if (!Placeholders.usedPAPIPlaceholders.contains(placeholder)) {
for (Placeholder p : Placeholders.getAll()) {
if (placeholder.equals(p.getIdentifier())) continue main;
}
for (Constant c : Placeholders.constants) {
if (placeholder.equals(c.getIdentifier())) continue main;
}
Placeholders.usedPAPIPlaceholders.add(placeholder);
Placeholders.playerPlaceholders.add(new PlayerPlaceholder(placeholder, 50){
public String get(ITabPlayer p) {
return PluginHooks.PlaceholderAPI_setPlaceholders(p, placeholder);
}
});
}
}
}
private String suggestFix(Exception e) {
try {
+8 -13
View File
@@ -1,7 +1,6 @@
package me.neznamy.tab.shared;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.Collectors;
@@ -170,31 +169,27 @@ public class PluginHooks {
return Shared.error(new String[] {"null"}, "Failed to get permission groups of " + p.getName() + " using PermissionsEx", t);
}
}
public static String PlaceholderAPI_setPlaceholders(ITabPlayer p, String s, String[] placeholders, boolean logCpu) {
if (!placeholderAPI) return s;
public static String PlaceholderAPI_setPlaceholders(ITabPlayer p, String placeholder) {
if (!placeholderAPI) return placeholder;
Player player = (p == null ? null : ((TabPlayer)p).player);
try {
long startTime = System.nanoTime();
String value = PlaceholderAPI.setPlaceholders(player, s);
if (logCpu) Shared.placeholderCpu("PlaceholderAPI" + Arrays.toString(placeholders), System.nanoTime()-startTime);
return value;
return PlaceholderAPI.setPlaceholders(player, placeholder);
} catch (Throwable t) {
Plugin papi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
if (papi != null) {
if (s.contains("%pinataparty")) {
if (placeholder.contains("%pinataparty")) {
//i'm done with arguing with that person about whose fault it is, just pretending like it works
return s.replace("%pinataparty_votes_total%", "0");
return "0";
} else {
Shared.error(null, "PlaceholderAPI replace task failed. PlaceholderAPI version: " + papi.getDescription().getVersion() + ". Placeholders to replace: " + Arrays.toString(placeholders));
Shared.error(null, "Input arguments: [Player = " + player + ", String = " + s + "]");
Shared.error(null, "Please send this error to the FIRST author whose name or plugin name you see here:", t);
String playername = (player == null ? "null" : player.getName());
Shared.error(null, "PlaceholderAPI v" + papi.getDescription().getVersion() + " generated an error when setting placeholder " + placeholder + " for player " + playername, t);
}
} else {
//thats why it failed
placeholderAPI = false;
}
}
return s;
return placeholder;
}
public static String PlaceholderAPI_setRelationalPlaceholders(ITabPlayer one, ITabPlayer two, String s) {
try {
+7 -25
View File
@@ -14,8 +14,7 @@ public class Property {
private String temporaryValue;
public String lastReplacedValue;
private List<Placeholder> tabPlaceholders = new ArrayList<Placeholder>();
private String[] placeholderapiPlaceholders;
private List<Placeholder> placeholders = new ArrayList<Placeholder>();
private boolean hasRelationalPlaceholders;
private long lastUpdate;
private boolean Static;
@@ -31,21 +30,9 @@ public class Property {
value = value.replace(c.getIdentifier(), c.get());
}
}
tabPlaceholders = detectPlaceholders(value, owner != null);
placeholders = detectPlaceholders(value, owner != null);
hasRelationalPlaceholders = value.contains("%rel_");
List<String> allPlaceholders = detectPlaceholderAPIPlaceholders(value);
for (Placeholder p : tabPlaceholders) {
for (String child : p.getChilds()) {
for (String p2 : detectPlaceholderAPIPlaceholders(child)) {
if (!allPlaceholders.contains(p2)) allPlaceholders.add(p2);
}
}
}
for (Placeholder tab : tabPlaceholders) {
allPlaceholders.remove(tab.getIdentifier());
}
placeholderapiPlaceholders = allPlaceholders.toArray(new String[0]);
if (tabPlaceholders.isEmpty() && placeholderapiPlaceholders.length == 0 && !hasRelationalPlaceholders) {
if (placeholders.isEmpty() && !hasRelationalPlaceholders) {
//no placeholders, this is a static string
//performing final changes before saving it
for (String removed : Configs.removeStrings) {
@@ -91,14 +78,10 @@ public class Property {
if (Static) return false;
String string = getCurrentRawValue();
//own placeholders
for (Placeholder pl : tabPlaceholders) {
//placeholders
for (Placeholder pl : placeholders) {
string = pl.set(string, owner);
}
//placeholderapi
if (placeholderapiPlaceholders.length > 0 && PluginHooks.placeholderAPI) {
string = PluginHooks.PlaceholderAPI_setPlaceholders(owner, string, placeholderapiPlaceholders, true);
}
//removing strings
for (String removed : Configs.removeStrings) {
@@ -127,8 +110,7 @@ public class Property {
List<Placeholder> placeholdersTotal = new ArrayList<Placeholder>();
for (Placeholder placeholder : playerPlaceholders ? Placeholders.getAll() : Placeholders.serverPlaceholders) {
if (rawValue.contains(placeholder.getIdentifier())) {
// if (!placeholdersTotal.contains(placeholder))
placeholdersTotal.add(placeholder);
placeholdersTotal.add(placeholder);
for (String child : placeholder.getChilds()) {
for (Placeholder p : detectPlaceholders(child, playerPlaceholders)) {
if (!placeholdersTotal.contains(p)) placeholdersTotal.add(p);
@@ -138,7 +120,7 @@ public class Property {
}
return placeholdersTotal;
}
private static List<String> detectPlaceholderAPIPlaceholders(String s){
public static List<String> detectPlaceholderAPIPlaceholders(String s){
List<String> list = new ArrayList<String>();
if (s == null) return list;
while (s.contains("%")) {
+5 -4
View File
@@ -37,8 +37,8 @@ public class Shared {
private static final String newline = System.getProperty("line.separator");
public static final String DECODER_NAME = "TABReader";
public static final ExecutorService exe = Executors.newCachedThreadPool();
public static final String pluginVersion = "2.6.3-pre5";
public static final int currentVersionId = 262;
public static final String pluginVersion = "2.6.3";
public static final int currentVersionId = 263;
public static final DecimalFormat decimal2 = new DecimalFormat("#.##");
public static final DecimalFormat decimal3 = new DecimalFormat("#.###");
public static final char COLOR = '\u00a7';
@@ -106,7 +106,7 @@ public class Shared {
buf.close();
}
} catch (Throwable ex) {
print('c', "An error occurred when generating error message");
print('c', "An error occurred when printing error message into file");
ex.printStackTrace();
print('c', "Original error: " + message);
if (t != null) t.printStackTrace();
@@ -287,7 +287,7 @@ public class Shared {
Shared.print('b', "Get the update at https://www.spigotmc.org/resources/57806/");
}
} catch (Exception e) {
Shared.print('c', "Failed to check for updates (" + e.getClass().getSimpleName() + ": " + e.getMessage() + ")");
// Shared.print('c', "Failed to check for updates (" + e.getClass().getSimpleName() + ": " + e.getMessage() + ")");
}
}
});
@@ -295,6 +295,7 @@ public class Shared {
public static void registerAnimationPlaceholders() {
for (Animation a : Configs.animations) {
Placeholders.usedPAPIPlaceholders.remove("%animation:" + a.getName() + "%");
Placeholders.serverPlaceholders.add(new ServerPlaceholder("%animation:" + a.getName() + "%", 0) {
public String get() {
return a.getMessage();
+1 -1
View File
@@ -186,7 +186,7 @@ public class TabCommand{
sendMessage(sender, "&8&l║ &7&lPLACEHOLDERS TOTAL: &a&l" + Shared.decimal3.format((float)placeholdersTotal/dataSize/10000000) + "%");
sendMessage(sender, "&8&l║ &7&lPLUGIN TOTAL: &e&l" + Shared.decimal3.format((float)featuresTotal/dataSize/10000000) + "%");
sendMessage(sender, "&8&l&m╚ &r&8&l[ &bTAB CPU Stats &8&l]&r&8&l&m ");
sendMessage(sender, " ");
sendMessage(sender, " ");
} else sendMessage(sender, Configs.no_perm);
} else help(sender);
} else help(sender);
@@ -30,4 +30,4 @@ public abstract class Placeholder {
}
}
public abstract String getValue(ITabPlayer p);
}
}
@@ -15,6 +15,7 @@ public class Placeholders {
public static List<PlayerPlaceholder> playerPlaceholders;
public static List<ServerPlaceholder> serverPlaceholders;
public static List<Constant> constants;
public static List<String> usedPAPIPlaceholders;
public static ConcurrentHashMap<String, Integer> online = new ConcurrentHashMap<String, Integer>();
static {
@@ -77,7 +78,7 @@ public class Placeholders {
for (Constant c : Placeholders.constants) {
if (string.contains(c.getIdentifier())) string = string.replace(c.getIdentifier(), c.get());
}
string = PluginHooks.PlaceholderAPI_setPlaceholders(p, string, new String[0], true);
string = PluginHooks.PlaceholderAPI_setPlaceholders(p, string);
for (String removed : Configs.removeStrings) {
string = string.replace(removed, "");
}
@@ -20,7 +20,7 @@ public abstract class PlayerPlaceholder extends Placeholder{
public abstract String get(ITabPlayer p);
@Override
public String getValue(ITabPlayer p) {
public synchronized String getValue(ITabPlayer p) {
long startTime = System.nanoTime();
if (!lastRefresh.containsKey(p.getName()) || System.currentTimeMillis() - lastRefresh.get(p.getName()) >= cooldown) {
lastRefresh.put(p.getName(), System.currentTimeMillis());
@@ -17,7 +17,7 @@ public abstract class ServerPlaceholder extends Placeholder{
public abstract String get();
@Override
public String getValue(ITabPlayer p) {
public synchronized String getValue(ITabPlayer p) {
long startTime = System.nanoTime();
if (System.currentTimeMillis() - lastRefresh >= cooldown) {
lastRefresh = System.currentTimeMillis();
+1 -1
View File
@@ -1,5 +1,5 @@
name: TAB
version: 2.6.3-pre5
version: 2.6.3
author: NEZNAMY
main: me.neznamy.tab.platforms.bukkit.Main
api-version: 1.13