Skip to content

Commit

Permalink
add: recipe!
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 8, 2024
1 parent 309cc28 commit 1ac69bc
Show file tree
Hide file tree
Showing 9 changed files with 515 additions and 34 deletions.
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 @@ -231,6 +232,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 @@ -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
2 changes: 2 additions & 0 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 Down Expand Up @@ -124,6 +125,7 @@ public enum ConfigOption
// 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
62 changes: 28 additions & 34 deletions src/main/java/xiamomc/morph/events/CommonEventProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.destroystokyo.paper.event.player.PlayerClientOptionsChangeEvent;
import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
Expand All @@ -16,10 +14,7 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.*;
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.checkerframework.checker.units.qual.A;
import org.bukkit.inventory.*;
import xiamomc.morph.MorphManager;
import xiamomc.morph.MorphPluginObject;
import xiamomc.morph.RevealingHandler;
Expand All @@ -30,7 +25,6 @@
import xiamomc.morph.messages.HintStrings;
import xiamomc.morph.messages.MessageUtils;
import xiamomc.morph.messages.MorphStrings;
import xiamomc.morph.messages.SkillStrings;
import xiamomc.morph.messages.vanilla.VanillaMessageStore;
import xiamomc.morph.misc.DisguiseTypes;
import xiamomc.morph.misc.OfflineDisguiseResult;
Expand Down Expand Up @@ -73,6 +67,33 @@ public class CommonEventProcessor extends MorphPluginObject implements Listener

private Bindable<Boolean> unMorphOnDeath;

private final Bindable<Boolean> doRevealing = new Bindable<>(true);

private final Bindable<Boolean> allowAcquireMorphs = new Bindable<>(false);

@Initializer
private void load()
{
config.bind(cooldownOnDamage, ConfigOption.SKILL_COOLDOWN_ON_DAMAGE);
config.bind(bruteIgnoreDisguises, ConfigOption.PIGLIN_BRUTE_IGNORE_DISGUISES);
config.bind(doRevealing, ConfigOption.REVEALING);
config.bind(allowAcquireMorphs, ConfigOption.ALLOW_ACQUIRE_MORPHS);

unMorphOnDeath = config.getBindable(Boolean.class, ConfigOption.UNMORPH_ON_DEATH);
this.addSchedule(this::update);
}

private void update()
{
this.addSchedule(this::update);

if (plugin.getCurrentTick() % 8 == 0)
{
playersMinedGoldBlocks.clear();
susIncreasedPlayers.clear();
}
}

@EventHandler
public void onEntityDeath(EntityDeathEvent e)
{
Expand Down Expand Up @@ -143,33 +164,6 @@ public void onPlayerTookDamage(EntityDamageEvent e)
}
}

private final Bindable<Boolean> doRevealing = new Bindable<>(true);

private final Bindable<Boolean> allowAcquireMorphs = new Bindable<>(false);

@Initializer
private void load()
{
config.bind(cooldownOnDamage, ConfigOption.SKILL_COOLDOWN_ON_DAMAGE);
config.bind(bruteIgnoreDisguises, ConfigOption.PIGLIN_BRUTE_IGNORE_DISGUISES);
config.bind(doRevealing, ConfigOption.REVEALING);
config.bind(allowAcquireMorphs, ConfigOption.ALLOW_ACQUIRE_MORPHS);

unMorphOnDeath = config.getBindable(Boolean.class, ConfigOption.UNMORPH_ON_DEATH);
this.addSchedule(this::update);
}

private void update()
{
this.addSchedule(this::update);

if (plugin.getCurrentTick() % 8 == 0)
{
playersMinedGoldBlocks.clear();
susIncreasedPlayers.clear();
}
}

@EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent e)
{
Expand Down
Loading

0 comments on commit 1ac69bc

Please sign in to comment.