Reformatted code using IntelliJ

This commit is contained in:
Finn
2025-09-29 18:46:31 +02:00
parent f9ec00add4
commit facac103e7
30 changed files with 298 additions and 153 deletions

View File

@@ -29,6 +29,7 @@ public abstract class OACPacket extends Packet {
/**
* Constructor for OACPacket.
*
* @param id The unique identifier for the packet.
* @param protocolVersion The protocol version associated with this packet.
*/
@@ -39,6 +40,7 @@ public abstract class OACPacket extends Packet {
/**
* Gets the response code for the packet.
*
* @return The DNSResponseCode associated with the packet.
*/
protected final DNSResponseCode getResponseCode() {
@@ -47,6 +49,7 @@ public abstract class OACPacket extends Packet {
/**
* Sets the response code for the packet.
*
* @param responseCode The DNSResponseCode to set for the packet.
*/
protected final void setResponseCode(DNSResponseCode responseCode) {
@@ -55,6 +58,7 @@ public abstract class OACPacket extends Packet {
/**
* Writes the packet data to the output stream.
*
* @param packetHandler The packet handler managing the packet.
* @param objectOutputStream The output stream to write the packet data to.
* @throws IOException If an I/O error occurs.
@@ -75,7 +79,8 @@ public abstract class OACPacket extends Packet {
onRead(packetHandler, objectInputStream);
// Read the response code if the protocol version is not classic
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC) responseCode = (DNSResponseCode) objectInputStream.readObject();
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC)
responseCode = (DNSResponseCode) objectInputStream.readObject();
else responseCode = DNSResponseCode.RESPONSE_NOT_REQUIRED;
// Call the response code read handler
@@ -84,6 +89,7 @@ public abstract class OACPacket extends Packet {
/**
* Abstract method to be implemented by subclasses for writing specific packet data.
*
* @param packetHandler The packet handler managing the packet.
* @param objectOutputStream The output stream to write the packet data to.
* @throws IOException If an I/O error occurs.
@@ -93,8 +99,9 @@ public abstract class OACPacket extends Packet {
/**
* Abstract method to be implemented by subclasses for reading specific packet data.
* @param packetHandler The packet handler managing the packet.
* @param objectInputStream The input stream to read the packet data from.
*
* @param packetHandler The packet handler managing the packet.
* @param objectInputStream The input stream to read the packet data from.
* @throws IOException If an I/O error occurs.
* @throws ClassNotFoundException If a class cannot be found during deserialization.
*/
@@ -103,8 +110,10 @@ public abstract class OACPacket extends Packet {
/**
* Method called after the response code has been read from the input stream.
* Subclasses can override this method to handle any additional logic based on the response code.
* @param packetHandler The packet handler managing the packet.
* @param objectInputStream The input stream from which the response code was read.
*
* @param packetHandler The packet handler managing the packet.
* @param objectInputStream The input stream from which the response code was read.
*/
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {}
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
}
}

View File

@@ -5,10 +5,10 @@ import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_DomainPacketReceivedEvent;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import java.io.IOException;
import java.io.ObjectInputStream;

View File

@@ -27,7 +27,8 @@ public final class Classic_MessagePacket extends OACPacket {
@Override
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
if (ProtocolBridge.getInstance().isRunningAsDNSServer() || ProtocolBridge.getInstance().isRunningAsWebServer()) objectOutputStream.writeInt(clientID);
if (ProtocolBridge.getInstance().isRunningAsDNSServer() || ProtocolBridge.getInstance().isRunningAsWebServer())
objectOutputStream.writeInt(clientID);
else if (ProtocolBridge.getInstance().isRunningAsClient()) {
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
objectOutputStream.writeInt(clientID);

View File

@@ -6,10 +6,10 @@ import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_PingPacketReceivedEvent;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import java.io.IOException;
import java.io.ObjectInputStream;