From a5d9f2e5fb245e32a1503fed9c3c6a455ad5b6e3 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Thu, 2 Nov 2023 17:51:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?misc:=20=E5=8F=AA=E6=A3=80=E6=9F=A5Release?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/xiamomc/morph/updates/UpdateHandler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/xiamomc/morph/updates/UpdateHandler.java b/src/main/java/xiamomc/morph/updates/UpdateHandler.java index bb6a2fef..1ec0f8d4 100644 --- a/src/main/java/xiamomc/morph/updates/UpdateHandler.java +++ b/src/main/java/xiamomc/morph/updates/UpdateHandler.java @@ -171,7 +171,10 @@ private void onUpdateReqFinish(CloseableHttpResponse response, int reqId, var supportedLoaders = m.supportedLoaders; if (supportedLoaders == null) return false; - return supportedLoaders.stream().anyMatch(s -> s.equalsIgnoreCase(loader.getImplName())); + var isRelease = "Release".equalsIgnoreCase(m.versionType); + var loaderMatch = supportedLoaders.stream().anyMatch(s -> s.equalsIgnoreCase(loader.getImplName())); + + return isRelease && loaderMatch; }).findFirst().orElse(null); if (matchMeta == null) From 76435dbafcf44663c0fa63816d634b9b3bbaf2a5 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Thu, 2 Nov 2023 17:56:20 +0800 Subject: [PATCH 2/5] =?UTF-8?q?misc:=20=E8=B0=83=E6=95=B4=E2=80=9C?= =?UTF-8?q?=E5=B7=B2=E6=98=AF=E6=9C=80=E6=96=B0=E7=89=88=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/subcommands/plugin/CheckUpdateSubCommand.java | 6 +++++- src/main/java/xiamomc/morph/updates/UpdateHandler.java | 2 +- src/main/resources/assets/feathermorph/lang/en_us.json | 2 +- src/main/resources/assets/feathermorph/lang/zh_cn.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/xiamomc/morph/commands/subcommands/plugin/CheckUpdateSubCommand.java b/src/main/java/xiamomc/morph/commands/subcommands/plugin/CheckUpdateSubCommand.java index 59ec5c0e..b84967f8 100644 --- a/src/main/java/xiamomc/morph/commands/subcommands/plugin/CheckUpdateSubCommand.java +++ b/src/main/java/xiamomc/morph/commands/subcommands/plugin/CheckUpdateSubCommand.java @@ -1,5 +1,6 @@ package xiamomc.morph.commands.subcommands.plugin; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,6 +54,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull String[] args) private void onRequestFinish(UpdateHandler.CheckResult result, CommandSender sender) { if (result == UpdateHandler.CheckResult.ALREADY_LATEST) - sender.sendMessage(MessageUtils.prefixes(sender, UpdateStrings.noNewVersionAvailable())); + { + var msg = UpdateStrings.noNewVersionAvailable().resolve("mc_version", Bukkit.getMinecraftVersion()); + sender.sendMessage(MessageUtils.prefixes(sender, msg)); + } } } diff --git a/src/main/java/xiamomc/morph/updates/UpdateHandler.java b/src/main/java/xiamomc/morph/updates/UpdateHandler.java index 1ec0f8d4..838c7a40 100644 --- a/src/main/java/xiamomc/morph/updates/UpdateHandler.java +++ b/src/main/java/xiamomc/morph/updates/UpdateHandler.java @@ -200,7 +200,7 @@ private void onUpdateReqFinish(CloseableHttpResponse response, int reqId, if (currentVersion.equals(latestVersion)) { - logger.info("Already on the latest version"); + logger.info("Already on the latest version for " + Bukkit.getMinecraftVersion()); if (onFinish != null) onFinish.accept(CheckResult.ALREADY_LATEST); diff --git a/src/main/resources/assets/feathermorph/lang/en_us.json b/src/main/resources/assets/feathermorph/lang/en_us.json index b0957e99..8c4f68ef 100644 --- a/src/main/resources/assets/feathermorph/lang/en_us.json +++ b/src/main/resources/assets/feathermorph/lang/en_us.json @@ -124,7 +124,7 @@ "update.msg_header_footer": "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", "update.checking_update": "Checking update...", "update.new_version_available": "A newer version of FeatherMorph has been released!( -> )", - "update.no_new_ver_available": "You're already on the latest version", + "update.no_new_ver_available": "You're already on the latest version for ", "update.update_here": "Update here: ", "requests.already_have_disguise": "You already have their disguise!", "requests.cant_send_to_self": "You can't send requests to yourself", diff --git a/src/main/resources/assets/feathermorph/lang/zh_cn.json b/src/main/resources/assets/feathermorph/lang/zh_cn.json index 62256957..5e11e1b0 100644 --- a/src/main/resources/assets/feathermorph/lang/zh_cn.json +++ b/src/main/resources/assets/feathermorph/lang/zh_cn.json @@ -124,7 +124,7 @@ "update.msg_header_footer": "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", "update.checking_update": "检查更新中...", "update.new_version_available": "FeatherMorph有新版本辣!( -> )", - "update.no_new_ver_available": "FeatherMorph已是最新版本", + "update.no_new_ver_available": "FeatherMorph已是上的最新版本", "update.update_here": "在此更新:", "requests.already_have_disguise": "你已经有对方的形态了", "requests.cant_send_to_self": "你不能给自己发请求", From 3cf402f895ae70fffc077367336e36b14485dd9d Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 3 Nov 2023 13:38:10 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20DisguiseState#SoundHandler=E5=9C=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=A3=B0=E9=9F=B3=E4=BF=A1=E6=81=AF=E5=89=8D?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../morph/events/CommonEventProcessor.java | 3 +-- .../java/xiamomc/morph/misc/DisguiseState.java | 15 ++++++++++++--- .../xiamomc/morph/skills/MorphSkillHandler.java | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/xiamomc/morph/events/CommonEventProcessor.java b/src/main/java/xiamomc/morph/events/CommonEventProcessor.java index 37983e6f..7fea7edd 100644 --- a/src/main/java/xiamomc/morph/events/CommonEventProcessor.java +++ b/src/main/java/xiamomc/morph/events/CommonEventProcessor.java @@ -37,7 +37,6 @@ import xiamomc.morph.misc.NetworkingHelper; import xiamomc.morph.misc.permissions.CommonPermissions; import xiamomc.morph.network.commands.S2C.S2CSwapCommand; -import xiamomc.morph.network.commands.S2C.clientrender.S2CRenderMapMetaCommand; import xiamomc.morph.network.commands.S2C.map.S2CMapRemoveCommand; import xiamomc.morph.network.server.MorphClientHandler; import xiamomc.morph.network.server.ServerSetEquipCommand; @@ -166,7 +165,7 @@ public void onPlayerTookDamage(EntityDamageEvent e) if (state != null) { - state.getSoundHandler().resetAmbientSoundInterval(); + state.getSoundHandler().resetSoundTime(); //如果伤害是0,那么取消事件 if (e.getDamage() > 0d) diff --git a/src/main/java/xiamomc/morph/misc/DisguiseState.java b/src/main/java/xiamomc/morph/misc/DisguiseState.java index 9b3a8ed0..cec07b8b 100644 --- a/src/main/java/xiamomc/morph/misc/DisguiseState.java +++ b/src/main/java/xiamomc/morph/misc/DisguiseState.java @@ -19,7 +19,6 @@ import org.jetbrains.annotations.Nullable; import xiamomc.morph.MorphManager; import xiamomc.morph.MorphPluginObject; -import xiamomc.morph.abilities.AbilityHandler; import xiamomc.morph.abilities.IMorphAbility; import xiamomc.morph.backends.DisguiseWrapper; import xiamomc.morph.config.ConfigOption; @@ -518,7 +517,7 @@ public void setDisguise(@NotNull String identifier, @NotNull String skillIdentif supportsDisguisedItems = skillHandler.hasSpeficSkill(skillIdentifier, SkillType.INVENTORY); //设置声音 - this.soundHandler.refreshSounds(getEntityType(), wrapper.isBaby()); + this.soundHandler.refreshSounds(wrapper.getEntityType(), wrapper.isBaby()); //重置伪装物品 if (shouldRefreshDisguiseItems) @@ -659,7 +658,7 @@ public static class SoundHandler private int soundTime; private double soundFrequency = 0D; - public void resetAmbientSoundInterval() + public void resetSoundTime() { soundTime = 0; } @@ -724,8 +723,18 @@ else if (sound != null && random.nextInt((int)(1000 * frequencyScale)) < soundTi private final MorphConfigManager config = MorphConfigManager.getInstance(); + public void resetSound() + { + ambientSoundPrimary = null; + ambientSoundSecondary = null; + ambientInterval = 0; + resetSoundTime(); + } + public void refreshSounds(EntityType entityType, boolean isBaby) { + resetSound(); + this.entityType = entityType; soundFrequency = MathUtils.clamp(0, 2, config.getBindable(Double.class, ConfigOption.AMBIENT_FREQUENCY).get()); diff --git a/src/main/java/xiamomc/morph/skills/MorphSkillHandler.java b/src/main/java/xiamomc/morph/skills/MorphSkillHandler.java index 2fc6a464..97bd68e3 100644 --- a/src/main/java/xiamomc/morph/skills/MorphSkillHandler.java +++ b/src/main/java/xiamomc/morph/skills/MorphSkillHandler.java @@ -243,7 +243,7 @@ public void executeDisguiseSkill(Player player, boolean bypassPermission) var cd = skill.executeSkillGeneric(player, state, config, option); cdInfo.setLastInvoke(plugin.getCurrentTick()); - state.getSoundHandler().resetAmbientSoundInterval(); + state.getSoundHandler().resetSoundTime(); if (!state.haveCooldown()) state.setCooldownInfo(cdInfo); else state.setSkillCooldown(cd); From 3046fdc247a249ec6d204d4257044d448be1aab1 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 3 Nov 2023 14:08:35 +0800 Subject: [PATCH 4/5] =?UTF-8?q?misc:=20=E5=85=81=E8=AE=B8=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=B8=B2=E6=9F=93=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/xiamomc/morph/MorphManager.java | 7 +++--- .../subcommands/plugin/OptionSubCommand.java | 2 ++ .../xiamomc/morph/config/ConfigOption.java | 2 ++ .../morph/config/MorphConfigManager.java | 2 +- .../morph/events/CommonEventProcessor.java | 12 +++++---- .../network/server/MorphClientHandler.java | 25 +++++++++++-------- src/main/resources/config.yml | 6 ++++- 7 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/main/java/xiamomc/morph/MorphManager.java b/src/main/java/xiamomc/morph/MorphManager.java index 84d17138..63e1f0da 100644 --- a/src/main/java/xiamomc/morph/MorphManager.java +++ b/src/main/java/xiamomc/morph/MorphManager.java @@ -117,9 +117,6 @@ private void load() try { - if (1+1==2) - throw new NoClassDefFoundError(); - this.currentBackend = new LibsBackend(); } catch (NoClassDefFoundError e) @@ -141,6 +138,7 @@ private void load() bannedDisguises = config.getBindableList(ConfigOption.BANNED_DISGUISES); config.bind(allowHeadMorph, ConfigOption.ALLOW_HEAD_MORPH); config.bind(allowAcquireMorph, ConfigOption.ALLOW_ACQUIRE_MORPHS); + config.bind(useClientRenderer, ConfigOption.USE_CLIENT_RENDERER); registerProviders(ObjectList.of( new VanillaDisguiseProvider(), @@ -330,6 +328,7 @@ public boolean registerProviders(List providers) private final Bindable allowHeadMorph = new Bindable<>(true); private final Bindable allowAcquireMorph = new Bindable<>(true); + private final Bindable useClientRenderer = new Bindable<>(false); private final Map uuidPlayerTexturesMap = new ConcurrentHashMap<>(); @@ -725,7 +724,7 @@ else if (!provider.isValid(key)) public boolean isUsingClientRenderer() { - return currentBackend == nilBackend; + return currentBackend == nilBackend && useClientRenderer.get(); } //region Command generating diff --git a/src/main/java/xiamomc/morph/commands/subcommands/plugin/OptionSubCommand.java b/src/main/java/xiamomc/morph/commands/subcommands/plugin/OptionSubCommand.java index 29a096d0..7298e390 100644 --- a/src/main/java/xiamomc/morph/commands/subcommands/plugin/OptionSubCommand.java +++ b/src/main/java/xiamomc/morph/commands/subcommands/plugin/OptionSubCommand.java @@ -72,6 +72,8 @@ public OptionSubCommand() subCommands.add(getToggle("allow_acquire_morphs", ConfigOption.ALLOW_ACQUIRE_MORPHS, "allow_acquire_morphs")); subCommands.add(getToggle("allow_flight", ConfigOption.ALLOW_FLIGHT, "allow_flight")); + + subCommands.add(getToggle("client_renderer", ConfigOption.USE_CLIENT_RENDERER, "client_renderer")); } private ISubCommand getGeneric(String name, ConfigOption option, String perm, diff --git a/src/main/java/xiamomc/morph/config/ConfigOption.java b/src/main/java/xiamomc/morph/config/ConfigOption.java index 4a62efb6..2222ae53 100644 --- a/src/main/java/xiamomc/morph/config/ConfigOption.java +++ b/src/main/java/xiamomc/morph/config/ConfigOption.java @@ -39,6 +39,8 @@ public enum ConfigOption LOG_INCOMING_PACKETS(clientNode().append("log_incoming_packets"), false), LOG_OUTGOING_PACKETS(clientNode().append("log_outgoing_packets"), false), + USE_CLIENT_RENDERER(clientNode().append("client_renderer"), true), + MIRROR_CONTROL_DISTANCE(interactionMirrorNode().append("normalDistance"), -1), MIRROR_IGNORE_DISGUISED(interactionMirrorNode().append("ignore_disguised"), true), MIRROR_DESTROY_TIMEOUT(interactionMirrorNode().append("destroy_timeout"), 40), diff --git a/src/main/java/xiamomc/morph/config/MorphConfigManager.java b/src/main/java/xiamomc/morph/config/MorphConfigManager.java index 31c00440..7d0cffec 100644 --- a/src/main/java/xiamomc/morph/config/MorphConfigManager.java +++ b/src/main/java/xiamomc/morph/config/MorphConfigManager.java @@ -129,7 +129,7 @@ public void reload() super.reload(); //更新配置 - int targetVersion = 26; + int targetVersion = 27; var configVersion = getOrDefault(Integer.class, ConfigOption.VERSION); diff --git a/src/main/java/xiamomc/morph/events/CommonEventProcessor.java b/src/main/java/xiamomc/morph/events/CommonEventProcessor.java index 7fea7edd..9e77ac1c 100644 --- a/src/main/java/xiamomc/morph/events/CommonEventProcessor.java +++ b/src/main/java/xiamomc/morph/events/CommonEventProcessor.java @@ -444,14 +444,16 @@ public void onPlayerJoin(PlayerJoinEvent e) networkingHelper.sendCommandToRevealablePlayers(morphs.genPartialMapCommand(state)); - var metaCommand = networkingHelper.prepareMeta(player) - .forDisguiseState(state) - .build(); - networkingHelper.sendCommandToAllPlayers(metaCommand); - if (morphs.isUsingClientRenderer()) + { networkingHelper.sendCommandToAllPlayers(morphs.genClientRenderAddCommand(state)); + var metaCommand = networkingHelper.prepareMeta(player) + .forDisguiseState(state) + .build(); + networkingHelper.sendCommandToAllPlayers(metaCommand); + } + //调用Morph事件 new PlayerJoinedWithDisguiseEvent(player, state).callEvent(); diff --git a/src/main/java/xiamomc/morph/network/server/MorphClientHandler.java b/src/main/java/xiamomc/morph/network/server/MorphClientHandler.java index 34a5e47a..a84a2501 100644 --- a/src/main/java/xiamomc/morph/network/server/MorphClientHandler.java +++ b/src/main/java/xiamomc/morph/network/server/MorphClientHandler.java @@ -127,6 +127,7 @@ private void logPacket(boolean isOutGoingPacket, Player player, String channel, private final CommandRegistries registries = new CommandRegistries(); private final Bindable modifyBoundingBoxes = new Bindable<>(false); + private final Bindable useClientRenderer = new Bindable<>(false); @Initializer private void load(MorphPlugin plugin, MorphConfigManager configManager) @@ -257,6 +258,8 @@ private void load(MorphPlugin plugin, MorphConfigManager configManager) configManager.bind(modifyBoundingBoxes, ConfigOption.MODIFY_BOUNDING_BOX); + configManager.bind(useClientRenderer, ConfigOption.USE_CLIENT_RENDERER); + modifyBoundingBoxes.onValueChanged((o, n) -> { var players = Bukkit.getOnlinePlayers(); @@ -265,6 +268,7 @@ private void load(MorphPlugin plugin, MorphConfigManager configManager) forceTargetVersion.onValueChanged((o, n) -> scheduleReAuthPlayers()); modifyBoundingBoxes.onValueChanged((o, n) -> scheduleReAuthPlayers()); + useClientRenderer.onValueChanged((o, n) -> scheduleReAuthPlayers()); allowClient.onValueChanged((o, n) -> { @@ -623,21 +627,20 @@ public void onInitialCommand(C2SInitialCommand c2SInitialCommand) sendCommand(player, manager.genMapCommand()); if (manager.isUsingClientRenderer()) + { sendCommand(player, manager.genRenderSyncCommand()); - logger.info("READY!"); - var disguises = manager.getDisguiseStates(); - for (DisguiseState bindingState : disguises) - { - logger.info("STATE! " + bindingState); - var bindingPlayer = bindingState.getPlayer(); + var disguises = manager.getDisguiseStates(); + for (DisguiseState bindingState : disguises) + { + var bindingPlayer = bindingState.getPlayer(); - var packet = networkingHelper.prepareMeta(bindingPlayer) - .forDisguiseState(bindingState) - .build(); + var packet = networkingHelper.prepareMeta(bindingPlayer) + .forDisguiseState(bindingState) + .build(); - this.sendCommand(player, packet); - logger.info("SEND! " + packet); + this.sendCommand(player, packet); + } } playerConnectionStates.put(player, InitializeState.DONE); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 84838519..b44ecdf3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -238,5 +238,9 @@ root: # Should we log packets sent to the client? log_outgoing_packets: false + # Make clients render other players' disguises when LibsDisguises is not present? + # Requires the client to implement the v11 protocol + client_renderer: true + # Do not touch unless you know what you're doing! - version: 26 + version: 27 From 024fb8ebfad957ec11fc80b410a6fed4b8af5677 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 3 Nov 2023 14:15:47 +0800 Subject: [PATCH 5/5] misc: Bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 387084ab..832349c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -project_version=0.13.3 +project_version=0.13.4 # FM Protocols protocols_version=09b2b0a077