For developers - PluginsCDTribe/VexView GitHub Wiki
VexGui
To use VexView to display a custom GUI, you need to use the VexGui object.
The corresponding construction method is as follows:
This object contains the following attributes:
url
picture URL
x
coordinate of the x texture display
y
coordinates of the y texture display
w
The actual width of the texture
h
The actual height of the texture
xs
Texture display width (can be used for scaling)
ys
Texture display height (can be used for zooming)
lvc
Components contained in the GUI (VexComponents)
"Components" include: buttons, text content, pictures, The components will be described later.
You can add components to a VexGui object using the addComponent()
method.
VexComponents
The VexText, VexImage, VexButton, and VexTextField classes all inherit from the VexComponents class. They all belong to the GUI component.
They are: text content, picture content, buttons, text boxes
A GUI can contain multiple components. With the combination of these components, a more perfect GUI will come out.
- VexText has 3 properties: text content, X coordinate, Y coordinate
- VexImage has 7 attributes: picture URL, X coordinate, Y coordinate, actual width of picture, actual length of picture, picture display width, picture display length
- VexButton has 8 properties: Button ID, Button Name, Button X Coordinate, Button Y Coordinate, Button Map Length, Button Map Width, Button Function (ButtonFunction Interface)
- VexTextField has 5 properties: X coordinate, Y coordinate, text box width, text box length, maximum input text number (must be greater than 0)
You can implement the Run method of the ButtonFunction interface when creating a VexButton object. The method body is the function that needs to be executed after the button is pressed.
Pay special attention to the ID of the button. Do not repeat it!
VexTextField
The text box component allows the player to enter text content. If the player opens a GUI and contains a text box, you can get what he enters at any time:
VexViewAPI.getTextField(Player player);
After using this method, you need to listen to the TextFieldGetEvent event to get the player's input.
Open the GUI for the player
You can use the openGui()
static method of the VexViewAPI class to open a GUI for the player.
Event system
The plug-in provides five kinds of events for controlling the player's various behaviors.
From top to bottom they are:
- BQConversationOptionSelectionEvent (monitoring player selected option)
- ButtonclickEvent (used to listen to player click on custom button)
- DownloadFailedEvent (Failed to download the client image)
- PlayerClosesMenuEvent (the player triggers after pressing ESC)
- CustomScoreboardEvent (called before each refresh scoreboard content)
Among them, there is an enumeration class in DownloadFailed
- It includes:
GUI, IMAGE, BUTTON, LOGIN_IMAGE, BQ_NPC_IMAGE, SCOREBOARD_IMAGE
- They are: GUI interface mapping, custom image mapping, custom button mapping, custom login interface, NPC mapping, custom scoreboard
Among them, there is also an enumerated class in PlayerCloseGuiEvent
- It includes:
LOADING, OPENED, LOGIN
- These are: the loading interface, the interface that has been loaded and displayed for the player, and the custom login interface.
Send FlowView scrolling broadcast
As a developer, it is also very simple to send a FlowView message to the player, just call the static method of the VexViewAPI class:
sendFlowView(Player player, String text, int y)
HUD
In the VexView 1.4 version, we provide a new set of APIs, including: lk.vexview.hud
So what's the use of this tool? Have you ever thought that you want the player's client interface to display more things, like scoreboards, chat boxes, etc., players can still display in the game, and you can view relevant information at any time, and this Set of tools is to achieve it!
VexImageShow and VexTextShow
VexImageShow and VexTextShow are two HUD contents provided under the package. They are used to display pictures and text contents respectively.
They all inherit from VexShow, the object must have an id, and like the button can not be repeated.
The relevant parameters are the same as VexGui, VexImage, etc. However, it should be noted that VexImageShow and VexTextShow can set the display time and disappear automatically after a certain period of time. Of course, you can set it to 0 or negative number to make it permanent. display.
Regarding the coordinates of VexImageShow and VexTextShow, you can set it to a negative number to make it to the right.
Send a HUD component to the player
When you complete the object creation of the HUD-related component, you can send the HUD component to the player and display it just like the GUI.
VexViewAPI.sendHUD(Player player, VexShow v);
Only one VexShow object can be sent at a time, but the client can have more than one VexShow content at a time.
Remove the HUD component for the client
If you want to remove the player client HUD component, you can use this method:
VexViewAPI.removeHUD(Player player, int id);
ID is the id of the VexShow object (now know why id can't be duplicated?)