Skip to content

Commit

Permalink
✨ Add a way to get player's brand
Browse files Browse the repository at this point in the history
  • Loading branch information
YvanMazy committed Apr 9, 2024
1 parent aa85ab5 commit f4d814b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ default void disconnect(final @NotNull String reason) {

void setHost(final @NotNull String hostname, final int hostPort);

void setBrand(final @Nullable String brand);

String getName();

UUID getUUID();
Expand All @@ -95,6 +97,13 @@ default void disconnect(final @NotNull String reason) {

int getHostPort();

default boolean hasBrand() {
return this.getBrand() != null;
}

@Nullable
String getBrand();

boolean isFromTransfer();

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class PlayerConnectionImpl extends SimpleChannelInboundHandler<Serverboun
private UUID uuid;
private ClientInformation information;
private boolean fromTransfer;
private String brand;

public PlayerConnectionImpl(final @NotNull Channel channel) {
this.channel = Objects.requireNonNull(channel, "channel must not be null");
Expand Down Expand Up @@ -280,6 +281,11 @@ public void setHost(final @NotNull String hostname, final int hostPort) {
this.hostPort = hostPort;
}

@Override
public void setBrand(final @Nullable String brand) {
this.brand = brand;
}

@Override
public String getName() {
return this.name;
Expand Down Expand Up @@ -320,6 +326,11 @@ public int getHostPort() {
return this.hostPort;
}

@Override
public @Nullable String getBrand() {
return this.brand;
}

@Override
public boolean isFromTransfer() {
return this.fromTransfer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public static PluginMessagePacket from(final @NotNull ByteBuf buf) {

@Override
public void handle(final @NotNull PlayerConnection connection) {
// do nothing
if (this.payload != null) {
this.payload.handle(connection);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package be.darkkraft.transferproxy.network.packet.config.payload;

import be.darkkraft.transferproxy.api.network.connection.PlayerConnection;
import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.NotNull;

Expand All @@ -36,6 +37,11 @@ public BrandPayload(final @NotNull ByteBuf buf) {
this(readString(buf));
}

@Override
public void handle(final @NotNull PlayerConnection connection) {
connection.setBrand(this.brand);
}

@Override
public void write(final @NotNull ByteBuf buf) {
writeString(buf, this.brand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@

package be.darkkraft.transferproxy.network.packet.config.payload;

import be.darkkraft.transferproxy.api.network.connection.PlayerConnection;
import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.NotNull;

public interface PayloadData {

void handle(final @NotNull PlayerConnection connection);

void write(final @NotNull ByteBuf buf);

String getChannel();
Expand Down

0 comments on commit f4d814b

Please sign in to comment.