diff --git a/build.gradle.kts b/build.gradle.kts index 2f151266..de67a000 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { allprojects { - version = "2.0.2" + version = "2.0.3" apply() apply(plugin = "java") diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 4b258c54..81d17fb6 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -44,7 +44,7 @@ dependencies { compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.21") compileOnly("com.github.MilkBowl:VaultAPI:1.7") compileOnly("org.betonquest:betonquest:2.0.0-SNAPSHOT") - compileOnly("xyz.xenondevs.invui:invui:1.23") + compileOnly("xyz.xenondevs.invui:invui:1.24") compileOnly("com.github.Xiao-MoMi:Custom-Crops:3.3.1.8") // local jars diff --git a/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java b/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java index 6ce2f66a..97c4e6f6 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java @@ -219,19 +219,26 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin { "org.mongodb:mongodb-driver-core:4.11.1", mavenRepo, "org.mongodb:bson:4.11.1", mavenRepo, "org.xerial:sqlite-jdbc:3.43.2.2", mavenRepo, - "dev.jorel:commandapi-bukkit-shade:9.3.0", mavenRepo, - "xyz.xenondevs.invui:invui-core:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r8:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r9:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r10:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r11:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r12:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r13:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r14:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r15:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r16:1.23", "https://repo.xenondevs.xyz/releases/", - "xyz.xenondevs.invui:inventory-access-r17:1.23", "https://repo.xenondevs.xyz/releases/" + "dev.jorel:commandapi-bukkit-shade:9.3.0", mavenRepo + ); + + String version = getServer().getClass().getPackage().getName().split("\\.")[3]; + String artifact = ""; + switch (version) { + case "v1_17_R1" -> artifact = "r9"; + case "v1_18_R1" -> artifact = "r10"; + case "v1_18_R2" -> artifact = "r11"; + case "v1_19_R1" -> artifact = "r12"; + case "v1_19_R2" -> artifact = "r13"; + case "v1_19_R3" -> artifact = "r15"; + case "v1_20_R1" -> artifact = "r16"; + case "v1_20_R2" -> artifact = "r17"; + case "v1_20_R3" -> artifact = "r18"; + } + LibraryLoader.loadDependencies( + "xyz.xenondevs.invui:invui-core:1.24", "https://repo.xenondevs.xyz/releases/", + "xyz.xenondevs.invui:inventory-access:1.24", "https://repo.xenondevs.xyz/releases/", + String.format("xyz.xenondevs.invui:inventory-access-%s:1.24", artifact), "https://repo.xenondevs.xyz/releases/" ); } diff --git a/plugin/src/main/java/net/momirealms/customfishing/adventure/AdventureManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/adventure/AdventureManagerImpl.java index 3b68b751..884a9fab 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/adventure/AdventureManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/adventure/AdventureManagerImpl.java @@ -17,6 +17,9 @@ package net.momirealms.customfishing.adventure; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedChatComponent; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.key.Key; import net.kyori.adventure.platform.bukkit.BukkitAudiences; @@ -26,8 +29,10 @@ import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.title.Title; +import net.momirealms.customfishing.CustomFishingPluginImpl; import net.momirealms.customfishing.api.CustomFishingPlugin; import net.momirealms.customfishing.api.manager.AdventureManager; +import net.momirealms.customfishing.api.util.LogUtils; import net.momirealms.customfishing.api.util.ReflectionUtils; import net.momirealms.customfishing.setting.CFConfig; import net.momirealms.customfishing.setting.CFLocale; @@ -100,13 +105,28 @@ public class AdventureManagerImpl implements AdventureManager { @Override public void sendTitle(Player player, String title, String subtitle, int in, int duration, int out) { - Audience au = adventure.player(player); - Title.Times times = Title.Times.times(Duration.ofMillis(in), Duration.ofMillis(duration), Duration.ofMillis(out)); - au.showTitle(Title.title(getComponentFromMiniMessage(title), getComponentFromMiniMessage(subtitle), times)); + sendTitle(player, getComponentFromMiniMessage(title), getComponentFromMiniMessage(subtitle), in, duration, out); } @Override public void sendTitle(Player player, Component title, Component subtitle, int in, int duration, int out) { + try { + PacketContainer titlePacket = new PacketContainer(PacketType.Play.Server.SET_TITLE_TEXT); + titlePacket.getModifier().write(0, getIChatComponent(componentToJson(title))); + PacketContainer subTitlePacket = new PacketContainer(PacketType.Play.Server.SET_SUBTITLE_TEXT); + subTitlePacket.getModifier().write(0, getIChatComponent(componentToJson(subtitle))); + PacketContainer timePacket = new PacketContainer(PacketType.Play.Server.SET_TITLES_ANIMATION); + timePacket.getIntegers().write(0, in); + timePacket.getIntegers().write(1, duration); + timePacket.getIntegers().write(2, out); + CustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, titlePacket); + CustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, subTitlePacket); + CustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, timePacket); + } catch (InvocationTargetException | IllegalAccessException e) { + LogUtils.warn("Error occurred when sending title"); + } + + Audience au = adventure.player(player); Title.Times times = Title.Times.times(Duration.ofMillis(in), Duration.ofMillis(duration), Duration.ofMillis(out)); au.showTitle(Title.title(title, subtitle, times)); @@ -114,8 +134,13 @@ public class AdventureManagerImpl implements AdventureManager { @Override public void sendActionbar(Player player, String s) { - Audience au = adventure.player(player); - au.sendActionBar(getComponentFromMiniMessage(s)); + try { + PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_ACTION_BAR_TEXT); + packet.getModifier().write(0, getIChatComponent(componentToJson(getComponentFromMiniMessage(s)))); + CustomFishingPluginImpl.getProtocolManager().sendServerPacket(player, packet); + } catch (InvocationTargetException | IllegalAccessException e) { + LogUtils.warn("Error occurred when sending actionbar"); + } } @Override @@ -226,4 +251,8 @@ public class AdventureManagerImpl implements AdventureManager { } return cp; } + + public Object getIChatComponent(String json) throws InvocationTargetException, IllegalAccessException { + return ReflectionUtils.iChatComponentMethod.invoke(null, json); + } } diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/action/ActionManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/action/ActionManagerImpl.java index ae795e34..cff1c1ea 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/action/ActionManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/action/ActionManagerImpl.java @@ -741,9 +741,9 @@ public class ActionManagerImpl implements ActionManager { condition.getPlayer(), PlaceholderManagerImpl.getInstance().parse(condition.getPlayer(), title, condition.getArgs()), PlaceholderManagerImpl.getInstance().parse(condition.getPlayer(), subtitle, condition.getArgs()), - fadeIn * 50, - stay * 50, - fadeOut * 50 + fadeIn, + stay, + fadeOut ); }; } else { @@ -770,9 +770,9 @@ public class ActionManagerImpl implements ActionManager { condition.getPlayer(), PlaceholderManagerImpl.getInstance().parse(condition.getPlayer(), title, condition.getArgs()), PlaceholderManagerImpl.getInstance().parse(condition.getPlayer(), subtitle, condition.getArgs()), - fadeIn * 50, - stay * 50, - fadeOut * 50 + fadeIn, + stay, + fadeOut ); condition.delArg("{near}"); } @@ -800,9 +800,9 @@ public class ActionManagerImpl implements ActionManager { condition.getPlayer(), PlaceholderManagerImpl.getInstance().parse(condition.getPlayer(), titles.get(ThreadLocalRandom.current().nextInt(titles.size())), condition.getArgs()), PlaceholderManagerImpl.getInstance().parse(condition.getPlayer(), subtitles.get(ThreadLocalRandom.current().nextInt(subtitles.size())), condition.getArgs()), - fadeIn * 50, - stay * 50, - fadeOut * 50 + fadeIn, + stay, + fadeOut ); }; } else { diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/game/GameManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/game/GameManagerImpl.java index 87f00ab3..09f8d63e 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/game/GameManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/game/GameManagerImpl.java @@ -255,7 +255,7 @@ public class GameManagerImpl implements GameManager { + OffsetUtils.getOffsetChars(pointerOffset + progress) + FontUtils.surroundWithFont(pointerImage, font) + OffsetUtils.getOffsetChars(totalWidth - progress - pointerWidth); - AdventureManagerImpl.getInstance().sendTitle(player, sendTitle, bar,0,500,0); + AdventureManagerImpl.getInstance().sendTitle(player, sendTitle, bar,0,10,0); } @Override @@ -399,7 +399,7 @@ public class GameManagerImpl implements GameManager { tip != null && !played ? tip : title.replace("{progress}", progress[(int) ((hold_time / time_requirement) * progress.length)]), bar, 0, - 500, + 10, 0 ); } @@ -491,7 +491,7 @@ public class GameManagerImpl implements GameManager { tip != null && !played ? tip : title.replace("{tension}", tension[(int) ((strain / ultimateTension) * tension.length)]), bar, 0, - 500, + 10, 0 ); } @@ -536,7 +536,7 @@ public class GameManagerImpl implements GameManager { title.replace("{click}", String.valueOf(clickedTimes)), subtitle.replace("{clicks}", String.valueOf(requiredTimes)).replace("{time}", String.format("%.1f", ((double) deadline - System.currentTimeMillis())/1000)), 0, - 500, + 10, 0 ); } @@ -612,7 +612,7 @@ public class GameManagerImpl implements GameManager { stringBuilder.toString(), subtitle, 0, - 500, + 10, 0 ); } @@ -688,7 +688,7 @@ public class GameManagerImpl implements GameManager { title, bar, 0, - 500, + 10, 0 ); } @@ -832,7 +832,7 @@ public class GameManagerImpl implements GameManager { tip != null && !played ? tip : title.replace("{progress}", progress[(int) ((hold_time / time_requirement) * progress.length)]), bar, 0, - 500, + 10, 0 ); } diff --git a/plugin/src/main/java/net/momirealms/customfishing/version/VersionManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/version/VersionManagerImpl.java index fcef8e73..844e169f 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/version/VersionManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/version/VersionManagerImpl.java @@ -20,6 +20,7 @@ package net.momirealms.customfishing.version; import net.momirealms.customfishing.CustomFishingPluginImpl; import net.momirealms.customfishing.api.manager.VersionManager; import net.momirealms.customfishing.api.util.LogUtils; +import org.bukkit.Bukkit; import java.io.BufferedReader; import java.io.InputStream;