diff --git a/src/main/java/xyz/nifeather/morph/MorphManager.java b/src/main/java/xyz/nifeather/morph/MorphManager.java index 5196de50..593a9152 100644 --- a/src/main/java/xyz/nifeather/morph/MorphManager.java +++ b/src/main/java/xyz/nifeather/morph/MorphManager.java @@ -15,17 +15,20 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import xyz.nifeather.morph.api.v0.disguise.DisguiseValidateResult; +import xyz.nifeather.morph.api.v0.disguise.IMorphManager; +import xyz.nifeather.morph.api.v0.disguise.MorphParameters; import xyz.nifeather.morph.backends.DisguiseBackend; import xyz.nifeather.morph.backends.DisguiseWrapper; import xyz.nifeather.morph.backends.WrapperProperties; import xyz.nifeather.morph.backends.fallback.NilBackend; import xyz.nifeather.morph.backends.server.ServerBackend; -import xyz.nifeather.morph.events.api.gameplay.*; +import xyz.nifeather.morph.api.v0.events.gameplay.*; import xyz.nifeather.morph.misc.*; import xyz.nifeather.morph.misc.playerList.PlayerListHandler; import xyz.nifeather.morph.config.ConfigOption; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.lifecycle.ManagerFinishedInitializeEvent; +import xyz.nifeather.morph.api.v0.events.lifecycle.ManagerFinishedInitializeEvent; import xyz.nifeather.morph.interfaces.IManagePlayerData; import xyz.nifeather.morph.messages.CommandStrings; import xyz.nifeather.morph.messages.HintStrings; @@ -66,7 +69,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; -public class MorphManager extends MorphPluginObject implements IManagePlayerData +public class MorphManager extends MorphPluginObject implements IManagePlayerData, IMorphManager { private final List activeDisguises = ObjectLists.synchronize(new ObjectArrayList<>()); @@ -240,7 +243,7 @@ private void load() config.bind(useClientRenderer, ConfigOption.USE_CLIENT_RENDERER); config.bind(hideDisguisedPlayers, ConfigOption.HIDE_DISGUISED_PLAYERS_IN_TAB); - registerProviders(ObjectList.of( + registerDisguiseProviders(ObjectList.of( new VanillaDisguiseProvider(), new PlayerDisguiseProvider(), //new ItemDisplayProvider(), @@ -339,6 +342,7 @@ public boolean canMorph(Player player) * @param uuid 玩家UUID * @return 是否可以伪装 */ + @Override public boolean canMorph(UUID uuid) { var val = uuidMoprhTimeMap.get(uuid); @@ -352,7 +356,13 @@ public boolean canMorph(UUID uuid) */ public void updateLastPlayerMorphOperationTime(Player player) { - uuidMoprhTimeMap.put(player.getUniqueId(), plugin.getCurrentTick()); + this.updateLastPlayerMorphOperationTime(player.getUniqueId()); + } + + @Override + public void updateLastPlayerMorphOperationTime(UUID uuid) + { + uuidMoprhTimeMap.put(uuid, plugin.getCurrentTick()); } private BindableList bannedDisguises; @@ -366,6 +376,12 @@ public BindableList getBannedDisguises() return bannedDisguises; } + @Override + public List getBannedDisguisesCopy() + { + return new ObjectArrayList<>(bannedDisguises); + } + //region 伪装提供器 private static final List providers = new ObjectArrayList<>(); @@ -391,12 +407,19 @@ public static DisguiseProvider getProvider(String id) return providers.stream().filter(p -> p.getNameSpace().equals(splitedId[0])).findFirst().orElse(fallbackProvider); } + @Override + @NotNull + public DisguiseProvider getDisguiseProvider(String namespaceIdentifier) + { + return getProvider(namespaceIdentifier); + } + /** * 注册一个DisguiseProvider * @param provider 目标Provider * @return 操作是否成功 */ - public boolean registerProvider(DisguiseProvider provider) + public boolean registerDisguiseProvider(DisguiseProvider provider) { //logger.info("Registering disguise provider: " + provider.getNameSpace()); @@ -421,11 +444,11 @@ public boolean registerProvider(DisguiseProvider provider) * @param providers Provider列表 * @return 所有操作是否成功 */ - public boolean registerProviders(List providers) + public boolean registerDisguiseProviders(List providers) { AtomicBoolean success = new AtomicBoolean(false); - providers.forEach(p -> success.set(registerProvider(p) || success.get())); + providers.forEach(p -> success.set(registerDisguiseProvider(p) || success.get())); return success.get(); } @@ -588,11 +611,7 @@ public void morphOrUnMorph(Player player, String key, @Nullable Entity targetEnt public boolean morph(CommandSender source, Player player, String key, @Nullable Entity targetEntity) { - var parameters = MorphParameters.create(player, key) - .setSource(source) - .setTargetedEntity(targetEntity); - - return this.doDisguise(parameters); + return this.morph(source, player, key, targetEntity, false); } /** @@ -638,16 +657,16 @@ private boolean doDisguise(MorphParameters parameters) var validateResult = validateDisguise(meta); switch (validateResult) { - case VALIDATE_NO_ISSUE -> {} + case DisguiseValidateResult.VALIDATE_NO_ISSUE -> {} - case VALIDATE_NO_PROVIDER -> + case DisguiseValidateResult.VALIDATE_NO_PROVIDER -> { logger.error("Unable to find any provider that matches the identifier '%s'".formatted(parameters.targetDisguiseIdentifier())); source.sendMessage(MessageUtils.prefixes(source, MorphStrings.disguiseBannedOrNotSupportedString())); return false; } - case VALIDATE_PROVIDER_FAIL -> + case DisguiseValidateResult.VALIDATE_PROVIDER_FAIL -> { source.sendMessage(MessageUtils.prefixes(source, MorphStrings.invalidIdentityString())); return false; @@ -761,25 +780,25 @@ else if (!disguiseIdentifier.equals("minecraft:player")) // 禁止不带参数 return info; } - public static final int VALIDATE_NO_ISSUE = 0; - public static final int VALIDATE_NO_PROVIDER = 1; - public static final int VALIDATE_PROVIDER_FAIL = 2; - - public int validateDisguise(DisguiseMeta meta) + @Override + public int validateDisguise(String disguiseIdentifier) { - var disguiseIdentifier = meta.getIdentifier(); - // 查找provider var strippedKey = disguiseIdentifier.split(":", 2); var provider = getProvider(strippedKey[0]); if (provider == MorphManager.fallbackProvider) // 如果没找到provider - return VALIDATE_NO_PROVIDER; + return DisguiseValidateResult.VALIDATE_NO_PROVIDER; else if (!provider.isValid(disguiseIdentifier)) // 如果provider不认识这个ID - return VALIDATE_PROVIDER_FAIL; + return DisguiseValidateResult.VALIDATE_PROVIDER_FAIL; - return VALIDATE_NO_ISSUE; + return DisguiseValidateResult.VALIDATE_NO_ISSUE; + } + + public int validateDisguise(DisguiseMeta meta) + { + return validateDisguise(meta.getIdentifier()); } /** @@ -1218,6 +1237,7 @@ public void unMorphAll(boolean ignoreOffline) * * @param player 目标玩家 */ + @Override public void unMorph(Player player) { this.unMorph(player, player, false, false); @@ -1229,6 +1249,7 @@ public void unMorph(Player player) * @param player 目标玩家 * @param bypassPermission 是否绕过权限检查(强制取消伪装) */ + @Override public void unMorph(Player player, boolean bypassPermission) { this.unMorph(player, player, bypassPermission, false); @@ -1249,6 +1270,7 @@ public void unMorph(Player player, boolean bypassPermission) * * @apiNote 如果 forceUnmorph 不为 true,则此操作可以被其他来源取消 */ + @Override public void unMorph(@Nullable CommandSender source, Player player, boolean bypassPermission, boolean forceUnmorph) { // 确保source不为null @@ -1362,6 +1384,7 @@ public void spawnParticle(Player player, Location location, double collX, double * @param player 目标玩家 * @return 正在伪装时返回客户端预览是否可用并已启用,没在伪装时返回玩家的客户端设置 */ + @Override public boolean clientViewAvailable(Player player) { var state = this.getDisguiseStateFor(player); @@ -1377,11 +1400,13 @@ public boolean clientViewAvailable(Player player) return playerOption.isClientSideSelfView() && state.getProvider().validForClient(state); } + @Override public void setSelfDisguiseVisible(Player player, boolean val, boolean saveToConfig) { this.setSelfDisguiseVisible(player, val, saveToConfig, clientHandler.getPlayerOption(player, true).isClientSideSelfView(), false); } + @Override public void setSelfDisguiseVisible(Player player, boolean value, boolean saveToConfig, boolean dontSetServerSide, boolean noClientCommand) { var state = getDisguiseStateFor(player); @@ -1413,6 +1438,7 @@ public void setSelfDisguiseVisible(Player player, boolean value, boolean saveToC * @param player 目标玩家 * @return 伪装状态,如果为null则表示玩家没有通过插件伪装 */ + @Override @Nullable public DisguiseState getDisguiseStateFor(@Nullable Player player) { diff --git a/src/main/java/xyz/nifeather/morph/abilities/AbilityManager.java b/src/main/java/xyz/nifeather/morph/abilities/AbilityManager.java index 4c677698..a6152ff9 100644 --- a/src/main/java/xyz/nifeather/morph/abilities/AbilityManager.java +++ b/src/main/java/xyz/nifeather/morph/abilities/AbilityManager.java @@ -13,7 +13,7 @@ import xyz.nifeather.morph.abilities.impl.potion.*; import xyz.nifeather.morph.abilities.impl.onAttack.ExtraKnockbackAbility; import xyz.nifeather.morph.abilities.impl.onAttack.PotionOnAttackAbility; -import xyz.nifeather.morph.events.api.lifecycle.AbilitiesFinishedInitializeEvent; +import xyz.nifeather.morph.api.v0.events.lifecycle.AbilitiesFinishedInitializeEvent; import xyz.nifeather.morph.storage.skill.ISkillOption; import xiamomc.pluginbase.Annotations.Initializer; import xiamomc.pluginbase.Annotations.Resolved; diff --git a/src/main/java/xyz/nifeather/morph/api/v0/disguise/DisguiseValidateResult.java b/src/main/java/xyz/nifeather/morph/api/v0/disguise/DisguiseValidateResult.java new file mode 100644 index 00000000..d1212103 --- /dev/null +++ b/src/main/java/xyz/nifeather/morph/api/v0/disguise/DisguiseValidateResult.java @@ -0,0 +1,8 @@ +package xyz.nifeather.morph.api.v0.disguise; + +public class DisguiseValidateResult +{ + public static final int VALIDATE_NO_ISSUE = 0; + public static final int VALIDATE_NO_PROVIDER = 1; + public static final int VALIDATE_PROVIDER_FAIL = 2; +} diff --git a/src/main/java/xyz/nifeather/morph/api/v0/disguise/IDisguiseState.java b/src/main/java/xyz/nifeather/morph/api/v0/disguise/IDisguiseState.java new file mode 100644 index 00000000..9ae29256 --- /dev/null +++ b/src/main/java/xyz/nifeather/morph/api/v0/disguise/IDisguiseState.java @@ -0,0 +1,40 @@ +package xyz.nifeather.morph.api.v0.disguise; + +import net.kyori.adventure.text.Component; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import xiamomc.pluginbase.Exceptions.NullDependencyException; + +public interface IDisguiseState +{ + @Nullable + Player tryGetPlayer(); + + /** + * + * @apiNote For a nullable method, use {@link IDisguiseState#tryGetPlayer()} + * @throws NullDependencyException If the player doesn't exist. + */ + @NotNull + Player getPlayer() throws NullDependencyException; + + boolean isSelfViewing(); + + /** + * @return The display component used for the player + */ + Component getPlayerDisplay(); + void setPlayerDisplay(@NotNull Component newName); + + /** + * @return The display component used for others, like Bossbar, ChatOverride, and PAPI integration + */ + Component getServerDisplay(); + void setServerDisplay(@NotNull Component newName); + + /** + * Sets both the player and the server display to the given component + */ + void setCustomDisplayName(Component newName); +} diff --git a/src/main/java/xyz/nifeather/morph/api/v0/disguise/IMorphManager.java b/src/main/java/xyz/nifeather/morph/api/v0/disguise/IMorphManager.java new file mode 100644 index 00000000..f41bc7b4 --- /dev/null +++ b/src/main/java/xyz/nifeather/morph/api/v0/disguise/IMorphManager.java @@ -0,0 +1,49 @@ +package xyz.nifeather.morph.api.v0.disguise; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import xyz.nifeather.morph.providers.disguise.DisguiseProvider; + +import java.util.List; +import java.util.UUID; + +public interface IMorphManager +{ + boolean canMorph(UUID playerUUID); + + void updateLastPlayerMorphOperationTime(UUID uuid); + + List getBannedDisguisesCopy(); + + boolean disguiseDisabled(String identifier); + + @NotNull + DisguiseProvider getDisguiseProvider(String namespaceIdentifier); + boolean registerDisguiseProvider(DisguiseProvider provider); + + boolean tryQuickDisguise(Player player); + + boolean morph(MorphParameters parameters); + + void unMorph(Player player); + void unMorph(Player player, boolean ignorePermissions); + void unMorph(@Nullable CommandSender source, Player player, boolean bypassPermission, boolean forceUnmorph); + + /** + * @return See {@link DisguiseValidateResult} + */ + int validateDisguise(String identifier); + + boolean clientViewAvailable(Player player); + + void setSelfDisguiseVisible(Player player, boolean value, boolean saveToConfig, boolean dontSetServerSide, boolean noClientCommand); + void setSelfDisguiseVisible(Player player, boolean value, boolean saveToConfig); + + IDisguiseState getDisguiseStateFor(Player player); + + boolean grantMorphToPlayer(Player player, String disguiseIdentifier); + + boolean revokeMorphFromPlayer(Player player, String disguiseIdentifier); +} diff --git a/src/main/java/xyz/nifeather/morph/misc/MorphParameters.java b/src/main/java/xyz/nifeather/morph/api/v0/disguise/MorphParameters.java similarity index 97% rename from src/main/java/xyz/nifeather/morph/misc/MorphParameters.java rename to src/main/java/xyz/nifeather/morph/api/v0/disguise/MorphParameters.java index 0e0470cb..23a8e267 100644 --- a/src/main/java/xyz/nifeather/morph/misc/MorphParameters.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/disguise/MorphParameters.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.misc; +package xyz.nifeather.morph.api.v0.disguise; import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; diff --git a/src/main/java/xyz/nifeather/morph/api/v0/disguise/backends/IDisguiseBackend.java b/src/main/java/xyz/nifeather/morph/api/v0/disguise/backends/IDisguiseBackend.java new file mode 100644 index 00000000..c99afca5 --- /dev/null +++ b/src/main/java/xyz/nifeather/morph/api/v0/disguise/backends/IDisguiseBackend.java @@ -0,0 +1,5 @@ +package xyz.nifeather.morph.api.v0.disguise.backends; + +public interface IDisguiseBackend> +{ +} diff --git a/src/main/java/xyz/nifeather/morph/api/v0/disguise/backends/IDisguiseWrapper.java b/src/main/java/xyz/nifeather/morph/api/v0/disguise/backends/IDisguiseWrapper.java new file mode 100644 index 00000000..f54c895a --- /dev/null +++ b/src/main/java/xyz/nifeather/morph/api/v0/disguise/backends/IDisguiseWrapper.java @@ -0,0 +1,11 @@ +package xyz.nifeather.morph.api.v0.disguise.backends; + +public interface IDisguiseWrapper +{ + /** + * @return The underlying disguise instance + */ + TInstance getInstance(); + + IDisguiseBackend> getBackend(); +} diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerDisguisedFromOfflineStateEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerDisguisedFromOfflineStateEvent.java similarity index 94% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerDisguisedFromOfflineStateEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerDisguisedFromOfflineStateEvent.java index 5f96dbf1..ff765703 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerDisguisedFromOfflineStateEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerDisguisedFromOfflineStateEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerExecuteSkillEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerExecuteSkillEvent.java similarity index 96% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerExecuteSkillEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerExecuteSkillEvent.java index d1968388..34f93138 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerExecuteSkillEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerExecuteSkillEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerJoinedWithDisguiseEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerJoinedWithDisguiseEvent.java similarity index 94% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerJoinedWithDisguiseEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerJoinedWithDisguiseEvent.java index b1c74664..43aa4129 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerJoinedWithDisguiseEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerJoinedWithDisguiseEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerMorphEarlyEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerMorphEarlyEvent.java similarity index 97% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerMorphEarlyEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerMorphEarlyEvent.java index 8b186f46..9b96d30f 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerMorphEarlyEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerMorphEarlyEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerMorphEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerMorphEvent.java similarity index 94% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerMorphEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerMorphEvent.java index 805e63e3..c16b8f6e 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerMorphEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerMorphEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerUnMorphEarlyEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerUnMorphEarlyEvent.java similarity index 97% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerUnMorphEarlyEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerUnMorphEarlyEvent.java index 6f14e6a5..3302b412 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerUnMorphEarlyEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerUnMorphEarlyEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; diff --git a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerUnMorphEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerUnMorphEvent.java similarity index 92% rename from src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerUnMorphEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerUnMorphEvent.java index 691e0e12..afe9456d 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/gameplay/PlayerUnMorphEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/gameplay/PlayerUnMorphEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.gameplay; +package xyz.nifeather.morph.api.v0.events.gameplay; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/AbilitiesFinishedInitializeEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/AbilitiesFinishedInitializeEvent.java similarity index 92% rename from src/main/java/xyz/nifeather/morph/events/api/lifecycle/AbilitiesFinishedInitializeEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/AbilitiesFinishedInitializeEvent.java index 54fef01f..02e8befe 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/AbilitiesFinishedInitializeEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/AbilitiesFinishedInitializeEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.lifecycle; +package xyz.nifeather.morph.api.v0.events.lifecycle; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/ConfigurationReloadEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/ConfigurationReloadEvent.java similarity index 93% rename from src/main/java/xyz/nifeather/morph/events/api/lifecycle/ConfigurationReloadEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/ConfigurationReloadEvent.java index adfdef60..b6d238e1 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/ConfigurationReloadEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/ConfigurationReloadEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.lifecycle; +package xyz.nifeather.morph.api.v0.events.lifecycle; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/ManagerFinishedInitializeEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/ManagerFinishedInitializeEvent.java similarity index 92% rename from src/main/java/xyz/nifeather/morph/events/api/lifecycle/ManagerFinishedInitializeEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/ManagerFinishedInitializeEvent.java index 65be2d8c..bbb1dc48 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/ManagerFinishedInitializeEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/ManagerFinishedInitializeEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.lifecycle; +package xyz.nifeather.morph.api.v0.events.lifecycle; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/SkillsFinishedInitializeEvent.java b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/SkillsFinishedInitializeEvent.java similarity index 92% rename from src/main/java/xyz/nifeather/morph/events/api/lifecycle/SkillsFinishedInitializeEvent.java rename to src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/SkillsFinishedInitializeEvent.java index eb32e077..dd09e43b 100644 --- a/src/main/java/xyz/nifeather/morph/events/api/lifecycle/SkillsFinishedInitializeEvent.java +++ b/src/main/java/xyz/nifeather/morph/api/v0/events/lifecycle/SkillsFinishedInitializeEvent.java @@ -1,4 +1,4 @@ -package xyz.nifeather.morph.events.api.lifecycle; +package xyz.nifeather.morph.api.v0.events.lifecycle; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/xyz/nifeather/morph/backends/DisguiseBackend.java b/src/main/java/xyz/nifeather/morph/backends/DisguiseBackend.java index c9e50da0..70c7a173 100644 --- a/src/main/java/xyz/nifeather/morph/backends/DisguiseBackend.java +++ b/src/main/java/xyz/nifeather/morph/backends/DisguiseBackend.java @@ -8,10 +8,11 @@ import org.jetbrains.annotations.Nullable; import xiamomc.pluginbase.Messages.FormattableMessage; import xyz.nifeather.morph.MorphPluginObject; +import xyz.nifeather.morph.api.v0.disguise.backends.IDisguiseBackend; import java.util.Collection; -public abstract class DisguiseBackend> extends MorphPluginObject +public abstract class DisguiseBackend> extends MorphPluginObject implements IDisguiseBackend { /** * Gets the identifier of this backend. diff --git a/src/main/java/xyz/nifeather/morph/backends/DisguiseWrapper.java b/src/main/java/xyz/nifeather/morph/backends/DisguiseWrapper.java index 9886e4b6..018847ea 100644 --- a/src/main/java/xyz/nifeather/morph/backends/DisguiseWrapper.java +++ b/src/main/java/xyz/nifeather/morph/backends/DisguiseWrapper.java @@ -15,6 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import xyz.nifeather.morph.MorphPlugin; +import xyz.nifeather.morph.api.v0.disguise.backends.IDisguiseWrapper; import xyz.nifeather.morph.misc.CollisionBoxRecord; import xyz.nifeather.morph.misc.DisguiseState; import xyz.nifeather.morph.misc.disguiseProperty.SingleProperty; @@ -29,7 +30,7 @@ * A wrapper that holds the underlying disguise instance * @param Type of the disguise instance */ -public abstract class DisguiseWrapper +public abstract class DisguiseWrapper implements IDisguiseWrapper { private static final Logger log = LoggerFactory.getLogger(DisguiseWrapper.class); protected TInstance instance; @@ -44,6 +45,7 @@ public DisguiseWrapper(@NotNull TInstance instance, DisguiseBackend> backend; + @Override public DisguiseBackend> getBackend() { return backend; diff --git a/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/ReloadSubCommand.java b/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/ReloadSubCommand.java index 43b051e7..d52f29be 100644 --- a/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/ReloadSubCommand.java +++ b/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/ReloadSubCommand.java @@ -10,7 +10,7 @@ import xyz.nifeather.morph.MorphManager; import xyz.nifeather.morph.MorphPluginObject; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.lifecycle.ConfigurationReloadEvent; +import xyz.nifeather.morph.api.v0.events.lifecycle.ConfigurationReloadEvent; import xyz.nifeather.morph.messages.CommandStrings; import xyz.nifeather.morph.messages.HelpStrings; import xyz.nifeather.morph.messages.MessageUtils; diff --git a/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/SkinCacheSubCommand.java b/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/SkinCacheSubCommand.java index 720ac9a6..f1ebfc85 100644 --- a/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/SkinCacheSubCommand.java +++ b/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/SkinCacheSubCommand.java @@ -25,7 +25,7 @@ import xyz.nifeather.morph.misc.CapeURL; import xyz.nifeather.morph.misc.DisguiseTypes; import xyz.nifeather.morph.misc.MorphGameProfile; -import xyz.nifeather.morph.misc.MorphParameters; +import xyz.nifeather.morph.api.v0.disguise.MorphParameters; import xyz.nifeather.morph.misc.permissions.CommonPermissions; import xyz.nifeather.morph.misc.skins.PlayerSkinProvider; diff --git a/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/management/ForceMorphSubCommand.java b/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/management/ForceMorphSubCommand.java index e93c17a4..6e373a2b 100644 --- a/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/management/ForceMorphSubCommand.java +++ b/src/main/java/xyz/nifeather/morph/commands/subcommands/plugin/management/ForceMorphSubCommand.java @@ -13,7 +13,7 @@ import xyz.nifeather.morph.messages.CommonStrings; import xyz.nifeather.morph.messages.HelpStrings; import xyz.nifeather.morph.messages.MessageUtils; -import xyz.nifeather.morph.misc.MorphParameters; +import xyz.nifeather.morph.api.v0.disguise.MorphParameters; import xyz.nifeather.morph.misc.permissions.CommonPermissions; import java.util.List; diff --git a/src/main/java/xyz/nifeather/morph/events/CommonEventProcessor.java b/src/main/java/xyz/nifeather/morph/events/CommonEventProcessor.java index 37411515..ca9c3e26 100644 --- a/src/main/java/xyz/nifeather/morph/events/CommonEventProcessor.java +++ b/src/main/java/xyz/nifeather/morph/events/CommonEventProcessor.java @@ -29,7 +29,7 @@ import xyz.nifeather.morph.abilities.impl.AttributeModifyingAbility; import xyz.nifeather.morph.config.ConfigOption; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.gameplay.PlayerJoinedWithDisguiseEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerJoinedWithDisguiseEvent; import xyz.nifeather.morph.messages.HintStrings; import xyz.nifeather.morph.messages.MessageUtils; import xyz.nifeather.morph.messages.MorphStrings; diff --git a/src/main/java/xyz/nifeather/morph/events/ForcedDisguiseProcessor.java b/src/main/java/xyz/nifeather/morph/events/ForcedDisguiseProcessor.java index 02e97d39..1bd6bcdc 100644 --- a/src/main/java/xyz/nifeather/morph/events/ForcedDisguiseProcessor.java +++ b/src/main/java/xyz/nifeather/morph/events/ForcedDisguiseProcessor.java @@ -12,9 +12,9 @@ import xyz.nifeather.morph.MorphPluginObject; import xyz.nifeather.morph.config.ConfigOption; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.gameplay.PlayerMorphEarlyEvent; -import xyz.nifeather.morph.events.api.gameplay.PlayerUnMorphEarlyEvent; -import xyz.nifeather.morph.misc.MorphParameters; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerMorphEarlyEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerUnMorphEarlyEvent; +import xyz.nifeather.morph.api.v0.disguise.MorphParameters; public class ForcedDisguiseProcessor extends MorphPluginObject implements Listener { diff --git a/src/main/java/xyz/nifeather/morph/events/InteractionMirrorProcessor.java b/src/main/java/xyz/nifeather/morph/events/InteractionMirrorProcessor.java index 92737503..a4ed9a3f 100644 --- a/src/main/java/xyz/nifeather/morph/events/InteractionMirrorProcessor.java +++ b/src/main/java/xyz/nifeather/morph/events/InteractionMirrorProcessor.java @@ -25,9 +25,9 @@ import xyz.nifeather.morph.MorphPluginObject; import xyz.nifeather.morph.config.ConfigOption; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.gameplay.PlayerJoinedWithDisguiseEvent; -import xyz.nifeather.morph.events.api.gameplay.PlayerMorphEvent; -import xyz.nifeather.morph.events.api.gameplay.PlayerUnMorphEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerJoinedWithDisguiseEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerMorphEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerUnMorphEvent; import xyz.nifeather.morph.misc.DisguiseState; import xyz.nifeather.morph.misc.DisguiseTypes; import xyz.nifeather.morph.misc.NmsRecord; diff --git a/src/main/java/xyz/nifeather/morph/events/RevealingEventProcessor.java b/src/main/java/xyz/nifeather/morph/events/RevealingEventProcessor.java index d0795fdf..bb366fa6 100644 --- a/src/main/java/xyz/nifeather/morph/events/RevealingEventProcessor.java +++ b/src/main/java/xyz/nifeather/morph/events/RevealingEventProcessor.java @@ -19,8 +19,8 @@ import xyz.nifeather.morph.RevealingHandler; import xyz.nifeather.morph.config.ConfigOption; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.gameplay.PlayerMorphEvent; -import xyz.nifeather.morph.events.api.gameplay.PlayerUnMorphEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerMorphEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerUnMorphEvent; import xyz.nifeather.morph.misc.DisguiseTypes; import xyz.nifeather.morph.misc.NmsRecord; diff --git a/src/main/java/xyz/nifeather/morph/misc/DisguiseState.java b/src/main/java/xyz/nifeather/morph/misc/DisguiseState.java index 35b3f1a0..7fe33dd5 100644 --- a/src/main/java/xyz/nifeather/morph/misc/DisguiseState.java +++ b/src/main/java/xyz/nifeather/morph/misc/DisguiseState.java @@ -11,7 +11,6 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import xiamomc.morph.network.PlayerOptions; @@ -23,8 +22,8 @@ import xyz.nifeather.morph.MorphManager; import xyz.nifeather.morph.MorphPluginObject; import xyz.nifeather.morph.abilities.AbilityUpdater; +import xyz.nifeather.morph.api.v0.disguise.IDisguiseState; import xyz.nifeather.morph.backends.DisguiseWrapper; -import xyz.nifeather.morph.backends.WrapperProperties; import xyz.nifeather.morph.messages.CommandStrings; import xyz.nifeather.morph.messages.EmoteStrings; import xyz.nifeather.morph.messages.MessageUtils; @@ -47,7 +46,7 @@ import static xyz.nifeather.morph.utilities.DisguiseUtils.itemOrAir; -public class DisguiseState extends MorphPluginObject +public class DisguiseState extends MorphPluginObject implements IDisguiseState { public DisguiseState(Player player, @NotNull String identifier, @NotNull String skillIdentifier, @NotNull DisguiseWrapper wrapper, @NotNull DisguiseProvider provider, @@ -283,6 +282,7 @@ public AnimationSequence getAnimationSequence() private Player cachedPlayer; @Nullable + @Override public Player tryGetPlayer() { // 如果缓存的玩家实例在线,那么返回缓存 @@ -314,6 +314,7 @@ public Player tryGetPlayer() * @throws NullDependencyException If the player was not found. For nullable method, check {@link DisguiseState#tryGetPlayer()} */ @NotNull + @Override public Player getPlayer() throws NullDependencyException { var player = tryGetPlayer(); @@ -338,6 +339,7 @@ public boolean isClientSideSelfViewing() return playerOptions.isClientSideSelfView(); } + @Override public boolean isSelfViewing() { return playerOptions.isClientSideSelfView() ? morphConfiguration.showDisguiseToSelf : serverSideSelfVisible; @@ -363,6 +365,7 @@ public void setServerSideSelfVisible(boolean val) * @apiNote 对于要显示到服务器公屏上的内容,请使用 {@link DisguiseState#getServerDisplay()} */ @NotNull + @Override public Component getPlayerDisplay() { return playerDisplay == null ? fallbackDisplay : playerDisplay; @@ -385,16 +388,19 @@ public void setPlayerDisplay(@NotNull Component newName) * @apiNote 对于要显示给玩家自己的内容,请使用 {@link DisguiseState#getPlayerDisplay()} */ @NotNull + @Override public Component getServerDisplay() { return serverDisplay == null ? fallbackDisplay : serverDisplay; } + @Override public void setServerDisplay(@NotNull Component newName) { serverDisplay = newName; } + @Override public void setCustomDisplayName(Component newName) { setPlayerDisplay(newName); diff --git a/src/main/java/xyz/nifeather/morph/misc/integrations/modelengine/ModelEngineHelper.java b/src/main/java/xyz/nifeather/morph/misc/integrations/modelengine/ModelEngineHelper.java index 329c947f..2c18d99d 100644 --- a/src/main/java/xyz/nifeather/morph/misc/integrations/modelengine/ModelEngineHelper.java +++ b/src/main/java/xyz/nifeather/morph/misc/integrations/modelengine/ModelEngineHelper.java @@ -4,7 +4,7 @@ import org.bukkit.event.Listener; import xyz.nifeather.morph.MorphPluginObject; import xyz.nifeather.morph.backends.modelengine.MEBackend; -import xyz.nifeather.morph.events.api.lifecycle.ManagerFinishedInitializeEvent; +import xyz.nifeather.morph.api.v0.events.lifecycle.ManagerFinishedInitializeEvent; import xyz.nifeather.morph.providers.disguise.ModelEngineProvider; public class ModelEngineHelper extends MorphPluginObject implements Listener @@ -28,7 +28,7 @@ public void onInitDone(ManagerFinishedInitializeEvent e) try { - manager.registerProvider(new ModelEngineProvider()); + manager.registerDisguiseProvider(new ModelEngineProvider()); } catch (Throwable t) { diff --git a/src/main/java/xyz/nifeather/morph/misc/integrations/towny/TownyAdapter.java b/src/main/java/xyz/nifeather/morph/misc/integrations/towny/TownyAdapter.java index 268401df..4f8448f8 100644 --- a/src/main/java/xyz/nifeather/morph/misc/integrations/towny/TownyAdapter.java +++ b/src/main/java/xyz/nifeather/morph/misc/integrations/towny/TownyAdapter.java @@ -26,13 +26,9 @@ import xiamomc.pluginbase.Bindables.Bindable; import xiamomc.pluginbase.Command.IPluginCommand; import xyz.nifeather.morph.MorphPluginObject; -import xyz.nifeather.morph.abilities.AbilityType; import xyz.nifeather.morph.abilities.impl.FlyAbility; import xyz.nifeather.morph.config.ConfigOption; import xyz.nifeather.morph.config.MorphConfigManager; -import xyz.nifeather.morph.events.api.gameplay.PlayerMorphEvent; -import xyz.nifeather.morph.events.api.gameplay.PlayerUnMorphEvent; -import xyz.nifeather.morph.misc.NmsRecord; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/xyz/nifeather/morph/skills/MorphSkillHandler.java b/src/main/java/xyz/nifeather/morph/skills/MorphSkillHandler.java index badf7e72..5466c682 100644 --- a/src/main/java/xyz/nifeather/morph/skills/MorphSkillHandler.java +++ b/src/main/java/xyz/nifeather/morph/skills/MorphSkillHandler.java @@ -18,16 +18,14 @@ import xiamomc.pluginbase.Annotations.Resolved; import xyz.nifeather.morph.MorphManager; import xyz.nifeather.morph.MorphPluginObject; -import xyz.nifeather.morph.events.api.gameplay.PlayerExecuteSkillEvent; -import xyz.nifeather.morph.events.api.lifecycle.SkillsFinishedInitializeEvent; +import xyz.nifeather.morph.api.v0.events.gameplay.PlayerExecuteSkillEvent; +import xyz.nifeather.morph.api.v0.events.lifecycle.SkillsFinishedInitializeEvent; import xyz.nifeather.morph.messages.CommandStrings; import xyz.nifeather.morph.messages.MessageUtils; import xyz.nifeather.morph.messages.MorphStrings; import xyz.nifeather.morph.messages.SkillStrings; import xyz.nifeather.morph.misc.permissions.CommonPermissions; -import xyz.nifeather.morph.providers.disguise.DefaultDisguiseProvider; import xyz.nifeather.morph.skills.impl.*; -import xyz.nifeather.morph.storage.skill.ISkillOption; import xyz.nifeather.morph.storage.skill.SkillAbilityConfiguration; import xyz.nifeather.morph.storage.skill.SkillsConfigurationStoreNew; import xyz.nifeather.morph.utilities.PermissionUtils;