Skip to content

Commit

Permalink
Merge branch '1.21.1' into 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 8, 2024
2 parents 48d295b + bfbd1ba commit b45b55d
Show file tree
Hide file tree
Showing 35 changed files with 1,195 additions and 228 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ bukkit {
permissionRoot + "lookup",
permissionRoot + "skin_cache",
permissionRoot + "switch_backend",
permissionRoot + "make_disguise_tool",

permissionRoot + "mirror.immune",

Expand Down
27 changes: 2 additions & 25 deletions src/main/java/xiamomc/morph/MorphManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ private void tryBackends()

//endregion Backends

private Material actionItem;
@Deprecated(forRemoval = true)
public Material getActionItem()
{
return actionItem;
return Material.AIR;
}

@Resolved
Expand Down Expand Up @@ -251,18 +251,6 @@ private void load()
fallbackProvider
));

var actionItemId = config.getBindable(String.class, ConfigOption.SKILL_ITEM);
actionItemId.onValueChanged((o, n) ->
{
var item = Material.matchMaterial(n);
var disabled = "disabled";

if (item == null && !disabled.equals(n))
logger.warn("Cannot find any item that matches \"" + n + "\" to set for the skill item, some related features may not work!");

actionItem = item;
}, true);

Bukkit.getPluginManager().callEvent(new ManagerFinishedInitializeEvent(this));
}

