mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Added some comments about exceptions
This commit is contained in:
parent
1d30e6e953
commit
7bdfc93334
@ -595,10 +595,13 @@ public class MinecraftServer {
|
||||
|
||||
/**
|
||||
* Starts the server.
|
||||
* <p>
|
||||
* It should be called after {@link #init()} and probably your own initialization code.
|
||||
*
|
||||
* @param address the server address
|
||||
* @param port the server port
|
||||
* @param responseDataConsumer the response data consumer, can be null
|
||||
* @throws IllegalStateException if called before {@link #init()} or if the server is already running
|
||||
*/
|
||||
public void start(String address, int port, ResponseDataConsumer responseDataConsumer) {
|
||||
Check.stateCondition(!initialized, "#start can only be called after #init");
|
||||
@ -627,6 +630,7 @@ public class MinecraftServer {
|
||||
*
|
||||
* @param address the server address
|
||||
* @param port the server port
|
||||
* @see #start(String, int, ResponseDataConsumer)
|
||||
*/
|
||||
public void start(String address, int port) {
|
||||
start(address, port, null);
|
||||
|
@ -242,6 +242,14 @@ public class ChatColor {
|
||||
return codeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color id, only present if this color has been retrieved from {@link ChatColor} constants.
|
||||
* <p>
|
||||
* Should only be used for some special packets which require it.
|
||||
*
|
||||
* @return the color id
|
||||
* @throws IllegalStateException if the color is not from the class constants
|
||||
*/
|
||||
public int getId() {
|
||||
Check.stateCondition(id == -1, "Please use one of the ChatColor constant instead");
|
||||
return id;
|
||||
@ -263,7 +271,7 @@ public class ChatColor {
|
||||
code = codeName;
|
||||
} else {
|
||||
// RGB color (special code not set)
|
||||
int color = (red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF;
|
||||
final int color = (red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF;
|
||||
|
||||
code = Integer.toHexString(color);
|
||||
}
|
||||
|
@ -1029,6 +1029,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
* Sets and refresh client food bar.
|
||||
*
|
||||
* @param food the new food value
|
||||
* @throws IllegalArgumentException if {@code food} is not between 0 and 20
|
||||
*/
|
||||
public void setFood(int food) {
|
||||
Check.argCondition(!MathUtils.isBetween(food, 0, 20), "Food has to be between 0 and 20");
|
||||
@ -1044,6 +1045,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
* Sets and refresh client food saturation.
|
||||
*
|
||||
* @param foodSaturation the food saturation
|
||||
* @throws IllegalArgumentException if {@code foodSaturation} is not between 0 and 5
|
||||
*/
|
||||
public void setFoodSaturation(float foodSaturation) {
|
||||
Check.argCondition(!MathUtils.isBetween(foodSaturation, 0, 5), "Food saturation has to be between 0 and 5");
|
||||
@ -1218,7 +1220,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
*
|
||||
* @param resourcePack the resource pack
|
||||
*/
|
||||
public void setResourcePack(ResourcePack resourcePack) {
|
||||
public void setResourcePack(@NotNull ResourcePack resourcePack) {
|
||||
Check.notNull(resourcePack, "The resource pack cannot be null");
|
||||
final String url = resourcePack.getUrl();
|
||||
final String hash = resourcePack.getHash();
|
||||
@ -1367,6 +1369,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
* This cannot change the displayed level, see {@link #setLevel(int)}.
|
||||
*
|
||||
* @param exp a percentage between 0 and 1
|
||||
* @throws IllegalArgumentException if {@code exp} is not between 0 and 1
|
||||
*/
|
||||
public void setExp(float exp) {
|
||||
Check.argCondition(!MathUtils.isBetween(exp, 0, 1), "Exp should be between 0 and 1");
|
||||
@ -1880,6 +1883,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
* Changes the player permission level.
|
||||
*
|
||||
* @param permissionLevel the new player permission level
|
||||
* @throws IllegalArgumentException if {@code permissionLevel} is not between 0 and 4
|
||||
*/
|
||||
public void setPermissionLevel(int permissionLevel) {
|
||||
Check.argCondition(!MathUtils.isBetween(permissionLevel, 0, 4), "permissionLevel has to be between 0 and 4");
|
||||
|
@ -259,6 +259,7 @@ public final class ConnectionManager {
|
||||
* Used during disconnection, you shouldn't have to do it manually.
|
||||
*
|
||||
* @param connection the player connection
|
||||
* @see PlayerConnection#disconnect() to properly disconnect a player
|
||||
*/
|
||||
public void removePlayer(@NotNull PlayerConnection connection) {
|
||||
final Player player = this.connectionPlayerMap.get(connection);
|
||||
|
@ -86,9 +86,12 @@ public class Sidebar implements Scoreboard {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ScoreboardLine}
|
||||
* Creates a new {@link ScoreboardLine}.
|
||||
*
|
||||
* @param scoreboardLine The new scoreboard line
|
||||
* @param scoreboardLine the new scoreboard line
|
||||
* @throws IllegalStateException if the sidebar cannot take more line
|
||||
* @throws IllegalArgumentException if the sidebar already contains the line {@code scoreboardLine}
|
||||
* or has a line with the same id
|
||||
*/
|
||||
public void createLine(ScoreboardLine scoreboardLine) {
|
||||
synchronized (lines) {
|
||||
@ -114,7 +117,7 @@ public class Sidebar implements Scoreboard {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a {@link ScoreboardLine} content through the given identifier
|
||||
* Updates a {@link ScoreboardLine} content through the given identifier.
|
||||
*
|
||||
* @param id The identifier of the {@link ScoreboardLine}
|
||||
* @param content The new content for the {@link ScoreboardLine}
|
||||
|
Loading…
Reference in New Issue
Block a user