Updated the library.
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.5-SNAPSHOT</version>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_12_R1</artifactId>
|
||||
|
||||
@@ -4,25 +4,25 @@
|
||||
|
||||
package net.jitse.npclib.nms.v1_12_R1;
|
||||
|
||||
import net.jitse.npclib.api.NPC;
|
||||
import net.jitse.npclib.nms.holograms.Hologram;
|
||||
import net.jitse.npclib.NPCLib;
|
||||
import net.jitse.npclib.hologram.Hologram;
|
||||
import net.jitse.npclib.internal.MinecraftVersion;
|
||||
import net.jitse.npclib.internal.SimpleNPC;
|
||||
import net.jitse.npclib.nms.v1_12_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
|
||||
import net.jitse.npclib.nms.v1_12_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
|
||||
import net.jitse.npclib.nms.v1_12_R1.packets.PacketPlayOutPlayerInfoWrapper;
|
||||
import net.jitse.npclib.nms.v1_12_R1.packets.PacketPlayOutScoreboardTeamWrapper;
|
||||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_12_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Jitse Boonstra
|
||||
*/
|
||||
public class NPC_v1_12_R1 extends NPC {
|
||||
public class NPC_v1_12_R1 extends SimpleNPC {
|
||||
|
||||
private Hologram hologram;
|
||||
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
|
||||
@@ -31,16 +31,15 @@ public class NPC_v1_12_R1 extends NPC {
|
||||
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
|
||||
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
|
||||
|
||||
public NPC_v1_12_R1(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
|
||||
super(plugin, skin, autoHideDistance, lines);
|
||||
public NPC_v1_12_R1(NPCLib instance, List<String> lines) {
|
||||
super(instance, lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().add(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(true, false);
|
||||
hologram.generatePackets(MinecraftVersion.V1_12_R1);
|
||||
|
||||
this.gameProfile = generateGameProfile(uuid, name);
|
||||
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
|
||||
|
||||
// Packets for spawning the NPC:
|
||||
@@ -79,8 +78,7 @@ public class NPC_v1_12_R1 extends NPC {
|
||||
|
||||
hologram.spawn(player);
|
||||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@@ -95,7 +93,7 @@ public class NPC_v1_12_R1 extends NPC {
|
||||
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
|
||||
+1
-4
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_12_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
|
||||
import net.minecraft.server.v1_12_R1.EnumGamemode;
|
||||
import net.minecraft.server.v1_12_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
|
||||
@@ -24,9 +23,7 @@ public class PacketPlayOutPlayerInfoWrapper {
|
||||
private final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClazz,
|
||||
packetPlayOutPlayerInfoClazz, GameProfile.class, int.class, EnumGamemode.class, IChatBaseComponent.class);
|
||||
|
||||
public PacketPlayOutPlayerInfo create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction action, GameProfileWrapper gameProfileWrapper, String name) {
|
||||
GameProfile gameProfile = (GameProfile) gameProfileWrapper.getGameProfile();
|
||||
|
||||
public PacketPlayOutPlayerInfo create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction action, GameProfile gameProfile, String name) {
|
||||
PacketPlayOutPlayerInfo packetPlayOutPlayerInfo = new PacketPlayOutPlayerInfo();
|
||||
Reflection.getField(packetPlayOutPlayerInfo.getClass(), "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.class)
|
||||
.set(packetPlayOutPlayerInfo, action);
|
||||
|
||||
Reference in New Issue
Block a user