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 diff --git a/src/main/java/xiamomc/morph/MorphManager.java b/src/main/java/xiamomc/morph/MorphManager.java index 1127e343..f8c3634e 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(), @@ -336,6 +334,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<>(); @@ -731,7 +730,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/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/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 37983e6f..9e77ac1c 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) @@ -445,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/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/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/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); diff --git a/src/main/java/xiamomc/morph/updates/UpdateHandler.java b/src/main/java/xiamomc/morph/updates/UpdateHandler.java index bb6a2fef..838c7a40 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) @@ -197,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": "你不能给自己发请求", 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