Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.ar.game.character.player;
- import net.ar.game.World;
- import java.util.concurrent.TimeUnit;
- /**
- * The enumerated type whose elements represent functionality for the quest tab.
- * @author <a href="http://www.rune-server.org/members/stand+up/">Stand Up</a>
- */
- public enum PlayerPanel {
- UPTIME(62154, "@or1@Server Uptime: @yel@" + World.getRunningTime().elapsedTime(TimeUnit.MINUTES) + " minutes"),
- PLAYERS_ONLINE(62155, "@or1@Players online: @yel@" + World.getPlayers().size()){
- @Override
- public void onClick(Player player) {
- player.getMessages().sendMessage("There is currently " + World.getPlayers().size() + " players online.");
- }
- },
- EMPTY1(62156, ""),
- USERNAME(62157, "@or1@Username: @yel@username"),
- PASSWORD(62158, "@or1@Password: @yel@password"),
- RANK(62158, "@or1@Rank: @yel@rank"),;
- /**
- * The button identification.
- */
- private final int buttonId;
- /**
- * The text displayed or sent.
- */
- private String text;
- /**
- * Constructs a new {@link PlayerPanel}.
- * @param buttonId {@link #buttonId}.
- * @param text {@link #text}.
- */
- PlayerPanel(int buttonId, String text) {
- this.buttonId = buttonId;
- this.text = text;
- }
- /**
- * Gets the line text.
- * @return line text.
- */
- public String getText() {
- return text;
- }
- /**
- * Sets the new value for {@link #text}.
- * @param text the new value to set.
- */
- public void setText(String text) {
- this.text = text;
- }
- /**
- * Gets the button id of the line.
- * @return the button id.
- */
- public int getButtonId() {
- return buttonId;
- }
- /**
- * Clears the tab on player's login.
- * @param player the player logging in.
- */
- public static void onLogin(Player player) {
- for(int i = 16016; i < 16126; i++) {
- player.getMessages().sendString("", i);
- }
- }
- /**
- * Loops the button click interactions.
- * @param player the player clicking a button.
- * @param buttonId the button id he clicked.
- * @return {@code true} of he clicked a tab id, {@code false} otherwise.
- */
- public static boolean interaction(Player player, int buttonId) {
- for(PlayerPanel panel : PlayerPanel.values()) {
- if(buttonId == panel.getButtonId()) {
- panel.onClick(player);
- return true;
- }
- }
- return false;
- }
- /**
- * The action to be done on the click.
- * @param player the player doing the click.
- */
- public void onClick(Player player) {
- //Empty
- }
- /**
- * Refreshes the specified tab asset for all the players on the world.
- * @param update the updated string for that tab.
- */
- public void refreshAll(String update) {
- World.getPlayers().forEach(player -> refresh(player, update));
- }
- /**
- * Refreshes the tab asset for a specified player
- * @param player the player we're refreshing this {@code enumerator} for.
- * @param text the new string to set.
- */
- public void refresh(Player player, String text) {
- player.getMessages().sendString(text, 16026 + ordinal());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement