-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>maps</artifactId> | ||
<groupId>dev.cerus</groupId> | ||
<version>1.0.6</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>dev.cerus.maps</groupId> | ||
<artifactId>bukkit-18_R2</artifactId> | ||
<version>1.0.6</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>dev.cerus.maps</groupId> | ||
<artifactId>common</artifactId> | ||
<version>1.0.6</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>craftbukkit</artifactId> | ||
<version>1.18.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
60 changes: 60 additions & 0 deletions
60
bukkit-18_R2/src/main/java/dev/cerus/maps/version/VersionAdapter18R2.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,60 @@ | ||
package dev.cerus.maps.version; | ||
|
||
import dev.cerus.maps.api.ClientsideMap; | ||
import dev.cerus.maps.api.version.VersionAdapter; | ||
import dev.cerus.maps.util.ReflectionUtil; | ||
import java.util.Collections; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; | ||
import net.minecraft.network.protocol.game.PacketPlayOutMap; | ||
import net.minecraft.network.syncher.DataWatcher; | ||
import net.minecraft.network.syncher.DataWatcherObject; | ||
import net.minecraft.network.syncher.DataWatcherRegistry; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.saveddata.maps.WorldMap; | ||
import org.bukkit.Material; | ||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; | ||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.meta.MapMeta; | ||
|
||
public class VersionAdapter18R2 implements VersionAdapter { | ||
|
||
@Override | ||
public Object makeMapPacket(final ClientsideMap map) { | ||
return new PacketPlayOutMap(map.getId(), | ||
(byte) 0, | ||
true, | ||
Collections.emptyList(), | ||
new WorldMap.b(0, | ||
0, | ||
128, | ||
128, | ||
map.getGraphics().getData())); | ||
} | ||
|
||
@Override | ||
public Object makeFramePacket(final int frameId, final ClientsideMap map) { | ||
final PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frameId, new DataWatcher(null), false); | ||
|
||
final org.bukkit.inventory.ItemStack mapItem = new org.bukkit.inventory.ItemStack(Material.FILLED_MAP, 1); | ||
final MapMeta mapMeta = (MapMeta) mapItem.getItemMeta(); | ||
mapMeta.setMapId(map.getId()); | ||
mapItem.setItemMeta(mapMeta); | ||
|
||
try { | ||
final DataWatcherObject<ItemStack> itemObj = DataWatcherRegistry.g.a((byte) 8); | ||
final DataWatcher.Item<ItemStack> itemItem = new DataWatcher.Item<>(itemObj, CraftItemStack.asNMSCopy(mapItem)); | ||
ReflectionUtil.set("b", packet.getClass(), packet, Collections.singletonList(itemItem)); | ||
} catch (final NoSuchFieldException | IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
return packet; | ||
} | ||
|
||
@Override | ||
public void sendPacket(final Player player, final Object packet) { | ||
((CraftPlayer) player).getHandle().b.a((Packet<?>) packet); | ||
} | ||
|
||
} |
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