2022-07-21 02:19:28 +02:00
|
|
|
|
package fr.pandacube.lib.players.standalone;
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
2022-08-08 03:16:00 +02:00
|
|
|
|
import fr.pandacube.lib.chat.ChatStatic;
|
2021-07-11 16:14:47 +02:00
|
|
|
|
import net.kyori.adventure.identity.Identified;
|
|
|
|
|
import net.kyori.adventure.identity.Identity;
|
|
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
|
import net.kyori.adventure.text.ComponentLike;
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
2022-08-08 03:16:00 +02:00
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.UUID;
|
2022-07-21 02:19:28 +02:00
|
|
|
|
|
2022-08-10 03:04:12 +02:00
|
|
|
|
/**
|
|
|
|
|
* Represents any online player.
|
|
|
|
|
*/
|
|
|
|
|
public interface AbstractOnlinePlayer extends AbstractOffPlayer {
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* General data and state
|
|
|
|
|
*/
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
2021-03-21 20:17:31 +01:00
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Returns the name of the current server the player is in.
|
|
|
|
|
* The returned value is used by the 'pandalib-permissions' system.
|
|
|
|
|
* @return the name of the current server the player is in.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
String getServerName();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the name of the current world the player is in.
|
|
|
|
|
* The returned value is used by the 'pandalib-permissions' system.
|
|
|
|
|
* @return the name of the current world the player is in.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
String getWorldName();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
2022-08-08 03:16:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Permissions and groups
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if this online player has the specified permission.
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* @param permission the permission to test on that player.
|
|
|
|
|
* @return weither this player has the specified permission or not.
|
2022-08-08 03:16:00 +02:00
|
|
|
|
* @implSpec Implementation of this method should call the permission system of their environment (paper/bungee),
|
|
|
|
|
* so this method will work independently of the usage of the 'pandalib-permissions' module.
|
|
|
|
|
*/
|
|
|
|
|
boolean hasPermission(String permission);
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
2022-04-10 01:11:12 +02:00
|
|
|
|
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
2022-08-08 03:16:00 +02:00
|
|
|
|
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
2022-07-21 02:19:28 +02:00
|
|
|
|
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sending packet and stuff to player
|
|
|
|
|
*/
|
|
|
|
|
|
2021-07-11 16:14:47 +02:00
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Display the provided message in the player’s chat, if the chat is activated.
|
2021-07-11 16:14:47 +02:00
|
|
|
|
* @param message the message to display.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
void sendMessage(Component message);
|
2021-07-11 16:14:47 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Display the provided message in the player’s chat, if the chat is activated.
|
2021-07-11 16:14:47 +02:00
|
|
|
|
* @param message the message to display.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
default void sendMessage(ComponentLike message) {
|
2021-07-11 16:14:47 +02:00
|
|
|
|
sendMessage(message.asComponent());
|
|
|
|
|
}
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
2021-07-11 16:14:47 +02:00
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Display the provided message in the player’s chat, if they allows to display CHAT messages.
|
2021-07-11 16:14:47 +02:00
|
|
|
|
* @param message the message to display.
|
|
|
|
|
* @param sender the player causing the send of this message. Client side filtering may occur.
|
|
|
|
|
* May be null if we don’t want client filtering, but still consider the message as CHAT message.
|
|
|
|
|
* @implNote implementation of this method should not filter the send of the message, based on
|
|
|
|
|
* the sender. This parameter is only there to be transmitted to the client, so client side filtering can
|
|
|
|
|
* be processed.
|
|
|
|
|
*/
|
2022-07-21 02:19:28 +02:00
|
|
|
|
void sendMessage(Component message, Identified sender);
|
2021-07-11 16:14:47 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Display the provided message in the player’s chat, if they allows to display CHAT messages.
|
2022-07-21 02:19:28 +02:00
|
|
|
|
* @param message the message to display
|
2021-07-11 16:14:47 +02:00
|
|
|
|
* @param sender the player causing the send of this message. Client side filtering may occur.
|
|
|
|
|
* May be null if we don’t want client filtering, but still consider the message as CHAT message.
|
|
|
|
|
* @implNote implementation of this method should not filter the send of the message, based on
|
|
|
|
|
* the sender. This parameter is only there to be transmitted to the client, so client side filtering can
|
|
|
|
|
* be processed.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
default void sendMessage(ComponentLike message, UUID sender) {
|
2022-07-21 02:19:28 +02:00
|
|
|
|
sendMessage(message.asComponent(), () -> sender == null ? Identity.nil() : Identity.identity(sender));
|
2021-07-11 16:14:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-21 20:17:31 +01:00
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Display the provided message in the player’s chat, if the chat is activated, prepended with the server prefix.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
* @param message the message to display
|
|
|
|
|
*/
|
2022-07-21 02:19:28 +02:00
|
|
|
|
default void sendPrefixedMessage(ComponentLike message) {
|
|
|
|
|
sendMessage(ChatStatic.prefixedAndColored(message));
|
2021-03-21 20:17:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-11 16:14:47 +02:00
|
|
|
|
/**
|
|
|
|
|
* Display a title in the middle of the screen.
|
|
|
|
|
* @param title The big text
|
|
|
|
|
* @param subtitle The less big text
|
|
|
|
|
* @param fadeIn Fade in time in tick
|
|
|
|
|
* @param stay Stay time in tick
|
|
|
|
|
* @param fadeOut Fade out time in tick
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
void sendTitle(Component title, Component subtitle, int fadeIn, int stay, int fadeOut);
|
2021-07-11 16:14:47 +02:00
|
|
|
|
|
2021-03-21 20:17:31 +01:00
|
|
|
|
/**
|
|
|
|
|
* Display a title in the middle of the screen.
|
|
|
|
|
* @param title The big text
|
|
|
|
|
* @param subtitle The less big text
|
|
|
|
|
* @param fadeIn Fade in time in tick
|
|
|
|
|
* @param stay Stay time in tick
|
|
|
|
|
* @param fadeOut Fade out time in tick
|
|
|
|
|
*/
|
2022-07-21 02:19:28 +02:00
|
|
|
|
default void sendTitle(ComponentLike title, ComponentLike subtitle, int fadeIn, int stay, int fadeOut) {
|
|
|
|
|
sendTitle(title.asComponent(), subtitle.asComponent(), fadeIn, stay, fadeOut);
|
2021-03-21 20:17:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Update the server brand field in the debug menu (F3) of the player (third line in 1.15 debug screen).
|
|
|
|
|
* Supports legacy section format but no line break.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
* @param brand the server brand to send to the client.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
void sendServerBrand(String brand);
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Client options
|
|
|
|
|
*/
|
|
|
|
|
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current client options of this player.
|
|
|
|
|
* @return the current client options of this player.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
ClientOptions getClientOptions();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Interface providing various configuration values of the Minecraft client.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
interface ClientOptions {
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The language of the client interface.
|
|
|
|
|
* @return language of the client interface.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
Locale getLocale();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The client view distance, in chunks.
|
|
|
|
|
* @return client view distance, in chunks.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
int getViewDistance();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If the chat displays the text colors.
|
|
|
|
|
* @return true if the chat displays the text colors, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasChatColorEnabled();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Tells if the client is configured to completely hide the chat to the player. When this is the case, nothing
|
|
|
|
|
* is displayed in the chat box, and the player can’t send any message or command.
|
|
|
|
|
* @return true if the chat is fully hidden, false otherwise.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean isChatHidden();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Tells if the client is configured to display the chat normally. When this is the case, chat messages and
|
|
|
|
|
* system messages are displayed in the chat box, and the player can send messages and commands.
|
|
|
|
|
* @return true if the chat is fully visible, false otherwise.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean isChatFullyVisible();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Tells if the client is configured to only display system messages in the chat.
|
|
|
|
|
* When this is the case, chat messages are hidden but system messages are visible in the chat box, and the
|
|
|
|
|
* player can only send commands.
|
|
|
|
|
* @return true if the chat is visible but only shows system messages, false otherwise.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean isChatOnlyDisplayingSystemMessages();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the client has configured the main hand on the left.
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* @return true if the player’s character is left handed, false otherwise.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean isLeftHanded();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the client has configured the main hand on the right.
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* @return true if the player’s character is right handed, false otherwise.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean isRightHanded();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
|
2022-02-01 20:26:46 +01:00
|
|
|
|
/**
|
|
|
|
|
* Tells if the client has enabled the filtering of texts on sign and book titles.
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* @return true if the client filters swearing in texts, false otherwise.
|
2022-02-01 20:26:46 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean isTextFilteringEnabled();
|
2022-02-01 20:26:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Tells if the client allows the server to list their player name in the multiplayer menu.
|
|
|
|
|
* <b>To respect the player privacy’s configuration, this configuration value must be verified when generating
|
|
|
|
|
* custom ping response packet (MOTD in multiplayer server’s menu) that includes player names.</b>
|
|
|
|
|
* @return true if the client allows the server to list their player name in the multiplayer menu, false
|
|
|
|
|
* otherwise.
|
2022-02-01 20:26:46 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean allowsServerListing();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the cape is enabled on the player’s skin.
|
|
|
|
|
* @return true if the cape is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinCapeEnabled();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the jacket is enabled on the player’s skin.
|
|
|
|
|
* @return true if the jacket is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinJacketEnabled();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the left sleeve is enabled on the player’s skin.
|
|
|
|
|
* @return true if the left sleeve is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinLeftSleeveEnabled();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the right sleeve is enabled on the player’s skin.
|
|
|
|
|
* @return true if the right sleeve is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinRightSleeveEnabled();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the left pants is enabled on the player’s skin.
|
|
|
|
|
* @return true if the left pants is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinLeftPantsEnabled();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the right pants is enabled on the player’s skin.
|
|
|
|
|
* @return true if the right pants is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinRightPantsEnabled();
|
2022-08-10 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tells if the hat is enabled on the player’s skin.
|
|
|
|
|
* @return true if the hat is enabled on the player’s skin, false otherwise.
|
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
boolean hasSkinHatsEnabled();
|
2021-03-21 20:17:31 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-08-10 03:04:12 +02:00
|
|
|
|
* Tells if the player can send chat messages or receive chat messages from other players, according to their client
|
|
|
|
|
* configuration.
|
|
|
|
|
* <p>
|
|
|
|
|
* Chat messages represent public communication between players. By default, it only include actual chat message.
|
|
|
|
|
* This method may be used in commands like /me, /afk or the login/logout broadcasted messages.
|
|
|
|
|
* @return true if the player can send chat messages or receive chat messages from other players, false otherwise.
|
2021-03-21 20:17:31 +01:00
|
|
|
|
*/
|
2022-07-10 00:55:56 +02:00
|
|
|
|
default boolean canChat() {
|
2021-03-21 20:17:31 +01:00
|
|
|
|
return getClientOptions().isChatFullyVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|