public class GuiMessageBox extends GuiModalWindow
The message box manages its own event Listener; it also turns the mouse cursor on on display and off on hiding.
GuiMessageBox inherits all GuiModalWindow behaviours.
This message box is practically "fire-and-forget": once it is shown, the player can only read it and then click on the close button to dismiss it.
Important: due to the way Rising World plug-ins are loaded, this class cannot instantiated or used in any way from within the onEnable() method of a plug-in, as it is impossible to be sure that, at that moment, the RWGui plug-in has already been loaded.
The first moment one can be sure that all plug-ins have been loaded, and it is safe to use this class, is when (or after) the first player connects to the server (either dedicated or local).
Constructor and Description |
---|
GuiMessageBox(net.risingworld.api.Plugin plugin,
net.risingworld.api.objects.Player player,
java.lang.String title,
java.lang.String[] texts,
int delay)
Creates a new GuiMessageBox.
|
GuiMessageBox(net.risingworld.api.Plugin plugin,
net.risingworld.api.objects.Player player,
java.lang.String title,
java.lang.String text,
int delay)
Overloaded constructor; similar to other constructor, but accepts a single
line of text as contents.
|
Modifier and Type | Method and Description |
---|---|
void |
onClick(net.risingworld.api.events.player.gui.PlayerGuiElementClickEvent event) |
addChild, addChild, close, free, getItemId, layout, onTextEntry, pop, poppush, push, removeChild, setCallback, setMargin, setPadding, show
destroy, equals, getAlpha, getBorderColor, getBorderThickness, getColor, getHeight, getHoverColor, getID, getParent, getParentID, getPivot, getPositionX, getPositionY, getWidth, hashCode, isRelativeBorderThickness, isRelativePosition, isRelativeSize, isVisible, refresh, removeFromParent, setAlpha, setBorderColor, setBorderColor, setBorderThickness, setColor, setColor, setPivot, setPosition, setSize, setVisible
public GuiMessageBox(net.risingworld.api.Plugin plugin, net.risingworld.api.objects.Player player, java.lang.String title, java.lang.String[] texts, int delay)
The message box adapts its vertical and horizontal sizes to the number and length of the text strings.
As the underlying Rising World API does not support clipping or reformatting a fluent text, the text to display has to be broken into separate strings of convenient length, to avoid the message having an excessive width.
plugin
- the plug-in the GuiMessageBox is intended for. This
is only needed to manage the internal event listener
and has no effects on the plug-in itself.player
- the player to show the message box to.title
- the text of the title.texts
- an array of String's with the text to display.delay
- a timed duration of the message box in seconds; once
this time elapses, the message box closes down
automatically. Use 0 for a non-closing box.public GuiMessageBox(net.risingworld.api.Plugin plugin, net.risingworld.api.objects.Player player, java.lang.String title, java.lang.String text, int delay)
public void onClick(net.risingworld.api.events.player.gui.PlayerGuiElementClickEvent event)
onClick
in class GuiModalWindow