Started thinking about the implemtation of #11

This commit is contained in:
Jitse Boonstra
2019-10-21 09:49:23 +02:00
parent 6d5895870b
commit 4d2140d24c
24 changed files with 377 additions and 254 deletions
@@ -6,9 +6,9 @@ package net.jitse.npclib.nms.v1_8_R1;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.state.NPCSlot;
import net.jitse.npclib.hologram.Hologram;
import net.jitse.npclib.hologram._Hologram;
import net.jitse.npclib.internal.MinecraftVersion;
import net.jitse.npclib.internal.SimpleNPC;
import net.jitse.npclib.internal.NPCBase;
import net.jitse.npclib.nms.v1_8_R1.packets.*;
import net.minecraft.server.v1_8_R1.*;
import org.bukkit.Bukkit;
@@ -25,9 +25,9 @@ import java.util.UUID;
/**
* @author Jitse Boonstra
*/
public class NPC_v1_8_R1 extends SimpleNPC {
public class NPC_v1_8_R1 extends NPCBase {
private Hologram hologram;
private _Hologram hologram;
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
@@ -41,7 +41,7 @@ public class NPC_v1_8_R1 extends SimpleNPC {
@Override
public void createPackets() {
this.hologram = new Hologram(location.clone().add(0, 0.5, 0), lines);
this.hologram = new _Hologram(location.clone().add(0, 0.5, 0), text);
hologram.generatePackets(MinecraftVersion.V1_8_R1);
PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper();
@@ -0,0 +1,64 @@
package net.jitse.npclib.nms.v1_8_R1.hologram;
import net.jitse.npclib.hologram.HologramBase;
import org.bukkit.Location;
import java.util.List;
public class Hologram extends HologramBase {
// Perhaps all logic methods should be placed in the base class instead then
// use a similar approach to the NPCBase class, with a HologramPacketHandler class...
// That way I can't mess up logic on different version whilst implementing new features.
// *cough cough* hologram text updates. I can already see this go wrong.
public Hologram(Location start, List<String> text) {
super(start, text);
}
// @Override
// public void show(Player player) {
// UUID uuid = player.getUniqueId();
// if (shown.contains(uuid))
// throw new IllegalArgumentException("Hologram is already shown to player");
//
// // TODO: Send packets
//
// this.shown.add(uuid);
// }
//
// @Override
// public void hide(Player player) {
// UUID uuid = player.getUniqueId();
// if (!shown.contains(uuid))
// throw new IllegalArgumentException("Hologram is not shown to player");
//
// // TODO: Send packets
//
// this.shown.remove(uuid);
// }
//
// @Override
// public void silentHide(UUID uuid) {
// if (!shown.contains(uuid))
// throw new IllegalArgumentException("Hologram is not shown to player");
// this.shown.remove(uuid);
// }
//
// @Override
// public void updateText(List<String> text) {
//
// }
@Override
public void sendTextUpdatePackets(int index, String newLine) {
if (newLine.isEmpty()) {
// Check if line was empty before, if not, remove the hologram line.
} else {
// Check if line was empty before, if it was, create the hologram line.
// If the line was not empty before and it isn't now, update its text.
}
// Send the packets to all players that can see the hologram (i.e. shown set).
}
}