Merge branch 'master' into ping
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides events for handling incoming connections to the proxy and loigns.
|
||||
* Provides events for handling incoming connections to the proxy and logins.
|
||||
*/
|
||||
package com.velocitypowered.api.event.connection;
|
@@ -0,0 +1,24 @@
|
||||
package com.velocitypowered.api.event.player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.playersettings.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public class PlayerSettingsChangedEvent {
|
||||
private final Player player;
|
||||
private final PlayerSettings playerSettings;
|
||||
|
||||
public PlayerSettingsChangedEvent(Player player, PlayerSettings playerSettings) {
|
||||
this.player = Preconditions.checkNotNull(player, "player");
|
||||
this.playerSettings = Preconditions.checkNotNull(playerSettings, "playerSettings");
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
//New settings
|
||||
public PlayerSettings getPlayerSettings() {
|
||||
return playerSettings;
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.velocitypowered.api.playersettings;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public interface PlayerSettings {
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
byte getViewDistance();
|
||||
|
||||
ChatMode getChatMode();
|
||||
|
||||
boolean hasChatColors();
|
||||
|
||||
SkinParts getSkinParts();
|
||||
|
||||
MainHand getMainHand();
|
||||
|
||||
public enum ChatMode {
|
||||
SHOWN,
|
||||
COMMANDS_ONLY,
|
||||
HIDDEN
|
||||
}
|
||||
|
||||
public enum MainHand {
|
||||
LEFT,
|
||||
RIGHT
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.velocitypowered.api.playersettings;
|
||||
|
||||
public class SkinParts {
|
||||
|
||||
static final SkinParts SKIN_SHOW_ALL = new SkinParts((byte) 127);
|
||||
private final byte bitmask;
|
||||
|
||||
public SkinParts(byte skinBitmask) {
|
||||
this.bitmask = skinBitmask;
|
||||
}
|
||||
|
||||
public boolean hasCape() {
|
||||
return ((bitmask >> 0) & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasJacket() {
|
||||
return ((bitmask >> 1) & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasLeftSleeve() {
|
||||
return ((bitmask >> 2) & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasRightSleeve() {
|
||||
return ((bitmask >> 3) & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasLeftPants() {
|
||||
return ((bitmask >> 4) & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasRightPants() {
|
||||
return ((bitmask >> 5) & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasHat() {
|
||||
return ((bitmask >> 6) & 1) == 1;
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package com.velocitypowered.api.proxy;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.playersettings.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
@@ -32,7 +33,9 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
|
||||
* @return an {@link Optional} the server that the player is connected to, which may be empty
|
||||
*/
|
||||
Optional<ServerConnection> getCurrentServer();
|
||||
|
||||
|
||||
PlayerSettings getPlayerSettings();
|
||||
|
||||
/**
|
||||
* Returns the current player's ping
|
||||
* @return the player's ping or -1 if ping information is currently unknown
|
||||
|
@@ -18,9 +18,9 @@ public class ServerPing {
|
||||
private final Component description;
|
||||
private final @Nullable Favicon favicon;
|
||||
|
||||
public ServerPing(@NonNull Version version, @NonNull Players players, @NonNull Component description, @Nullable Favicon favicon) {
|
||||
public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon) {
|
||||
this.version = Preconditions.checkNotNull(version, "version");
|
||||
this.players = Preconditions.checkNotNull(players, "players");
|
||||
this.players = players;
|
||||
this.description = Preconditions.checkNotNull(description, "description");
|
||||
this.favicon = favicon;
|
||||
}
|
||||
@@ -29,8 +29,8 @@ public class ServerPing {
|
||||
return version;
|
||||
}
|
||||
|
||||
public Players getPlayers() {
|
||||
return players;
|
||||
public Optional<Players> getPlayers() {
|
||||
return Optional.ofNullable(players);
|
||||
}
|
||||
|
||||
public Component getDescription() {
|
||||
@@ -76,6 +76,7 @@ public class ServerPing {
|
||||
private final List<SamplePlayer> samplePlayers = new ArrayList<>();
|
||||
private Component description;
|
||||
private Favicon favicon;
|
||||
private boolean nullOutPlayers;
|
||||
|
||||
private Builder() {
|
||||
|
||||
@@ -106,6 +107,11 @@ public class ServerPing {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder nullPlayers() {
|
||||
this.nullOutPlayers = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder description(Component description) {
|
||||
this.description = Preconditions.checkNotNull(description, "description");
|
||||
return this;
|
||||
@@ -117,7 +123,7 @@ public class ServerPing {
|
||||
}
|
||||
|
||||
public ServerPing build() {
|
||||
return new ServerPing(version, new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon);
|
||||
return new ServerPing(version, nullOutPlayers ? null : new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon);
|
||||
}
|
||||
|
||||
public Version getVersion() {
|
||||
|
Reference in New Issue
Block a user