3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Add block break sounds for blocks with 0 hardness, and refactor some things

The refactors in this commit go a bit beyond the scope of what the sound/effects branch was meant to accomplish, however most of these changes are necessary so chunk caching could be reintroduced for the standalone version. The chunk caching here allows for us to get the block ID before the block was broken, and in the future allow us to implement newer features. Chunk caching is optional (and disabled by default) as on non-Bukkit versions, it can eat up a lot of RAM with many players online.
Dieser Commit ist enthalten in:
RednedEpic 2020-04-29 15:01:53 -05:00
Ursprung efcf739973
Commit 31be608038
74 geänderte Dateien mit 873 neuen und 598 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.platform.bukkit; package org.geysermc.platform.bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.connector.GeyserConfiguration;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@ -34,7 +34,7 @@ import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class GeyserBukkitConfiguration implements IGeyserConfiguration { public class GeyserBukkitConfiguration implements GeyserConfiguration {
private FileConfiguration config; private FileConfiguration config;
private File dataFolder; private File dataFolder;
@ -111,6 +111,11 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")); return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
} }
@Override
public boolean isCacheChunks() {
return true; // We override this as with Bukkit, we have direct access to the server implementation
}
@Override @Override
public IMetricsInfo getMetrics() { public IMetricsInfo getMetrics() {
return metricsInfo; return metricsInfo;

Datei anzeigen

@ -27,13 +27,13 @@ package org.geysermc.platform.bukkit;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.geysermc.common.logger.IGeyserLogger; import org.geysermc.connector.GeyserLogger;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@AllArgsConstructor @AllArgsConstructor
public class GeyserBukkitLogger implements IGeyserLogger { public class GeyserBukkitLogger implements GeyserLogger {
private Logger logger; private Logger logger;
private boolean debugMode; private boolean debugMode;

Datei anzeigen

@ -27,20 +27,22 @@ package org.geysermc.platform.bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.common.command.ICommandManager;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager; import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.network.translators.world.WorldManager;
import org.geysermc.platform.bukkit.command.GeyserBukkitCommandExecutor; import org.geysermc.platform.bukkit.command.GeyserBukkitCommandExecutor;
import org.geysermc.platform.bukkit.command.GeyserBukkitCommandManager; import org.geysermc.platform.bukkit.command.GeyserBukkitCommandManager;
import org.geysermc.platform.bukkit.world.GeyserBukkitWorldManager;
import java.util.UUID; import java.util.UUID;
public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap { public class GeyserBukkitPlugin extends JavaPlugin implements GeyserBootstrap {
private GeyserBukkitCommandManager geyserCommandManager; private GeyserBukkitCommandManager geyserCommandManager;
private GeyserBukkitConfiguration geyserConfig; private GeyserBukkitConfiguration geyserConfig;
private GeyserBukkitLogger geyserLogger; private GeyserBukkitLogger geyserLogger;
private GeyserBukkitWorldManager geyserWorldManager;
private GeyserConnector connector; private GeyserConnector connector;
@ -58,6 +60,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this); this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector); this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);
this.geyserWorldManager = new GeyserBukkitWorldManager();
this.getCommand("geyser").setExecutor(new GeyserBukkitCommandExecutor(connector)); this.getCommand("geyser").setExecutor(new GeyserBukkitCommandExecutor(connector));
} }
@ -81,4 +84,9 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
public CommandManager getGeyserCommandManager() { public CommandManager getGeyserCommandManager() {
return this.geyserCommandManager; return this.geyserCommandManager;
} }
@Override
public WorldManager getWorldManager() {
return this.geyserWorldManager;
}
} }

Datei anzeigen

@ -21,18 +21,22 @@
* *
* @author GeyserMC * @author GeyserMC
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*
*/ */
package org.geysermc.common.command; package org.geysermc.platform.bukkit.world;
public interface ICommandManager { import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
/** import org.bukkit.Bukkit;
* Returns the description of the given command import org.geysermc.connector.network.session.GeyserSession;
* import org.geysermc.connector.network.translators.world.WorldManager;
* @param command Command to get the description for import org.geysermc.connector.network.translators.world.block.BlockTranslator;
*
* @return Command description public class GeyserBukkitWorldManager extends WorldManager {
*/
String getDescription(String command); @Override
public BlockState getBlockAt(GeyserSession session, int x, int y, int z) {
return BlockTranslator.getJavaIdBlockMap().get(Bukkit.getPlayer(session.getName()).getWorld().getBlockAt(x, y, z).getBlockData().getAsString());
}
} }

Datei anzeigen

