|
| 1 | +package io.papermc.paper.event.player; |
| 2 | + |
| 3 | +import com.google.common.base.Preconditions; |
| 4 | +import io.papermc.paper.connection.PlayerCommonConnection; |
| 5 | +import io.papermc.paper.connection.PlayerConfigurationConnection; |
| 6 | +import org.bukkit.event.Event; |
| 7 | +import org.bukkit.event.HandlerList; |
| 8 | +import org.jetbrains.annotations.ApiStatus; |
| 9 | +import org.jspecify.annotations.NullMarked; |
| 10 | + |
| 11 | +/** |
| 12 | + * This event is called when the code of conduct is sent to the player. |
| 13 | + */ |
| 14 | +@ApiStatus.Experimental |
| 15 | +@NullMarked |
| 16 | +public class PlayerCodeOfConductSendEvent extends Event { |
| 17 | + |
| 18 | + private static final HandlerList HANDLER_LIST = new HandlerList(); |
| 19 | + |
| 20 | + private String codeOfConduct; |
| 21 | + private final PlayerCommonConnection connection; |
| 22 | + |
| 23 | + @ApiStatus.Internal |
| 24 | + public PlayerCodeOfConductSendEvent( final PlayerConfigurationConnection connection, final String codeOfConduct) { |
| 25 | + this.connection = connection; |
| 26 | + this.codeOfConduct = codeOfConduct; |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Gets the connection that will receive the code of conduct. |
| 31 | + * |
| 32 | + * @return connection |
| 33 | + */ |
| 34 | + public PlayerCommonConnection getConnection() { |
| 35 | + return connection; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Gets the code of conduct to be sent. |
| 40 | + * |
| 41 | + * @return the code of conduct |
| 42 | + */ |
| 43 | + public String getCodeOfConduct() { |
| 44 | + return this.codeOfConduct; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Sets the code of conduct to be sent. |
| 49 | + * |
| 50 | + * @param codeOfConduct the code of conduct |
| 51 | + */ |
| 52 | + public void setCodeOfConduct(final String codeOfConduct) { |
| 53 | + Preconditions.checkArgument(codeOfConduct != null, "Code of Conduct cannot be null"); |
| 54 | + this.codeOfConduct = codeOfConduct; |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public HandlerList getHandlers() { |
| 59 | + return HANDLER_LIST; |
| 60 | + } |
| 61 | + |
| 62 | + public static HandlerList getHandlerList() { |
| 63 | + return HANDLER_LIST; |
| 64 | + } |
| 65 | +} |
0 commit comments