Expand Down Expand Up @@ -1106,17 +1094,6 @@ private void afterDisguise(DisguiseBuildResult result,
}
else
{
if (!playerOptions.shownServerSkillHint && actionItem != null)
{
var locale = MessageUtils.getLocale(player);
var skillHintMessage = HintStrings.skillString()
.withLocale(locale)
.resolve("item", vanillaMessageStore.get(actionItem.translationKey(), "???", locale));

player.sendMessage(MessageUtils.prefixes(player, skillHintMessage));
playerOptions.shownServerSkillHint = true;
}

if (clientHandler.clientInitialized(player) && !playerOptions.shownDisplayToSelfHint)
{
player.sendMessage(MessageUtils.prefixes(player, HintStrings.morphVisibleAfterCommandString()));
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/xiamomc/morph/MorphPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import xiamomc.morph.messages.vanilla.VanillaMessageStore;
import xiamomc.morph.misc.NetworkingHelper;
import xiamomc.morph.misc.PlayerOperationSimulator;
import xiamomc.morph.misc.recipe.RecipeManager;
import xiamomc.morph.misc.disguiseProperty.DisguiseProperties;
import xiamomc.morph.misc.gui.IconLookup;
import xiamomc.morph.misc.integrations.modelengine.ModelEngineHelper;
Expand Down Expand Up @@ -230,6 +231,8 @@ public void onEnable()

dependencyManager.cache(DisguiseProperties.INSTANCE);

dependencyManager.cache(new RecipeManager());

mirrorProcessor = new InteractionMirrorProcessor();

//注册EventProcessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public List<PacketContainer> buildSpawnPackets(DisplayParameters parameters)

List<PacketContainer> packets = new ObjectArrayList<>();

if (watcher.readEntryOrDefault(CustomEntries.VANISHED, false))
return packets;

//logger.info("Build spawn packets, player is " + player.getName() + " :: parameters are " + parameters);

var disguiseEntityType = watcher.getEntityType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import xiamomc.morph.misc.NmsRecord;
import xiamomc.morph.misc.AnimationNames;

import java.util.concurrent.atomic.AtomicBoolean;

public class WardenWatcher extends EHasAttackAnimationWatcher
{
public WardenWatcher(Player bindingPlayer)
{
super(bindingPlayer, EntityType.WARDEN);
}

private final Pose DIG_PLACEHOLDER_POSE = Pose.SLEEPING;

@Override
protected <X> void onEntryWrite(RegistryKey<X> key, X oldVal, X newVal)
{
Expand All @@ -48,20 +48,20 @@ protected <X> void onEntryWrite(RegistryKey<X> key, X oldVal, X newVal)
{
case AnimationNames.ROAR ->
{
if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return;
if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return;

this.block(ValueIndex.BASE_LIVING.POSE);
this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.ROARING);
}
case AnimationNames.ROAR_SOUND ->
{
if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return;
if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return;

world.playSound(bindingPlayer.getLocation(), Sound.ENTITY_WARDEN_ROAR, SoundCategory.HOSTILE, 3, 1);
}
case AnimationNames.SNIFF ->
{
if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return;
if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return;

this.block(ValueIndex.BASE_LIVING.POSE);
this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.SNIFFING);
Expand All @@ -70,20 +70,21 @@ protected <X> void onEntryWrite(RegistryKey<X> key, X oldVal, X newVal)
}
case AnimationNames.DIGDOWN ->
{
if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return;
if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return;

this.block(ValueIndex.BASE_LIVING.POSE);
this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.DIGGING);
world.playSound(bindingPlayer.getLocation(), Sound.ENTITY_WARDEN_DIG, 5, 1);
}
case AnimationNames.VANISH ->
{
this.writePersistent(ValueIndex.BASE_LIVING.POSE, DIG_PLACEHOLDER_POSE);
this.writePersistent(ValueIndex.BASE_ENTITY.GENERAL, (byte)0x20);
this.writePersistent(ValueIndex.BASE_LIVING.SILENT, true);
this.writeEntry(CustomEntries.VANISHED, true);
}
case AnimationNames.APPEAR ->
{
this.writeEntry(CustomEntries.VANISHED, false);
this.block(ValueIndex.BASE_LIVING.POSE);
this.remove(ValueIndex.BASE_ENTITY.GENERAL);
this.writePersistent(ValueIndex.BASE_LIVING.POSE, Pose.EMERGING);
Expand All @@ -102,7 +103,9 @@ protected <X> void onEntryWrite(RegistryKey<X> key, X oldVal, X newVal)
}
case AnimationNames.TRY_RESET ->
{
if (this.read(ValueIndex.BASE_LIVING.POSE) == DIG_PLACEHOLDER_POSE) return;
// 如果当前已消失,则不要调用重置
// 因为重置会将一些动作数据重新同步为玩家的数据
if (this.readEntryOrDefault(CustomEntries.VANISHED, false)) return;

reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class CustomEntries

public static final RegistryKey<UUID> SPAWN_UUID = RegistryKey.of("spawn_uuid", Util.NIL_UUID);
public static final RegistryKey<Integer> SPAWN_ID = RegistryKey.of("spawn_id", -1);

public static final RegistryKey<Boolean> VANISHED = RegistryKey.of("vanished", false);
}
14 changes: 9 additions & 5 deletions src/main/java/xiamomc/morph/commands/AnimationCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import xiamomc.morph.messages.EmoteStrings;
import xiamomc.morph.messages.HelpStrings;
import xiamomc.morph.messages.MessageUtils;
import xiamomc.morph.misc.gui.AnimSelectScreenWrapper;
import xiamomc.pluginbase.Annotations.Resolved;
import xiamomc.pluginbase.Command.IPluginCommand;
import xiamomc.pluginbase.Messages.FormattableMessage;
Expand Down Expand Up @@ -66,18 +67,21 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
return true;
}

var animationSet = state.getProvider()
.getAnimationProvider()
.getAnimationSetFor(state.getDisguiseIdentifier());

if (args.length == 0)
{
player.sendMessage(MessageUtils.prefixes(player, CommandStrings.listNoEnoughArguments()));
var screen = new AnimSelectScreenWrapper(state, animationSet.getAvailableAnimationsForClient());
screen.show();

//player.sendMessage(MessageUtils.prefixes(player, CommandStrings.listNoEnoughArguments()));
return true;
}

var animationId = args[0];

var animationSet = state.getProvider()
.getAnimationProvider()
.getAnimationSetFor(state.getDisguiseIdentifier());

var animations = animationSet.getAvailableAnimationsForClient();

if (!animations.contains(animationId))
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/xiamomc/morph/commands/MorphPluginCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public FormattableMessage getHelpMessage()
new StatSubCommand(),
new CheckUpdateSubCommand(),
new LookupSubCommand(),
new SkinCacheSubCommand()
new SkinCacheSubCommand(),
new MakeSkillItemSubCommand()
//new BackendSubCommand()
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package xiamomc.morph.commands.subcommands.plugin;

import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xiamomc.morph.MorphPluginObject;
import xiamomc.morph.messages.CommandStrings;
import xiamomc.morph.messages.MessageUtils;
import xiamomc.morph.misc.permissions.CommonPermissions;
import xiamomc.morph.utilities.ItemUtils;
import xiamomc.pluginbase.Command.ISubCommand;
import xiamomc.pluginbase.Messages.FormattableMessage;

import java.util.List;

public class MakeSkillItemSubCommand extends MorphPluginObject implements ISubCommand
{
@Override
public @NotNull String getCommandName()
{
return "make_disguise_tool";
}

@Override
public @Nullable String getPermissionRequirement()
{
return CommonPermissions.MAKE_DISGUISE_TOOL;
}

@Override
public FormattableMessage getHelpMessage()
{
return new FormattableMessage(plugin, "make selected a disguise tool");
}

private final List<String> emptyList = List.of();

@Override
public @Nullable List<String> onTabComplete(List<String> args, CommandSender source)
{
return emptyList;
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull String[] args)
{
if (!(sender instanceof Player player))
{
sender.sendMessage(MessageUtils.prefixes(sender, CommandStrings.noPermissionMessage()));
return true;
}

var item = player.getEquipment().getItemInMainHand();
if (item.isEmpty() || item.getType().isAir())
{
sender.sendMessage(MessageUtils.prefixes(sender, CommandStrings.illegalArgumentString().resolve("detail", "air... :(")));
return true;
}

item = ItemUtils.buildSkillItemFrom(item);
player.getEquipment().setItemInMainHand(item);

sender.sendMessage(MessageUtils.prefixes(sender, CommandStrings.success()));

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import xiamomc.morph.messages.MessageUtils;
import xiamomc.morph.messages.MorphMessageStore;
import xiamomc.morph.messages.vanilla.VanillaMessageStore;
import xiamomc.morph.misc.recipe.RecipeManager;
import xiamomc.morph.misc.skins.PlayerSkinProvider;
import xiamomc.morph.network.multiInstance.MultiInstanceService;
import xiamomc.morph.network.server.MorphClientHandler;
Expand Down Expand Up @@ -62,6 +63,9 @@ public FormattableMessage getHelpMessage()
@Resolved
private MultiInstanceService multiInstanceService;

@Resolved
private RecipeManager recipeManager;

private final List<String> subcommands = ObjectImmutableList.of("data", "message", "update_message");

@Override
Expand Down Expand Up @@ -103,6 +107,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull String[] args)
PlayerSkinProvider.getInstance().reload();

multiInstanceService.onReload();

recipeManager.reload();
}

if (reloadsMessage)
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/xiamomc/morph/config/ConfigOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import xiamomc.pluginbase.Configuration.ConfigNode;

import java.util.ArrayList;
import java.util.HashMap;

public enum ConfigOption
{
Expand All @@ -19,16 +20,21 @@ public enum ConfigOption

SKILL_COOLDOWN_ON_DAMAGE(ConfigNode.create().append("cooldown_on_damage"), 15),

@Deprecated
@Deprecated(forRemoval = true)
ACTION_ITEM(ConfigNode.create().append("action_item"), "", true),
SKILL_ITEM(ConfigNode.create().append("skill_item"), "minecraft:feather"),

@Deprecated(forRemoval = true, since = "1.3.0")
SKILL_ITEM(ConfigNode.create().append("skill_item"), "", true),

//@Deprecated(forRemoval = true)
//SKILL_ITEM_USE_COMPONENT(ConfigNode.create().append("skill_item_use_component_detection"), true, true),

ARMORSTAND_SHOW_ARMS(ConfigNode.create().append("armorstand_show_arms"), true),

MODIFY_BOUNDING_BOX(boundingBoxNode().append("modify_boxes"), false),
CHECK_AVAILABLE_SPACE(boundingBoxNode().append("check_space"), true),

@Deprecated
@Deprecated(forRemoval = true)
MODIFY_BOUNDING_BOX_LEGACY(ConfigNode.create().append("modify_bounding_boxes"), false, true),

UNMORPH_ON_DEATH(ConfigNode.create().append("unmorph_on_death"), true),
Expand Down Expand Up @@ -70,7 +76,7 @@ public enum ConfigOption
FLYABILITY_DISALLOW_FLY_IN_WATER(flyAbilityNode().append("disallow_in_water"), new ArrayList<String>()),
FLYABILITY_DISALLOW_FLY_IN_LAVA(flyAbilityNode().append("disallow_in_lava"), new ArrayList<String>()),

@Deprecated(since = "1.2.2")
@Deprecated(since = "1.2.2", forRemoval = true)
FLYABILITY_NO_LIQUID(flyAbilityNode().append("no_fly_in_liquid"), true, true),

LANGUAGE_CODE(languageNode().append("code"), "en_us"),
Expand Down Expand Up @@ -112,11 +118,14 @@ public enum ConfigOption

GUI_PATTERN(ConfigNode.create().append("gui_pattern"), new ArrayList<String>()),

//ANIM_SELECT_PATTERN(ConfigNode.create().append("anim_select_pattern"), new ArrayList<String>()),

HIDE_DISGUISED_PLAYERS_IN_TAB(ConfigNode.create().append("hide_disguised_players_in_tab"), false),

// SRR -> ServerRenderer
SR_SHOW_PLAYER_DISGUISES_IN_TAB(serverRendererNode().append("show_player_disguises_in_tab"), false),


VERSION(ConfigNode.create().append("version"), 0);

public final ConfigNode node;
Expand Down
Loading

0 comments on commit b45b55d

Please sign in to comment.