@ -27,7 +27,7 @@ package org.geysermc.platform.bungeecord;
import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.Configuration;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.connector.GeyserConfiguration;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@ -35,7 +35,7 @@ import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class GeyserBungeeConfiguration implements IGeyserConfiguration { public class GeyserBungeeConfiguration implements GeyserConfiguration {
private File dataFolder; private File dataFolder;
private Configuration config; private Configuration config;
@ -112,6 +112,11 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration {
return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")); return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
} }
@Override
public boolean isCacheChunks() {
return config.getBoolean("cache-chunks", false);
}
@Override @Override
public BungeeMetricsInfo getMetrics() { public BungeeMetricsInfo getMetrics() {
return metricsInfo; return metricsInfo;

Datei anzeigen

@ -25,12 +25,12 @@
package org.geysermc.platform.bungeecord; package org.geysermc.platform.bungeecord;
import org.geysermc.common.logger.IGeyserLogger; import org.geysermc.connector.GeyserLogger;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
public class GeyserBungeeLogger implements IGeyserLogger { public class GeyserBungeeLogger implements GeyserLogger {
private Logger logger; private Logger logger;
private boolean debugMode; private boolean debugMode;

Datei anzeigen

@ -32,7 +32,7 @@ import net.md_5.bungee.config.YamlConfiguration;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager; import org.geysermc.connector.command.CommandManager;
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandExecutor; import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandExecutor;
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandManager; import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandManager;
@ -44,7 +44,7 @@ import java.nio.file.Files;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap { public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
private GeyserBungeeCommandManager geyserCommandManager; private GeyserBungeeCommandManager geyserCommandManager;
private GeyserBungeeConfiguration geyserConfig; private GeyserBungeeConfiguration geyserConfig;

Datei anzeigen

@ -29,7 +29,7 @@ import lombok.AllArgsConstructor;
import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.ConfigurationNode;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.connector.GeyserConfiguration;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@ -38,7 +38,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class GeyserSpongeConfiguration implements IGeyserConfiguration { public class GeyserSpongeConfiguration implements GeyserConfiguration {
private File dataFolder; private File dataFolder;
private ConfigurationNode node; private ConfigurationNode node;
@ -115,6 +115,11 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration {
return Paths.get(dataFolder.toString(), node.getNode("floodgate-key-file").getString("public-key.pem")); return Paths.get(dataFolder.toString(), node.getNode("floodgate-key-file").getString("public-key.pem"));
} }
@Override
public boolean isCacheChunks() {
return node.getNode("cache-chunks").getBoolean(false);
}
@Override @Override
public SpongeMetricsInfo getMetrics() { public SpongeMetricsInfo getMetrics() {
return metricsInfo; return metricsInfo;

Datei anzeigen

@ -27,11 +27,11 @@ package org.geysermc.platform.sponge;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.geysermc.common.logger.IGeyserLogger; import org.geysermc.connector.GeyserLogger;
import org.slf4j.Logger; import org.slf4j.Logger;
@AllArgsConstructor @AllArgsConstructor
public class GeyserSpongeLogger implements IGeyserLogger { public class GeyserSpongeLogger implements GeyserLogger {
private Logger logger; private Logger logger;
private boolean debugMode; private boolean debugMode;

Datei anzeigen

@ -31,8 +31,7 @@ import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader; import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.common.command.ICommandManager;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandManager; import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
@ -51,7 +50,7 @@ import java.io.IOException;
import java.util.UUID; import java.util.UUID;
@Plugin(id = "geyser", name = GeyserConnector.NAME + "-Sponge", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC") @Plugin(id = "geyser", name = GeyserConnector.NAME + "-Sponge", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC")
public class GeyserSpongePlugin implements IGeyserBootstrap { public class GeyserSpongePlugin implements GeyserBootstrap {
@Inject @Inject
private Logger logger; private Logger logger;

Datei anzeigen

@ -81,7 +81,7 @@
<configuration> <configuration>
<archive> <archive>
<manifestEntries> <manifestEntries>
<Main-Class>org.geysermc.platform.standalone.GeyserBootstrap</Main-Class> <Main-Class>org.geysermc.platform.standalone.GeyserStandaloneBootstrap</Main-Class>
</manifestEntries> </manifestEntries>
</archive> </archive>
</configuration> </configuration>
@ -119,7 +119,7 @@
</filters> </filters>
<transformers> <transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.geysermc.platform.standalone.GeyserBootstrap</mainClass> <mainClass>org.geysermc.platform.standalone.GeyserStandaloneBootstrap</mainClass>
<manifestEntries> <manifestEntries>
<Multi-Release>true</Multi-Release> <Multi-Release>true</Multi-Release>
</manifestEntries> </manifestEntries>

Datei anzeigen

@ -26,38 +26,38 @@
package org.geysermc.platform.standalone; package org.geysermc.platform.standalone;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandManager; import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
import org.geysermc.platform.standalone.command.GeyserCommandManager; import org.geysermc.platform.standalone.command.GeyserCommandManager;
import org.geysermc.platform.standalone.console.GeyserLogger;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
public class GeyserBootstrap implements IGeyserBootstrap { public class GeyserStandaloneBootstrap implements GeyserBootstrap {
private GeyserCommandManager geyserCommandManager; private GeyserCommandManager geyserCommandManager;
private GeyserConfiguration geyserConfig; private GeyserConfiguration geyserConfig;
private GeyserLogger geyserLogger; private GeyserStandaloneLogger geyserLogger;
private GeyserConnector connector; private GeyserConnector connector;
public static void main(String[] args) { public static void main(String[] args) {
new GeyserBootstrap().onEnable(); new GeyserStandaloneBootstrap().onEnable();
} }
@Override @Override
public void onEnable() { public void onEnable() {
geyserLogger = new GeyserLogger(); geyserLogger = new GeyserStandaloneLogger();
LoopbackUtil.checkLoopback(geyserLogger); LoopbackUtil.checkLoopback(geyserLogger);
try { try {
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString())); File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
geyserConfig = FileUtils.loadConfig(configFile, GeyserConfiguration.class); geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
} catch (IOException ex) { } catch (IOException ex) {
geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
System.exit(0); System.exit(0);
@ -80,7 +80,7 @@ public class GeyserBootstrap implements IGeyserBootstrap {
} }
@Override @Override
public GeyserLogger getGeyserLogger() { public GeyserStandaloneLogger getGeyserLogger() {
return geyserLogger; return geyserLogger;
} }

Datei anzeigen

@ -29,8 +29,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.common.IGeyserConfiguration;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -38,7 +37,7 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@Getter @Getter
public class GeyserConfiguration implements IGeyserConfiguration { public class GeyserStandaloneConfiguration implements GeyserConfiguration {
private BedrockConfiguration bedrock; private BedrockConfiguration bedrock;
private RemoteConfiguration remote; private RemoteConfiguration remote;
@ -66,6 +65,9 @@ public class GeyserConfiguration implements IGeyserConfiguration {
@JsonProperty("default-locale") @JsonProperty("default-locale")
private String defaultLocale; private String defaultLocale;
@JsonProperty("cache-chunks")
private boolean cacheChunks;
private MetricsInfo metrics; private MetricsInfo metrics;
@Override @Override

Datei anzeigen

@ -21,9 +21,10 @@
* *
* @author GeyserMC * @author GeyserMC
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*
*/ */
package org.geysermc.platform.standalone.console; package org.geysermc.platform.standalone;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@ -31,12 +32,11 @@ import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.apache.logging.log4j.core.config.Configurator; import org.apache.logging.log4j.core.config.Configurator;
import org.geysermc.common.ChatColor; import org.geysermc.common.ChatColor;
import org.geysermc.common.logger.IGeyserLogger;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender; import org.geysermc.connector.command.CommandSender;
@Log4j2 @Log4j2
public class GeyserLogger extends SimpleTerminalConsole implements IGeyserLogger, CommandSender { public class GeyserStandaloneLogger extends SimpleTerminalConsole implements org.geysermc.connector.GeyserLogger, CommandSender {
private boolean colored = true; private boolean colored = true;

Datei anzeigen

@ -6,14 +6,13 @@ import java.nio.file.OpenOption;
import java.nio.file.Paths; import java.nio.file.Paths;
import org.geysermc.common.ChatColor; import org.geysermc.common.ChatColor;
import org.geysermc.platform.standalone.console.GeyserLogger;
public class LoopbackUtil { public class LoopbackUtil {
private static final String checkExemption = "powershell -Command \"CheckNetIsolation LoopbackExempt -s\""; // Java's Exec feature runs as CMD, NetIsolation is only accessible from PowerShell. private static final String checkExemption = "powershell -Command \"CheckNetIsolation LoopbackExempt -s\""; // Java's Exec feature runs as CMD, NetIsolation is only accessible from PowerShell.
private static final String loopbackCommand = "powershell -Command \"CheckNetIsolation LoopbackExempt -a -n='Microsoft.MinecraftUWP_8wekyb3d8bbwe'\""; private static final String loopbackCommand = "powershell -Command \"CheckNetIsolation LoopbackExempt -a -n='Microsoft.MinecraftUWP_8wekyb3d8bbwe'\"";
private static final String startScript = "powershell -Command \"Start-Process 'cmd' -ArgumentList /c,%temp%/loopback_minecraft.bat -Verb runAs\""; private static final String startScript = "powershell -Command \"Start-Process 'cmd' -ArgumentList /c,%temp%/loopback_minecraft.bat -Verb runAs\"";
public static void checkLoopback(GeyserLogger geyserLogger) { public static void checkLoopback(GeyserStandaloneLogger geyserLogger) {
if (System.getProperty("os.name").equalsIgnoreCase("Windows 10")) { if (System.getProperty("os.name").equalsIgnoreCase("Windows 10")) {
try { try {
Process process = Runtime.getRuntime().exec(checkExemption); Process process = Runtime.getRuntime().exec(checkExemption);

Datei anzeigen

@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.connector.GeyserConfiguration;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -38,7 +38,7 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@Getter @Getter
public class GeyserVelocityConfiguration implements IGeyserConfiguration { public class GeyserVelocityConfiguration implements GeyserConfiguration {
private BedrockConfiguration bedrock; private BedrockConfiguration bedrock;
private RemoteConfiguration remote; private RemoteConfiguration remote;
@ -66,6 +66,9 @@ public class GeyserVelocityConfiguration implements IGeyserConfiguration {
@JsonProperty("default-locale") @JsonProperty("default-locale")
private String defaultLocale; private String defaultLocale;
@JsonProperty("cache-chunks")
private boolean cacheChunks;
private MetricsInfo metrics; private MetricsInfo metrics;
@Override @Override

Datei anzeigen

@ -27,11 +27,11 @@ package org.geysermc.platform.velocity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.geysermc.common.logger.IGeyserLogger; import org.geysermc.connector.GeyserLogger;
import org.slf4j.Logger; import org.slf4j.Logger;
@AllArgsConstructor @AllArgsConstructor
public class GeyserVelocityLogger implements IGeyserLogger { public class GeyserVelocityLogger implements GeyserLogger {
private Logger logger; private Logger logger;
private boolean debugMode; private boolean debugMode;

Datei anzeigen

@ -34,8 +34,8 @@ import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.Plugin;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.common.bootstrap.IGeyserBootstrap;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
import org.geysermc.platform.velocity.command.GeyserVelocityCommandExecutor; import org.geysermc.platform.velocity.command.GeyserVelocityCommandExecutor;
import org.geysermc.platform.velocity.command.GeyserVelocityCommandManager; import org.geysermc.platform.velocity.command.GeyserVelocityCommandManager;
@ -46,7 +46,7 @@ import java.io.IOException;
import java.util.UUID; import java.util.UUID;
@Plugin(id = "geyser", name = GeyserConnector.NAME + "-Velocity", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC") @Plugin(id = "geyser", name = GeyserConnector.NAME + "-Velocity", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC")
public class GeyserVelocityPlugin implements IGeyserBootstrap { public class GeyserVelocityPlugin implements GeyserBootstrap {
@Inject @Inject
private Logger logger; private Logger logger;

Datei anzeigen

@ -1,87 +0,0 @@
/*
* Copyright (c) 2019-2020 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.common;
import java.nio.file.Path;
import java.util.Map;
public interface IGeyserConfiguration {
IBedrockConfiguration getBedrock();
IRemoteConfiguration getRemote();
Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
boolean isPingPassthrough();
int getMaxPlayers();
boolean isDebugMode();
int getGeneralThreadPool();
boolean isAllowThirdPartyCapes();
String getDefaultLocale();
Path getFloodgateKeyFile();
IMetricsInfo getMetrics();
interface IBedrockConfiguration {
String getAddress();
int getPort();
String getMotd1();
String getMotd2();
}
interface IRemoteConfiguration {
String getAddress();
int getPort();
String getAuthType();
}
interface IUserAuthenticationInfo {
String getEmail();
String getPassword();
}
interface IMetricsInfo {
boolean isEnabled();
String getUniqueId();
}
}

Datei anzeigen

@ -1,64 +0,0 @@
/*
* Copyright (c) 2019-2020 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.common.bootstrap;
import org.geysermc.common.IGeyserConfiguration;
import org.geysermc.common.command.ICommandManager;
import org.geysermc.common.logger.IGeyserLogger;
public interface IGeyserBootstrap {
/**
* Called when the GeyserBootstrap is enabled
*/
void onEnable();
/**
* Called when the GeyserBootstrap is disabled
*/
void onDisable();
/**
* Returns the current GeyserConfig
*
* @return The current GeyserConfig
*/
IGeyserConfiguration getGeyserConfig();
/**
* Returns the current GeyserLogger
*
* @return The current GeyserLogger
*/
IGeyserLogger getGeyserLogger();
/**
* Returns the current GeyserCommandManager
*
* @return The current GeyserCommandManager
*/
ICommandManager getGeyserCommandManager();
}

Datei anzeigen

@ -1,81 +0,0 @@
/*
* Copyright (c) 2019-2020 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.common.logger;
public interface IGeyserLogger {
/**
* Logs a severe message to console
*
* @param message the message to log
*/
void severe(String message);
/**
* Logs a severe message and an exception to console
*/
void severe(String message, Throwable error);
/**
* Logs an error message to console
*
* @param message the message to log
*/
void error(String message);
/**
* Logs an error message and an exception to console
*/
void error(String message, Throwable error);
/**
* Logs a warning message to console
*
* @param message the message to log
*/
void warning(String message);
/**
* Logs an info message to console
*
* @param message the message to log
*/
void info(String message);
/**
* Logs a debug message to console
*
* @param message the message to log
*/
void debug(String message);
/**
* Sets if the logger should print debug messages
*
* @param debug if the logger should print debug messages
*/
void setDebug(boolean debug);
}

Datei anzeigen

@ -0,0 +1,90 @@
/*
* Copyright (c) 2019-2020 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;
import java.nio.file.Path;
import java.util.Map;
public interface GeyserConfiguration {
IBedrockConfiguration getBedrock();
IRemoteConfiguration getRemote();
Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
boolean isPingPassthrough();
int getMaxPlayers();
boolean isDebugMode();
int getGeneralThreadPool();
boolean isAllowThirdPartyCapes();
String getDefaultLocale();
Path getFloodgateKeyFile();
boolean isCacheChunks();
IMetricsInfo getMetrics();
interface IBedrockConfiguration {
String getAddress();
int getPort();
String getMotd1();
String getMotd2();
}
interface IRemoteConfiguration {
String getAddress();
int getPort();
String getAuthType();
}
interface IUserAuthenticationInfo {
String getEmail();
String getPassword();
}
interface IMetricsInfo {
boolean isEnabled();
String getUniqueId();
}
}

Datei anzeigen

@ -32,16 +32,15 @@ import com.nukkitx.protocol.bedrock.v390.Bedrock_v390;
import lombok.Getter; import lombok.Getter;
import org.geysermc.common.AuthType; import org.geysermc.common.AuthType;
import org.geysermc.common.IGeyserConfiguration;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.common.logger.IGeyserLogger;
import org.geysermc.connector.command.CommandManager; import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.metrics.Metrics; import org.geysermc.connector.metrics.Metrics;
import org.geysermc.connector.network.ConnectorServerEventHandler; import org.geysermc.connector.network.ConnectorServerEventHandler;
import org.geysermc.connector.network.remote.RemoteServer; import org.geysermc.connector.network.remote.RemoteServer;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
import org.geysermc.connector.network.translators.world.WorldManager;
import org.geysermc.connector.thread.PingPassthroughThread; import org.geysermc.connector.thread.PingPassthroughThread;
import org.geysermc.connector.utils.Toolbox; import org.geysermc.connector.utils.Toolbox;
@ -76,19 +75,19 @@ public class GeyserConnector {
private BedrockServer bedrockServer; private BedrockServer bedrockServer;
private PlatformType platformType; private PlatformType platformType;
private IGeyserBootstrap bootstrap; private GeyserBootstrap bootstrap;
private Metrics metrics; private Metrics metrics;
private GeyserConnector(PlatformType platformType, IGeyserBootstrap bootstrap) { private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
long startupTime = System.currentTimeMillis(); long startupTime = System.currentTimeMillis();
instance = this; instance = this;
this.bootstrap = bootstrap; this.bootstrap = bootstrap;
IGeyserLogger logger = bootstrap.getGeyserLogger(); GeyserLogger logger = bootstrap.getGeyserLogger();
IGeyserConfiguration config = bootstrap.getGeyserConfig(); GeyserConfiguration config = bootstrap.getGeyserConfig();
this.platformType = platformType; this.platformType = platformType;
@ -191,7 +190,7 @@ public class GeyserConnector {
players.remove(player.getSocketAddress()); players.remove(player.getSocketAddress());
} }
public static GeyserConnector start(PlatformType platformType, IGeyserBootstrap bootstrap) { public static GeyserConnector start(PlatformType platformType, GeyserBootstrap bootstrap) {
return new GeyserConnector(platformType, bootstrap); return new GeyserConnector(platformType, bootstrap);
} }
@ -200,16 +199,20 @@ public class GeyserConnector {
bootstrap.onEnable(); bootstrap.onEnable();
} }
public IGeyserLogger getLogger() { public GeyserLogger getLogger() {
return bootstrap.getGeyserLogger(); return bootstrap.getGeyserLogger();
} }
public IGeyserConfiguration getConfig() { public GeyserConfiguration getConfig() {
return bootstrap.getGeyserConfig(); return bootstrap.getGeyserConfig();
} }
public CommandManager getCommandManager() { public CommandManager getCommandManager() {
return (CommandManager) bootstrap.getGeyserCommandManager(); return bootstrap.getGeyserCommandManager();
}
public WorldManager getWorldManager() {
return bootstrap.getWorldManager();
} }
public static GeyserConnector getInstance() { public static GeyserConnector getInstance() {

Datei anzeigen

@ -0,0 +1,82 @@
/*
* Copyright (c) 2019-2020 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;
public interface GeyserLogger {
/**
* Logs a severe message to console
*
* @param message the message to log
*/
void severe(String message);
/**
* Logs a severe message and an exception to console
*/
void severe(String message, Throwable error);
/**
* Logs an error message to console
*
* @param message the message to log
*/
void error(String message);
/**
* Logs an error message and an exception to console
*/
void error(String message, Throwable error);
/**
* Logs a warning message to console
*
* @param message the message to log
*/
void warning(String message);
/**
* Logs an info message to console
*
* @param message the message to log
*/
void info(String message);
/**
* Logs a debug message to console
*
* @param message the message to log
*/
void debug(String message);
/**
* Sets if the logger should print debug messages
*
* @param debug if the logger should print debug messages
*/
void setDebug(boolean debug);
}

Datei anzeigen

@ -0,0 +1,78 @@
/*
* Copyright (c) 2019-2020 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.bootstrap;
import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserLogger;
import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.network.translators.world.CachedChunkManager;
import org.geysermc.connector.network.translators.world.WorldManager;
public interface GeyserBootstrap {
CachedChunkManager DEFAULT_CHUNK_MANAGER = new CachedChunkManager();
/**
* Called when the GeyserBootstrap is enabled
*/
void onEnable();
/**
* Called when the GeyserBootstrap is disabled
*/
void onDisable();
/**
* Returns the current GeyserConfiguration
*
* @return The current GeyserConfiguration
*/
GeyserConfiguration getGeyserConfig();
/**
* Returns the current GeyserLogger
*
* @return The current GeyserLogger
*/
GeyserLogger getGeyserLogger();
/**
* Returns the current CommandManager
*
* @return The current CommandManager
*/
CommandManager getGeyserCommandManager();
/**
* Returns the current WorldManager
*
* @return the current WorldManager
*/
default WorldManager getWorldManager() {
return DEFAULT_CHUNK_MANAGER;
}
}

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.connector.command; package org.geysermc.connector.command;
import lombok.Getter; import lombok.Getter;
import org.geysermc.common.command.ICommandManager;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.defaults.*; import org.geysermc.connector.command.defaults.*;
@ -34,7 +34,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public abstract class CommandManager implements ICommandManager { public abstract class CommandManager {
@Getter @Getter
private final Map<String, GeyserCommand> commands = Collections.synchronizedMap(new HashMap<>()); private final Map<String, GeyserCommand> commands = Collections.synchronizedMap(new HashMap<>());
@ -87,4 +87,12 @@ public abstract class CommandManager implements ICommandManager {
cmd.execute(sender, args); cmd.execute(sender, args);
} }
/**
* Returns the description of the given command
*
* @param command Command to get the description for
* @return Command description
*/
public abstract String getDescription(String command);
} }

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.connector.entity;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityData;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
public class FallingBlockEntity extends Entity { public class FallingBlockEntity extends Entity {

Datei anzeigen

@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.ItemData;
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket; import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
public class LlamaEntity extends ChestedHorseEntity { public class LlamaEntity extends ChestedHorseEntity {

Datei anzeigen

@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.EntityData;
import com.nukkitx.protocol.bedrock.data.EntityFlag; import com.nukkitx.protocol.bedrock.data.EntityFlag;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
public class EndermanEntity extends MonsterEntity { public class EndermanEntity extends MonsterEntity {

Datei anzeigen

@ -30,7 +30,7 @@ import com.nukkitx.protocol.bedrock.BedrockPong;
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler; import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.BedrockServerSession;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.MessageUtils; import org.geysermc.connector.utils.MessageUtils;
@ -55,7 +55,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) { public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
connector.getLogger().debug(inetSocketAddress + " has pinged you!"); connector.getLogger().debug(inetSocketAddress + " has pinged you!");
IGeyserConfiguration config = connector.getConfig(); GeyserConfiguration config = connector.getConfig();
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo(); ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
BedrockPong pong = new BedrockPong(); BedrockPong pong = new BedrockPong();
@ -101,11 +101,6 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
if (player != null) { if (player != null) {
player.disconnect(disconnectReason.name()); player.disconnect(disconnectReason.name());
connector.removePlayer(player); connector.removePlayer(player);
player.getEntityCache().clear();
player.getInventoryCache().getInventories().clear();
player.getWindowCache().getWindows().clear();
player.getScoreboardCache().removeScoreboard();
} }
}); });
bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC); bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC);

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.connector.network;
import com.nukkitx.protocol.bedrock.BedrockPacket; import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.common.AuthType; import org.geysermc.common.AuthType;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.Registry; import org.geysermc.connector.network.translators.Registry;
@ -94,7 +94,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
private boolean couldLoginUserByName(String bedrockUsername) { private boolean couldLoginUserByName(String bedrockUsername) {
if (connector.getConfig().getUserAuths() != null) { if (connector.getConfig().getUserAuths() != null) {
IGeyserConfiguration.IUserAuthenticationInfo info = connector.getConfig().getUserAuths().get(bedrockUsername); GeyserConfiguration.IUserAuthenticationInfo info = connector.getConfig().getUserAuths().get(bedrockUsername);
if (info != null) { if (info != null) {
connector.getLogger().info("using stored credentials for bedrock user " + session.getAuthData().getName()); connector.getLogger().info("using stored credentials for bedrock user " + session.getAuthData().getName());

Datei anzeigen

@ -62,7 +62,7 @@ import org.geysermc.connector.network.session.auth.AuthData;
import org.geysermc.connector.network.session.auth.BedrockClientData; import org.geysermc.connector.network.session.auth.BedrockClientData;
import org.geysermc.connector.network.session.cache.*; import org.geysermc.connector.network.session.cache.*;
import org.geysermc.connector.network.translators.Registry; import org.geysermc.connector.network.translators.Registry;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.utils.ChunkUtils; import org.geysermc.connector.utils.ChunkUtils;
import org.geysermc.connector.utils.LocaleUtils; import org.geysermc.connector.utils.LocaleUtils;
import org.geysermc.connector.utils.Toolbox; import org.geysermc.connector.utils.Toolbox;
@ -337,10 +337,11 @@ public class GeyserSession implements CommandSender {
} }
} }
this.entityCache.getEntities().clear(); this.chunkCache = null;
this.scoreboardCache.removeScoreboard(); this.entityCache = null;
this.inventoryCache.getInventories().clear(); this.scoreboardCache = null;
this.windowCache.getWindows().clear(); this.inventoryCache = null;
this.windowCache = null;
closed = true; closed = true;
} }

Datei anzeigen

@ -29,34 +29,39 @@ import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
import com.github.steveice10.mc.protocol.data.game.chunk.Column; import com.github.steveice10.mc.protocol.data.game.chunk.Column;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
import org.geysermc.connector.world.chunk.ChunkPosition;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class ChunkCache { public class ChunkCache {
private GeyserSession session; private boolean cache;
private final GeyserSession session;
@Getter @Getter
private Map<ChunkPosition, Column> chunks; private Map<ChunkPosition, Column> chunks = new HashMap<>();
public ChunkCache(GeyserSession session) { public ChunkCache(GeyserSession session) {
this.session = session; this.session = session;
this.chunks = new HashMap<>(); this.cache = session.getConnector().getConfig().isCacheChunks();
} }
public void addToCache(Column chunk) { public void addToCache(Column chunk) {
if (!cache) {
return;
}
ChunkPosition position = new ChunkPosition(chunk.getX(), chunk.getZ()); ChunkPosition position = new ChunkPosition(chunk.getX(), chunk.getZ());
chunks.put(position, chunk); chunks.put(position, chunk);
} }
public void updateBlock(Position position, BlockState block) { public void updateBlock(Position position, BlockState block) {
if (!cache) {
return;
}
ChunkPosition chunkPosition = new ChunkPosition(position.getX() >> 4, position.getZ() >> 4); ChunkPosition chunkPosition = new ChunkPosition(position.getX() >> 4, position.getZ() >> 4);
if (!chunks.containsKey(chunkPosition)) if (!chunks.containsKey(chunkPosition))
return; return;
@ -70,6 +75,9 @@ public class ChunkCache {
} }
public BlockState getBlockAt(Position position) { public BlockState getBlockAt(Position position) {
if (!cache) {
return BlockTranslator.AIR;
}
ChunkPosition chunkPosition = new ChunkPosition(position.getX() >> 4, position.getZ() >> 4); ChunkPosition chunkPosition = new ChunkPosition(position.getX() >> 4, position.getZ() >> 4);
if (!chunks.containsKey(chunkPosition)) if (!chunks.containsKey(chunkPosition))
return BlockTranslator.AIR; return BlockTranslator.AIR;
@ -85,24 +93,9 @@ public class ChunkCache {
} }
public void removeChunk(ChunkPosition position) { public void removeChunk(ChunkPosition position) {
chunks.remove(position); if (!cache) {
sendEmptyChunk(position, true);
}
public void sendEmptyChunk(ChunkPosition position) {
sendEmptyChunk(position, false);
}
public void sendEmptyChunk(ChunkPosition position, boolean force) {
if (!force && chunks.containsKey(position))
return; return;
}
LevelChunkPacket levelChunkPacket = new LevelChunkPacket(); chunks.remove(position);
levelChunkPacket.setChunkX(position.getX());
levelChunkPacket.setChunkZ(position.getZ());
levelChunkPacket.setCachingEnabled(false);
levelChunkPacket.setSubChunksLength(0);
levelChunkPacket.setData(Translators.EMPTY_LEVEL_CHUNK_DATA);
session.getUpstream().sendPacket(levelChunkPacket);
} }
} }

Datei anzeigen

@ -33,8 +33,8 @@ import java.util.Map;
import com.github.steveice10.mc.protocol.data.game.window.WindowType; import com.github.steveice10.mc.protocol.data.game.window.WindowType;
import com.nukkitx.protocol.bedrock.data.ContainerType; import com.nukkitx.protocol.bedrock.data.ContainerType;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.block.entity.*; import org.geysermc.connector.network.translators.world.block.entity.*;
import org.geysermc.connector.network.translators.inventory.*; import org.geysermc.connector.network.translators.inventory.*;
import org.geysermc.connector.network.translators.inventory.updater.ContainerInventoryUpdater; import org.geysermc.connector.network.translators.inventory.updater.ContainerInventoryUpdater;
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater; import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;
@ -117,7 +117,7 @@ public class Translators {
} }
private static void registerBlockEntityTranslators() { private static void registerBlockEntityTranslators() {
Reflections ref = new Reflections("org.geysermc.connector.network.translators.block.entity"); Reflections ref = new Reflections("org.geysermc.connector.network.translators.world.block.entity");
for (Class<?> clazz : ref.getTypesAnnotatedWith(BlockEntity.class)) { for (Class<?> clazz : ref.getTypesAnnotatedWith(BlockEntity.class)) {

Datei anzeigen

@ -28,9 +28,7 @@ package org.geysermc.connector.network.translators.bedrock;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.nukkitx.protocol.bedrock.data.LevelEventType; import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.data.SoundEvent;
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket; import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
@ -45,7 +43,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket; import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket; import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
@Translator(packet = PlayerActionPacket.class) @Translator(packet = PlayerActionPacket.class)
public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket> { public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket> {

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.connector.network.translators.bedrock; package org.geysermc.connector.network.translators.bedrock;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
@ -37,8 +38,10 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket; import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket;
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
@ -47,6 +50,7 @@ import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
import org.geysermc.connector.network.translators.item.ItemEntry; import org.geysermc.connector.network.translators.item.ItemEntry;
import org.geysermc.connector.network.translators.item.ItemTranslator; import org.geysermc.connector.network.translators.item.ItemTranslator;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.utils.InventoryUtils; import org.geysermc.connector.utils.InventoryUtils;
@Translator(packet = InventoryTransactionPacket.class) @Translator(packet = InventoryTransactionPacket.class)
@ -76,31 +80,31 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(), packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
false); false);
session.getDownstream().getSession().send(blockPacket); session.getDownstream().getSession().send(blockPacket);
Vector3i clickPos = packet.getBlockPosition(); Vector3i blockPos = packet.getBlockPosition();
// TODO: Find a better way to do this? // TODO: Find a better way to do this?
switch (packet.getFace()) { switch (packet.getFace()) {
case 0: case 0:
clickPos = clickPos.sub(0, 1, 0); blockPos = blockPos.sub(0, 1, 0);
break; break;
case 1: case 1:
clickPos = clickPos.add(0, 1, 0); blockPos = blockPos.add(0, 1, 0);
break; break;
case 2: case 2:
clickPos = clickPos.sub(0, 0, 1); blockPos = blockPos.sub(0, 0, 1);
break; break;
case 3: case 3:
clickPos = clickPos.add(0, 0, 1); blockPos = blockPos.add(0, 0, 1);
break; break;
case 4: case 4:
clickPos = clickPos.sub(1, 0, 0); blockPos = blockPos.sub(1, 0, 0);
break; break;
case 5: case 5:
clickPos = clickPos.add(1, 0, 0); blockPos = blockPos.add(1, 0, 0);
break; break;
} }
ItemEntry handItem = Translators.getItemTranslator().getItem(packet.getItemInHand()); ItemEntry handItem = Translators.getItemTranslator().getItem(packet.getItemInHand());
if (handItem.isBlock()) { if (handItem.isBlock()) {
session.setLastBlockPlacePosition(clickPos); session.setLastBlockPlacePosition(blockPos);
session.setLastBlockPlacedId(handItem.getJavaIdentifier()); session.setLastBlockPlacedId(handItem.getJavaIdentifier());
} }
break; break;
@ -112,6 +116,18 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
session.getDownstream().getSession().send(useItemPacket); session.getDownstream().getSession().send(useItemPacket);
break; break;
case 2: case 2:
BlockState blockState = session.getChunkCache().getBlockAt(new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()));
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(blockState.getId());
if (session.getGameMode() == GameMode.CREATIVE || blockHardness == 0) {
session.setLastBlockPlacedId(null);
session.setLastBlockPlacePosition(null);
LevelEventPacket blockBreakPacket = new LevelEventPacket();
blockBreakPacket.setType(LevelEventType.DESTROY);
blockBreakPacket.setPosition(packet.getBlockPosition().toFloat());
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
session.getUpstream().sendPacket(blockBreakPacket);
}
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING; PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
Position pos = new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()); Position pos = new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getFace()]); ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getFace()]);

Datei anzeigen

@ -29,7 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.nukkitx.protocol.bedrock.data.ContainerType; import com.nukkitx.protocol.bedrock.data.ContainerType;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.inventory.holder.BlockInventoryHolder; import org.geysermc.connector.network.translators.inventory.holder.BlockInventoryHolder;
import org.geysermc.connector.network.translators.inventory.holder.InventoryHolder; import org.geysermc.connector.network.translators.inventory.holder.InventoryHolder;
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater; import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;

Datei anzeigen

@ -35,7 +35,7 @@ import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.inventory.updater.ChestInventoryUpdater; import org.geysermc.connector.network.translators.inventory.updater.ChestInventoryUpdater;
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater; import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;

Datei anzeigen

@ -36,7 +36,7 @@ import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.inventory.InventoryTranslator; import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
@AllArgsConstructor @AllArgsConstructor

Datei anzeigen

@ -26,8 +26,7 @@
package org.geysermc.connector.network.translators.java.entity.player; package org.geysermc.connector.network.translators.java.entity.player;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.world.particle.BlockParticleData;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
@ -37,7 +36,7 @@ import org.geysermc.connector.inventory.PlayerInventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.item.ItemEntry; import org.geysermc.connector.network.translators.item.ItemEntry;
import org.geysermc.connector.utils.BlockUtils; import org.geysermc.connector.utils.BlockUtils;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
@ -49,13 +48,16 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
@Override @Override
public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) { public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) {
LevelEventPacket levelEvent = new LevelEventPacket(); LevelEventPacket levelEvent = new LevelEventPacket();
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState().getId());
switch (packet.getAction()) { switch (packet.getAction()) {
case FINISH_DIGGING: case FINISH_DIGGING:
if (session.getGameMode() != GameMode.CREATIVE && blockHardness != 0) {
levelEvent.setType(LevelEventType.DESTROY); levelEvent.setType(LevelEventType.DESTROY);
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock())); levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
session.getUpstream().sendPacket(levelEvent); session.getUpstream().sendPacket(levelEvent);
session.setBreakingBlock(null); session.setBreakingBlock(null);
}
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition()); ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
break; break;
case START_DIGGING: case START_DIGGING:
@ -65,7 +67,6 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
packet.getPosition().getY(), packet.getPosition().getY(),
packet.getPosition().getZ() packet.getPosition().getZ()
)); ));
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState().getId());
PlayerInventory inventory = session.getInventory(); PlayerInventory inventory = session.getInventory();
ItemStack item = inventory.getItemInHand(); ItemStack item = inventory.getItemInHand();
ItemEntry itemEntry = null; ItemEntry itemEntry = null;

Datei anzeigen

@ -31,7 +31,7 @@ import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.utils.ChunkUtils; import org.geysermc.connector.utils.ChunkUtils;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;

Datei anzeigen

@ -44,9 +44,7 @@ import org.geysermc.connector.network.translators.BiomeTranslator;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.utils.ChunkUtils; import org.geysermc.connector.utils.ChunkUtils;
import org.geysermc.connector.world.chunk.ChunkSection; import org.geysermc.connector.network.translators.world.chunk.ChunkSection;
import java.util.Map;
@Translator(packet = ServerChunkDataPacket.class) @Translator(packet = ServerChunkDataPacket.class)
public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPacket> { public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPacket> {
@ -110,7 +108,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z)); ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z));
} }
chunkData.getLoadBlockEntitiesLater().clear(); chunkData.getLoadBlockEntitiesLater().clear();
session.getChunkCache().addToCache(packet.getColumn());
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

Datei anzeigen

@ -37,7 +37,7 @@ import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.effect.Effect; import org.geysermc.connector.network.translators.effect.Effect;
import org.geysermc.connector.utils.EffectUtils; import org.geysermc.connector.utils.EffectUtils;

Datei anzeigen

@ -35,7 +35,7 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.utils.EffectUtils; import org.geysermc.connector.utils.EffectUtils;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket;

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.java.world;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.world.chunk.ChunkPosition; import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket;

Datei anzeigen

@ -30,8 +30,8 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdate
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.block.entity.BlockEntity; import org.geysermc.connector.network.translators.world.block.entity.BlockEntity;
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator; import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
import org.geysermc.connector.utils.BlockEntityUtils; import org.geysermc.connector.utils.BlockEntityUtils;
import org.geysermc.connector.utils.ChunkUtils; import org.geysermc.connector.utils.ChunkUtils;

Datei anzeigen

@ -0,0 +1,39 @@
/*
* Copyright (c) 2019-2020 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.network.translators.world;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import org.geysermc.connector.network.session.GeyserSession;
public class CachedChunkManager extends WorldManager {
@Override
public BlockState getBlockAt(GeyserSession session, int x, int y, int z) {
return session.getChunkCache().getBlockAt(new Position(x, y, z));
}
}

Datei anzeigen

@ -0,0 +1,52 @@
/*
* Copyright (c) 2019-2020 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.network.translators.world;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import org.geysermc.connector.network.session.GeyserSession;
/**
* Class that manages or retrieves various information
* from the world. Everything in this class should be
* safe to return null or an empty value in the event
* that chunk caching or anything of the sort is disabled
* on the standalone version of Geyser.
*/
public abstract class WorldManager {
/**
* Gets the {@link BlockState} at the specified location
*
* @param session the session
* @param x the x coordinate to get the block at
* @param y the y coordinate to get the block at
* @param z the z coordinate to get the block at
* @return the block state at the specified location
*/
public abstract BlockState getBlockAt(GeyserSession session, int x, int y, int z);
}

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block; package org.geysermc.connector.network.translators.world.block;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block; package org.geysermc.connector.network.translators.world.block;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
@ -47,7 +47,7 @@ import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.translators.block.entity.BlockEntity; import org.geysermc.connector.network.translators.world.block.entity.BlockEntity;
import org.geysermc.connector.utils.Toolbox; import org.geysermc.connector.utils.Toolbox;
import org.reflections.Reflections; import org.reflections.Reflections;
@ -109,7 +109,7 @@ public class BlockTranslator {
addedStatesMap.defaultReturnValue(-1); addedStatesMap.defaultReturnValue(-1);
List<CompoundTag> paletteList = new ArrayList<>(); List<CompoundTag> paletteList = new ArrayList<>();
Reflections ref = new Reflections("org.geysermc.connector.network.translators.block.entity"); Reflections ref = new Reflections("org.geysermc.connector.network.translators.world.block.entity");
ref.getTypesAnnotatedWith(BlockEntity.class); ref.getTypesAnnotatedWith(BlockEntity.class);
int waterRuntimeId = -1; int waterRuntimeId = -1;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
@ -32,7 +32,7 @@ import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.IntTag; import com.nukkitx.nbt.tag.IntTag;
import com.nukkitx.nbt.tag.StringTag; import com.nukkitx.nbt.tag.StringTag;
import com.nukkitx.nbt.tag.Tag; import com.nukkitx.nbt.tag.Tag;
import org.geysermc.connector.network.translators.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

Datei anzeigen

@ -23,14 +23,14 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.CompoundTagBuilder; import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.ByteTag; import com.nukkitx.nbt.tag.ByteTag;
import com.nukkitx.nbt.tag.Tag; import com.nukkitx.nbt.tag.Tag;
import org.geysermc.connector.network.translators.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.mc.protocol.data.message.Message; import com.github.steveice10.mc.protocol.data.message.Message;

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.block.entity; package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.nukkitx.nbt.CompoundTagBuilder; import com.nukkitx.nbt.CompoundTagBuilder;
@ -31,7 +31,7 @@ import com.nukkitx.nbt.tag.ByteTag;
import com.nukkitx.nbt.tag.CompoundTag; import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.nbt.tag.FloatTag; import com.nukkitx.nbt.tag.FloatTag;
import com.nukkitx.nbt.tag.Tag; import com.nukkitx.nbt.tag.Tag;
import org.geysermc.connector.network.translators.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

Datei anzeigen

@ -1,21 +1,37 @@
/* /*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
* *
* This code in this file is derived from NukkitX and permission has * Permission is hereby granted, free of charge, to any person obtaining a copy
* been granted to us allowing the usage of it in Geyser. * 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
* *
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/ */
package org.geysermc.connector.world.chunk; package org.geysermc.connector.network.translators.world.chunk;
import com.nukkitx.network.VarInts; import com.nukkitx.network.VarInts;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import org.geysermc.connector.world.chunk.bitarray.BitArray; import org.geysermc.connector.network.translators.world.chunk.bitarray.BitArray;
import org.geysermc.connector.world.chunk.bitarray.BitArrayVersion; import org.geysermc.connector.network.translators.world.chunk.bitarray.BitArrayVersion;
import java.util.function.IntConsumer; import java.util.function.IntConsumer;

Datei anzeigen

@ -0,0 +1,54 @@
/*
* Copyright (c) 2019-2020 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.network.translators.world.chunk;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class ChunkPosition {
private int x;
private int z;
public Position getBlock(int x, int y, int z) {
return new Position((this.x << 4) + x, y, (this.z << 4) + z);
}
public Position getChunkBlock(int x, int y, int z) {
int chunkX = x & 15;
int chunkY = y & 15;
int chunkZ = z & 15;
return new Position(chunkX, chunkY, chunkZ);
}
}

Datei anzeigen

@ -1,14 +1,30 @@
/* /*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
* *
* This code in this file is derived from NukkitX and permission has * Permission is hereby granted, free of charge, to any person obtaining a copy
* been granted to us allowing the usage of it in Geyser. * 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
* *
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/ */
package org.geysermc.connector.world.chunk; package org.geysermc.connector.network.translators.world.chunk;
import com.nukkitx.network.util.Preconditions; import com.nukkitx.network.util.Preconditions;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;

Datei anzeigen

@ -1,14 +1,30 @@
/* /*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
* *
* This code in this file is derived from NukkitX and permission has * Permission is hereby granted, free of charge, to any person obtaining a copy
* been granted to us allowing the usage of it in Geyser. * 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
* *
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/ */
package org.geysermc.connector.world.chunk; package org.geysermc.connector.network.translators.world.chunk;
import com.nukkitx.network.util.Preconditions; import com.nukkitx.network.util.Preconditions;

Datei anzeigen

@ -0,0 +1,42 @@
/*
* Copyright (c) 2019-2020 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.network.translators.world.chunk.bitarray;
public interface BitArray {
void set(int index, int value);
int get(int index);
int size();
int[] getWords();
BitArrayVersion getVersion();
BitArray copy();
}

Datei anzeigen

@ -1,14 +1,30 @@
/* /*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
* *
* This code in this file is derived from NukkitX and permission has * Permission is hereby granted, free of charge, to any person obtaining a copy
* been granted to us allowing the usage of it in Geyser. * 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
* *
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/ */
package org.geysermc.connector.world.chunk.bitarray; package org.geysermc.connector.network.translators.world.chunk.bitarray;
import org.geysermc.connector.utils.MathUtils; import org.geysermc.connector.utils.MathUtils;

Datei anzeigen

@ -1,14 +1,30 @@
/* /*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
* *
* This code in this file is derived from NukkitX and permission has * Permission is hereby granted, free of charge, to any person obtaining a copy
* been granted to us allowing the usage of it in Geyser. * 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
* *
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/ */
package org.geysermc.connector.world.chunk.bitarray; package org.geysermc.connector.network.translators.world.chunk.bitarray;
import com.nukkitx.network.util.Preconditions; import com.nukkitx.network.util.Preconditions;
import org.geysermc.connector.utils.MathUtils; import org.geysermc.connector.utils.MathUtils;

Datei anzeigen

@ -1,14 +1,30 @@
/* /*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
* *
* This code in this file is derived from NukkitX and permission has * Permission is hereby granted, free of charge, to any person obtaining a copy
* been granted to us allowing the usage of it in Geyser. * 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
* *
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/ */
package org.geysermc.connector.world.chunk.bitarray; package org.geysermc.connector.network.translators.world.chunk.bitarray;
import com.nukkitx.network.util.Preconditions; import com.nukkitx.network.util.Preconditions;
import org.geysermc.connector.utils.MathUtils; import org.geysermc.connector.utils.MathUtils;

Datei anzeigen

@ -6,7 +6,7 @@ import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator; import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
public class BlockEntityUtils { public class BlockEntityUtils {

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.connector.utils;
import com.github.steveice10.mc.protocol.data.game.entity.Effect; import com.github.steveice10.mc.protocol.data.game.entity.Effect;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.item.ItemEntry; import org.geysermc.connector.network.translators.item.ItemEntry;
import org.geysermc.connector.network.translators.item.ToolItemEntry; import org.geysermc.connector.network.translators.item.ToolItemEntry;

Datei anzeigen

@ -42,16 +42,16 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.block.entity.*; import org.geysermc.connector.network.translators.world.block.entity.*;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.world.chunk.ChunkPosition; import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
import org.geysermc.connector.world.chunk.ChunkSection; import org.geysermc.connector.network.translators.world.chunk.ChunkSection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.geysermc.connector.network.translators.block.BlockTranslator.BEDROCK_WATER_ID; import static org.geysermc.connector.network.translators.world.block.BlockTranslator.BEDROCK_WATER_ID;
public class ChunkUtils { public class ChunkUtils {
@ -181,6 +181,7 @@ public class ChunkUtils {
} }
} }
} }
session.getChunkCache().updateBlock(new Position(position.getX(), position.getY(), position.getZ()), blockState);
} }
public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius, boolean forceUpdate) { public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius, boolean forceUpdate) {

Datei anzeigen

@ -1,53 +0,0 @@
/*
* Copyright (c) 2019-2020 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.world.chunk;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class ChunkPosition {
private int x;
private int z;
public Position getBlock(int x, int y, int z) {
return new Position((this.x << 4) + x, y, (this.z << 4) + z);
}
public Position getChunkBlock(int x, int y, int z) {
int chunkX = x & 15;
int chunkY = y & 15;
int chunkZ = z & 15;
return new Position(chunkX, chunkY, chunkZ);
}
}

Datei anzeigen

@ -1,26 +0,0 @@
/*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* This code in this file is derived from NukkitX and permission has
* been granted to us allowing the usage of it in Geyser.
*
* Copyright (C) 2020 The NukkitX Project
* https://github.com/NukkitX/Nukkit
*/
package org.geysermc.connector.world.chunk.bitarray;
public interface BitArray {
void set(int index, int value);
int get(int index);
int size();
int[] getWords();
BitArrayVersion getVersion();
BitArray copy();
}

Datei anzeigen

@ -60,6 +60,15 @@ allow-third-party-capes: true
# The default locale if we dont have the one the client requested # The default locale if we dont have the one the client requested
default-locale: en_us default-locale: en_us
# Configures if chunk caching should be enabled or not. This keeps an individual
# record of each block the client loads in. While this feature does allow for a few
# things such as block break animations to show up in creative mode and among others,
# it is HIGHLY recommended you disable this on a production environment as it can eat
# up a lot of RAM. However, when using the Bukkit version of Geyser, support for features
# or implementations this allows is automatically enabled without the additional caching as
# Geyser has direct access to the server itself.
cache-chunks: false
# bStats is a stat tracker that is entirely anonymous and tracks only basic information # 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, # 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/. # what OS is being used, etc. You can learn more about bStats here: https://bstats.org/.