Worked on fixing issues with groups

This commit is contained in:
Robert 2013-11-25 19:17:47 -05:00
parent f5bbcbd925
commit a6c868e7da
7 changed files with 34 additions and 63 deletions

View file

@ -52,7 +52,7 @@ public class Group<J>
return memebers.contains(obj);
}
public String name()
public String getName()
{
return this.groupName;
}

View file

@ -62,7 +62,7 @@ public class AccessGroup extends Group<AccessUser>
public NBTTagCompound save(NBTTagCompound nbt)
{
nbt.setString("groupName", this.name());
nbt.setString("groupName", this.getName());
NBTTagList usersTag = new NBTTagList();
for (AccessUser user : this.memebers)
{
@ -73,7 +73,7 @@ public class AccessGroup extends Group<AccessUser>
usersTag.appendTag(accessData);
}
}
nbt.setTag("Users", usersTag);
nbt.setTag("users", usersTag);
NBTTagList nodesTag = new NBTTagList();
for (String str : this.nodes)
{
@ -91,12 +91,12 @@ public class AccessGroup extends Group<AccessUser>
NBTTagList userList = nbt.getTagList("users");
for (int i = 0; i < userList.tagCount(); ++i)
{
memebers.add(AccessUser.loadFromNBT((NBTTagCompound) userList.tagAt(i)));
this.addMemeber(AccessUser.loadFromNBT((NBTTagCompound) userList.tagAt(i)));
}
userList = nbt.getTagList("nodes");
for (int i = 0; i < userList.tagCount(); ++i)
NBTTagList nodeList = nbt.getTagList("nodes");
for (int i = 0; i < nodeList.tagCount(); ++i)
{
this.nodes.add(((NBTTagCompound) userList.tagAt(i)).getString("name"));
this.nodes.add(((NBTTagCompound) nodeList.tagAt(i)).getString("name"));
}
}

View file

@ -159,7 +159,7 @@ public class GuiGlobalList extends GuiContainer implements IScroll
if (object instanceof AccessUser)
{
AccessUser accesInfo = (AccessUser) object;
line = accesInfo.getName() + " (" + accesInfo.getGroup().name() + ")";
line = accesInfo.getName() + " (" + accesInfo.getGroup().getName() + ")";
}
else if (object instanceof String)
{

View file

@ -36,10 +36,6 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
public void initiate()
{
thisPos = new Vector3(this);
if (this.groups == null || this.groups.isEmpty())
{
TerminalCommandRegistry.loadNewGroupSet(this);
}
}
public Vector3 getThisPos()
@ -264,9 +260,9 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
@Override
public AccessGroup getGroup(String name)
{
for (AccessGroup group : this.groups)
for (AccessGroup group : this.getGroups())
{
if (group.name().equalsIgnoreCase(name))
if (group.getName().equalsIgnoreCase(name))
{
return group;
}
@ -281,7 +277,7 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
{
for (AccessGroup g : this.groups)
{
if (group.name().equalsIgnoreCase(g.name()))
if (group.getName().equalsIgnoreCase(g.getName()))
{
return false;
}
@ -294,16 +290,16 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
@Override
public AccessGroup getOwnerGroup()
{
if (this.getGroup("owner") == null)
{
this.groups.add(new AccessGroup("owner"));
}
return this.getGroup("owner");
}
@Override
public List<AccessGroup> getGroups()
{
if (this.groups == null || this.groups.isEmpty())
{
TerminalCommandRegistry.loadNewGroupSet(this);
}
return this.groups;
}
@ -312,37 +308,10 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
{
super.readFromNBT(nbt);
this.getInventory().loadInv(nbt);
// Read user list
if (!nbt.hasKey("group"))
NBTTagList userList = nbt.getTagList("groups");
if (userList != null && userList.tagCount() > 0)
{
NBTTagList userList = nbt.getTagList("Users");
AccessGroup usr = new AccessGroup("user");
AccessGroup admin = new AccessGroup("admin");
AccessGroup owner = new AccessGroup("owner");
this.groups.add(usr);
this.groups.add(admin);
this.groups.add(owner);
for (int i = 0; i < userList.tagCount(); ++i)
{
AccessUser user = new AccessUser(((NBTTagCompound) userList.tagAt(i)).getString("username"));
switch (nbt.getInteger("ID"))
{
case 1:
case 2:
usr.addMemeber(user);
break;
case 3:
admin.addMemeber(user);
break;
case 4:
owner.addMemeber(user);
break;
}
}
}
else
{
NBTTagList userList = nbt.getTagList("groups");
this.groups.clear();
for (int i = 0; i < userList.tagCount(); i++)
{
AccessGroup group = new AccessGroup("");
@ -357,9 +326,9 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
{
super.writeToNBT(nbt);
this.getInventory().saveInv(nbt);
// Write user list
NBTTagList usersTag = new NBTTagList();
for (AccessGroup group : this.groups)
for (AccessGroup group : this.getGroups())
{
usersTag.appendTag(group.save(new NBTTagCompound()));
}

View file

@ -67,10 +67,7 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
{
this.sendPowerUpdate();
}
if (this.ticks % 5 == 0)
{
this.sendGUIPacket();
}
this.sendGUIPacket();
}
if (this.disabledTicks > 0)
@ -179,7 +176,7 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
}
if (id.equalsIgnoreCase(SimplePacketTypes.NBT.name))
{
this.readFromNBT(Packet.readNBTTagCompound(dis));
this.readFromNBT(PacketHandler.instance().readNBTTagCompound(dis));
return true;
}
}
@ -219,15 +216,18 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
public void sendGUIPacket()
{
if (this.hasGUI && this.getContainer() != null)
if (this.hasGUI && this.getContainer() != null && this.ticks % 5 == 0)
{
this.playersUsingMachine = 0;
for (Object entity : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - 10, yCoord - 10, zCoord - 10, xCoord + 10, yCoord + 10, zCoord + 10)))
for (Object entity : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(10, 10, 10)))
{
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).openContainer.getClass().equals(this.getContainer()))
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).openContainer != null)
{
this.playersUsingMachine += 1;
this.sendGUIPacket(((EntityPlayer) entity));
if (((EntityPlayer) entity).openContainer.getClass().isAssignableFrom(this.getContainer()))
{
this.playersUsingMachine += 1;
this.sendGUIPacket(((EntityPlayer) entity));
}
}
}
}

View file

@ -92,6 +92,7 @@ public class TerminalCommandRegistry
group.addNode(string);
}
}
groups.add(group);
}
return groups;
}
@ -104,7 +105,7 @@ public class TerminalCommandRegistry
List<AccessGroup> groups = getNewGroupSet();
for (AccessGroup group : groups)
{
terminal.addGroup(group);
terminal.addGroup(group);
}
}
}

View file

@ -44,7 +44,8 @@ public abstract class TileEntityTerminal extends TileEntityEnergyMachine impleme
super(wattsPerTick, maxEnergy);
}
public void senGUIPacket(EntityPlayer entity)
@Override
public void sendGUIPacket(EntityPlayer entity)
{
if (!this.worldObj.isRemote)
{