-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chore/1-20-6' into feat/sse-events
- Loading branch information
Showing
59 changed files
with
870 additions
and
1,195 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# do not count these lines | ||
.github/ | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.tokeignore | ||
LICENSE | ||
gradle/ | ||
*.gradle* | ||
*.json | ||
*.accesswidener | ||
*.yml | ||
*.config.js |
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
52 changes: 52 additions & 0 deletions
52
bukkit/src/main/java/net/pl3x/map/bukkit/command/BukkitParsers.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,52 @@ | ||
package net.pl3x.map.bukkit.command; | ||
|
||
import net.minecraft.world.phys.Vec3; | ||
import net.pl3x.map.bukkit.BukkitPlayer; | ||
import net.pl3x.map.core.Pl3xMap; | ||
import net.pl3x.map.core.command.Sender; | ||
import net.pl3x.map.core.command.parser.PlatformParsers; | ||
import net.pl3x.map.core.markers.Point; | ||
import net.pl3x.map.core.player.Player; | ||
import org.incendo.cloud.bukkit.data.SinglePlayerSelector; | ||
import org.incendo.cloud.bukkit.parser.location.Location2D; | ||
import org.incendo.cloud.bukkit.parser.location.Location2DParser; | ||
import org.incendo.cloud.bukkit.parser.selector.SinglePlayerSelectorParser; | ||
import org.incendo.cloud.context.CommandContext; | ||
import org.incendo.cloud.parser.ParserDescriptor; | ||
|
||
public class BukkitParsers implements PlatformParsers { | ||
@Override | ||
public ParserDescriptor<Sender, ?> columnPosParser() { | ||
return Location2DParser.location2DParser(); | ||
} | ||
|
||
@Override | ||
public Point resolvePointFromColumnPos(String name, CommandContext<Sender> context) { | ||
Location2D location2D = context.<Location2D>getOrDefault(name, null); | ||
if (location2D == null) { | ||
return Point.ZERO; | ||
} | ||
return Point.of(location2D.blockX(), location2D.blockZ()); | ||
} | ||
|
||
@Override | ||
public ParserDescriptor<Sender, ?> playerSelectorParser() { | ||
return SinglePlayerSelectorParser.singlePlayerSelectorParser(); | ||
} | ||
|
||
@Override | ||
public Player resolvePlayerFromPlayerSelector(String name, CommandContext<Sender> context) { | ||
Sender sender = context.sender(); | ||
SinglePlayerSelector playerSelector = context.getOrDefault(name, null); | ||
if (playerSelector == null) { | ||
if (sender instanceof Sender.Player<?> senderPlayer) { | ||
Player player = Pl3xMap.api().getPlayerRegistry().get(senderPlayer.getUUID()); | ||
if (player != null) { | ||
return player; | ||
} | ||
} | ||
return null; | ||
} | ||
return new BukkitPlayer(playerSelector.single()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
bukkit/src/main/java/net/pl3x/map/bukkit/network/ClientboundMapPayload.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,35 @@ | ||
package net.pl3x.map.bukkit.network; | ||
|
||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.pl3x.map.core.network.Constants; | ||
|
||
public record ClientboundMapPayload(int protocol, int response, int mapId, byte scale, int centerX, int centerZ, String worldName) implements CustomPacketPayload { | ||
public static final StreamCodec<FriendlyByteBuf, ClientboundMapPayload> STREAM_CODEC = CustomPacketPayload.codec(ClientboundMapPayload::write, ClientboundMapPayload::new); | ||
public static final Type<ClientboundMapPayload> TYPE = new Type<>(new ResourceLocation(Constants.MODID, "client_map_data")); | ||
|
||
public ClientboundMapPayload(int protocol, int response, int mapId) { | ||
this(protocol, response, mapId, (byte) 0, 0, 0, null); | ||
} | ||
|
||
public ClientboundMapPayload(FriendlyByteBuf friendlyByteBuf) { | ||
this(friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readByte(), friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readUtf()); | ||
} | ||
|
||
private void write(FriendlyByteBuf friendlyByteBuf) { | ||
friendlyByteBuf.writeInt(protocol); | ||
friendlyByteBuf.writeInt(response); | ||
friendlyByteBuf.writeInt(mapId); | ||
friendlyByteBuf.writeByte(scale); | ||
friendlyByteBuf.writeInt(centerX); | ||
friendlyByteBuf.writeInt(centerZ); | ||
friendlyByteBuf.writeUtf(worldName); | ||
} | ||
|
||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return TYPE; | ||
} | ||
} |
Oops, something went wrong.