Search in sources :

Example 1 with SecurityMode

use of mekanism.common.lib.security.SecurityMode in project Mekanism by mekanism.

the class TileComponentSecurity method read.

@Override
public void read(CompoundNBT nbtTags) {
    if (nbtTags.contains(NBTConstants.COMPONENT_SECURITY, NBT.TAG_COMPOUND)) {
        CompoundNBT securityNBT = nbtTags.getCompound(NBTConstants.COMPONENT_SECURITY);
        NBTUtils.setEnumIfPresent(securityNBT, NBTConstants.SECURITY_MODE, SecurityMode::byIndexStatic, mode -> securityMode = mode);
        NBTUtils.setUUIDIfPresent(securityNBT, NBTConstants.OWNER_UUID, uuid -> ownerUUID = uuid);
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) SecurityMode(mekanism.common.lib.security.SecurityMode)

Example 2 with SecurityMode

use of mekanism.common.lib.security.SecurityMode in project Mekanism by mekanism.

the class GuiSecurityTab method getOverlay.

@Override
protected ResourceLocation getOverlay() {
    SecurityMode mode = getSecurity();
    UUID ownerUUID = dataSource.getOwnerUUID();
    SecurityData data = ownerUUID == null ? null : MekanismClient.clientSecurityMap.get(ownerUUID);
    if (data != null && data.override) {
        mode = data.mode;
    }
    if (mode == SecurityMode.PRIVATE) {
        return PRIVATE;
    } else if (mode == SecurityMode.TRUSTED) {
        return PROTECTED;
    }
    return super.getOverlay();
}
Also used : SecurityMode(mekanism.common.lib.security.SecurityMode) PacketSecurityMode(mekanism.common.network.to_server.PacketSecurityMode) SecurityData(mekanism.common.lib.security.SecurityData) UUID(java.util.UUID)

Example 3 with SecurityMode

use of mekanism.common.lib.security.SecurityMode in project Mekanism by mekanism.

the class EntityRobit method setSecurityMode.

@Override
public void setSecurityMode(SecurityMode mode) {
    if (securityMode != mode) {
        SecurityMode old = securityMode;
        securityMode = mode;
        onSecurityChanged(old, securityMode);
    }
}
Also used : SecurityMode(mekanism.common.lib.security.SecurityMode)

Example 4 with SecurityMode

use of mekanism.common.lib.security.SecurityMode in project Mekanism by mekanism.

the class TileComponentSecurity method setMode.

public void setMode(SecurityMode mode) {
    if (securityMode != mode) {
        SecurityMode old = securityMode;
        securityMode = mode;
        tile.markDirty(false);
        tile.onSecurityChanged(old, securityMode);
    }
}
Also used : SecurityMode(mekanism.common.lib.security.SecurityMode)

Example 5 with SecurityMode

use of mekanism.common.lib.security.SecurityMode in project Mekanism by mekanism.

the class TileEntitySecurityDesk method setSecurityDeskMode.

public void setSecurityDeskMode(SecurityMode mode) {
    SecurityFrequency frequency = getFreq();
    if (frequency != null) {
        SecurityMode old = frequency.getSecurityMode();
        if (old != mode) {
            frequency.setSecurityMode(mode);
            markDirty(false);
            // send the security update to other players; this change will be visible on machine security tabs
            Mekanism.packetHandler.sendToAll(new PacketSecurityUpdate(frequency.getOwner(), new SecurityData(frequency)));
            if (old == SecurityMode.PUBLIC || (old == SecurityMode.TRUSTED && mode == SecurityMode.PRIVATE)) {
                validateAccess();
            }
        }
    }
}
Also used : SecurityFrequency(mekanism.common.lib.security.SecurityFrequency) SecurityMode(mekanism.common.lib.security.SecurityMode) SecurityData(mekanism.common.lib.security.SecurityData) PacketSecurityUpdate(mekanism.common.network.to_client.PacketSecurityUpdate)

Aggregations

SecurityMode (mekanism.common.lib.security.SecurityMode)5 SecurityData (mekanism.common.lib.security.SecurityData)2 UUID (java.util.UUID)1 SecurityFrequency (mekanism.common.lib.security.SecurityFrequency)1 PacketSecurityUpdate (mekanism.common.network.to_client.PacketSecurityUpdate)1 PacketSecurityMode (mekanism.common.network.to_server.PacketSecurityMode)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1