ViaVersion/api/src/main/java/com/viaversion/viaversion/api/boss/BossBar.java

225 lines
6.2 KiB
Java
Raw Normal View History

/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
2016-03-06 19:27:26 +01:00
package us.myles.ViaVersion.api.boss;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
2016-03-06 19:27:26 +01:00
import java.util.Set;
import java.util.UUID;
2016-09-25 18:20:42 +02:00
public abstract class BossBar<T> {
2016-03-08 13:46:30 +01:00
/**
* Get the current title
*
* @return the title
*/
public abstract String getTitle();
2016-03-08 13:46:30 +01:00
2016-03-06 19:27:26 +01:00
/**
* Change the title
2016-03-06 19:27:26 +01:00
*
* @param title Title can be in either JSON or just text
2016-05-26 14:54:22 +02:00
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar setTitle(String title);
2016-03-06 19:27:26 +01:00
/**
2016-03-08 13:46:30 +01:00
* Get the health
2016-03-06 19:27:26 +01:00
*
2016-03-08 13:46:30 +01:00
* @return float between 0F - 1F
2016-03-06 19:27:26 +01:00
*/
public abstract float getHealth();
2016-03-06 19:27:26 +01:00
/**
* Change the health
2016-03-06 19:27:26 +01:00
*
* @param health this float has to be between 0F - 1F
2016-05-26 14:54:22 +02:00
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar setHealth(float health);
2016-03-06 19:27:26 +01:00
2016-03-08 13:46:30 +01:00
/**
* Get the bossbar color
*
2016-05-26 14:54:22 +02:00
* @return The colour
2016-03-08 13:46:30 +01:00
*/
public abstract BossColor getColor();
2016-03-08 13:46:30 +01:00
2016-03-06 19:27:26 +01:00
/**
* Yay colors!
2016-03-06 19:27:26 +01:00
*
* @param color Whatever color you want!
2016-05-26 14:54:22 +02:00
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar setColor(BossColor color);
2016-03-06 19:27:26 +01:00
2016-03-08 13:46:30 +01:00
/**
* Get the bosbar style
*
* @return BossStyle
*/
public abstract BossStyle getStyle();
2016-03-08 13:46:30 +01:00
/**
* Change the bosbar style
*
* @param style BossStyle
2016-05-26 14:54:22 +02:00
* @return The BossBar object
*/
public abstract BossBar setStyle(BossStyle style);
2016-03-06 19:27:26 +01:00
/**
* Show the bossbar to a player.
*
2016-05-26 14:54:22 +02:00
* @param player The player
* @return The BossBar object
2016-09-25 18:20:42 +02:00
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
2016-03-06 19:27:26 +01:00
*/
2016-09-25 18:20:42 +02:00
@Deprecated
2016-09-25 21:17:09 +02:00
public BossBar addPlayer(T player) {
2016-09-27 18:48:56 +02:00
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
2016-03-06 19:27:26 +01:00
/**
2020-06-25 17:07:30 +02:00
* Show the bossbar to a player (uuid). This only works for frontend connections. Use #addConnection(UserConnection) for other types.
*
* @param player uuid of the player
2016-05-26 14:54:22 +02:00
* @return The BossBar object
*/
public abstract BossBar addPlayer(UUID player);
2016-09-25 21:17:09 +02:00
/**
* Show the bossbar to a player connection.
*
* @param conn UserConnection of the connection
* @return The BossBar object
*/
public abstract BossBar addConnection(UserConnection conn);
/**
* add multiple players
*
* @param players list of players
2016-05-26 14:54:22 +02:00
* @return The BossBar object
2016-09-25 18:20:42 +02:00
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
2016-09-25 18:20:42 +02:00
@Deprecated
2016-09-25 21:17:09 +02:00
public BossBar addPlayers(T... players) {
2016-09-27 18:48:56 +02:00
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
2016-03-06 19:27:26 +01:00
/**
* Remove the bossbar from a player
*
2016-05-26 14:54:22 +02:00
* @param player The player
* @return The BossBar object
2016-09-25 18:20:42 +02:00
* @deprecated Deprecated use UUID's instead of Player objects {@link #removePlayer(UUID)}
2016-03-06 19:27:26 +01:00
*/
2016-09-25 18:20:42 +02:00
@Deprecated
2016-09-25 21:17:09 +02:00
public BossBar removePlayer(T player) {
2016-09-27 18:48:56 +02:00
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
2016-09-27 18:31:10 +02:00
/**
2020-06-25 17:07:30 +02:00
* Removes the bossbar from a player. This only works for frontend connections. For others types, use #removeConnection(UserConnection)
2016-09-27 18:31:10 +02:00
*
* @param uuid The players UUID
2016-09-27 18:31:10 +02:00
* @return The BossBar object
*/
public abstract BossBar removePlayer(UUID uuid);
2016-03-06 19:27:26 +01:00
/**
* Removes the bossbar from a player connection.
*
* @param conn The UserConnection
* @return The BossBar object
*/
public abstract BossBar removeConnection(UserConnection conn);
2016-03-06 19:27:26 +01:00
/**
* Add flags
*
2016-05-26 14:54:22 +02:00
* @param flag The flag to add
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar addFlag(BossFlag flag);
2016-03-06 19:27:26 +01:00
/**
* Remove flags.
*
2016-05-26 14:54:22 +02:00
* @param flag The flag to remove
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar removeFlag(BossFlag flag);
2016-03-06 19:27:26 +01:00
/**
2016-05-26 14:54:22 +02:00
* @param flag The flag to check against
* @return True if it has the flag
2016-03-06 19:27:26 +01:00
*/
public abstract boolean hasFlag(BossFlag flag);
2016-03-06 19:27:26 +01:00
/**
* Get players. Only returns UUIDs which are front-end. For all connections, use #getConnections()
2016-03-06 19:27:26 +01:00
*
* @return UUIDS from players (sorry I lied)
*/
public abstract Set<UUID> getPlayers();
2016-03-06 19:27:26 +01:00
/**
* Get UserConnections.
*
* @return UserConnection from players
*/
public abstract Set<UserConnection> getConnections();
2016-03-06 19:27:26 +01:00
/**
* Show the bossbar to everyone (In the getPlayer set)
2016-05-26 14:54:22 +02:00
*
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar show();
2016-03-06 19:27:26 +01:00
/**
* Hide the bossbar from everyone (In the getPlayer set)
2016-05-26 14:54:22 +02:00
*
* @return The BossBar object
2016-03-06 19:27:26 +01:00
*/
public abstract BossBar hide();
2016-03-06 19:27:26 +01:00
/**
* Is it visible?
*
* @return visibility changable with show() and hide()
*/
public abstract boolean isVisible();
/**
* Get the UUID of this bossbar
*
* @return Unique Id for this bossbar
*/
public abstract UUID getId();
2016-03-06 19:27:26 +01:00
}