Skip to content

Commit

Permalink
Implement support for Minecraft Education Edition 1.12.60
Browse files Browse the repository at this point in the history
Changes:
* Temporarily Disable Github Action
* Add gamerule "codebuilder":"false" to disable MCEE code builder.
* Update config.yml so that both an edition and version can be specified. That allows multiple version to be tracked.
* Move away from static class to dependency injection. This allows versions to use the existing classes or redefine them. Instead of using Toolbox.something one uses GeyserEdition.TOOLBOX.something.
* Move version specific classes into their own packages.  As all classes are very intertwined this will require lots of testing to ensure it remains clear and simple without introducing too much baggage.
* Where possible all version specific translations and mappings are provided in the GeyserEdition class for the specific version. This moves away from magic annotations as this does not allow one version to selectively use translators fromo other versions.
* Move mappings to be namespaced by both the edition and version (resources/edition/version), with fullstops replaced with underscores (though I can't quite remember why now I did that).
* Check for legacy SkinData
  • Loading branch information
bundabrg committed May 18, 2020
1 parent 31d3d2e commit 3ede1d5
Show file tree
Hide file tree
Showing 153 changed files with 80,211 additions and 2,199 deletions.
File renamed without changes.
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "connector/src/main/resources/mappings"]
path = connector/src/main/resources/mappings
[submodule "connector/src/main/resources/bedrock/1_14_60/mappings"]
path = connector/src/main/resources/bedrock/1_14_60/mappings
url = https://github.com/GeyserMC/mappings.git
[submodule "connector/src/main/resources/education/1_12_60/mappings"]
path = connector/src/main/resources/education/1_12_60/mappings
url = https://github.com/Bundabrg/mappings-education.git
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public IMetricsInfo getMetrics() {

public class BukkitBedrockConfiguration implements IBedrockConfiguration {

private BukkitEducationConfiguration education;

public BukkitBedrockConfiguration() {
education = new BukkitEducationConfiguration();
}

@Override
public String getAddress() {
return config.getString("bedrock.address", "0.0.0.0");
Expand All @@ -152,6 +158,28 @@ public String getMotd1() {
public String getMotd2() {
return config.getString("bedrock.motd2", "GeyserMC");
}

@Override
public String getEdition() {
return config.getString("edition", "bedrock");
}

@Override
public String getVersion() {
return config.getString("version", "latest");
}

@Override
public IEducationConfiguration getEducation() {
return education;
}

public class BukkitEducationConfiguration implements IBedrockConfiguration.IEducationConfiguration {
@Override
public String getToken() {
return config.getString("bedrock.education.token");
}
}
}

public class BukkitRemoteConfiguration implements IRemoteConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ public void onEnable() {

geyserConfig.loadFloodgate(this);

this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
try {
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
} catch (GeyserConnector.GeyserConnectorException e) {
geyserLogger.error(e.getMessage(), e.getCause());
getServer().getPluginManager().disablePlugin(this);
return;
}

this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.GeyserEdition;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;

@AllArgsConstructor
public class GeyserBukkitBlockPlaceListener implements Listener {
Expand All @@ -55,12 +55,12 @@ public void place(final BlockPlaceEvent event) {
placeBlockSoundPacket.setBabySound(false);
String javaBlockId;
if (isLegacy) {
javaBlockId = BlockTranslator.getJavaIdBlockMap().inverse().get(GeyserBukkitWorldManager.getLegacyBlock(session,
javaBlockId = GeyserEdition.TRANSLATORS.getBlockTranslator().getJavaIdBlockMap().inverse().get(GeyserBukkitWorldManager.getLegacyBlock(session,
event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ(), isViaVersion));
} else {
javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
}
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().get(javaBlockId)));
placeBlockSoundPacket.setExtraData(GeyserEdition.TRANSLATORS.getBlockTranslator().getBedrockBlockId(GeyserEdition.TRANSLATORS.getBlockTranslator().getJavaIdBlockMap().get(javaBlockId)));
placeBlockSoundPacket.setIdentifier(":");
session.sendUpstreamPacket(placeBlockSoundPacket);
session.setLastBlockPlacePosition(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.geysermc.connector.GeyserEdition;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.WorldManager;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.platform.bukkit.GeyserBukkitPlugin;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;

Expand All @@ -50,12 +48,12 @@ public class GeyserBukkitWorldManager extends WorldManager {
@Override
public BlockState getBlockAt(GeyserSession session, int x, int y, int z) {
if (session.getPlayerEntity() == null) {
return BlockTranslator.AIR;
return GeyserEdition.TRANSLATORS.getBlockTranslator().getAir();
}
if (isLegacy) {
return getLegacyBlock(session, x, y, z, isViaVersion);
}
return BlockTranslator.getJavaIdBlockMap().get(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getBlockAt(x, y, z).getBlockData().getAsString());
return GeyserEdition.TRANSLATORS.getBlockTranslator().getJavaIdBlockMap().get(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getBlockAt(x, y, z).getBlockData().getAsString());
}

@SuppressWarnings("deprecation")
Expand All @@ -70,7 +68,7 @@ public static BlockState getLegacyBlock(GeyserSession session, int x, int y, int
int fourteenBlockId = us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.blockStateMappings.getNewId(thirteenPointOneBlockId);
return new BlockState(MappingData.blockStateMappings.getNewId(fourteenBlockId));
} else {
return BlockTranslator.AIR;
return GeyserEdition.TRANSLATORS.getBlockTranslator().getAir();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ public BungeeMetricsInfo getMetrics() {

public class BungeeBedrockConfiguration implements IBedrockConfiguration {

private BungeeEducationConfiguration education;

public BungeeBedrockConfiguration() {
education = new BungeeEducationConfiguration();
}

@Override
public String getAddress() {
return config.getString("bedrock.address", "0.0.0.0");
Expand All @@ -151,6 +157,29 @@ public String getMotd1() {
public String getMotd2() {
return config.getString("bedrock.motd2", "GeyserMC");
}

@Override
public String getEdition() {
return config.getString("bedrock.edition", "bedrock");
}

@Override
public String getVersion() {
return config.getString("bedrock.version", "lastest");
}


@Override
public IEducationConfiguration getEducation() {
return education;
}

public class BungeeEducationConfiguration implements IBedrockConfiguration.IEducationConfiguration {
@Override
public String getToken() {
return config.getString("bedrock.education.token");
}
}
}

public class BungeeRemoteConfiguration implements IRemoteConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ public void onEnable() {

geyserConfig.loadFloodgate(this);

this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
try {
this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
} catch (GeyserConnector.GeyserConnectorException e) {
getLogger().log(Level.SEVERE, e.getMessage(), e.getCause());
return;
}

this.geyserCommandManager = new GeyserBungeeCommandManager(connector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,16 @@ public SpongeMetricsInfo getMetrics() {
return metricsInfo;
}

@AllArgsConstructor

public class SpongeBedrockConfiguration implements IBedrockConfiguration {

private ConfigurationNode node;
private SpongeEducationConfiguration education;

public SpongeBedrockConfiguration(ConfigurationNode node) {
this.node = node;
education = new SpongeEducationConfiguration(node.getNode("education"));
}

@Override
public String getAddress() {
Expand All @@ -148,6 +154,32 @@ public String getMotd1() {
public String getMotd2() {
return node.getNode("motd2").getString("GeyserMC");
}

@Override
public String getEdition() {
return node.getNode("edition").getString("bedrock");
}

@Override
public String getVersion() {
return node.getNode("version").getString("latest");
}

@Override
public IEducationConfiguration getEducation() {
return education;
}

@AllArgsConstructor
public class SpongeEducationConfiguration implements IBedrockConfiguration.IEducationConfiguration {

private ConfigurationNode node;

@Override
public String getToken() {
return node.getNode("token").getString(null);
}
}
}

@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public void onEnable() {
}

this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
this.connector = GeyserConnector.start(PlatformType.SPONGE, this);
try {
this.connector = GeyserConnector.start(PlatformType.SPONGE, this);
} catch (GeyserConnector.GeyserConnectorException e) {
logger.error(e.getMessage(), e.getCause());
return;
}
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), connector);

Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(connector), "geyser");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onEnable() {
geyserLogger = new GeyserStandaloneLogger();

LoopbackUtil.checkLoopback(geyserLogger);

try {
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
Expand All @@ -63,7 +63,12 @@ public void onEnable() {
System.exit(0);
}

connector = GeyserConnector.start(PlatformType.STANDALONE, this);
try {
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
} catch (GeyserConnector.GeyserConnectorException e) {
geyserLogger.severe(e.getMessage(), e.getCause());
System.exit(1);
}
geyserCommandManager = new GeyserCommandManager(connector);
geyserLogger.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public static class BedrockConfiguration implements IBedrockConfiguration {

private String motd1;
private String motd2;

private String edition;
private String version;

private EducationConfiguration education;

@Getter
public static class EducationConfiguration implements IBedrockConfiguration.IEducationConfiguration {
private String token;
}
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ public static class BedrockConfiguration implements IBedrockConfiguration {

private String motd1;
private String motd2;

private String edition;
private String version;

private EducationConfiguration education;

@Getter
public static class EducationConfiguration implements IBedrockConfiguration.IEducationConfiguration {
private String token;
}
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ public void onEnable() {

geyserConfig.loadFloodgate(this, proxyServer, configDir);

this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
try {
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
} catch (GeyserConnector.GeyserConnectorException e) {
logger.error(e.getMessage(), e.getCause());
return;
}

this.geyserCommandManager = new GeyserVelocityCommandManager(connector);
this.commandManager.register(new GeyserVelocityCommandExecutor(connector), "geyser");
Expand Down
16 changes: 15 additions & 1 deletion connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,24 @@
<version>2.9.8</version>
<scope>compile</scope>
</dependency>
<!-- Current Bedrock Protocol -->
<dependency>
<groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v390</artifactId>
<version>2.5.6-SNAPSHOT</version>
<version>2.5.7-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Current MCEE Protocol -->
<dependency>
<groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v363</artifactId>
<version>2.5.7-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ interface IBedrockConfiguration {
String getMotd1();

String getMotd2();

String getEdition();

String getVersion();

IEducationConfiguration getEducation();

interface IEducationConfiguration {
String getToken();
}
}

interface IRemoteConfiguration {
Expand Down
Loading

0 comments on commit 3ede1d5

Please sign in to comment.