Skip to content

OnlineUser (in edit)

EtroakaSunny edited this page Apr 26, 2023 · 14 revisions

Receive player-object of user in reference

To receive the player object of a user in reference, you can use the following method:

Player getPlayer();

To receive the user data from Minecraft, you can use the following method:

User getUser();

This method returns a User object that provides access to information such as the player's name, UUID, and more.

To prevent a bug when a player joins, you can use the following method to close their inventory:

void closeInventory();

To check if a player is using LabyMod, you can use the following method:

boolean isUsingLabyMod();

This method returns a boolean value indicating whether the player is using LabyMod. Note that there may be a delay before this value is set.

McVersion getVersion();

This method returns an object representing the client's version, which can be useful for determining compatibility with certain features or plugins.

Sound & Ambient

Sound

A sound can be played for a player using void playSound(String sound) or void playSound(Sound sound) methods. The first parameter is always the sound, which can either be a string with the correct sound name or a Sound object.

Optionally, a location can be defined where the sound is played by using a Location object. When a location is defined, a boolean value is needed to define if the sound is spatial.

Example:

void playSound(String sound, Location location, boolean spatial);

void playSound(Sound sound);

Ambient

The current ambient a user is hearing can be obtained by using AmbientSound getAmbient(); .

Credits

The credits of the developers can be sent using void sendCredits();

Sending Messages

Use sendMessage to send messages to a user

The method is overloaded to allow for different options. Options include a prefix, notice, or chat menu

sendActionBar sends a message to the actionbar

Creating Messages

sendMessage sends a message without any prefix or color

sendMessage with Notice sends a message with a clickable notice

sendMessage with MessageType sends a message with a specific prefix

sendMessage with both MessageType and Notice sends a message with a prefix and a clickable notice

sendMessage with BaseComponent allows for hover and click events

sendMessage with both BaseComponent and Notice sends a message with hover and click events and a clickable notice

The notice can provide additional information for the user in reference.

Chat Menu

Use ChatMenu to create a message with clickable options

Use addOption to add options to the menu

An Option contains a string and a Clickable Message

Error Message

Use sendError to send the "Unbekannter Befehl!" message to the player

Chat Interface

Request input of an user Use isInChatInterface to check if the user is in a chat interface Use leaveInterface to stop the input and exit the interface.

Bank

Use askForBankAccount to request the user to select a bank account: void askForBankAccount(Consumer<BankAccount> callback)

The Consumer callback is called when the user selects a bank account. The selected BankAccount is passed to the callback as an argument.

If the user doesn't select a bank account, the callback is not called.

If the user has only one bank account they can access, the callback is immediately called with that account.

Fraction-service

Fraction a player is in

To retrieve the fraction a player is currently in, you can use the method FractionService getFractionService(). If the player is not currently in a fraction, the method will return NONE. Note that the player needs to be in FractionService in order for this method to work.

Joining the fraction-service

To join the fraction-service, you can use the method void enterFractionService(FractionService service). The service parameter specifies which fraction the player is supposed to join. Here is a list of possible fractions that can be used: ENTER LIST HERE

leaving the fraction-service

When a player should leave the fraction-service, the method void leaveFractionService() can be used.

Team-ranks

Check for team-member in service

To verify if a player is a team member who is in team-service boolean isTeamler(); is used. boolean isTeamPlus(); is to receive if the player has the team-member-plus rank. The boolean is true if the player is in team-service / teamPlus-service.

Check for the rank

To change the team-rank of a team member the void setTeamRank(TeamRank rank); method is used. The parameter 'rank' is the new rank the player is supposed to receive. Only players with the permission to do so are able to change the rank.

When the team-member has a custom rank void setCustomTeamRank(String rankName); is used. The parameter 'rankName' is the new custom rank the player is supposed to receive. Only players with the permission to do so are able to change the rank.

In order to check if the player is in a list of team-ranks boolean hasTeamRank(@NonNull TeamRank... ranks); is used.

General-key

