-
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.
Update to 1.21, optimise world loading, add credits
- Loading branch information
1 parent
648d1e0
commit afc67dc
Showing
13 changed files
with
180 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,7 @@ | |
"z": 0.5, | ||
"yaw": -90.0, | ||
"pitch": 0.0 | ||
} | ||
}, | ||
"name": "City", | ||
"credits": ["emortaldev", "Iternalplayer"] | ||
} |
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 |
---|---|---|
|
@@ -12,5 +12,7 @@ | |
"z": 0.5, | ||
"yaw": -90.0, | ||
"pitch": 0.0 | ||
} | ||
}, | ||
"name": "Ruins", | ||
"credits": [] | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/dev/emortal/minestom/parkourtag/blockhandler/SignHandler.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,26 @@ | ||
package dev.emortal.minestom.parkourtag.blockhandler; | ||
|
||
import net.minestom.server.instance.block.BlockHandler; | ||
import net.minestom.server.tag.Tag; | ||
import net.minestom.server.utils.NamespaceID; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public final class SignHandler implements BlockHandler { | ||
|
||
@Override | ||
public @NotNull Collection<Tag<?>> getBlockEntityTags() { | ||
return List.of( | ||
Tag.Boolean("is_waxed"), | ||
Tag.NBT("front_text"), | ||
Tag.NBT("back_text") | ||
); | ||
} | ||
|
||
@Override | ||
public @NotNull NamespaceID getNamespaceId() { | ||
return NamespaceID.from("minecraft:sign"); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/dev/emortal/minestom/parkourtag/commands/CreditsCommand.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,63 @@ | ||
package dev.emortal.minestom.parkourtag.commands; | ||
|
||
import dev.emortal.minestom.gamesdk.game.Game; | ||
import dev.emortal.minestom.gamesdk.game.GameProvider; | ||
import dev.emortal.minestom.parkourtag.ParkourTagGame; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.TextComponent; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import net.minestom.server.command.CommandSender; | ||
import net.minestom.server.command.builder.Command; | ||
import net.minestom.server.command.builder.CommandContext; | ||
import net.minestom.server.command.builder.condition.Conditions; | ||
import net.minestom.server.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public final class CreditsCommand extends Command { | ||
private static final @NotNull Component UNKNOWN_MESSAGE = Component.text("We're not sure who made this map", NamedTextColor.RED); | ||
|
||
private final @NotNull GameProvider gameProvider; | ||
|
||
public CreditsCommand(@NotNull GameProvider gameProvider) { | ||
super("credits"); | ||
this.gameProvider = gameProvider; | ||
|
||
super.setCondition(Conditions::playerOnly); | ||
super.setDefaultExecutor(this::execute); | ||
} | ||
|
||
private @Nullable ParkourTagGame getGame(@NotNull CommandSender sender) { | ||
Game game = this.gameProvider.findGame((Player) sender); | ||
if (game == null) { | ||
sender.sendMessage("You are not in a game!"); | ||
return null; | ||
} | ||
|
||
return (ParkourTagGame) game; | ||
} | ||
|
||
private void execute(@NotNull CommandSender sender, @NotNull CommandContext context) { | ||
ParkourTagGame game = this.getGame(sender); | ||
if (game == null) return; | ||
|
||
String[] mapUsernames = game.getMap().mapData().credits(); | ||
if (mapUsernames.length == 0) { | ||
sender.sendMessage(UNKNOWN_MESSAGE); | ||
return; | ||
} | ||
|
||
TextComponent.Builder message = Component.text(); | ||
message.append(Component.text("You're currently playing on ", NamedTextColor.LIGHT_PURPLE)); | ||
message.append(Component.text(game.getMap().mapData().name(), NamedTextColor.LIGHT_PURPLE)); | ||
message.append(Component.text(", created by:", NamedTextColor.LIGHT_PURPLE)); | ||
|
||
for (String mapUsername : mapUsernames) { | ||
message.append(Component.newline()); | ||
message.append(Component.text(" - ")); | ||
message.append(Component.text(mapUsername)); | ||
} | ||
|
||
sender.sendMessage(message.build()); | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/dev/emortal/minestom/parkourtag/utils/NoopChunkLoader.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,31 @@ | ||
package dev.emortal.minestom.parkourtag.utils; | ||
|
||
import net.minestom.server.instance.Chunk; | ||
import net.minestom.server.instance.IChunkLoader; | ||
import net.minestom.server.instance.Instance; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class NoopChunkLoader implements IChunkLoader { | ||
@Override | ||
public @NotNull CompletableFuture<@Nullable Chunk> loadChunk(@NotNull Instance instance, int chunkX, int chunkZ) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
|
||
@Override | ||
public @NotNull CompletableFuture<Void> saveChunk(@NotNull Chunk chunk) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
|
||
@Override | ||
public boolean supportsParallelSaving() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean supportsParallelLoading() { | ||
return true; | ||
} | ||
} |