forked from APDevTeam/Movecraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'APDevTeam:main' into main
- Loading branch information
Showing
31 changed files
with
518 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Movecraft/src/main/java/net/countercraft/movecraft/features/fading/FadeTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.countercraft.movecraft.features.fading; | ||
|
||
import net.countercraft.movecraft.MovecraftLocation; | ||
import net.countercraft.movecraft.processing.MovecraftWorld; | ||
import net.countercraft.movecraft.processing.WorldManager; | ||
import net.countercraft.movecraft.processing.effects.Effect; | ||
import net.countercraft.movecraft.processing.effects.SetBlockEffect; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.block.data.BlockData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Fades a block if the data for the intended block has not been mutated since creation. | ||
*/ | ||
public class FadeTask implements Supplier<Effect> { | ||
private final @NotNull BlockData compareData; | ||
private final @NotNull BlockData setData; | ||
private final @NotNull MovecraftWorld world; | ||
private final @NotNull MovecraftLocation location; | ||
|
||
public FadeTask(@NotNull BlockData compareData, @NotNull BlockData setData, @NotNull MovecraftWorld world, @NotNull MovecraftLocation location){ | ||
this.compareData = compareData; | ||
this.setData = setData; | ||
this.world = world; | ||
this.location = location; | ||
} | ||
|
||
@Override | ||
public Effect get() { | ||
var testData = world.getData(location); | ||
|
||
return () -> Objects.requireNonNull(Bukkit.getWorld(world.getWorldUUID())) | ||
.getChunkAtAsync(location.toBukkit(null)) | ||
.thenRunAsync(() -> WorldManager.INSTANCE.submit(() -> testData.equals(compareData) | ||
? new SetBlockEffect(world, location, setData) | ||
: null)); | ||
} | ||
} |
Oops, something went wrong.