Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package io.papermc.paper.event.player;

import com.google.common.base.Preconditions;
import io.papermc.paper.connection.PlayerCommonConnection;
import io.papermc.paper.connection.PlayerConfigurationConnection;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;

/**
* This event is called when the code of conduct is sent to the player.
*/
@ApiStatus.Experimental
@NullMarked
public class PlayerCodeOfConductSendEvent extends Event {

private static final HandlerList HANDLER_LIST = new HandlerList();

private String codeOfConduct;
private final PlayerCommonConnection connection;

@ApiStatus.Internal
public PlayerCodeOfConductSendEvent(final PlayerConfigurationConnection connection, final String codeOfConduct) {
this.connection = connection;
this.codeOfConduct = codeOfConduct;
}

/**
* Gets the connection that will receive the code of conduct.
*
* @return connection
*/
Comment thread
mbax marked this conversation as resolved.
public PlayerCommonConnection getConnection() {
return connection;
}

/**
* Gets the code of conduct to be sent.
*
* @return the code of conduct
*/
public String getCodeOfConduct() {
return this.codeOfConduct;
}

/**
* Sets the code of conduct to be sent.
*
* @param codeOfConduct the code of conduct
*/
public void setCodeOfConduct(final String codeOfConduct) {
Preconditions.checkArgument(codeOfConduct != null, "Code of Conduct cannot be null");
this.codeOfConduct = codeOfConduct;
}

@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@
this.configurationTasks.add(this.prepareSpawnTask);
this.configurationTasks.add(new JoinWorldTask());
this.startNextTask();
@@ -120,6 +_,12 @@
string = codeOfConducts.values().iterator().next();
}

+ // Paper start - Code of Conduct event
+ io.papermc.paper.event.player.PlayerCodeOfConductSendEvent event = new io.papermc.paper.event.player.PlayerCodeOfConductSendEvent(this.paperConnection, string);
+ event.callEvent();
+ string = event.getCodeOfConduct();
+ // Paper end - Code of Conduct event
+
return string;
}));
}
@@ -132,12 +_,14 @@
@Override
public void handleClientInformation(ServerboundClientInformationPacket packet) {
Expand Down
Loading