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
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<project
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>pom</packaging>
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms</artifactId>
<modules>
<module>v1_8_R1</module>
<module>v1_8_R2</module>
<module>v1_8_R3</module>
<module>v1_9_R1</module>
<module>v1_9_R2</module>
<module>v1_10_R1</module>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
<module>v1_13_R1</module>
<module>v1_13_R2</module>
<module>v1_14_R1</module>
</modules>
<dependencies>
<dependency>
<groupId>net.jitse</groupId>
<artifactId>npclib-api</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
+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_10_R1</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_10_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_10_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_10_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_10_R1.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_10_R1.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_10_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_10_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_10_R1 extends NPC {
public class NPC_v1_10_R1 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_10_R1 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_10_R1(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_10_R1(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(true, false);
hologram.generatePackets(MinecraftVersion.V1_10_R1);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -80,7 +79,7 @@ public class NPC_v1_10_R1 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_10_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);
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_10_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_10_R1.EnumGamemode;
import net.minecraft.server.v1_10_R1.IChatBaseComponent;
import net.minecraft.server.v1_10_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);
+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_11_R1</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_11_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_11_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_11_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_11_R1.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_11_R1.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_11_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_11_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_11_R1 extends NPC {
public class NPC_v1_11_R1 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_11_R1 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_11_R1(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_11_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_11_R1);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -80,7 +79,7 @@ public class NPC_v1_11_R1 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_11_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);
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_11_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_11_R1.EnumGamemode;
import net.minecraft.server.v1_11_R1.IChatBaseComponent;
import net.minecraft.server.v1_11_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);
+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_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);
@@ -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);
+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_13_R1</artifactId>
@@ -4,26 +4,25 @@
package net.jitse.npclib.nms.v1_13_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_13_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_13_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_13_R1.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_13_R1.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_13_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_13_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_13_R1 extends NPC {
public class NPC_v1_13_R1 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -32,16 +31,15 @@ public class NPC_v1_13_R1 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_13_R1(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_13_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, true);
hologram.generatePackets(MinecraftVersion.V1_13_R1);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -81,7 +79,7 @@ public class NPC_v1_13_R1 extends NPC {
hologram.spawn(player);
Bukkit.getScheduler().runTaskLater(plugin, () ->
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
}
@@ -96,7 +94,7 @@ public class NPC_v1_13_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);
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_13_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_13_R1.EnumGamemode;
import net.minecraft.server.v1_13_R1.IChatBaseComponent;
import net.minecraft.server.v1_13_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);
+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_13_R2</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_13_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_13_R2.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_13_R2.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_13_R2.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_13_R2.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_13_R2.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_13_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_13_R2 extends NPC {
public class NPC_v1_13_R2 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_13_R2 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_13_R2(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_13_R2(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, true);
hologram.generatePackets(MinecraftVersion.V1_13_R2);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -80,7 +79,7 @@ public class NPC_v1_13_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_13_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_13_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_13_R2.EnumGamemode;
import net.minecraft.server.v1_13_R2.IChatBaseComponent;
import net.minecraft.server.v1_13_R2.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);
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project
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>2.0-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_14_R1</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,99 @@
package net.jitse.npclib.nms.v1_14_R1;
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_14_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_14_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_14_R1.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_14_R1.packets.PacketPlayOutScoreboardTeamWrapper;
import net.minecraft.server.v1_14_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.List;
/**
* @author Jitse Boonstra
*/
public class NPC_v1_14_R1 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister, packetPlayOutScoreboardTeamUnregister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_14_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(MinecraftVersion.V1_14_R1);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
this.packetPlayOutScoreboardTeamRegister = new PacketPlayOutScoreboardTeamWrapper()
.createRegisterTeam(name); // First packet to send.
this.packetPlayOutPlayerInfoAdd = packetPlayOutPlayerInfoWrapper
.create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, gameProfile, name); // Second packet to send.
this.packetPlayOutNamedEntitySpawn = new PacketPlayOutNamedEntitySpawnWrapper()
.create(uuid, location, entityId); // Third packet to send.
this.packetPlayOutEntityHeadRotation = new PacketPlayOutEntityHeadRotationWrapper()
.create(location, entityId); // Fourth packet to send.
this.packetPlayOutPlayerInfoRemove = packetPlayOutPlayerInfoWrapper
.create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, gameProfile, name); // Fifth packet to send (delayed).
// Packet for destroying the NPC:
this.packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(entityId); // First packet to send.
// Second packet to send is "packetPlayOutPlayerInfoRemove".
this.packetPlayOutScoreboardTeamUnregister = new PacketPlayOutScoreboardTeamWrapper()
.createUnregisterTeam(name); // Third packet to send.
}
@Override
public void sendShowPackets(Player player) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutScoreboardTeamRegister);
playerConnection.sendPacket(packetPlayOutPlayerInfoAdd);
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
hologram.spawn(player);
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
}
@Override
public void sendHidePackets(Player player, boolean scheduler) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
hologram.destroy(player);
if (scheduler) {
// Sending this a bit later so the player doesn't see the name (for that split second).
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
} else {
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
}
}
}
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_14_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityHeadRotation;
import org.bukkit.Location;
/**
* @author Jitse Boonstra
*/
public class PacketPlayOutEntityHeadRotationWrapper {
public PacketPlayOutEntityHeadRotation create(Location location, int entityId) {
PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation = new PacketPlayOutEntityHeadRotation();
Reflection.getField(packetPlayOutEntityHeadRotation.getClass(), "a", int.class).
set(packetPlayOutEntityHeadRotation, entityId);
Reflection.getField(packetPlayOutEntityHeadRotation.getClass(), "b", byte.class)
.set(packetPlayOutEntityHeadRotation, (byte) ((int) location.getYaw() * 256.0F / 360.0F));
return packetPlayOutEntityHeadRotation;
}
}
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_14_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_14_R1.DataWatcher;
import net.minecraft.server.v1_14_R1.DataWatcherObject;
import net.minecraft.server.v1_14_R1.DataWatcherRegistry;
import net.minecraft.server.v1_14_R1.PacketPlayOutNamedEntitySpawn;
import org.bukkit.Location;
import java.util.UUID;
/**
* @author Jitse Boonstra
*/
public class PacketPlayOutNamedEntitySpawnWrapper {
public PacketPlayOutNamedEntitySpawn create(UUID uuid, Location location, int entityId) {
PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn = new PacketPlayOutNamedEntitySpawn();
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "a", int.class)
.set(packetPlayOutNamedEntitySpawn, entityId);
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "b", UUID.class)
.set(packetPlayOutNamedEntitySpawn, uuid);
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "c", double.class)
.set(packetPlayOutNamedEntitySpawn, location.getX());
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "d", double.class)
.set(packetPlayOutNamedEntitySpawn, location.getY());
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "e", double.class)
.set(packetPlayOutNamedEntitySpawn, location.getZ());
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "f", byte.class)
.set(packetPlayOutNamedEntitySpawn, (byte) ((int) (location.getYaw() * 256.0F / 360.0F)));
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "g", byte.class)
.set(packetPlayOutNamedEntitySpawn, (byte) ((int) (location.getPitch() * 256.0F / 360.0F)));
DataWatcher dataWatcher = new DataWatcher(null);
dataWatcher.register(new DataWatcherObject<>(13, DataWatcherRegistry.a), (byte) 127);
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "h", DataWatcher.class)
.set(packetPlayOutNamedEntitySpawn, dataWatcher);
return packetPlayOutNamedEntitySpawn;
}
}
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_14_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_14_R1.EnumGamemode;
import net.minecraft.server.v1_14_R1.IChatBaseComponent;
import net.minecraft.server.v1_14_R1.PacketPlayOutPlayerInfo;
import org.bukkit.ChatColor;
import java.util.List;
/**
* @author Jitse Boonstra
*/
public class PacketPlayOutPlayerInfoWrapper {
private final Class<?> packetPlayOutPlayerInfoClazz = Reflection.getMinecraftClass("PacketPlayOutPlayerInfo");
private final Class<?> playerInfoDataClazz = Reflection.getMinecraftClass("PacketPlayOutPlayerInfo$PlayerInfoData");
private final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClazz,
packetPlayOutPlayerInfoClazz, GameProfile.class, int.class, EnumGamemode.class, IChatBaseComponent.class);
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);
Object playerInfoData = playerInfoDataConstructor.invoke(packetPlayOutPlayerInfo,
gameProfile, 1, EnumGamemode.NOT_SET,
IChatBaseComponent.ChatSerializer.b("{\"text\":\"" + ChatColor.BLUE + "[NPC] " + name + "\"}")
);
Reflection.FieldAccessor<List> fieldAccessor = Reflection.getField(packetPlayOutPlayerInfo.getClass(), "b", List.class);
List list = fieldAccessor.get(packetPlayOutPlayerInfo);
list.add(playerInfoData);
fieldAccessor.set(packetPlayOutPlayerInfo, list);
return packetPlayOutPlayerInfo;
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_14_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_14_R1.ChatComponentText;
import net.minecraft.server.v1_14_R1.IChatBaseComponent;
import net.minecraft.server.v1_14_R1.PacketPlayOutScoreboardTeam;
import java.util.Collection;
/**
* @author Jitse Boonstra
*/
public class PacketPlayOutScoreboardTeamWrapper {
public PacketPlayOutScoreboardTeam createRegisterTeam(String name) {
PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeam = new PacketPlayOutScoreboardTeam();
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "i", int.class)
.set(packetPlayOutScoreboardTeam, 0);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "a", String.class)
.set(packetPlayOutScoreboardTeam, name);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "b", IChatBaseComponent.class)
.set(packetPlayOutScoreboardTeam, new ChatComponentText(name));
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "e", String.class)
.set(packetPlayOutScoreboardTeam, "never");
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "f", String.class)
.set(packetPlayOutScoreboardTeam, "never");
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "j", int.class)
.set(packetPlayOutScoreboardTeam, 0);
Reflection.FieldAccessor<Collection> collectionFieldAccessor = Reflection.getField(
packetPlayOutScoreboardTeam.getClass(), "h", Collection.class);
Collection collection = collectionFieldAccessor.get(packetPlayOutScoreboardTeam);
collection.add(name);
collectionFieldAccessor.set(packetPlayOutScoreboardTeam, collection);
return packetPlayOutScoreboardTeam;
}
public PacketPlayOutScoreboardTeam createUnregisterTeam(String name) {
PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeam = new PacketPlayOutScoreboardTeam();
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "i", int.class)
.set(packetPlayOutScoreboardTeam, 1);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "a", String.class)
.set(packetPlayOutScoreboardTeam, name);
return packetPlayOutScoreboardTeam;
}
}
+20 -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_8_R1</artifactId>
@@ -26,4 +27,22 @@
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_8_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_8_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_8_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_8_R1.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_8_R1.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_8_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_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_8_R1 extends NPC {
public class NPC_v1_8_R1 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_8_R1 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_8_R1(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_8_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(false, false);
hologram.generatePackets(MinecraftVersion.V1_8_R1);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -79,7 +78,7 @@ public class NPC_v1_8_R1 extends NPC {
hologram.spawn(player);
Bukkit.getScheduler().runTaskLater(plugin, () ->
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
}
@@ -94,7 +93,7 @@ public class NPC_v1_8_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);
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_8_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_8_R1.*;
import java.util.List;
@@ -16,9 +15,7 @@ import java.util.List;
*/
public class PacketPlayOutPlayerInfoWrapper {
public PacketPlayOutPlayerInfo create(EnumPlayerInfoAction action, GameProfileWrapper gameProfileWrapper, String name) {
GameProfile gameProfile = (GameProfile) gameProfileWrapper.getGameProfile();
public PacketPlayOutPlayerInfo create(EnumPlayerInfoAction action, GameProfile gameProfile, String name) {
PacketPlayOutPlayerInfo packetPlayOutPlayerInfo = new PacketPlayOutPlayerInfo();
Reflection.getField(packetPlayOutPlayerInfo.getClass(), "a", EnumPlayerInfoAction.class)
.set(packetPlayOutPlayerInfo, action);
+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_8_R2</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_8_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_8_R2.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_8_R2.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_8_R2.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_8_R2.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_8_R2.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_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_8_R2 extends NPC {
public class NPC_v1_8_R2 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_8_R2 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_8_R2(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_8_R2(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(false, false);
hologram.generatePackets(MinecraftVersion.V1_8_R2);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -79,7 +78,7 @@ public class NPC_v1_8_R2 extends NPC {
hologram.spawn(player);
Bukkit.getScheduler().runTaskLater(plugin, () ->
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
}
@@ -94,7 +93,7 @@ public class NPC_v1_8_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_8_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_8_R2.IChatBaseComponent;
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R2.WorldSettings;
@@ -18,9 +17,7 @@ import java.util.List;
*/
public class PacketPlayOutPlayerInfoWrapper {
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);
+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_8_R3</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_8_R3;
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_8_R3.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_8_R3.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_8_R3.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_8_R3.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
/**
* @author Jitse Boonstra
*/
public class NPC_v1_8_R3 extends NPC {
public class NPC_v1_8_R3 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_8_R3 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_8_R3(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_8_R3(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(false, false);
hologram.generatePackets(MinecraftVersion.V1_8_R3);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -80,7 +79,7 @@ public class NPC_v1_8_R3 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_8_R3 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_8_R3.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R3.WorldSettings;
@@ -18,9 +17,7 @@ import java.util.List;
*/
public class PacketPlayOutPlayerInfoWrapper {
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);
+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_R1</artifactId>
@@ -4,25 +4,25 @@
package net.jitse.npclib.nms.v1_9_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_9_R1.packets.PacketPlayOutEntityHeadRotationWrapper;
import net.jitse.npclib.nms.v1_9_R1.packets.PacketPlayOutNamedEntitySpawnWrapper;
import net.jitse.npclib.nms.v1_9_R1.packets.PacketPlayOutPlayerInfoWrapper;
import net.jitse.npclib.nms.v1_9_R1.packets.PacketPlayOutScoreboardTeamWrapper;
import net.jitse.npclib.skin.Skin;
import net.minecraft.server.v1_9_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_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_9_R1 extends NPC {
public class NPC_v1_9_R1 extends SimpleNPC {
private Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
@@ -31,16 +31,15 @@ public class NPC_v1_9_R1 extends NPC {
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_9_R1(JavaPlugin plugin, Skin skin, double autoHideDistance, List<String> lines) {
super(plugin, skin, autoHideDistance, lines);
public NPC_v1_9_R1(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_R1);
this.gameProfile = generateGameProfile(uuid, name);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
// Packets for spawning the NPC:
@@ -80,7 +79,7 @@ public class NPC_v1_9_R1 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_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);
@@ -6,7 +6,6 @@ package net.jitse.npclib.nms.v1_9_R1.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.jitse.npclib.api.wrapper.GameProfileWrapper;
import net.minecraft.server.v1_9_R1.IChatBaseComponent;
import net.minecraft.server.v1_9_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_9_R1.WorldSettings;
@@ -19,9 +18,7 @@ import java.util.List;
*/
public class PacketPlayOutPlayerInfoWrapper {
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);
+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);