mirror of
https://github.com/GeyserMC/Geyser.git
synced 2026-01-06 15:41:50 +00:00
Upstream
This commit is contained in:
@@ -37,6 +37,9 @@ public final class Constants {
|
||||
|
||||
public static final String FLOODGATE_DOWNLOAD_LOCATION = "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/";
|
||||
|
||||
public static final String GEYSER_DOWNLOAD_LOCATION = "https://ci.geysermc.org";
|
||||
public static final String UPDATE_PERMISSION = "geyser.update";
|
||||
|
||||
static final String SAVED_REFRESH_TOKEN_FILE = "saved-refresh-tokens.json";
|
||||
|
||||
static {
|
||||
|
||||
@@ -41,6 +41,8 @@ import io.netty.util.internal.SystemPropertyUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -77,7 +79,6 @@ import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
|
||||
import org.geysermc.geyser.session.SessionManager;
|
||||
import org.geysermc.geyser.skin.FloodgateSkinUploader;
|
||||
import org.geysermc.geyser.skin.SkinProvider;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.text.MinecraftLocale;
|
||||
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
|
||||
@@ -312,8 +313,8 @@ public class GeyserImpl implements GeyserApi {
|
||||
int port = config.getBedrock().port();
|
||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
|
||||
if (!"0.0.0.0".equals(address)) {
|
||||
logger.info(ChatColor.GREEN + "Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0");
|
||||
logger.info(ChatColor.GREEN + "Then, restart this server.");
|
||||
logger.info(Component.text("Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0", NamedTextColor.GREEN));
|
||||
logger.info(Component.text("Then, restart this server.", NamedTextColor.GREEN));
|
||||
}
|
||||
}
|
||||
}).join();
|
||||
@@ -465,6 +466,9 @@ public class GeyserImpl implements GeyserApi {
|
||||
newsHandler.handleNews(null, NewsItemAction.ON_SERVER_STARTED);
|
||||
|
||||
this.eventBus.fire(new GeyserPostInitializeEvent(this.extensionManager, this.eventBus));
|
||||
if (config.isNotifyOnNewBedrockUpdate()) {
|
||||
VersionCheckUtils.checkForGeyserUpdate(this::getLogger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
|
||||
package org.geysermc.geyser;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.geyser.command.CommandSender;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface GeyserLogger {
|
||||
public interface GeyserLogger extends CommandSender {
|
||||
|
||||
/**
|
||||
* Logs a severe message to console
|
||||
@@ -73,6 +76,15 @@ public interface GeyserLogger {
|
||||
*/
|
||||
void info(String message);
|
||||
|
||||
/**
|
||||
* Logs an info component to console
|
||||
*
|
||||
* @param message the message to log
|
||||
*/
|
||||
default void info(Component message) {
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a debug message to console
|
||||
*
|
||||
@@ -100,4 +112,24 @@ public interface GeyserLogger {
|
||||
* If debug is enabled for this logger
|
||||
*/
|
||||
boolean isDebug();
|
||||
|
||||
@Override
|
||||
default String name() {
|
||||
return "CONSOLE";
|
||||
}
|
||||
|
||||
@Override
|
||||
default void sendMessage(String message) {
|
||||
info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isConsole() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ public interface GeyserConfiguration {
|
||||
|
||||
int getCustomSkullRenderDistance();
|
||||
|
||||
boolean isNotifyOnNewBedrockUpdate();
|
||||
|
||||
IMetricsInfo getMetrics();
|
||||
|
||||
int getPendingAuthenticationTimeout();
|
||||
|
||||
@@ -148,6 +148,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
||||
@JsonProperty("xbox-achievements-enabled")
|
||||
private boolean xboxAchievementsEnabled = false;
|
||||
|
||||
@JsonProperty("notify-on-new-bedrock-update")
|
||||
private boolean notifyOnNewBedrockUpdate = true;
|
||||
|
||||
private MetricsInfo metrics = new MetricsInfo();
|
||||
|
||||
@JsonProperty("pending-authentication-timeout")
|
||||
|
||||
@@ -106,6 +106,9 @@ public class LivingEntity extends Entity {
|
||||
|
||||
// Riptide spin attack
|
||||
setFlag(EntityFlag.DAMAGE_NEARBY_MOBS, (xd & 0x04) == 0x04);
|
||||
|
||||
// OptionalPack usage
|
||||
setFlag(EntityFlag.EMERGING, isUsingItem && isUsingOffhand);
|
||||
}
|
||||
|
||||
public void setHealth(FloatEntityMetadata entityMetadata) {
|
||||
|
||||
@@ -45,7 +45,10 @@ public final class GameProtocol {
|
||||
* Default Bedrock codec that should act as a fallback. Should represent the latest available
|
||||
* release of the game that Geyser supports.
|
||||
*/
|
||||
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v544.V544_CODEC;
|
||||
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v544.V544_CODEC.toBuilder()
|
||||
.minecraftVersion("1.19.21")
|
||||
.protocolVersion(545)
|
||||
.build();
|
||||
/**
|
||||
* A list of all supported Bedrock versions that can join Geyser
|
||||
*/
|
||||
@@ -64,6 +67,7 @@ public final class GameProtocol {
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v534.V534_CODEC.toBuilder()
|
||||
.minecraftVersion("1.19.10/1.19.11")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v544.V544_CODEC);
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.nukkitx.protocol.bedrock.packet.SetTitlePacket;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.scoreboard.Scoreboard;
|
||||
import org.geysermc.geyser.scoreboard.ScoreboardUpdater.ScoreboardSession;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.geysermc.geyser.inventory.Inventory;
|
||||
import org.geysermc.geyser.inventory.PlayerInventory;
|
||||
import org.geysermc.geyser.inventory.click.Click;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.network.MinecraftProtocol;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.registry.type.ItemMappings;
|
||||
@@ -62,10 +63,7 @@ import org.geysermc.geyser.translator.inventory.InventoryTranslator;
|
||||
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.util.BlockUtils;
|
||||
import org.geysermc.geyser.util.EntityUtils;
|
||||
import org.geysermc.geyser.util.InteractionResult;
|
||||
import org.geysermc.geyser.util.InventoryUtils;
|
||||
import org.geysermc.geyser.util.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -468,6 +466,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entityId,
|
||||
InteractAction.ATTACK, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
|
||||
if (MinecraftProtocol.supports1_19_10(session)) {
|
||||
// Since 1.19.10, LevelSoundEventPackets are no longer sent by the client when attacking entities
|
||||
CooldownUtils.sendCooldown(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.Server
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3d;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||
@@ -49,17 +48,6 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||
if (!session.isSpawned()) return;
|
||||
|
||||
if (!session.getUpstream().isInitialized()) {
|
||||
MoveEntityAbsolutePacket moveEntityBack = new MoveEntityAbsolutePacket();
|
||||
moveEntityBack.setRuntimeEntityId(entity.getGeyserId());
|
||||
moveEntityBack.setPosition(entity.getPosition());
|
||||
moveEntityBack.setRotation(entity.getBedrockRotation());
|
||||
moveEntityBack.setTeleported(true);
|
||||
moveEntityBack.setOnGround(true);
|
||||
session.sendUpstreamPacketImmediately(moveEntityBack);
|
||||
return;
|
||||
}
|
||||
|
||||
session.setLastMovementTimestamp(System.currentTimeMillis());
|
||||
|
||||
// Send book update before the player moves
|
||||
|
||||
@@ -25,10 +25,22 @@
|
||||
|
||||
package org.geysermc.geyser.util;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.geysermc.geyser.Constants;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.command.CommandSender;
|
||||
import org.geysermc.geyser.network.MinecraftProtocol;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class VersionCheckUtils {
|
||||
|
||||
public static void checkForOutdatedFloodgate(GeyserLogger logger) {
|
||||
@@ -42,6 +54,41 @@ public final class VersionCheckUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkForGeyserUpdate(Supplier<CommandSender> recipient) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
JsonNode json = WebUtils.getJson("https://api.geysermc.org/v2/versions/geyser");
|
||||
JsonNode bedrock = json.get("bedrock").get("protocol");
|
||||
int protocolVersion = bedrock.get("id").asInt();
|
||||
if (MinecraftProtocol.getBedrockCodec(protocolVersion) != null) {
|
||||
// We support the latest version! No need to print a message.
|
||||
return;
|
||||
}
|
||||
|
||||
final String newBedrockVersion = bedrock.get("name").asText();
|
||||
|
||||
// Delayed for two reasons: save unnecessary processing, and wait to load locale if this is on join.
|
||||
CommandSender sender = recipient.get();
|
||||
|
||||
// Overarching component is green - geyser.version.new component cannot be green or else the link blue is overshadowed
|
||||
Component message = Component.text().color(NamedTextColor.GREEN)
|
||||
.append(Component.text(GeyserLocale.getPlayerLocaleString("geyser.version.new", sender.getLocale(), newBedrockVersion))
|
||||
.replaceText(TextReplacementConfig.builder()
|
||||
.match("\\{1\\}") // Replace "Download here: {1}" so we can use fancy text component yesyes
|
||||
.replacement(Component.text()
|
||||
.content(Constants.GEYSER_DOWNLOAD_LOCATION)
|
||||
.color(NamedTextColor.BLUE)
|
||||
.decoration(TextDecoration.UNDERLINED, TextDecoration.State.TRUE)
|
||||
.clickEvent(ClickEvent.openUrl(Constants.GEYSER_DOWNLOAD_LOCATION)))
|
||||
.build()))
|
||||
.build();
|
||||
sender.sendMessage(message);
|
||||
} catch (Exception e) {
|
||||
GeyserImpl.getInstance().getLogger().error("Error whilst checking for Geyser update!", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private VersionCheckUtils() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ public class WebUtils {
|
||||
public static JsonNode getJson(String reqURL) throws IOException {
|
||||
HttpURLConnection con = (HttpURLConnection) new URL(reqURL).openConnection();
|
||||
con.setRequestProperty("User-Agent", "Geyser-" + GeyserImpl.getInstance().getPlatformType().toString() + "/" + GeyserImpl.VERSION);
|
||||
con.setConnectTimeout(10000);
|
||||
con.setReadTimeout(10000);
|
||||
return GeyserImpl.JSON_MAPPER.readTree(con.getInputStream());
|
||||
}
|
||||
|
||||
|
||||
@@ -175,6 +175,11 @@ force-resource-packs: true
|
||||
# THIS DISABLES ALL COMMANDS FROM SUCCESSFULLY RUNNING FOR BEDROCK IN-GAME, as otherwise Bedrock thinks you are cheating.
|
||||
xbox-achievements-enabled: false
|
||||
|
||||
# Whether to alert the console and operators that a new Geyser version is available that supports a Bedrock version
|
||||
# that this Geyser version does not support. It's recommended to keep this option enabled, as many Bedrock platforms
|
||||
# auto-update.
|
||||
notify-on-new-bedrock-update: true
|
||||
|
||||
# bStats is a stat tracker that is entirely anonymous and tracks only basic information
|
||||
# about Geyser, such as how many people are online, how many servers are using Geyser,
|
||||
# what OS is being used, etc. You can learn more about bStats here: https://bstats.org/.
|
||||
|
||||
Reference in New Issue
Block a user