Search in sources :

Example 1 with IChannelManager

use of logisticspipes.interfaces.routing.IChannelManager in project LogisticsPipes by RS485.

the class ChannelManagerProvider method getChannelManager.

@Override
public IChannelManager getChannelManager(@Nonnull World world) {
    if (worldWeakReference == null || worldWeakReference.get() == null || channelManager == null) {
        worldWeakReference = new WeakReference<>(world);
        if (channelManager != null) {
            channelManager.markDirty();
        }
        channelManager = new ChannelManager(world);
    }
    return channelManager;
}
Also used : IChannelManager(logisticspipes.interfaces.routing.IChannelManager)

Example 2 with IChannelManager

use of logisticspipes.interfaces.routing.IChannelManager in project LogisticsPipes by RS485.

the class AddNewChannelPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    IChannelManager manager = SimpleServiceLocator.channelManagerProvider.getChannelManager(player.getEntityWorld());
    manager.createNewChannel(name, PlayerIdentifier.get(player), rights, securityStationID);
}
Also used : IChannelManager(logisticspipes.interfaces.routing.IChannelManager)

Example 3 with IChannelManager

use of logisticspipes.interfaces.routing.IChannelManager in project LogisticsPipes by RS485.

the class DeleteChannelPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    IChannelManager manager = SimpleServiceLocator.channelManagerProvider.getChannelManager(player.getEntityWorld());
    manager.removeChannel(channelIdentifier);
}
Also used : IChannelManager(logisticspipes.interfaces.routing.IChannelManager)

Example 4 with IChannelManager

use of logisticspipes.interfaces.routing.IChannelManager in project LogisticsPipes by RS485.

the class EditChannelPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    IChannelManager manager = SimpleServiceLocator.channelManagerProvider.getChannelManager(player.getEntityWorld());
    Optional<ChannelInformation> channelOpt = manager.getChannels().stream().filter(chan -> chan.getChannelIdentifier().equals(channelIdentifier)).findFirst();
    if (channelOpt.isPresent()) {
        ChannelInformation channel = channelOpt.get();
        if (!channel.getName().equals(getName())) {
            manager.updateChannelName(channelIdentifier, getName());
        }
        if (!channel.getRights().equals(getRights()) || (channel.getResponsibleSecurityID() != null && getSecurityStationID() != null && !channel.getResponsibleSecurityID().equals(getSecurityStationID())) || channel.getResponsibleSecurityID() != getSecurityStationID()) {
            manager.updateChannelRights(channelIdentifier, getRights(), getSecurityStationID());
        }
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) Setter(lombok.Setter) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) Getter(lombok.Getter) LPDataInput(network.rs485.logisticspipes.util.LPDataInput) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IChannelManager(logisticspipes.interfaces.routing.IChannelManager) Optional(java.util.Optional) ChannelInformation(logisticspipes.routing.channels.ChannelInformation) StaticResolve(logisticspipes.utils.StaticResolve) UUID(java.util.UUID) LPDataOutput(network.rs485.logisticspipes.util.LPDataOutput) ChannelInformation(logisticspipes.routing.channels.ChannelInformation) IChannelManager(logisticspipes.interfaces.routing.IChannelManager)

Example 5 with IChannelManager

use of logisticspipes.interfaces.routing.IChannelManager in project LogisticsPipes by RS485.

the class OpenEditChannelGUIPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(getPosX(), getPosY(), getPosZ()));
    UUID securityID = null;
    if (tile instanceof LogisticsSecurityTileEntity) {
        LogisticsSecurityTileEntity security = (LogisticsSecurityTileEntity) tile;
        securityID = security.getSecId();
    }
    UUID finalSecurityID = securityID;
    IChannelManager channelManager = SimpleServiceLocator.channelManagerProvider.getChannelManager(player.getEntityWorld());
    Optional<ChannelInformation> match = channelManager.getChannels().stream().filter(channel -> channel.getChannelIdentifier().toString().equals(getIdentifier())).findFirst();
    match.ifPresent(channel -> NewGuiHandler.getGui(EditChannelGuiProvider.class).setResponsibleSecurityID(finalSecurityID).setChannel(channel).open(player));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) NewGuiHandler(logisticspipes.network.NewGuiHandler) Setter(lombok.Setter) Getter(lombok.Getter) LPDataInput(network.rs485.logisticspipes.util.LPDataInput) BlockPos(net.minecraft.util.math.BlockPos) UUID(java.util.UUID) LPDataOutput(network.rs485.logisticspipes.util.LPDataOutput) CoordinatesPacket(logisticspipes.network.abstractpackets.CoordinatesPacket) EditChannelGuiProvider(logisticspipes.network.guis.EditChannelGuiProvider) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IChannelManager(logisticspipes.interfaces.routing.IChannelManager) Optional(java.util.Optional) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) ChannelInformation(logisticspipes.routing.channels.ChannelInformation) StaticResolve(logisticspipes.utils.StaticResolve) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) ChannelInformation(logisticspipes.routing.channels.ChannelInformation) IChannelManager(logisticspipes.interfaces.routing.IChannelManager) BlockPos(net.minecraft.util.math.BlockPos) UUID(java.util.UUID)

Aggregations

IChannelManager (logisticspipes.interfaces.routing.IChannelManager)9 Optional (java.util.Optional)4 UUID (java.util.UUID)4 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)4 ChannelInformation (logisticspipes.routing.channels.ChannelInformation)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 NewGuiHandler (logisticspipes.network.NewGuiHandler)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 Nonnull (javax.annotation.Nonnull)2