Skip to content

Commit

Permalink
1.0.3 Update:
Browse files Browse the repository at this point in the history
- SpawnCorpseCommand fixed to spawn an online player
- Skin now rendered (1.8-1.12)
- Other minor fixes
  • Loading branch information
unldenis committed Feb 7, 2022
1 parent 3e17485 commit 3871ce9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
10 changes: 1 addition & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.unldenis.corpse</groupId>
<artifactId>Corpse</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -46,14 +46,6 @@
<version>20.1.0</version>
<scope>provided</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.guava/guava
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
-->
</dependencies>

<build>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/github/unldenis/corpse/api/CorpseAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public CorpseAPI() {
throw new IllegalArgumentException();
}

private CorpseAPI(Object dummy) { }

/**
* Method that creates a corpse in the player's position and with its skin and inventory
* @param player The player to copy
Expand Down Expand Up @@ -133,7 +135,7 @@ public void removeCorpse(@NotNull Corpse corpse) {
@NotNull
public static synchronized CorpseAPI getInstance() {
if(instance == null) {
instance = new CorpseAPI();
instance = new CorpseAPI(null);
}
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.github.unldenis.corpse.command;


import com.github.unldenis.corpse.api.*;
import com.github.unldenis.corpse.logic.*;
import org.bukkit.*;
import org.bukkit.command.*;
Expand All @@ -38,7 +39,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
return true;
}else if(args.length==1) {
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
new Corpse(player.getLocation(), target, null);
if(target.isOnline()) {
CorpseAPI.getInstance().spawnCorpse((Player) target, player.getLocation());
} else {
new Corpse(player.getLocation(), target, null);
}
player.sendMessage(ChatColor.GREEN+"Corpse created");
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/github/unldenis/corpse/logic/Corpse.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public void show(@NotNull Player player) {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
}
}

Bukkit.getScheduler().runTaskLater(CorpseP.getInstance(), ()->{
Bukkit.getScheduler().runTaskLaterAsynchronously(CorpseP.getInstance(), ()->{
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, this.packetLoader.getWrapperPlayerInfoRemove().get());
} catch (InvocationTargetException e) {
Expand All @@ -147,7 +146,6 @@ public void hide(@NotNull Player player) {
this.seeingPlayers.remove(player);
}


public boolean isShownFor(@NotNull Player player) {
return this.seeingPlayers.contains(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@

public class PacketLoader {

private final Corpse corpse;


private final Collection<IPacket> packets = new CopyOnWriteArraySet<>();

private final WrapperEntityDestroy wrapperEntityDestroy;
private final WrapperEntityEquipment wrapperEntityEquipment;
private final WrapperEntityMetadata wrapperEntityMetadata;
Expand All @@ -40,8 +36,6 @@ public class PacketLoader {
private final WrapperPlayerInfo wrapperPlayerInfoRemove;

public PacketLoader(@NotNull Corpse corpse) {
this.corpse = corpse;

//init packets
this.wrapperEntityDestroy = new WrapperEntityDestroy(corpse.id);
this.wrapperEntityEquipment = new WrapperEntityEquipment(corpse.id, corpse.armorContents);
Expand All @@ -59,11 +53,9 @@ public void load() {
packets.add(wrapperNamedEntitySpawn);
packets.add(wrapperPlayerInfoAdd);
packets.add(wrapperPlayerInfoRemove);

this.packets.forEach(IPacket::load);
}


public WrapperEntityDestroy getWrapperEntityDestroy() {
return wrapperEntityDestroy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ public void load() {
if(VersionUtil.isAbove(VersionUtil.VersionEnum.V1_13)) {
WrappedDataWatcher.WrappedDataWatcherObject visible = new WrappedDataWatcher.WrappedDataWatcherObject(6, WrappedDataWatcher.Registry.get(EnumWrappers.getEntityPoseClass()));
watcher.setObject(visible, EnumWrappers.EntityPose.SLEEPING.toNms());

/*
//Works and set location a little higher
WrappedDataWatcher.WrappedDataWatcherObject bed = new WrappedDataWatcher.WrappedDataWatcherObject(14, WrappedDataWatcher.Registry.getBlockPositionSerializer(true));
watcher.setObject(bed, Optional.of(BlockPosition.getConverter().getGeneric(new BlockPosition(corpse.location.toVector()))));
*/

int indexSkinLayer = VersionUtil.isAbove(VersionUtil.VersionEnum.V1_17) ? 17 : 16;
WrappedDataWatcher.WrappedDataWatcherObject skinLayers = new WrappedDataWatcher.WrappedDataWatcherObject(indexSkinLayer, WrappedDataWatcher.Registry.get(Byte.class));
watcher.setObject(skinLayers, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80));
Expand Down

0 comments on commit 3871ce9

Please sign in to comment.