Merge branch 'master' into fix/getPlayerHolo-npe

This commit is contained in:
Jitse Boonstra 2020-07-28 12:18:01 +02:00 committed by GitHub
commit d61b8cd1d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 25 additions and 408 deletions

View File

@ -2,13 +2,12 @@
NPCLib Basic non-player character library.<br> NPCLib Basic non-player character library.<br>
[![Release](https://jitpack.io/v/JitseB/NPCLib.svg)](https://github.com/JitseB/NPCLib/releases) [![Release](https://jitpack.io/v/JitseB/NPCLib.svg)](https://github.com/JitseB/NPCLib/releases)
[![Build Status](https://travis-ci.com/JitseB/NPCLib.svg?branch=master)](https://travis-ci.com/JitseB/NPCLib) [![Build Status](https://travis-ci.com/JitseB/NPCLib.svg?branch=master)](https://travis-ci.com/JitseB/NPCLib)
[![Versions](https://img.shields.io/badge/MC-1.8%20R2%20--%20latest-blue.svg)](https://github.com/JitseB/NPCLib/releases) [![Versions](https://img.shields.io/badge/MC-1.8.8%20--%20latest-blue.svg)](https://github.com/JitseB/NPCLib/releases)
[![Resource](https://img.shields.io/badge/SpigotMC-Resource-orange.svg)](https://www.spigotmc.org/resources/npclib.55884/) [![Resource](https://img.shields.io/badge/SpigotMC-Resource-orange.svg)](https://www.spigotmc.org/resources/npclib.55884/)
[![Discord](https://img.shields.io/badge/Support-Discord-blue.svg)](https://discord.gg/pvJGhEq)
= =
This is an API made specifically for spigot servers (Minecraft). Current supported versions: **1.8 R2 - latest**\*. Lightweight replacement for Citizens. NPCLib only uses packets instead of registering the entity in the actual Minecraft server. This is an API made specifically for spigot servers (Minecraft). Current supported versions: **1.8.8 - latest**. Lightweight replacement for Citizens. NPCLib only uses packets instead of registering the entity in the actual Minecraft server.
\*You can find a version of NPCLib with basic support for 1.7.10 on the [legacy branch](https://github.com/JitseB/NPCLib/tree/legacy). This branch is not actively maintained as the master branch. This version does not support multi-line text.
### Preview (click to play video) ### Preview (click to play video)
[![YouTube Video](http://img.youtube.com/vi/LqwdqIxPIvE/0.jpg)](http://www.youtube.com/watch?v=LqwdqIxPIvE "NPCLib Basic non-player character library (Minecraft).") [![YouTube Video](http://img.youtube.com/vi/LqwdqIxPIvE/0.jpg)](http://www.youtube.com/watch?v=LqwdqIxPIvE "NPCLib Basic non-player character library (Minecraft).")
@ -47,7 +46,7 @@ If you have NPCLib under your `plugins` folder, you may use the following:
<dependency> <dependency>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-api</artifactId> <artifactId>npclib-api</artifactId>
<version>2.7-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-api</artifactId> <artifactId>npclib-api</artifactId>
@ -28,7 +28,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version> <version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -85,13 +85,13 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
Validate.notNull(targetPlayer, "Player cannot be null."); Validate.notNull(targetPlayer, "Player cannot be null.");
List<String> originalLines = getPlayerLines(targetPlayer); List<String> originalLines = getPlayerLines(targetPlayer);
setPlayerLines(uniqueLines, targetPlayer); setPlayerLines(uniqueLines, targetPlayer);
if (update){ if (update) {
if (originalLines.size() != uniqueLines.size()){ // recreate the entire hologram if (originalLines.size() != uniqueLines.size()) { // recreate the entire hologram
Hologram originalhologram = getPlayerHologram(targetPlayer); Hologram originalhologram = getPlayerHologram(targetPlayer);
originalhologram.hide(targetPlayer); // essentially destroy the hologram originalhologram.hide(targetPlayer); // essentially destroy the hologram
textDisplayHolograms.remove(targetPlayer.getUniqueId()); // remove the old obj textDisplayHolograms.remove(targetPlayer.getUniqueId()); // remove the old obj
} }
if (isShown(targetPlayer)) { //only show hologram if the player is in range if (isShown(targetPlayer)) { //only show hologram if the player is in range
Hologram hologram = getPlayerHologram(targetPlayer); Hologram hologram = getPlayerHologram(targetPlayer);
List<Object> updatePackets = hologram.getUpdatePackets(getPlayerLines(targetPlayer)); List<Object> updatePackets = hologram.getUpdatePackets(getPlayerLines(targetPlayer));
@ -217,7 +217,7 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
public boolean inViewOf(Player player) { public boolean inViewOf(Player player) {
Vector dir = location.toVector().subtract(player.getEyeLocation().toVector()).normalize(); Vector dir = location.toVector().subtract(player.getEyeLocation().toVector()).normalize();
return dir.dot(player.getLocation().getDirection()) >= cosFOV; return dir.dot(player.getEyeLocation().getDirection()) >= cosFOV;
} }
@Override @Override

View File

@ -8,13 +8,12 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<modules> <modules>
<module>v1_8_R2</module>
<module>v1_8_R3</module> <module>v1_8_R3</module>
<module>v1_9_R1</module> <module>v1_9_R1</module>
<module>v1_9_R2</module> <module>v1_9_R2</module>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_10_R1</artifactId> <artifactId>npclib-nms-v1_10_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_11_R1</artifactId> <artifactId>npclib-nms-v1_11_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_12_R1</artifactId> <artifactId>npclib-nms-v1_12_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_13_R1</artifactId> <artifactId>npclib-nms-v1_13_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_13_R2</artifactId> <artifactId>npclib-nms-v1_13_R2</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_14_R1</artifactId> <artifactId>npclib-nms-v1_14_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_15_R1</artifactId> <artifactId>npclib-nms-v1_15_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_16_R1</artifactId> <artifactId>npclib-nms-v1_16_R1</artifactId>

View File

@ -1,24 +0,0 @@
<?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.10-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R2</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,160 +0,0 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_8_R2;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.skin.Skin;
import net.jitse.npclib.api.state.NPCAnimation;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_8_R2.packets.*;
import net.minecraft.server.v1_8_R2.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* @author Jitse Boonstra
*/
public class NPC_v1_8_R2 extends NPCBase {
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
public NPC_v1_8_R2(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null){
holo = new Hologram(MinecraftVersion.V1_8_R2, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
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.
}
@Override
public void sendShowPackets(Player player) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
if (hasTeamRegistered.add(player.getUniqueId()))
playerConnection.sendPacket(packetPlayOutScoreboardTeamRegister);
playerConnection.sendPacket(packetPlayOutPlayerInfoAdd);
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
playerConnection.sendPacket(packetPlayOutEntityHeadRotation);
getPlayerHologram(player).show(player);
// Removing the player info after 10 seconds.
Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () ->
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 200);
}
@Override
public void sendHidePackets(Player player) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
getPlayerHologram(player).hide(player);
}
@Override
public void sendMetadataPacket(Player player) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadataWrapper().create(activeStates, entityId);
playerConnection.sendPacket(packet);
}
@Override
public void sendEquipmentPacket(Player player, NPCSlot slot, boolean auto) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
if (slot == NPCSlot.OFFHAND) {
if (!auto) {
throw new UnsupportedOperationException("Offhand is not supported on servers below 1.9");
}
return;
}
ItemStack item = getItem(slot);
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, slot.getSlot(), CraftItemStack.asNMSCopy(item));
playerConnection.sendPacket(packet);
}
@Override
public void sendAnimationPacket(Player player, NPCAnimation animation) {
if(animation == NPCAnimation.SWING_OFFHAND) {
throw new IllegalArgumentException("Offhand Swing Animations are only available on 1.9 and up.");
}
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
PacketPlayOutAnimation packet = new PacketPlayOutAnimationWrapper().create(animation, entityId);
playerConnection.sendPacket(packet);
}
@Override
public void updateSkin(Skin skin) {
GameProfile newProfile = new GameProfile(uuid, name);
newProfile.getProperties().get("textures").clear();
newProfile.getProperties().put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
this.packetPlayOutPlayerInfoAdd = new PacketPlayOutPlayerInfoWrapper().create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, newProfile, name);
for (Player player : Bukkit.getOnlinePlayers()) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove);
playerConnection.sendPacket(packetPlayOutEntityDestroy);
playerConnection.sendPacket(packetPlayOutPlayerInfoAdd);
playerConnection.sendPacket(packetPlayOutNamedEntitySpawn);
}
}
}

View File

@ -1,20 +0,0 @@
package net.jitse.npclib.nms.v1_8_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.jitse.npclib.api.state.NPCAnimation;
import net.minecraft.server.v1_8_R2.PacketPlayOutAnimation;
public class PacketPlayOutAnimationWrapper {
public PacketPlayOutAnimation create(NPCAnimation npcAnimation, int entityId) {
PacketPlayOutAnimation packetPlayOutAnimation = new PacketPlayOutAnimation();
Reflection.getField(packetPlayOutAnimation.getClass(), "a", int.class)
.set(packetPlayOutAnimation, entityId);
Reflection.getField(packetPlayOutAnimation.getClass(), "b", int.class)
.set(packetPlayOutAnimation, npcAnimation.getId());
return packetPlayOutAnimation;
}
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_8_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_8_R2.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;
}
}

View File

@ -1,18 +0,0 @@
package net.jitse.npclib.nms.v1_8_R2.packets;
import net.jitse.npclib.api.state.NPCState;
import net.minecraft.server.v1_8_R2.DataWatcher;
import net.minecraft.server.v1_8_R2.PacketPlayOutEntityMetadata;
import java.util.Collection;
public class PacketPlayOutEntityMetadataWrapper {
public PacketPlayOutEntityMetadata create(Collection<NPCState> activateStates, int entityId) {
DataWatcher dataWatcher = new DataWatcher(null);
byte masked = NPCState.getMasked(activateStates);
dataWatcher.a(0, masked);
return new PacketPlayOutEntityMetadata(entityId, dataWatcher, true);
}
}

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_8_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_8_R2.DataWatcher;
import net.minecraft.server.v1_8_R2.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", int.class)
.set(packetPlayOutNamedEntitySpawn, (int) Math.floor(location.getX() * 32.0D));
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "d", int.class)
.set(packetPlayOutNamedEntitySpawn, (int) Math.floor(location.getY() * 32.0D));
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "e", int.class)
.set(packetPlayOutNamedEntitySpawn, (int) Math.floor(location.getZ() * 32.0D));
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.a(10, (byte) 127);
Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "i", DataWatcher.class)
.set(packetPlayOutNamedEntitySpawn, dataWatcher);
return packetPlayOutNamedEntitySpawn;
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_8_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_8_R2.IChatBaseComponent;
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R2.WorldSettings;
import java.util.Collections;
import java.util.List;
/**
* @author Jitse Boonstra
*/
public class PacketPlayOutPlayerInfoWrapper {
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);
PacketPlayOutPlayerInfo.PlayerInfoData playerInfoData = packetPlayOutPlayerInfo.new PlayerInfoData(gameProfile, 1,
WorldSettings.EnumGamemode.NOT_SET, IChatBaseComponent.ChatSerializer.a("{\"text\":\"[NPC] " + name + "\",\"color\":\"dark_gray\"}"));
Reflection.FieldAccessor<List> fieldAccessor = Reflection.getField(packetPlayOutPlayerInfo.getClass(), "b", List.class);
fieldAccessor.set(packetPlayOutPlayerInfo, Collections.singletonList(playerInfoData));
return packetPlayOutPlayerInfo;
}
}

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_8_R2.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_8_R2.PacketPlayOutScoreboardTeam;
import java.util.Collection;
import java.util.Collections;
/**
* @author Jitse Boonstra
*/
public class PacketPlayOutScoreboardTeamWrapper {
public PacketPlayOutScoreboardTeam createRegisterTeam(String name) {
PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeam = new PacketPlayOutScoreboardTeam();
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "h", int.class)
.set(packetPlayOutScoreboardTeam, 0);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "b", String.class)
.set(packetPlayOutScoreboardTeam, name);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "a", String.class)
.set(packetPlayOutScoreboardTeam, name);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "e", String.class)
.set(packetPlayOutScoreboardTeam, "never");
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "i", int.class)
.set(packetPlayOutScoreboardTeam, 1);
Reflection.FieldAccessor<Collection> collectionFieldAccessor = Reflection.getField(
packetPlayOutScoreboardTeam.getClass(), "g", Collection.class);
collectionFieldAccessor.set(packetPlayOutScoreboardTeam, Collections.singletonList(name));
return packetPlayOutScoreboardTeam;
}
public PacketPlayOutScoreboardTeam createUnregisterTeam(String name) {
PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeam = new PacketPlayOutScoreboardTeam();
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "h", int.class)
.set(packetPlayOutScoreboardTeam, 1);
Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "a", String.class)
.set(packetPlayOutScoreboardTeam, name);
return packetPlayOutScoreboardTeam;
}
}

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_8_R3</artifactId> <artifactId>npclib-nms-v1_8_R3</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_9_R1</artifactId> <artifactId>npclib-nms-v1_9_R1</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId> <artifactId>npclib-nms</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-nms-v1_9_R2</artifactId> <artifactId>npclib-nms-v1_9_R2</artifactId>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>npclib-plugin</artifactId> <artifactId>npclib-plugin</artifactId>
@ -17,7 +17,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version> <version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -26,12 +26,6 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms-v1_8_R2</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib-nms-v1_8_R3</artifactId> <artifactId>npclib-nms-v1_8_R3</artifactId>

View File

@ -7,7 +7,7 @@
<groupId>net.jitse</groupId> <groupId>net.jitse</groupId>
<artifactId>npclib</artifactId> <artifactId>npclib</artifactId>
<version>2.10-SNAPSHOT</version> <version>2.9-SNAPSHOT</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>