use of logisticspipes.security.SecuritySettings in project LogisticsPipes by RS485.
the class ChannelManager method isChannelAllowedFor.
private boolean isChannelAllowedFor(ChannelInformation channel, EntityPlayer player) {
switch(channel.getRights()) {
case PUBLIC:
return true;
case SECURED:
final UUID secUUID = channel.getResponsibleSecurityID();
final LogisticsSecurityTileEntity station = SimpleServiceLocator.securityStationManager.getStation(secUUID);
if (station != null) {
final SecuritySettings settings = station.getSecuritySettingsForPlayer(player, false);
if (settings != null) {
return settings.accessRoutingChannels;
}
}
case PRIVATE:
return channel.getOwner().equals(PlayerIdentifier.get(player));
}
return false;
}
use of logisticspipes.security.SecuritySettings in project LogisticsPipes by RS485.
the class LogisticsSecurityTileEntity method saveNewSecuritySettings.
public void saveNewSecuritySettings(NBTTagCompound tag) {
SecuritySettings setting = settingsList.get(tag.getString("name"));
if (setting == null) {
setting = new SecuritySettings(tag.getString("name"));
settingsList.put(tag.getString("name"), setting);
}
setting.readFromNBT(tag);
}
use of logisticspipes.security.SecuritySettings in project LogisticsPipes by RS485.
the class LogisticsSecurityTileEntity method handleOpenSecurityPlayer.
public void handleOpenSecurityPlayer(EntityPlayer player, @Nonnull String string) {
SecuritySettings setting = settingsList.get(string);
if (setting == null) {
if (string.isEmpty())
return;
setting = new SecuritySettings(string);
settingsList.put(string, setting);
}
NBTTagCompound nbt = new NBTTagCompound();
setting.writeToNBT(nbt);
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SecurityStationOpenPlayer.class).setTag(nbt), player);
}
use of logisticspipes.security.SecuritySettings in project LogisticsPipes by RS485.
the class LogisticsSecurityTileEntity method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
if (par1nbtTagCompound.hasKey("UUID")) {
secId = UUID.fromString(par1nbtTagCompound.getString("UUID"));
}
allowCC = par1nbtTagCompound.getBoolean("allowCC");
allowAutoDestroy = par1nbtTagCompound.getBoolean("allowAutoDestroy");
inv.readFromNBT(par1nbtTagCompound);
settingsList.clear();
NBTTagList list = par1nbtTagCompound.getTagList("settings", 10);
while (list.tagCount() > 0) {
NBTBase base = list.removeTag(0);
String name = ((NBTTagCompound) base).getString("name");
NBTTagCompound value = ((NBTTagCompound) base).getCompoundTag("content");
SecuritySettings settings = new SecuritySettings(name);
settings.readFromNBT(value);
settingsList.put(name, settings);
}
excludedCC.clear();
list = par1nbtTagCompound.getTagList("excludedCC", 3);
while (list.tagCount() > 0) {
NBTBase base = list.removeTag(0);
excludedCC.add(((NBTTagInt) base).getInt());
}
}
use of logisticspipes.security.SecuritySettings in project LogisticsPipes by RS485.
the class LogisticsSecurityTileEntity method writeToNBT.
@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) {
par1nbtTagCompound = super.writeToNBT(par1nbtTagCompound);
par1nbtTagCompound.setString("UUID", getSecId().toString());
par1nbtTagCompound.setBoolean("allowCC", allowCC);
par1nbtTagCompound.setBoolean("allowAutoDestroy", allowAutoDestroy);
inv.writeToNBT(par1nbtTagCompound);
NBTTagList list = new NBTTagList();
for (Entry<String, SecuritySettings> entry : settingsList.entrySet()) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("name", entry.getKey());
NBTTagCompound value = new NBTTagCompound();
entry.getValue().writeToNBT(value);
nbt.setTag("content", value);
list.appendTag(nbt);
}
par1nbtTagCompound.setTag("settings", list);
list = new NBTTagList();
for (Integer i : excludedCC) {
list.appendTag(new NBTTagInt(i));
}
par1nbtTagCompound.setTag("excludedCC", list);
return par1nbtTagCompound;
}
Aggregations