Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/master' into server-in…
Browse files Browse the repository at this point in the history
…ventory-upstream

# Conflicts:
#	connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
  • Loading branch information
AJ-Ferguson committed Jan 14, 2021
2 parents feae057 + 16fdf51 commit e87ae8f
Show file tree
Hide file tree
Showing 15 changed files with 680 additions and 24 deletions.
5 changes: 3 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ pipeline {
success {
script {
if (env.BRANCH_NAME == 'master') {
build propagate: false, wait: false, job: 'GeyserMC/Geyser-Fabric/java-1.16'
build propagate: false, wait: false, job: 'GeyserMC/GeyserAndroid/master'
build propagate: false, wait: false, job: 'GeyserMC/Geyser-Fabric/java-1.16', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
build propagate: false, wait: false, job: 'GeyserMC/GeyserAndroid/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
build propagate: false, wait: false, job: 'GeyserMC/GeyserConnect/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
}
}
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set
- Horse Inventory
- Loom
- Smithing Table
- Grindstone

## What can't be fixed
The following things can't be fixed because of Bedrock limitations. They might be fixable in the future, but not as of now.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public CommandManager(GeyserConnector connector) {
registerCommand(new VersionCommand(connector, "version", "geyser.commands.version.desc", "geyser.command.version"));
registerCommand(new SettingsCommand(connector, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
registerCommand(new StatisticsCommand(connector, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
registerCommand(new AdvancementsCommand(connector, "advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
}

public void registerCommand(GeyserCommand command) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
*
* 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.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.connector.command.defaults;

import org.geysermc.common.window.SimpleFormWindow;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.AdvancementsCache;

public class AdvancementsCommand extends GeyserCommand {

private final GeyserConnector connector;

public AdvancementsCommand(GeyserConnector connector, String name, String description, String permission) {
super(name, description, permission);

this.connector = connector;
}

@Override
public void execute(CommandSender sender, String[] args) {
if (sender.isConsole()) {
return;
}

// Make sure the sender is a Bedrock edition client
GeyserSession session = null;
if (sender instanceof GeyserSession) {
session = (GeyserSession) sender;
} else {
// Needed for Spigot - sender is not an instance of GeyserSession
for (GeyserSession otherSession : connector.getPlayers()) {
if (sender.getName().equals(otherSession.getPlayerEntity().getUsername())) {
session = otherSession;
break;
}
}
}
if (session == null) return;

SimpleFormWindow window = session.getAdvancementsCache().buildMenuForm();
session.sendForm(window, AdvancementsCache.ADVANCEMENTS_MENU_FORM_ID);
}

@Override
public boolean isExecutableOnConsole() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public class BedrockProtocol {
* 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_v422.V422_CODEC;
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v422.V422_CODEC.toBuilder()
.minecraftVersion("1.16.201")
.build();
/**
* A list of all supported Bedrock versions that can join Geyser
*/
Expand All @@ -50,7 +52,9 @@ public class BedrockProtocol {
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v419.V419_CODEC.toBuilder()
.minecraftVersion("1.16.100/1.16.101") // We change this as 1.16.100.60 is a beta
.build());
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
.minecraftVersion("1.16.200/1.16.201")
.build());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@
import org.geysermc.connector.common.AuthType;
import org.geysermc.connector.configuration.GeyserConfiguration;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.AdvancementsCache;
import org.geysermc.connector.network.translators.PacketTranslatorRegistry;
import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.connector.utils.LoginEncryptionUtils;
import org.geysermc.connector.utils.MathUtils;
import org.geysermc.connector.utils.ResourcePack;
import org.geysermc.connector.utils.ResourcePackManifest;
import org.geysermc.connector.utils.SettingsUtils;
import org.geysermc.connector.utils.StatisticsUtils;
import org.geysermc.connector.utils.*;

import java.io.FileInputStream;
import java.io.InputStream;
Expand Down Expand Up @@ -144,12 +139,19 @@ public boolean handle(ResourcePackClientResponsePacket packet) {

@Override
public boolean handle(ModalFormResponsePacket packet) {
if (packet.getFormId() == SettingsUtils.SETTINGS_FORM_ID) {
return SettingsUtils.handleSettingsForm(session, packet.getFormData());
} else if (packet.getFormId() == StatisticsUtils.STATISTICS_MENU_FORM_ID) {
return StatisticsUtils.handleMenuForm(session, packet.getFormData());
} else if (packet.getFormId() == StatisticsUtils.STATISTICS_LIST_FORM_ID) {
return StatisticsUtils.handleListForm(session, packet.getFormData());
switch (packet.getFormId()) {
case AdvancementsCache.ADVANCEMENT_INFO_FORM_ID:
return session.getAdvancementsCache().handleInfoForm(packet.getFormData());
case AdvancementsCache.ADVANCEMENTS_LIST_FORM_ID:
return session.getAdvancementsCache().handleListForm(packet.getFormData());
case AdvancementsCache.ADVANCEMENTS_MENU_FORM_ID:
return session.getAdvancementsCache().handleMenuForm(packet.getFormData());
case SettingsUtils.SETTINGS_FORM_ID:
return SettingsUtils.handleSettingsForm(session, packet.getFormData());
case StatisticsUtils.STATISTICS_LIST_FORM_ID:
return StatisticsUtils.handleListForm(session, packet.getFormData());
case StatisticsUtils.STATISTICS_MENU_FORM_ID:
return StatisticsUtils.handleMenuForm(session, packet.getFormData());
}

return LoginEncryptionUtils.authenticateFromForm(session, connector, packet.getFormId(), packet.getFormData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public class GeyserSession implements CommandSender {

private final SessionPlayerEntity playerEntity;

private AdvancementsCache advancementsCache;
private BookEditCache bookEditCache;
private ChunkCache chunkCache;
private EntityCache entityCache;
Expand Down Expand Up @@ -384,6 +385,7 @@ public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServ
this.connector = connector;
this.upstream = new UpstreamSession(bedrockServerSession);

this.advancementsCache = new AdvancementsCache(this);
this.bookEditCache = new BookEditCache(this);
this.chunkCache = new ChunkCache(this);
this.entityCache = new EntityCache(this);
Expand All @@ -409,6 +411,10 @@ public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServ

connector.getPlayers().forEach(player -> this.emotes.addAll(player.getEmotes()));

// Make a copy to prevent ConcurrentModificationException
final List<GeyserSession> tmpPlayers = new ArrayList<>(connector.getPlayers());
tmpPlayers.forEach(player -> this.emotes.addAll(player.getEmotes()));

bedrockServerSession.addDisconnectHandler(disconnectReason -> {
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.disconnect", bedrockServerSession.getAddress().getAddress(), disconnectReason));

Expand Down Expand Up @@ -723,6 +729,7 @@ public void disconnect(String reason) {
tickThread.cancel(true);
}

this.advancementsCache = null;
this.bookEditCache = null;
this.chunkCache = null;
this.entityCache = null;
Expand Down Expand Up @@ -862,6 +869,7 @@ private void startGame() {
startGamePacket.setLevelName(serverName);

startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000");
// startGamePacket.setCurrentTick(0);
startGamePacket.setEnchantmentSeed(0);
startGamePacket.setMultiplayerCorrelationId("");
startGamePacket.setItemEntries(ItemRegistry.ITEMS);
Expand Down
Loading

0 comments on commit e87ae8f

Please sign in to comment.