mcMMO-Folia-PR (#4925)

Folia Support

---------

Co-authored-by: Rockyers <ethan@yocom.org>
Co-authored-by: TechnicallyCoded <technicallycoded@gmail.com>
Co-authored-by: HSGamer <huynhqtienvtag@gmail.com>
This commit is contained in:
Yomamaeatstoes
2023-08-26 19:16:18 -04:00
committed by GitHub
parent 192626f4da
commit c34230a82e
77 changed files with 257 additions and 197 deletions

View File

@@ -113,7 +113,7 @@ public class AcrobaticsManager extends SkillManager {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob, mcMMO.p);
metaCleanupTask.runTaskTimer(mcMMO.p, 20, 20*60); //one minute
mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(mob, metaCleanupTask, 20, 20*60); //one minute
}
} else {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);

View File

@@ -259,13 +259,13 @@ public final class AlchemyPotionBrewer {
}
public static void scheduleCheck(Player player, BrewingStand brewingStand) {
new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, new AlchemyBrewCheckTask(player, brewingStand));
}
public static void scheduleUpdate(Inventory inventory) {
for (HumanEntity humanEntity : inventory.getViewers()) {
if (humanEntity instanceof Player) {
new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAtEntity(humanEntity, new PlayerUpdateInventoryTask((Player) humanEntity));
}
}
}

View File

@@ -96,7 +96,8 @@ public class ArcheryManager extends SkillManager {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
defender.teleport(dazedLocation);
// defender.teleport(dazedLocation);
mcMMO.p.getFoliaLib().getImpl().teleportAsync(defender, dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));

View File

@@ -1,12 +1,12 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID;
public class TrackedEntity extends BukkitRunnable {
public class TrackedEntity extends CancellableRunnable {
private final LivingEntity livingEntity;
private final UUID id;
private int arrowCount;
@@ -15,7 +15,7 @@ public class TrackedEntity extends BukkitRunnable {
this.livingEntity = livingEntity;
this.id = livingEntity.getUniqueId();
this.runTaskTimer(mcMMO.p, 12000, 12000);
mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(livingEntity, this, 12000, 12000);
}
@Override

View File

@@ -244,7 +244,7 @@ public class FishingManager extends SkillManager {
}
public void masterAngler(@NotNull FishHook hook, int lureLevel) {
new MasterAnglerTask(hook, this, lureLevel).runTaskLater(mcMMO.p, 0); //We run later to get the lure bonus applied
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(hook, new MasterAnglerTask(hook, this, lureLevel), 1); //We run later to get the lure bonus applied
}
/**

View File

@@ -39,7 +39,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -107,12 +106,12 @@ public class HerbalismManager extends SkillManager {
}
CheckBushAge checkBushAge = new CheckBushAge(blockState.getBlock(), mmoPlayer, xpReward);
checkBushAge.runTaskLater(mcMMO.p, 1);
mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockState.getLocation(), checkBushAge, 1);
}
}
}
private class CheckBushAge extends BukkitRunnable {
private class CheckBushAge extends CancellableRunnable {
@NotNull Block block;
@NotNull McMMOPlayer mmoPlayer;
@@ -311,7 +310,7 @@ public class HerbalismManager extends SkillManager {
DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mmoPlayer, delayedChorusBlocks);
//Large delay because the tree takes a while to break
delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 0); //Calculate Chorus XP + Bonus Drops 1 tick later
mcMMO.p.getFoliaLib().getImpl().runAtEntity(mmoPlayer.getPlayer(), delayedHerbalismXPCheckTask); //Calculate Chorus XP + Bonus Drops 1 tick later
}
}
@@ -742,7 +741,7 @@ public class HerbalismManager extends SkillManager {
*/
private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) {
//Mark the plant as recently replanted to avoid accidental breakage
new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(mcMMO.p, 20 * 2);
mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockBreakEvent.getBlock().getLocation(), new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature), 2 * Misc.TICK_CONVERSION_FACTOR);
blockBreakEvent.getBlock().setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, true));
}

View File

@@ -130,7 +130,7 @@ public class MiningManager extends SkillManager {
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
mmoPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mmoPlayer.getPlayer(), new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING), (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
}
/**

View File

@@ -95,7 +95,7 @@ public class SwordsManager extends SkillManager {
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(mmoPlayer.getPlayer(), ruptureTask, 0, 1);
target.setMetadata(MetadataConstants.METADATA_KEY_RUPTURE, ruptureTaskMeta);
// if (mmoPlayer.useChatNotifications()) {

View File

@@ -2,13 +2,13 @@ package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
public class TrackedTamingEntity extends BukkitRunnable {
public class TrackedTamingEntity extends CancellableRunnable {
private final @NotNull LivingEntity livingEntity;
private final @NotNull CallOfTheWildType callOfTheWildType;
private final @NotNull Player player;
@@ -22,7 +22,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
if (tamingCOTWLength > 0) {
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
this.runTaskLater(mcMMO.p, length);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(livingEntity, this, length);
}
}