diff --git a/build.gradle b/build.gradle index e42d205..5070e2b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,28 +39,32 @@ repositories { url = 'https://jitpack.io' } maven { - name = 'Protocolize-repo' + name = 'Protocolize-repo' url = 'https://mvn.exceptionflug.de/repository/exceptionflug-public/' } + maven { + name = "sonatype-oss-snapshots1" + url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + } } dependencies { compileOnly 'net.md-5:bungeecord-api:1.20-R0.1-SNAPSHOT' - compileOnly 'org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT' - compileOnly files('../../dependencies/TAB-4.0.6.jar') + compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT' + compileOnly files('../../dependencies/TAB-4.1.3-SNAPSHOT.jar') compileOnly 'org.projectlombok:lombok:1.18.20' annotationProcessor 'org.projectlombok:lombok:1.18.20' - compileOnly 'com.discordsrv:discordsrv:1.27.0-SNAPSHOT' - compileOnly 'net.essentialsx:EssentialsXDiscord:2.19.4' - compileOnly 'com.loohp:InteractiveChat:4.2.8.0' + compileOnly 'com.discordsrv:discordsrv:1.27.0' + compileOnly 'net.essentialsx:EssentialsXDiscord:2.20.1' + compileOnly 'com.loohp:InteractiveChat:4.2.9.0' compileOnly 'com.github.DevLeoko:AdvancedBan:2.3.0' compileOnly 'dev.simplix:protocolize-api:2.2.6' - implementation "net.kyori:adventure-platform-bukkit:4.3.1" - implementation "net.kyori:adventure-platform-bungeecord:4.3.1" - implementation "net.kyori:adventure-text-minimessage:4.14.0" - implementation("net.kyori:adventure-text-serializer-plain:4.14.0") + implementation "net.kyori:adventure-platform-bukkit:4.3.2" + implementation "net.kyori:adventure-platform-bungeecord:4.3.2" + implementation "net.kyori:adventure-text-minimessage:4.15.0" + implementation("net.kyori:adventure-text-serializer-plain:4.15.0") } shadowJar { diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/TABAdditions.java b/src/main/java/io/github/tanguygab/tabadditions/shared/TABAdditions.java index a71efca..2a8ed81 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/TABAdditions.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/TABAdditions.java @@ -26,9 +26,9 @@ import me.neznamy.tab.shared.features.PlaceholderManagerImpl; import me.neznamy.tab.shared.features.types.TabFeature; import me.neznamy.tab.shared.features.types.UnLoadable; -import me.neznamy.tab.shared.placeholders.PlayerPlaceholderImpl; -import me.neznamy.tab.shared.placeholders.RelationalPlaceholderImpl; -import me.neznamy.tab.shared.placeholders.ServerPlaceholderImpl; +import me.neznamy.tab.shared.placeholders.types.PlayerPlaceholderImpl; +import me.neznamy.tab.shared.placeholders.types.RelationalPlaceholderImpl; +import me.neznamy.tab.shared.placeholders.types.ServerPlaceholderImpl; import me.neznamy.tab.shared.platform.TabPlayer; import me.neznamy.tab.shared.placeholders.conditions.Condition; diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/AdvancedConditions.java b/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/AdvancedConditions.java index 3219725..e952a45 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/AdvancedConditions.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/AdvancedConditions.java @@ -6,7 +6,7 @@ import lombok.Getter; import me.neznamy.tab.shared.TAB; -import me.neznamy.tab.shared.placeholders.TabPlaceholder; +import me.neznamy.tab.shared.placeholders.types.TabPlaceholder; import me.neznamy.tab.shared.platform.TabPlayer; import me.neznamy.tab.shared.features.PlaceholderManagerImpl; @@ -63,15 +63,13 @@ public class AdvancedConditions { */ public AdvancedConditions(String name, Map conditions) { this.name = name; - if (conditions == null) { - TAB.getInstance().getMisconfigurationHelper().conditionHasNoConditions(name); - return; - } + if (conditions == null) return; + PlaceholderManagerImpl pm = TAB.getInstance().getPlaceholderManager(); conditions.forEach((line,text)->{ BiFunction condition = compile(line); if (condition == null && !line.equals("else")) { - TAB.getInstance().getMisconfigurationHelper().invalidConditionPattern("[TAB-Additions]-"+name, line); + TAB.getInstance().getConfigHelper().startup().invalidConditionPattern("[TAB-Additions]-"+name, line); return; } subConditions.put(condition,text); diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/NumericCondition.java b/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/NumericCondition.java index fd57127..16e6bfb 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/NumericCondition.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/features/advancedconditions/NumericCondition.java @@ -2,6 +2,7 @@ import me.neznamy.tab.shared.platform.TabPlayer; import me.neznamy.tab.shared.TAB; +import org.jetbrains.annotations.NotNull; import java.util.function.BiFunction; @@ -54,7 +55,7 @@ public double getLeftSide(TabPlayer viewer, TabPlayer target) { if (leftSideStatic) return leftSideValue; String value = parseLeftSide(viewer,target); if (value.contains(",")) value = value.replace(",", ""); - return TAB.getInstance().getErrorManager().parseDouble(value, 0); + return parseDouble(leftSide,value,0,viewer); } /** @@ -67,11 +68,34 @@ public double getRightSide(TabPlayer viewer, TabPlayer target) { if (rightSideStatic) return rightSideValue; String value = parseRightSide(viewer,target); if (value.contains(",")) value = value.replace(",", ""); - return TAB.getInstance().getErrorManager().parseDouble(value, 0); + return parseDouble(rightSide,value,0,viewer); } @Override public boolean isMet(TabPlayer viewer, TabPlayer target) { return function.apply(getLeftSide(viewer,target), getRightSide(viewer,target)); } + + /** + * Parses double in given string and returns it. + * Returns second argument if string is not valid and prints a console warn. + * + * @param placeholder + * Raw placeholder, used in error message + * @param output + * string to parse + * @param defaultValue + * value to return if string is not valid + * @param player + * Player name used in error message + * @return parsed double or {@code defaultValue} if input is invalid + */ + public double parseDouble(@NotNull String placeholder, @NotNull String output, double defaultValue, TabPlayer player) { + try { + return Double.parseDouble(output); + } catch (NumberFormatException e) { + TAB.getInstance().getConfigHelper().runtime().invalidNumberForCondition(placeholder, output, player); + return defaultValue; + } + } } \ No newline at end of file diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/Chat.java b/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/Chat.java index 40ee8fb..b3e6191 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/Chat.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/Chat.java @@ -15,8 +15,8 @@ import me.neznamy.tab.shared.TAB; import me.neznamy.tab.shared.config.file.ConfigurationFile; import me.neznamy.tab.shared.features.types.*; -import me.neznamy.tab.shared.placeholders.PlayerPlaceholderImpl; -import me.neznamy.tab.shared.placeholders.RelationalPlaceholderImpl; +import me.neznamy.tab.shared.placeholders.types.PlayerPlaceholderImpl; +import me.neznamy.tab.shared.placeholders.types.RelationalPlaceholderImpl; import me.neznamy.tab.shared.platform.TabPlayer; import net.kyori.adventure.platform.AudienceProvider; import net.kyori.adventure.text.Component; diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/ChatManager.java b/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/ChatManager.java index 77030ef..17e1588 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/ChatManager.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/features/chat/ChatManager.java @@ -3,7 +3,7 @@ import io.github.tanguygab.tabadditions.shared.TABAdditions; import io.github.tanguygab.tabadditions.shared.TranslationFile; import me.neznamy.tab.shared.TAB; -import me.neznamy.tab.shared.placeholders.PlayerPlaceholderImpl; +import me.neznamy.tab.shared.placeholders.types.PlayerPlaceholderImpl; import me.neznamy.tab.shared.platform.TabPlayer; import java.util.List; diff --git a/src/main/java/io/github/tanguygab/tabadditions/spigot/SpigotPlatform.java b/src/main/java/io/github/tanguygab/tabadditions/spigot/SpigotPlatform.java index 405bf07..9331156 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/spigot/SpigotPlatform.java +++ b/src/main/java/io/github/tanguygab/tabadditions/spigot/SpigotPlatform.java @@ -5,7 +5,7 @@ import me.neznamy.tab.api.placeholder.PlaceholderManager; import me.neznamy.tab.api.TabAPI; import me.neznamy.tab.api.TabPlayer; -import me.neznamy.tab.shared.TAB; +import me.neznamy.tab.platforms.bukkit.nms.BukkitReflection; import net.essentialsx.api.v2.services.discord.DiscordService; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.md_5.bungee.api.ChatMessageType; @@ -40,7 +40,7 @@ public class SpigotPlatform extends Platform { public SpigotPlatform(TABAdditionsSpigot plugin) { this.plugin = plugin; kyori = BukkitAudiences.create(plugin); - chatSuggestions = TAB.getInstance().getServerVersion().getNetworkId() >= 762; + chatSuggestions = BukkitReflection.is1_19_3Plus(); try { getCommandMap = plugin.getServer().getClass().getMethod("getCommandMap"); } catch (Exception ignored) {} @@ -76,7 +76,7 @@ public void registerPlaceholders(PlaceholderManager pm) { public void registerCommand(String cmd, String... aliases) { try { Command command = new BukkitCommand(cmd,"","/"+cmd,List.of(aliases)) { - @Override public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args) {return true;} + @Override public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {return true;} }; ((SimpleCommandMap)getCommandMap.invoke(plugin.getServer())).register(cmd,"chat",command); } catch (Exception e) {e.printStackTrace();}