mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 05:45:03 +00:00
Fix UUIDs not saving to NPCs - Revert TagMapUUID List
This commit is contained in:
1 parent
aa02580c28
commit
9d68a5e079
4 files changed
+19
-29
No files matched your search
@@ -103,7 +103,7 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (UUID uuid : npc.advanced.tagUUIDs) {
|
||||
Tag tag = TagController.getInstance().get(uuid);
|
||||
Tag tag = TagController.getInstance().getTagFromUUID(uuid);
|
||||
if (tag != null) {
|
||||
tagList.appendTag(new NBTTagString(tag.name));
|
||||
}
|
||||
@@ -763,7 +763,7 @@ public class PacketHandlerServer{
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.TagSet){
|
||||
npc.advanced.tagUUIDs.removeIf(uuid -> TagController.getInstance().get(uuid) != null);
|
||||
npc.advanced.tagUUIDs.removeIf(uuid -> TagController.getInstance().getTagFromUUID(uuid) != null);
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
NBTTagList list = compound.getTagList("TagNames",8);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
@@ -1081,7 +1081,10 @@ public class PacketHandlerServer{
|
||||
TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("CloneTags", tagMap.writeNBT());
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.CloneAllTags) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
HashSet<Tag> validTags = TagController.getInstance().getAllTags();
|
||||
NBTTagList validTagList = new NBTTagList();
|
||||
for(Tag tag : validTags){
|
||||
@@ -1091,6 +1094,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
compound.setTag("AllTags", validTagList);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
System.out.println("-------------- We sent the tags");
|
||||
}
|
||||
else
|
||||
warn(player,"WE 2 tried todo something with the wrong tool, probably a hacker");
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
this.closeOnEsc = true;
|
||||
|
||||
setBackground("menubg.png");
|
||||
Client.sendData(EnumPacketServer.TagsGet);
|
||||
Client.sendData(EnumPacketServer.CloneAllTags, activeTab);
|
||||
}
|
||||
public void initGui()
|
||||
{
|
||||
@@ -357,6 +357,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
Tag tag = new Tag();
|
||||
tag.readNBT(tagStructure);
|
||||
tags.put(tag.uuid, tag);
|
||||
tagNames.put(tag.name, tag.uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public enum EnumPacketServer {
|
||||
RoleCompanionUpdate(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
LinkedSet(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
|
||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList, CloneTagList,
|
||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList, CloneTagList, CloneAllTags,
|
||||
|
||||
ScriptGlobalGuiDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptGlobalGuiDataGet(false),
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class TagController implements ITagHandler {
|
||||
public HashMap<Integer, Tag> tags;
|
||||
public HashMap<UUID, Integer> tagsUUID;
|
||||
private static TagController instance;
|
||||
|
||||
private int lastUsedID = 0;
|
||||
@@ -25,7 +24,6 @@ public class TagController implements ITagHandler {
|
||||
public TagController(){
|
||||
instance = this;
|
||||
tags = new HashMap<Integer, Tag>();
|
||||
tagsUUID = new HashMap<UUID, Integer>();
|
||||
loadTags();
|
||||
// if(tags.isEmpty()){
|
||||
// // TO-DO
|
||||
@@ -85,7 +83,6 @@ public class TagController implements ITagHandler {
|
||||
}
|
||||
}
|
||||
this.tags = tags;
|
||||
this.tagsUUID = tagUUIDs;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBT(){
|
||||
@@ -132,14 +129,6 @@ public class TagController implements ITagHandler {
|
||||
return tags.get(tagSlot);
|
||||
}
|
||||
|
||||
public Tag get(UUID uuid) {
|
||||
Integer id = tagsUUID.get(uuid);
|
||||
if(id != null){
|
||||
get(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ITag> list() {
|
||||
return new ArrayList(this.tags.values());
|
||||
}
|
||||
@@ -159,7 +148,6 @@ public class TagController implements ITagHandler {
|
||||
}
|
||||
tags.remove(tag.id);
|
||||
tags.put(tag.id, tag);
|
||||
tagsUUID.put(tag.uuid, tag.id);
|
||||
saveTags();
|
||||
}
|
||||
|
||||
@@ -193,7 +181,6 @@ public class TagController implements ITagHandler {
|
||||
if (tag == null) {
|
||||
return null;
|
||||
} else {
|
||||
this.tagsUUID.remove(tag.uuid);
|
||||
this.saveTags();
|
||||
tag.id = -1;
|
||||
return tag;
|
||||
@@ -221,6 +208,15 @@ public class TagController implements ITagHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Tag getTagFromUUID(UUID uuid){
|
||||
for (Map.Entry<Integer,Tag> entryTag: TagController.getInstance().tags.entrySet()){
|
||||
if (entryTag.getValue().uuid.equals(uuid)) {
|
||||
return entryTag.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] getNames() {
|
||||
String[] names = new String[tags.size()];
|
||||
int i = 0;
|
||||
@@ -234,15 +230,4 @@ public class TagController implements ITagHandler {
|
||||
public HashSet<Tag> getAllTags(){
|
||||
return new HashSet<Tag>(this.tags.values());
|
||||
}
|
||||
|
||||
public HashSet<Tag> getValidTags(TagMap tagMap){
|
||||
HashSet<Tag> tags = new HashSet<Tag>();
|
||||
for(UUID tagUUID : tagMap.getAllUUIDs()){
|
||||
Tag foundTag = get(tagUUID);
|
||||
if(foundTag != null){
|
||||
tags.add(foundTag);
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user