Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed Aug 26, 2023
2 parents dd339c2 + c34230a commit 3e26eca
Show file tree
Hide file tree
Showing 77 changed files with 257 additions and 197 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
#### Classic Maintainer
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)

#### Folia Inquisitors
[<img src="https://github.com/HSGamer.png" width=80 alt="HSGamer">](https://github.com/HSGamer)
[<img src="https://github.com/TechnicallyCoded.png" width=80 alt="TechnicallyCoded">](https://github.com/TechnicallyCoded)
[<img src="https://github.com/Yomamaeatstoes.png" width=80 alt="Yomamaeatstoes">](https://github.com/Yomamaeatstoes)
[<img src="https://github.com/Rockyers.png" width=80 alt="Rockyers">](https://github.com/Rockyers)

## Former Team Members

### Former Lead & Awesome guy
Expand Down
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
<include>co.aikar:acf-bukkit</include>
<include>com.tcoded:FoliaLib</include>
</includes>
</artifactSet>
<relocations>
Expand Down Expand Up @@ -189,6 +190,10 @@
<pattern>org.bstats</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.folialib</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down Expand Up @@ -245,6 +250,10 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>devmart-other</id>
<url>https://nexuslite.gcnt.net/repos/other/</url>
</repository>
<!-- ... -->
<!-- ... -->
</repositories>
Expand Down Expand Up @@ -372,5 +381,11 @@
<version>32.1.1-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.tcoded</groupId>
<artifactId>FoliaLib</artifactId>
<version>0.3.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
mcMMO.getDatabaseManager().saveUser(profile);
}

new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}

new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()));
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
UserManager.saveAll();
UserManager.clearAll();

new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
mcMMO.p.getFoliaLib().getImpl().runLater(new FormulaConversionTask(sender, newType), 1);

for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ protected static void handleTeleportWarmup(Player teleportingPlayer, Player targ

if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(teleportingPlayer, new TeleportationWarmup(mcMMOPlayer, mcMMOTarget), 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void display(CommandSender sender, String playerName) {
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();

new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new McrankCommandAsyncTask(playerName, sender, useBoard, useChat));
}

private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();

new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat));
}

private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -1356,7 +1355,7 @@ private void checkUpgradeAddUUIDs(final Statement statement) {
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD `uuid` varchar(36) NULL DEFAULT NULL");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD UNIQUE INDEX `uuid` (`uuid`) USING BTREE");

new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new GetUUIDUpdatesRequired(), 100); // wait until after first purge
}

mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
Expand All @@ -1369,7 +1368,7 @@ private void checkUpgradeAddUUIDs(final Statement statement) {
}
}

private class GetUUIDUpdatesRequired extends BukkitRunnable {
private class GetUUIDUpdatesRequired implements Runnable {
public void run() {
massUpdateLock.lock();
List<String> names = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ public void checkAbilityActivation(PrimarySkillType primarySkillType) {
}

setToolPreparationMode(tool, false);
new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, (long) ticks * Misc.TICK_CONVERSION_FACTOR);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityDisableTask(this, superAbilityType), (long) ticks * Misc.TICK_CONVERSION_FACTOR);
}

public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
Expand Down Expand Up @@ -1013,7 +1013,7 @@ public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType)
}

setToolPreparationMode(tool, true);
new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ToolLowerTask(this, tool), 4 * Misc.TICK_CONVERSION_FACTOR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, Map<Primar
}

public void scheduleAsyncSave() {
new PlayerProfileSaveTask(this, false).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new PlayerProfileSaveTask(this, false));
}

public void scheduleAsyncSaveDelay() {
new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(mcMMO.p, 20);
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileSaveTask(this, false), 20);
}

@Deprecated
public void scheduleSyncSaveDelay() {
new PlayerProfileSaveTask(this, true).runTaskLater(mcMMO.p, 20);
mcMMO.p.getFoliaLib().getImpl().runLater(new PlayerProfileSaveTask(this, true), 20);
}

public void save(boolean useSync) {
Expand All @@ -138,7 +138,7 @@ public void save(boolean useSync) {

//Back out of async saving if we detect a server shutdown, this is not always going to be caught
if(mcMMO.isServerShutdownExecuted() || useSync)
new PlayerProfileSaveTask(this, true).runTask(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runNextTick(new PlayerProfileSaveTask(this, true));
else
scheduleAsyncSave();

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/gmail/nossr50/listeners/BlockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ public void onBlockPistonExtend(BlockPistonExtendEvent event) {

final BlockFace direction = event.getDirection();

Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
for (final Block block : event.getBlocks()) {
final Block movedBlock = block.getRelative(direction);
mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), t -> {
final Block movedBlock = block.getRelative(direction);

if(BlockUtils.isWithinWorldBounds(movedBlock)) {
BlockUtils.setUnnaturalBlock(movedBlock);
}
}});
if (BlockUtils.isWithinWorldBounds(movedBlock)) {
BlockUtils.setUnnaturalBlock(movedBlock);
}
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {

entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
TravelingBlockMetaCleanup metaCleanupTask = new TravelingBlockMetaCleanup(entity, pluginRef);
metaCleanupTask.runTaskTimer(pluginRef, 20, 20*60); //6000 ticks is 5 minutes
mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(entity, metaCleanupTask, 20, 20*60); //6000 ticks is 5 minutes
}
else if (isTracked) {
BlockUtils.setUnnaturalBlock(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public void onCraftItem(CraftItemEvent event) {
return;
}

new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
mcMMO.p.getFoliaLib().getImpl().runAtEntity(whoClicked, new PlayerUpdateInventoryTask((Player) whoClicked));
}

}
10 changes: 2 additions & 8 deletions src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.Locale;

Expand Down Expand Up @@ -149,12 +148,7 @@ else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDama
new MobHealthDisplayUpdaterTask(attacker).run();

// set the name back
new BukkitRunnable() {
@Override
public void run() {
MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p);
}
}.runTaskLater(mcMMO.p, 1);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(attacker, () -> MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p), 1);
}

/**
Expand Down Expand Up @@ -595,7 +589,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();

//Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60);
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 60);

if (mcMMO.p.getGeneralConfig().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gmail/nossr50/listeners/WorldListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -30,7 +29,8 @@ public void onStructureGrow(StructureGrowEvent event) {
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;

Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
// Using 50 ms later as I do not know of a way to run one tick later (safely)
plugin.getFoliaLib().getImpl().runLater(() -> {
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
Expand Down
Loading

0 comments on commit 3e26eca

Please sign in to comment.