Search in sources :

Example 1 with SecuritySettings

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;
}
Also used : LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) SecuritySettings(logisticspipes.security.SecuritySettings) UUID(java.util.UUID)

Example 2 with SecuritySettings

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);
}
Also used : SecuritySettings(logisticspipes.security.SecuritySettings)

Example 3 with SecuritySettings

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);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SecuritySettings(logisticspipes.security.SecuritySettings)

Example 4 with SecuritySettings

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());
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SecuritySettings(logisticspipes.security.SecuritySettings)

Example 5 with SecuritySettings

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;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagInt(net.minecraft.nbt.NBTTagInt) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SecuritySettings(logisticspipes.security.SecuritySettings)

Aggregations

SecuritySettings (logisticspipes.security.SecuritySettings)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)2 UUID (java.util.UUID)1 LogisticsSecurityTileEntity (logisticspipes.blocks.LogisticsSecurityTileEntity)1 GuiSecurityStation (logisticspipes.gui.GuiSecurityStation)1 NBTBase (net.minecraft.nbt.NBTBase)1 NBTTagInt (net.minecraft.nbt.NBTTagInt)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1