Skip to content

Commit

Permalink
misc: Initial Folia support? I'm not sure
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 22, 2023
1 parent f8a98a6 commit 5cd3303
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/main/java/xiamomc/morph/MorphPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,16 @@ public boolean acceptSchedules()
{
return true;
}

@Override
public void startMainLoop(Runnable r)
{
Bukkit.getGlobalRegionScheduler().runAtFixedRate(this, o -> r.run(), 1, 1);
}

@Override
public void runAsync(Runnable r)
{
Bukkit.getAsyncScheduler().runNow(this, o -> r.run());
}
}
12 changes: 12 additions & 0 deletions src/main/java/xiamomc/morph/MorphPluginObject.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package xiamomc.morph;

import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import xiamomc.pluginbase.PluginObject;

public class MorphPluginObject extends PluginObject<MorphPlugin>
Expand All @@ -9,4 +11,14 @@ protected String getPluginNamespace()
{
return MorphPlugin.getMorphNameSpace();
}

protected void scheduleOn(Entity entity, Runnable r)
{
entity.getScheduler().execute(plugin, r, null, 1);
}

protected void scheduleWorld(Entity entity, Runnable r)
{
Bukkit.getRegionScheduler().execute(plugin, entity.getLocation(), r);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xiamomc.morph.MorphManager;
import xiamomc.morph.RevealingHandler;
import xiamomc.morph.abilities.AbilityHandler;
import xiamomc.morph.backends.DisguiseBackend;
Expand All @@ -24,6 +25,7 @@
import xiamomc.morph.network.server.ServerSetEquipCommand;
import xiamomc.morph.skills.MorphSkillHandler;
import xiamomc.morph.skills.SkillType;
import xiamomc.pluginbase.Annotations.Initializer;
import xiamomc.pluginbase.Annotations.Resolved;
import xiamomc.pluginbase.Messages.MessageStore;
import xiamomc.pluginbase.Utilities.ColorUtils;
Expand Down Expand Up @@ -152,7 +154,7 @@ private void addIfPresents(EntityEquipment equipment, ObjectArrayList<AbstractS2
public void postConstructDisguise(DisguiseState state, @Nullable Entity targetEntity)
{
var disguise = state.getDisguiseWrapper();
var backend = getMorphManager().getCurrentBackend();
var backend = getBackend();

//被动技能
var abilities = abilityHandler.getAbilitiesFor(state.getSkillLookupIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ public int executeSkill(Player player, DisguiseState state, SkillAbilityConfigur
playSoundToNearbyPlayers(player, 10,
Key.key("minecraft", "entity.enderman.teleport"), Sound.Source.HOSTILE);

player.teleport(loc);

playSoundToNearbyPlayers(player, 10,
Key.key("minecraft", "entity.enderman.teleport"), Sound.Source.HOSTILE);
player.teleportAsync(loc).thenRun(() ->
{
playSoundToNearbyPlayers(player, 10,
Key.key("minecraft", "entity.enderman.teleport"), Sound.Source.HOSTILE);
});

//重设下落距离
player.setFallDistance(0);
Expand Down

0 comments on commit 5cd3303

Please sign in to comment.