Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 22:40:18 +01:00
Merge remote-tracking branch 'upstream/master' into feature/blocky
Dieser Commit ist enthalten in:
Commit
1efe7342eb
@ -37,6 +37,7 @@ import org.geysermc.geyser.entity.type.Entity;
|
|||||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -132,6 +133,10 @@ public final class Scoreboard {
|
|||||||
team = new Team(this, teamName);
|
team = new Team(this, teamName);
|
||||||
team.addEntities(players);
|
team.addEntities(players);
|
||||||
teams.put(teamName, team);
|
teams.put(teamName, team);
|
||||||
|
|
||||||
|
// Update command parameters - is safe to send even if the command enum doesn't exist on the client (as of 1.19.51)
|
||||||
|
session.addCommandEnum("Geyser_Teams", team.getId());
|
||||||
|
|
||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,9 +348,16 @@ public final class Scoreboard {
|
|||||||
// We need to use the direct entities list here, so #refreshSessionPlayerDisplays also updates accordingly
|
// We need to use the direct entities list here, so #refreshSessionPlayerDisplays also updates accordingly
|
||||||
// With the player's lack of a team in visibility checks
|
// With the player's lack of a team in visibility checks
|
||||||
updateEntityNames(remove, remove.getEntities(), true);
|
updateEntityNames(remove, remove.getEntities(), true);
|
||||||
|
|
||||||
|
session.removeCommandEnum("Geyser_Teams", remove.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract("-> new")
|
||||||
|
public String[] getTeamNames() {
|
||||||
|
return teams.keySet().toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the display names of all entities in a given team.
|
* Updates the display names of all entities in a given team.
|
||||||
* @param teamChange the players have either joined or left the team. Used for optimizations when just the display name updated.
|
* @param teamChange the players have either joined or left the team. Used for optimizations when just the display name updated.
|
||||||
|
@ -67,7 +67,9 @@ import com.nukkitx.nbt.NbtMap;
|
|||||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||||
import com.nukkitx.protocol.bedrock.data.*;
|
import com.nukkitx.protocol.bedrock.data.*;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.command.CommandEnumData;
|
||||||
import com.nukkitx.protocol.bedrock.data.command.CommandPermission;
|
import com.nukkitx.protocol.bedrock.data.command.CommandPermission;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.command.SoftEnumUpdateType;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.*;
|
import com.nukkitx.protocol.bedrock.packet.*;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
@ -1905,4 +1907,19 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
sendUpstreamPacket(transferPacket);
|
sendUpstreamPacket(transferPacket);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCommandEnum(String name, String... enums) {
|
||||||
|
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCommandEnum(String name, String... enums) {
|
||||||
|
softEnumPacket(name, SoftEnumUpdateType.REMOVE, enums);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void softEnumPacket(String name, SoftEnumUpdateType type, String... enums) {
|
||||||
|
UpdateSoftEnumPacket packet = new UpdateSoftEnumPacket();
|
||||||
|
packet.setType(type);
|
||||||
|
packet.setSoftEnum(new CommandEnumData(name, enums, true));
|
||||||
|
sendUpstreamPacket(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,6 +240,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
|||||||
case RESOURCE -> handleResource(context, ((ResourceProperties) node.getProperties()).getRegistryKey(), false);
|
case RESOURCE -> handleResource(context, ((ResourceProperties) node.getProperties()).getRegistryKey(), false);
|
||||||
case RESOURCE_OR_TAG -> handleResource(context, ((ResourceProperties) node.getProperties()).getRegistryKey(), true);
|
case RESOURCE_OR_TAG -> handleResource(context, ((ResourceProperties) node.getProperties()).getRegistryKey(), true);
|
||||||
case DIMENSION -> context.session.getLevels();
|
case DIMENSION -> context.session.getLevels();
|
||||||
|
case TEAM -> context.getTeams(); // Note: as of Java 1.19.3, objectives are currently parsed from the server
|
||||||
default -> CommandParam.STRING;
|
default -> CommandParam.STRING;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -271,6 +272,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
|||||||
private Object biomesNoTags;
|
private Object biomesNoTags;
|
||||||
private String[] blockStates;
|
private String[] blockStates;
|
||||||
private String[] entityTypes;
|
private String[] entityTypes;
|
||||||
|
private CommandEnumData teams;
|
||||||
|
|
||||||
CommandBuilderContext(GeyserSession session) {
|
CommandBuilderContext(GeyserSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
@ -307,6 +309,14 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
|||||||
}
|
}
|
||||||
return (entityTypes = Registries.JAVA_ENTITY_IDENTIFIERS.get().keySet().toArray(new String[0]));
|
return (entityTypes = Registries.JAVA_ENTITY_IDENTIFIERS.get().keySet().toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CommandEnumData getTeams() {
|
||||||
|
if (teams != null) {
|
||||||
|
return teams;
|
||||||
|
}
|
||||||
|
return (teams = new CommandEnumData("Geyser_Teams",
|
||||||
|
session.getWorldCache().getScoreboard().getTeamNames(), true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -376,7 +386,10 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
|||||||
CommandEnumData enumData = null;
|
CommandEnumData enumData = null;
|
||||||
CommandParam type = null;
|
CommandParam type = null;
|
||||||
boolean optional = this.paramNode.isExecutable();
|
boolean optional = this.paramNode.isExecutable();
|
||||||
if (mappedType instanceof String[]) {
|
if (mappedType instanceof CommandEnumData) {
|
||||||
|
// Likely to specify isSoft, to be possibly updated later.
|
||||||
|
enumData = (CommandEnumData) mappedType;
|
||||||
|
} else if (mappedType instanceof String[]) {
|
||||||
enumData = new CommandEnumData(getEnumDataName(paramNode).toLowerCase(Locale.ROOT), (String[]) mappedType, false);
|
enumData = new CommandEnumData(getEnumDataName(paramNode).toLowerCase(Locale.ROOT), (String[]) mappedType, false);
|
||||||
} else {
|
} else {
|
||||||
type = (CommandParam) mappedType;
|
type = (CommandParam) mappedType;
|
||||||
|
@ -5,7 +5,7 @@ netty = "4.1.80.Final"
|
|||||||
guava = "29.0-jre"
|
guava = "29.0-jre"
|
||||||
gson = "2.3.1" # Provided by Spigot 1.8.8
|
gson = "2.3.1" # Provided by Spigot 1.8.8
|
||||||
websocket = "1.5.1"
|
websocket = "1.5.1"
|
||||||
protocol = "2.9.15-20221129.204554-2"
|
protocol = "2.9.15-20230106.005737-3"
|
||||||
raknet = "1.6.28-20220125.214016-6"
|
raknet = "1.6.28-20220125.214016-6"
|
||||||
mcauthlib = "d9d773e"
|
mcauthlib = "d9d773e"
|
||||||
mcprotocollib = "1.19.3-20230107.194116-10"
|
mcprotocollib = "1.19.3-20230107.194116-10"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren