Updated the library.

This commit is contained in:
Jitse Boonstra
2019-08-03 13:47:12 +02:00
parent b8a7dcaddb
commit e0752c5d7e
68 changed files with 1116 additions and 696 deletions
+2 -1
View File
@@ -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_9_R2</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_9_R2;
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_9_R2.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_9_R2.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_9_R2.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_9_R2.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_9_R2.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
/**
* @author Jitse Boonstra
*/
public class NPC_v1_9_R2 extends NPC {
public class NPC_v1_9_R2 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_9_R2 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_9_R2(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_9_R2(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public void createPackets() {
this.hologram = new Hologram(location.clone().subtract(0, 0.5, 0), lines);
hologram.generatePackets(false, false);
hologram.generatePackets(MinecraftVersion.V1_9_R2);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -80,7 +79,7 @@ public class NPC_v1_9_R2 extends NPC {
hologram.spawn(player);
Bukkit.getScheduler().runTaskLater(plugin, () ->
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
}
@@ -95,7 +94,7 @@ public class NPC_v1_9_R2 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);
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_9_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_9_R2.IChatBaseComponent;
import net.minecraft.server.v1_9_R2.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_9_R2.WorldSettings;
@@ -24,9 +23,7 @@ public class PacketPlayOutPlayerInfoWrapper {
private final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClazz,
packetPlayOutPlayerInfoClazz, GameProfile.class, int.class, WorldSettings.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);