Search in sources :

Example 1 with SatelliteNamingResult

use of logisticspipes.pipes.SatelliteNamingResult in project LogisticsPipes by RS485.

the class SatelliteSetNamePacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.PIPE);
    if (pipe == null || pipe.pipe == null) {
        return;
    }
    String newName = getString();
    SatelliteNamingResult result = null;
    if (newName.trim().isEmpty()) {
        result = SatelliteNamingResult.BLANK_NAME;
    } else if (pipe.pipe instanceof SatellitePipe) {
        final SatellitePipe satellitePipe = (SatellitePipe) pipe.pipe;
        if (satellitePipe.getSatellitesOfType().stream().anyMatch(it -> it.getSatellitePipeName().equals(newName))) {
            result = SatelliteNamingResult.DUPLICATE_NAME;
        } else {
            result = SatelliteNamingResult.SUCCESS;
            satellitePipe.setSatellitePipeName(newName);
            satellitePipe.updateWatchers();
            satellitePipe.ensureAllSatelliteStatus();
        }
    }
    if (result != null) {
        MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SetNameResult.class).setResult(result).setNewName(getString()), player);
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) SatellitePipe(network.rs485.logisticspipes.SatellitePipe) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) EntityPlayer(net.minecraft.entity.player.EntityPlayer) StaticResolve(logisticspipes.utils.StaticResolve) PacketHandler(logisticspipes.network.PacketHandler) MainProxy(logisticspipes.proxy.MainProxy) SatelliteNamingResult(logisticspipes.pipes.SatelliteNamingResult) StringCoordinatesPacket(logisticspipes.network.abstractpackets.StringCoordinatesPacket) SatellitePipe(network.rs485.logisticspipes.SatellitePipe) SatelliteNamingResult(logisticspipes.pipes.SatelliteNamingResult) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Aggregations

PacketHandler (logisticspipes.network.PacketHandler)1 ModernPacket (logisticspipes.network.abstractpackets.ModernPacket)1 StringCoordinatesPacket (logisticspipes.network.abstractpackets.StringCoordinatesPacket)1 SatelliteNamingResult (logisticspipes.pipes.SatelliteNamingResult)1 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)1 MainProxy (logisticspipes.proxy.MainProxy)1 StaticResolve (logisticspipes.utils.StaticResolve)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 SatellitePipe (network.rs485.logisticspipes.SatellitePipe)1