A general-key is used for the vehicle system. It grants access to every vehicle. In order to check if the user has the permission to use a general-key boolean isAllowedToUseGeneralKey(); can be used. To check if the user is currently trying to use a general-key by holding the key in his hand boolean isUsingGeneralKey();is used. When the user doesn't have permission to use a general-key, the key is removed from his inventory.

Team- and Supportservice

Teamservice

The Teamservice is used to clearly communicate to players who are currently active on the server as a team-member. A user can enter the team or support service when he has the permission. When the user doesn't have the permission required nothing happens. void joinTeamService(); is used to let the user join the Team Service. To leave the team service again void leaveTeamService(); is used.

Supportservice

The Supportservice is used to show which team-members are currently helping other players. To receive if a user is allowed to enter Supportservice boolean canEnterSupportService(); is used. This doesn't set the user in Supportservice. For that void joinSupportService(); is used. To exit it again void leaveSupportService(); is used. To check if a user is in Supportservice boolean isInSupportService(); can be used. If an user doesn't have the required permission nothing will happen.

Healing and reviving

When a users health reaches zero he is put into a mode where he is unable to move. The void heal(); command will not revive him. The heal method only regenerates his health. To revive him the void revive(); method is used.

Moderating user

In order to moderate user many things are important. This includes idle time and block breaking/placing

Idle

When a user doesn't perform any action on the server his idle time is being measured. After some time he is put into a idle-mode. The interactions with the user are then restricted for other players. To receive weither a user is in idle-mode boolean isIdle(); is used.

Vanish

Team members can enter a vanish state which **doesn't ** affect his visibility. He will be hidden however from things like the tab-list. A Team member can be put into the vanish state by using the void setVanish(boolean vanish); method. This can either be true or false. To check if someone is in vanish boolean isVanish(); is used.

Prison

INFORMATION NEEDED WHETHER THIS IS A PUNISHMENT ON SERVER SIDE OR ARREST OF THE POLICE ** / * Imprisons this user. * * @param duration duration in minutes */ void imprison(int duration);

/**
 * Releases this user from prison (im imprisoned).
 */
void releaseFromPrison();

Check for registration on network

INFORMATION REQUIERED WHETHER THIS IS ONLY FOR BETA-TESTING OR A NORMAL PROCEDURE

Blockplacement

To prevent the destruction of the map a build protection is in place. Since users are going to use the region system to build their own houses a way to build on the region the have permission to. This can be done by using boolean isAllowedToUse(Block block);. This includes placing, breaking and using.

Signs

A sign can either be changed or be cleared. To change a sign the void changeSign(Block block, final String line1, final String line2, final String line3, final String line4); Method is used. Every line can contain a maximum of 15 characters (Minecraft Standard). To clear a sign void resetSign(Block block); is used. This will remove any content from the sign and set it into its default state.

Navigation

To help user navigate on the server a Navigation System is used. To set the navigation void setNavigationTarget(Location location); is used. To reset the navigation void resetNavigationTarget(); is used.

Update Last join

Use updateLatestJoin() to update the last join time of a user.

This method updates the player's lastJoin attribute to the current time.

Vehicle

Retrieving the current vehicle

To retrieve the current vehicle of a player, you can use the getVehicle() method which returns a LoadedVehicle object.

Checking registration

To check if a vehicle is registered, you can use the void checkRegistration(); method.

Sudo

The performCommand(String command) method is used when a player needs to perform a command as if it was executed by another player or the console.

Inventory

Add an item

To add an item to a player's inventory, you can use the boolean addItem(ItemStack item) method. This method will attempt to add the given ItemStack to the player's inventory, and will return true if it was successful, and false otherwise.

Inventory Slots

Amount of Free Inventory

To get the amount of free inventory slots that a player has, you can use the int getAmountOfFreeInventorySlots() method. This method will return the number of empty slots in the player's inventory.

If the player has free Inventory Slots

To check if a player has any free inventory slots, you can use the boolean hasFreeInventorySlot() method. This method will return true if the player has at least one empty inventory slot, and false otherwise.