forked from GeyserMC/Geyser
Merge branch 'master' of https://github.com/GeyserMC/Geyser into mcprotocollibupdate
This commit is contained in:
commit
1015b830ce
11 changed files with 84 additions and 26 deletions
|
@ -31,6 +31,7 @@ import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
|||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||
import com.nukkitx.protocol.bedrock.v390.Bedrock_v390;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.common.AuthType;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
||||
|
@ -79,6 +80,7 @@ public class GeyserConnector {
|
|||
private static GeyserConnector instance;
|
||||
|
||||
private RemoteServer remoteServer;
|
||||
@Setter
|
||||
private AuthType authType;
|
||||
|
||||
private boolean shuttingDown = false;
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.geysermc.connector.command.CommandManager;
|
|||
import org.geysermc.connector.network.translators.world.CachedChunkManager;
|
||||
import org.geysermc.connector.network.translators.world.WorldManager;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface GeyserBootstrap {
|
||||
|
||||
CachedChunkManager DEFAULT_CHUNK_MANAGER = new CachedChunkManager();
|
||||
|
@ -83,4 +85,11 @@ public interface GeyserBootstrap {
|
|||
default WorldManager getWorldManager() {
|
||||
return DEFAULT_CHUNK_MANAGER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the data folder where files get stored
|
||||
*
|
||||
* @return Path location of data folder
|
||||
*/
|
||||
Path getConfigFolder();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityDataMap;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityFlag;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -74,33 +75,43 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
|||
Entity interactEntity = session.getEntityCache().getEntityByGeyserId(packet.getRuntimeEntityId());
|
||||
if (interactEntity == null)
|
||||
return;
|
||||
EntityDataMap entityMetadata = interactEntity.getMetadata();
|
||||
|
||||
String interactiveTag;
|
||||
switch (interactEntity.getEntityType()) {
|
||||
case PIG:
|
||||
if (interactEntity.getMetadata().getFlags().getFlag(EntityFlag.SADDLED)) {
|
||||
interactiveTag = "action.interact.mount";
|
||||
} else interactiveTag = "";
|
||||
case BOAT:
|
||||
interactiveTag = "action.interact.ride.boat";
|
||||
break;
|
||||
case HORSE:
|
||||
case SKELETON_HORSE:
|
||||
case ZOMBIE_HORSE:
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case HORSE:
|
||||
case LLAMA:
|
||||
case MULE:
|
||||
case SKELETON_HORSE:
|
||||
case TRADER_LLAMA:
|
||||
if (interactEntity.getMetadata().getFlags().getFlag(EntityFlag.TAMED)) {
|
||||
case ZOMBIE_HORSE:
|
||||
if (entityMetadata.getFlags().getFlag(EntityFlag.TAMED)) {
|
||||
interactiveTag = "action.interact.ride.horse";
|
||||
} else {
|
||||
interactiveTag = "action.interact.mount";
|
||||
}
|
||||
break;
|
||||
case BOAT:
|
||||
interactiveTag = "action.interact.ride.boat";
|
||||
break;
|
||||
case MINECART:
|
||||
interactiveTag = "action.interact.ride.minecart";
|
||||
break;
|
||||
case PIG:
|
||||
if (entityMetadata.getFlags().getFlag(EntityFlag.SADDLED)) {
|
||||
interactiveTag = "action.interact.mount";
|
||||
} else interactiveTag = "";
|
||||
break;
|
||||
case VILLAGER:
|
||||
if (entityMetadata.getInt(EntityData.VARIANT) != 14 && entityMetadata.getInt(EntityData.VARIANT) != 0
|
||||
&& entityMetadata.getFloat(EntityData.SCALE) >= 0.75f) { // Not a nitwit, has a profession and is not a baby
|
||||
interactiveTag = "action.interact.trade";
|
||||
} else interactiveTag = "";
|
||||
break;
|
||||
case WANDERING_TRADER:
|
||||
interactiveTag = "action.interact.trade"; // Since you can always trade with a wandering villager, presumably.
|
||||
break;
|
||||
default:
|
||||
return; // No need to process any further since there is no interactive tag
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.geysermc.connector.GeyserConnector;
|
|||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipFile;
|
||||
|
@ -49,7 +50,8 @@ public class LocaleUtils {
|
|||
|
||||
static {
|
||||
// Create the locales folder
|
||||
File localesFolder = new File("locales/");
|
||||
File localesFolder = GeyserConnector.getInstance().getBootstrap().getConfigFolder().resolve("locales").toFile();
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
localesFolder.mkdir();
|
||||
|
||||
// Download the latest asset list and cache it
|
||||
|
@ -132,7 +134,7 @@ public class LocaleUtils {
|
|||
* @param locale Locale to download
|
||||
*/
|
||||
private static void downloadLocale(String locale) {
|
||||
File localeFile = new File("locales/" + locale + ".json");
|
||||
File localeFile = Paths.get(GeyserConnector.getInstance().getBootstrap().getConfigFolder().toString(),"locales",locale + ".json").toFile();
|
||||
|
||||
// Check if we have already downloaded the locale file
|
||||
if (localeFile.exists()) {
|
||||
|
@ -149,7 +151,7 @@ public class LocaleUtils {
|
|||
|
||||
// Get the hash and download the locale
|
||||
String hash = ASSET_MAP.get("minecraft/lang/" + locale + ".json").getHash();
|
||||
WebUtils.downloadFile("http://resources.download.minecraft.net/" + hash.substring(0, 2) + "/" + hash, "locales/" + locale + ".json");
|
||||
WebUtils.downloadFile("http://resources.download.minecraft.net/" + hash.substring(0, 2) + "/" + hash, localeFile.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,10 +207,11 @@ public class LocaleUtils {
|
|||
GeyserConnector.getInstance().getLogger().debug("Download URL: " + smallestURL);
|
||||
|
||||
// Download the smallest JAR (client or server)
|
||||
WebUtils.downloadFile(smallestURL, "tmp_locale.jar");
|
||||
Path tmpFilePath = GeyserConnector.getInstance().getBootstrap().getConfigFolder().resolve("tmp_locale.jar");
|
||||
WebUtils.downloadFile(smallestURL, tmpFilePath.toString());
|
||||
|
||||
// Load in the JAR as a zip and extract the file
|
||||
ZipFile localeJar = new ZipFile("tmp_locale.jar");
|
||||
ZipFile localeJar = new ZipFile(tmpFilePath.toString());
|
||||
InputStream inputStream = localeJar.getInputStream(localeJar.getEntry("assets/minecraft/lang/en_us.json"));
|
||||
FileOutputStream outputStream = new FileOutputStream(localeFile);
|
||||
|
||||
|
@ -227,7 +230,7 @@ public class LocaleUtils {
|
|||
localeJar.close();
|
||||
|
||||
// Delete the nolonger needed client/server jar
|
||||
Files.delete(Paths.get("tmp_locale.jar"));
|
||||
Files.delete(tmpFilePath);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError("Unable to download and extract en_us locale!", e);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
# --------------------------------
|
||||
|
||||
bedrock:
|
||||
# The IP address that will listen for connections
|
||||
# The IP address that will listen for connections.
|
||||
# There is no reason to change this unless you want to limit what IPs can connect to your server.
|
||||
address: 0.0.0.0
|
||||
# The port that will listen for connections
|
||||
port: 19132
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue