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);
}
}
Aggregations