diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java
index 5b8842b4..37ba44f9 100644
--- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java
@@ -26,7 +26,7 @@
package org.geysermc.platform.bukkit;
import org.bukkit.configuration.file.FileConfiguration;
-import org.geysermc.common.IGeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.io.File;
import java.nio.file.Path;
@@ -34,7 +34,7 @@ import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-public class GeyserBukkitConfiguration implements IGeyserConfiguration {
+public class GeyserBukkitConfiguration implements GeyserConfiguration {
private FileConfiguration config;
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"));
}
+ @Override
+ public boolean isCacheChunks() {
+ return true; // We override this as with Bukkit, we have direct access to the server implementation
+ }
+
@Override
public IMetricsInfo getMetrics() {
return metricsInfo;
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java
index 454ec9f6..08822568 100644
--- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java
@@ -27,13 +27,13 @@ package org.geysermc.platform.bukkit;
import lombok.AllArgsConstructor;
-import org.geysermc.common.logger.IGeyserLogger;
+import org.geysermc.connector.GeyserLogger;
import java.util.logging.Level;
import java.util.logging.Logger;
@AllArgsConstructor
-public class GeyserBukkitLogger implements IGeyserLogger {
+public class GeyserBukkitLogger implements GeyserLogger {
private Logger logger;
private boolean debugMode;
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
index c2662695..d5226245 100644
--- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
@@ -27,20 +27,22 @@ package org.geysermc.platform.bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.common.PlatformType;
-import org.geysermc.common.command.ICommandManager;
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.network.translators.world.WorldManager;
import org.geysermc.platform.bukkit.command.GeyserBukkitCommandExecutor;
import org.geysermc.platform.bukkit.command.GeyserBukkitCommandManager;
+import org.geysermc.platform.bukkit.world.GeyserBukkitWorldManager;
import java.util.UUID;
-public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
+public class GeyserBukkitPlugin extends JavaPlugin implements GeyserBootstrap {
private GeyserBukkitCommandManager geyserCommandManager;
private GeyserBukkitConfiguration geyserConfig;
private GeyserBukkitLogger geyserLogger;
+ private GeyserBukkitWorldManager geyserWorldManager;
private GeyserConnector connector;
@@ -58,6 +60,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);
+ this.geyserWorldManager = new GeyserBukkitWorldManager();
this.getCommand("geyser").setExecutor(new GeyserBukkitCommandExecutor(connector));
}
@@ -81,4 +84,9 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
public CommandManager getGeyserCommandManager() {
return this.geyserCommandManager;
}
+
+ @Override
+ public WorldManager getWorldManager() {
+ return this.geyserWorldManager;
+ }
}
diff --git a/common/src/main/java/org/geysermc/common/command/ICommandManager.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitWorldManager.java
similarity index 64%
rename from common/src/main/java/org/geysermc/common/command/ICommandManager.java
rename to bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitWorldManager.java
index f46dfafc..6172b831 100644
--- a/common/src/main/java/org/geysermc/common/command/ICommandManager.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitWorldManager.java
@@ -21,18 +21,22 @@
*
* @author GeyserMC
* @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;
- /**
- * Returns the description of the given command
- *
- * @param command Command to get the description for
- *
- * @return Command description
- */
- String getDescription(String command);
+import org.bukkit.Bukkit;
+import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.translators.world.WorldManager;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+
+public class GeyserBukkitWorldManager extends WorldManager {
+
+ @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());
+ }
}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java
index e0f6a6ef..85971d0f 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java
@@ -27,7 +27,7 @@ package org.geysermc.platform.bungeecord;
import net.md_5.bungee.config.Configuration;
-import org.geysermc.common.IGeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.io.File;
import java.nio.file.Path;
@@ -35,7 +35,7 @@ import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-public class GeyserBungeeConfiguration implements IGeyserConfiguration {
+public class GeyserBungeeConfiguration implements GeyserConfiguration {
private File dataFolder;
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"));
}
+ @Override
+ public boolean isCacheChunks() {
+ return config.getBoolean("cache-chunks", false);
+ }
+
@Override
public BungeeMetricsInfo getMetrics() {
return metricsInfo;
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java
index 7aba88bc..cd07b333 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java
@@ -25,12 +25,12 @@
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.Logger;
-public class GeyserBungeeLogger implements IGeyserLogger {
+public class GeyserBungeeLogger implements GeyserLogger {
private Logger logger;
private boolean debugMode;
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java
index 9c3934cf..3483c293 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java
@@ -32,7 +32,7 @@ import net.md_5.bungee.config.YamlConfiguration;
import org.geysermc.common.PlatformType;
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.platform.bungeecord.command.GeyserBungeeCommandExecutor;
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandManager;
@@ -44,7 +44,7 @@ import java.nio.file.Files;
import java.util.UUID;
import java.util.logging.Level;
-public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap {
+public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
private GeyserBungeeCommandManager geyserCommandManager;
private GeyserBungeeConfiguration geyserConfig;
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java
index be4923e2..efcf489d 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java
@@ -29,7 +29,7 @@ import lombok.AllArgsConstructor;
import ninja.leaping.configurate.ConfigurationNode;
-import org.geysermc.common.IGeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.io.File;
import java.nio.file.Path;
@@ -38,7 +38,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class GeyserSpongeConfiguration implements IGeyserConfiguration {
+public class GeyserSpongeConfiguration implements GeyserConfiguration {
private File dataFolder;
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"));
}
+ @Override
+ public boolean isCacheChunks() {
+ return node.getNode("cache-chunks").getBoolean(false);
+ }
+
@Override
public SpongeMetricsInfo getMetrics() {
return metricsInfo;
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java
index 758ac98d..fb7cb54b 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java
@@ -27,11 +27,11 @@ package org.geysermc.platform.sponge;
import lombok.AllArgsConstructor;
-import org.geysermc.common.logger.IGeyserLogger;
+import org.geysermc.connector.GeyserLogger;
import org.slf4j.Logger;
@AllArgsConstructor
-public class GeyserSpongeLogger implements IGeyserLogger {
+public class GeyserSpongeLogger implements GeyserLogger {
private Logger logger;
private boolean debugMode;
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java
index 88996fd2..57470e28 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java
@@ -31,8 +31,7 @@ import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.geysermc.common.PlatformType;
-import org.geysermc.common.bootstrap.IGeyserBootstrap;
-import org.geysermc.common.command.ICommandManager;
+import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.utils.FileUtils;
@@ -51,7 +50,7 @@ import java.io.IOException;
import java.util.UUID;
@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
private Logger logger;
diff --git a/bootstrap/standalone/pom.xml b/bootstrap/standalone/pom.xml
index 0a583fa7..770ca100 100644
--- a/bootstrap/standalone/pom.xml
+++ b/bootstrap/standalone/pom.xml
@@ -81,7 +81,7 @@
- org.geysermc.platform.standalone.GeyserBootstrap
+ org.geysermc.platform.standalone.GeyserStandaloneBootstrap
@@ -119,7 +119,7 @@
- org.geysermc.platform.standalone.GeyserBootstrap
+ org.geysermc.platform.standalone.GeyserStandaloneBootstrap
true
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java
similarity index 87%
rename from bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java
rename to bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java
index 20b7f5ea..9d249363 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java
@@ -26,38 +26,38 @@
package org.geysermc.platform.standalone;
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.command.CommandManager;
import org.geysermc.connector.utils.FileUtils;
import org.geysermc.platform.standalone.command.GeyserCommandManager;
-import org.geysermc.platform.standalone.console.GeyserLogger;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
-public class GeyserBootstrap implements IGeyserBootstrap {
+public class GeyserStandaloneBootstrap implements GeyserBootstrap {
private GeyserCommandManager geyserCommandManager;
private GeyserConfiguration geyserConfig;
- private GeyserLogger geyserLogger;
+ private GeyserStandaloneLogger geyserLogger;
private GeyserConnector connector;
public static void main(String[] args) {
- new GeyserBootstrap().onEnable();
+ new GeyserStandaloneBootstrap().onEnable();
}
@Override
public void onEnable() {
- geyserLogger = new GeyserLogger();
+ geyserLogger = new GeyserStandaloneLogger();
LoopbackUtil.checkLoopback(geyserLogger);
try {
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) {
geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
System.exit(0);
@@ -80,7 +80,7 @@ public class GeyserBootstrap implements IGeyserBootstrap {
}
@Override
- public GeyserLogger getGeyserLogger() {
+ public GeyserStandaloneLogger getGeyserLogger() {
return geyserLogger;
}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserConfiguration.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java
similarity index 94%
rename from bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserConfiguration.java
rename to bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java
index afd6179e..8ae83d02 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserConfiguration.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java
@@ -29,8 +29,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
-
-import org.geysermc.common.IGeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -38,7 +37,7 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
-public class GeyserConfiguration implements IGeyserConfiguration {
+public class GeyserStandaloneConfiguration implements GeyserConfiguration {
private BedrockConfiguration bedrock;
private RemoteConfiguration remote;
@@ -66,6 +65,9 @@ public class GeyserConfiguration implements IGeyserConfiguration {
@JsonProperty("default-locale")
private String defaultLocale;
+ @JsonProperty("cache-chunks")
+ private boolean cacheChunks;
+
private MetricsInfo metrics;
@Override
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java
similarity index 64%
rename from bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java
rename to bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java
index 631de905..ffb252b2 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java
@@ -1,29 +1,30 @@
/*
* 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:
+ * 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 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.
+ * 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
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.platform.standalone.console;
+package org.geysermc.platform.standalone;
import lombok.extern.log4j.Log4j2;
@@ -31,12 +32,11 @@ import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.apache.logging.log4j.core.config.Configurator;
import org.geysermc.common.ChatColor;
-import org.geysermc.common.logger.IGeyserLogger;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
@Log4j2
-public class GeyserLogger extends SimpleTerminalConsole implements IGeyserLogger, CommandSender {
+public class GeyserStandaloneLogger extends SimpleTerminalConsole implements org.geysermc.connector.GeyserLogger, CommandSender {
private boolean colored = true;
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java
index 20a81072..03c49705 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java
@@ -6,14 +6,13 @@ import java.nio.file.OpenOption;
import java.nio.file.Paths;
import org.geysermc.common.ChatColor;
-import org.geysermc.platform.standalone.console.GeyserLogger;
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 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\"";
- public static void checkLoopback(GeyserLogger geyserLogger) {
+ public static void checkLoopback(GeyserStandaloneLogger geyserLogger) {
if (System.getProperty("os.name").equalsIgnoreCase("Windows 10")) {
try {
Process process = Runtime.getRuntime().exec(checkExemption);
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java
index 920c6537..62ae20e2 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java
@@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
-import org.geysermc.common.IGeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -38,7 +38,7 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
-public class GeyserVelocityConfiguration implements IGeyserConfiguration {
+public class GeyserVelocityConfiguration implements GeyserConfiguration {
private BedrockConfiguration bedrock;
private RemoteConfiguration remote;
@@ -66,6 +66,9 @@ public class GeyserVelocityConfiguration implements IGeyserConfiguration {
@JsonProperty("default-locale")
private String defaultLocale;
+ @JsonProperty("cache-chunks")
+ private boolean cacheChunks;
+
private MetricsInfo metrics;
@Override
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java
index 623c6481..a935d786 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java
@@ -27,11 +27,11 @@ package org.geysermc.platform.velocity;
import lombok.AllArgsConstructor;
-import org.geysermc.common.logger.IGeyserLogger;
+import org.geysermc.connector.GeyserLogger;
import org.slf4j.Logger;
@AllArgsConstructor
-public class GeyserVelocityLogger implements IGeyserLogger {
+public class GeyserVelocityLogger implements GeyserLogger {
private Logger logger;
private boolean debugMode;
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java
index 160c2d52..6e721a5f 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java
@@ -34,8 +34,8 @@ import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.plugin.Plugin;
import org.geysermc.common.PlatformType;
-import org.geysermc.common.bootstrap.IGeyserBootstrap;
import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.utils.FileUtils;
import org.geysermc.platform.velocity.command.GeyserVelocityCommandExecutor;
import org.geysermc.platform.velocity.command.GeyserVelocityCommandManager;
@@ -46,7 +46,7 @@ import java.io.IOException;
import java.util.UUID;
@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
private Logger logger;
diff --git a/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java b/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java
deleted file mode 100644
index 774e3394..00000000
--- a/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java
+++ /dev/null
@@ -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 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();
- }
-}
diff --git a/common/src/main/java/org/geysermc/common/bootstrap/IGeyserBootstrap.java b/common/src/main/java/org/geysermc/common/bootstrap/IGeyserBootstrap.java
deleted file mode 100644
index 5df61953..00000000
--- a/common/src/main/java/org/geysermc/common/bootstrap/IGeyserBootstrap.java
+++ /dev/null
@@ -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();
-}
diff --git a/common/src/main/java/org/geysermc/common/logger/IGeyserLogger.java b/common/src/main/java/org/geysermc/common/logger/IGeyserLogger.java
deleted file mode 100644
index ad571ebb..00000000
--- a/common/src/main/java/org/geysermc/common/logger/IGeyserLogger.java
+++ /dev/null
@@ -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);
-}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConfiguration.java b/connector/src/main/java/org/geysermc/connector/GeyserConfiguration.java
new file mode 100644
index 00000000..cbbd507a
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConfiguration.java
@@ -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 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();
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index 2679857c..6c9e8c7d 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -32,16 +32,15 @@ import com.nukkitx.protocol.bedrock.v390.Bedrock_v390;
import lombok.Getter;
import org.geysermc.common.AuthType;
-import org.geysermc.common.IGeyserConfiguration;
import org.geysermc.common.PlatformType;
-import org.geysermc.common.bootstrap.IGeyserBootstrap;
-import org.geysermc.common.logger.IGeyserLogger;
+import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.metrics.Metrics;
import org.geysermc.connector.network.ConnectorServerEventHandler;
import org.geysermc.connector.network.remote.RemoteServer;
import org.geysermc.connector.network.session.GeyserSession;
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.utils.Toolbox;
@@ -76,19 +75,19 @@ public class GeyserConnector {
private BedrockServer bedrockServer;
private PlatformType platformType;
- private IGeyserBootstrap bootstrap;
+ private GeyserBootstrap bootstrap;
private Metrics metrics;
- private GeyserConnector(PlatformType platformType, IGeyserBootstrap bootstrap) {
+ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
long startupTime = System.currentTimeMillis();
instance = this;
this.bootstrap = bootstrap;
- IGeyserLogger logger = bootstrap.getGeyserLogger();
- IGeyserConfiguration config = bootstrap.getGeyserConfig();
+ GeyserLogger logger = bootstrap.getGeyserLogger();
+ GeyserConfiguration config = bootstrap.getGeyserConfig();
this.platformType = platformType;
@@ -191,7 +190,7 @@ public class GeyserConnector {
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);
}
@@ -200,16 +199,20 @@ public class GeyserConnector {
bootstrap.onEnable();
}
- public IGeyserLogger getLogger() {
+ public GeyserLogger getLogger() {
return bootstrap.getGeyserLogger();
}
- public IGeyserConfiguration getConfig() {
+ public GeyserConfiguration getConfig() {
return bootstrap.getGeyserConfig();
}
public CommandManager getCommandManager() {
- return (CommandManager) bootstrap.getGeyserCommandManager();
+ return bootstrap.getGeyserCommandManager();
+ }
+
+ public WorldManager getWorldManager() {
+ return bootstrap.getWorldManager();
}
public static GeyserConnector getInstance() {
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserLogger.java b/connector/src/main/java/org/geysermc/connector/GeyserLogger.java
new file mode 100644
index 00000000..4acab222
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/GeyserLogger.java
@@ -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);
+}
diff --git a/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java b/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java
new file mode 100644
index 00000000..24b338c8
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java
@@ -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;
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/command/CommandManager.java b/connector/src/main/java/org/geysermc/connector/command/CommandManager.java
index 7b1b4d69..88b9e795 100644
--- a/connector/src/main/java/org/geysermc/connector/command/CommandManager.java
+++ b/connector/src/main/java/org/geysermc/connector/command/CommandManager.java
@@ -26,7 +26,7 @@
package org.geysermc.connector.command;
import lombok.Getter;
-import org.geysermc.common.command.ICommandManager;
+
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.defaults.*;
@@ -34,7 +34,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-public abstract class CommandManager implements ICommandManager {
+public abstract class CommandManager {
@Getter
private final Map commands = Collections.synchronizedMap(new HashMap<>());
@@ -87,4 +87,12 @@ public abstract class CommandManager implements ICommandManager {
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);
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java b/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java
index 5a0cac8f..59e1d408 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/FallingBlockEntity.java
@@ -28,7 +28,7 @@ package org.geysermc.connector.entity;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData;
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 {
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java
index 26c13a5c..c2dad7a5 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java
@@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.ItemData;
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
import org.geysermc.connector.entity.type.EntityType;
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 {
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java
index a423013c..644181ab 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java
@@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.EntityData;
import com.nukkitx.protocol.bedrock.data.EntityFlag;
import org.geysermc.connector.entity.type.EntityType;
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 {
diff --git a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java
index 60ad28d4..8810cffb 100644
--- a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java
+++ b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java
@@ -30,7 +30,7 @@ import com.nukkitx.protocol.bedrock.BedrockPong;
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
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.network.session.GeyserSession;
import org.geysermc.connector.utils.MessageUtils;
@@ -55,7 +55,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
connector.getLogger().debug(inetSocketAddress + " has pinged you!");
- IGeyserConfiguration config = connector.getConfig();
+ GeyserConfiguration config = connector.getConfig();
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
BedrockPong pong = new BedrockPong();
@@ -101,11 +101,6 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
if (player != null) {
player.disconnect(disconnectReason.name());
connector.removePlayer(player);
-
- player.getEntityCache().clear();
- player.getInventoryCache().getInventories().clear();
- player.getWindowCache().getWindows().clear();
- player.getScoreboardCache().removeScoreboard();
}
});
bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC);
diff --git a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java
index 7e41fca8..2839237e 100644
--- a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java
+++ b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java
@@ -28,7 +28,7 @@ package org.geysermc.connector.network;
import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.common.AuthType;
-import org.geysermc.common.IGeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.Registry;
@@ -94,7 +94,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
private boolean couldLoginUserByName(String bedrockUsername) {
if (connector.getConfig().getUserAuths() != null) {
- IGeyserConfiguration.IUserAuthenticationInfo info = connector.getConfig().getUserAuths().get(bedrockUsername);
+ GeyserConfiguration.IUserAuthenticationInfo info = connector.getConfig().getUserAuths().get(bedrockUsername);
if (info != null) {
connector.getLogger().info("using stored credentials for bedrock user " + session.getAuthData().getName());
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
index fafa2bfa..0b4a57dc 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
@@ -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.cache.*;
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.LocaleUtils;
import org.geysermc.connector.utils.Toolbox;
@@ -337,10 +337,11 @@ public class GeyserSession implements CommandSender {
}
}
- this.entityCache.getEntities().clear();
- this.scoreboardCache.removeScoreboard();
- this.inventoryCache.getInventories().clear();
- this.windowCache.getWindows().clear();
+ this.chunkCache = null;
+ this.entityCache = null;
+ this.scoreboardCache = null;
+ this.inventoryCache = null;
+ this.windowCache = null;
closed = true;
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
index bc88694d..ac7ab06c 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
@@ -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.entity.metadata.Position;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
-import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import lombok.Getter;
import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.Translators;
-import org.geysermc.connector.network.translators.block.BlockTranslator;
-import org.geysermc.connector.world.chunk.ChunkPosition;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
import java.util.HashMap;
import java.util.Map;
public class ChunkCache {
- private GeyserSession session;
+ private boolean cache;
+ private final GeyserSession session;
@Getter
- private Map chunks;
+ private Map chunks = new HashMap<>();
public ChunkCache(GeyserSession session) {
this.session = session;
- this.chunks = new HashMap<>();
+ this.cache = session.getConnector().getConfig().isCacheChunks();
}
public void addToCache(Column chunk) {
+ if (!cache) {
+ return;
+ }
ChunkPosition position = new ChunkPosition(chunk.getX(), chunk.getZ());
chunks.put(position, chunk);
}
public void updateBlock(Position position, BlockState block) {
+ if (!cache) {
+ return;
+ }
ChunkPosition chunkPosition = new ChunkPosition(position.getX() >> 4, position.getZ() >> 4);
if (!chunks.containsKey(chunkPosition))
return;
@@ -70,6 +75,9 @@ public class ChunkCache {
}
public BlockState getBlockAt(Position position) {
+ if (!cache) {
+ return BlockTranslator.AIR;
+ }
ChunkPosition chunkPosition = new ChunkPosition(position.getX() >> 4, position.getZ() >> 4);
if (!chunks.containsKey(chunkPosition))
return BlockTranslator.AIR;
@@ -85,24 +93,9 @@ public class ChunkCache {
}
public void removeChunk(ChunkPosition position) {
- chunks.remove(position);
- sendEmptyChunk(position, true);
- }
-
- public void sendEmptyChunk(ChunkPosition position) {
- sendEmptyChunk(position, false);
- }
-
- public void sendEmptyChunk(ChunkPosition position, boolean force) {
- if (!force && chunks.containsKey(position))
+ if (!cache) {
return;
-
- LevelChunkPacket levelChunkPacket = new LevelChunkPacket();
- 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);
+ }
+ chunks.remove(position);
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/Translators.java b/connector/src/main/java/org/geysermc/connector/network/translators/Translators.java
index f0a3fd28..96323c1b 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/Translators.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/Translators.java
@@ -33,8 +33,8 @@ import java.util.Map;
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
import com.nukkitx.protocol.bedrock.data.ContainerType;
import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.network.translators.block.BlockTranslator;
-import org.geysermc.connector.network.translators.block.entity.*;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+import org.geysermc.connector.network.translators.world.block.entity.*;
import org.geysermc.connector.network.translators.inventory.*;
import org.geysermc.connector.network.translators.inventory.updater.ContainerInventoryUpdater;
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;
@@ -117,7 +117,7 @@ public class Translators {
}
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)) {
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
index 43e0a570..1c8159cf 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
@@ -28,9 +28,7 @@ package org.geysermc.connector.network.translators.bedrock;
import java.util.concurrent.TimeUnit;
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.LevelSoundEventPacket;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession;
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.protocol.bedrock.packet.PlayStatusPacket;
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)
public class BedrockActionTranslator extends PacketTranslator {
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
index 7eb051c5..905d7afb 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
@@ -25,6 +25,7 @@
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.data.game.entity.metadata.Position;
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.nukkitx.math.vector.Vector3i;
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.LevelEventPacket;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.inventory.Inventory;
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.item.ItemEntry;
import org.geysermc.connector.network.translators.item.ItemTranslator;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.utils.InventoryUtils;
@Translator(packet = InventoryTransactionPacket.class)
@@ -76,31 +80,31 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator {
@@ -110,7 +108,7 @@ public class JavaChunkDataTranslator extends PacketTranslator 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);
int waterRuntimeId = -1;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java
similarity index 96%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java
index 22d26cb4..0fc9abda 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java
@@ -23,7 +23,7 @@
* @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.opennbt.tag.builtin.CompoundTag;
@@ -32,7 +32,7 @@ import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.IntTag;
import com.nukkitx.nbt.tag.StringTag;
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.List;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BedBlockEntityTranslator.java
similarity index 94%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BedBlockEntityTranslator.java
index a8dae253..543828e8 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BedBlockEntityTranslator.java
@@ -23,14 +23,14 @@
* @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.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.ByteTag;
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.List;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BlockEntity.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BlockEntity.java
similarity index 96%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BlockEntity.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BlockEntity.java
index 47cbbaf3..d08ab561 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BlockEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BlockEntity.java
@@ -23,7 +23,7 @@
* @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.RetentionPolicy;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BlockEntityTranslator.java
similarity index 98%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BlockEntityTranslator.java
index f2825789..4545aed5 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BlockEntityTranslator.java
@@ -23,7 +23,7 @@
* @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.opennbt.tag.builtin.CompoundTag;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/CampfireBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/CampfireBlockEntityTranslator.java
similarity index 98%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/CampfireBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/CampfireBlockEntityTranslator.java
index 11b7e864..d91e47c2 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/CampfireBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/CampfireBlockEntityTranslator.java
@@ -23,7 +23,7 @@
* @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.opennbt.tag.builtin.CompoundTag;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/EmptyBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EmptyBlockEntityTranslator.java
similarity index 96%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/EmptyBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EmptyBlockEntityTranslator.java
index e4601400..f95cb89e 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/EmptyBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EmptyBlockEntityTranslator.java
@@ -23,7 +23,7 @@
* @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.opennbt.tag.builtin.CompoundTag;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/EndGatewayBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java
similarity index 98%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/EndGatewayBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java
index de5868a4..10de9d32 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/EndGatewayBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java
@@ -23,7 +23,7 @@
* @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.opennbt.tag.builtin.CompoundTag;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/RequiresBlockState.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/RequiresBlockState.java
similarity index 95%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/RequiresBlockState.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/RequiresBlockState.java
index ed8e6ede..4df7292a 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/RequiresBlockState.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/RequiresBlockState.java
@@ -23,7 +23,7 @@
* @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;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SignBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SignBlockEntityTranslator.java
similarity index 97%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SignBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SignBlockEntityTranslator.java
index 74dcdd13..0dde3307 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SignBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SignBlockEntityTranslator.java
@@ -23,7 +23,7 @@
* @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.message.Message;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java
similarity index 93%
rename from connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java
index 2380663b..7e73c846 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/SkullBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java
@@ -1,71 +1,71 @@
-/*
- * 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.block.entity;
-
-import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
-import com.nukkitx.nbt.CompoundTagBuilder;
-import com.nukkitx.nbt.tag.ByteTag;
-import com.nukkitx.nbt.tag.CompoundTag;
-import com.nukkitx.nbt.tag.FloatTag;
-import com.nukkitx.nbt.tag.Tag;
-import org.geysermc.connector.network.translators.block.BlockStateValues;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@BlockEntity(name = "Skull", delay = false, regex = "skull")
-public class SkullBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
-
- @Override
- public boolean isBlock(BlockState blockState) {
- return BlockStateValues.getSkullVariant(blockState) != -1;
- }
-
- @Override
- public List> translateTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag tag, BlockState blockState) {
- List> tags = new ArrayList<>();
- byte skullVariant = BlockStateValues.getSkullVariant(blockState);
- float rotation = BlockStateValues.getSkullRotation(blockState) * 22.5f;
- // Just in case...
- if (skullVariant == -1) skullVariant = 0;
- tags.add(new FloatTag("Rotation", rotation));
- tags.add(new ByteTag("SkullType", skullVariant));
- return tags;
- }
-
- @Override
- public com.github.steveice10.opennbt.tag.builtin.CompoundTag getDefaultJavaTag(String javaId, int x, int y, int z) {
- return null;
- }
-
- @Override
- public CompoundTag getDefaultBedrockTag(String bedrockId, int x, int y, int z) {
- CompoundTagBuilder tagBuilder = getConstantBedrockTag(bedrockId, x, y, z).toBuilder();
- tagBuilder.floatTag("Rotation", 0);
- tagBuilder.byteTag("SkullType", (byte) 0);
- return tagBuilder.buildRootTag();
- }
-}
+/*
+ * 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.block.entity;
+
+import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
+import com.nukkitx.nbt.CompoundTagBuilder;
+import com.nukkitx.nbt.tag.ByteTag;
+import com.nukkitx.nbt.tag.CompoundTag;
+import com.nukkitx.nbt.tag.FloatTag;
+import com.nukkitx.nbt.tag.Tag;
+import org.geysermc.connector.network.translators.world.block.BlockStateValues;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@BlockEntity(name = "Skull", delay = false, regex = "skull")
+public class SkullBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
+
+ @Override
+ public boolean isBlock(BlockState blockState) {
+ return BlockStateValues.getSkullVariant(blockState) != -1;
+ }
+
+ @Override
+ public List> translateTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag tag, BlockState blockState) {
+ List> tags = new ArrayList<>();
+ byte skullVariant = BlockStateValues.getSkullVariant(blockState);
+ float rotation = BlockStateValues.getSkullRotation(blockState) * 22.5f;
+ // Just in case...
+ if (skullVariant == -1) skullVariant = 0;
+ tags.add(new FloatTag("Rotation", rotation));
+ tags.add(new ByteTag("SkullType", skullVariant));
+ return tags;
+ }
+
+ @Override
+ public com.github.steveice10.opennbt.tag.builtin.CompoundTag getDefaultJavaTag(String javaId, int x, int y, int z) {
+ return null;
+ }
+
+ @Override
+ public CompoundTag getDefaultBedrockTag(String bedrockId, int x, int y, int z) {
+ CompoundTagBuilder tagBuilder = getConstantBedrockTag(bedrockId, x, y, z).toBuilder();
+ tagBuilder.floatTag("Rotation", 0);
+ tagBuilder.byteTag("SkullType", (byte) 0);
+ return tagBuilder.buildRootTag();
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/BlockStorage.java
similarity index 68%
rename from connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/BlockStorage.java
index 360fdea4..5995ecf9 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/BlockStorage.java
@@ -1,21 +1,37 @@
/*
* 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.
+ * 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
*
- * 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 io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
-import org.geysermc.connector.world.chunk.bitarray.BitArray;
-import org.geysermc.connector.world.chunk.bitarray.BitArrayVersion;
+import org.geysermc.connector.network.translators.world.chunk.bitarray.BitArray;
+import org.geysermc.connector.network.translators.world.chunk.bitarray.BitArrayVersion;
import java.util.function.IntConsumer;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/ChunkPosition.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/ChunkPosition.java
new file mode 100644
index 00000000..a51755d0
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/ChunkPosition.java
@@ -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);
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkSection.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/ChunkSection.java
similarity index 77%
rename from connector/src/main/java/org/geysermc/connector/world/chunk/ChunkSection.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/ChunkSection.java
index c160d11b..4ede0c25 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkSection.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/ChunkSection.java
@@ -1,14 +1,30 @@
/*
* 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.
+ * 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
*
- * 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 io.netty.buffer.ByteBuf;
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/NibbleArray.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/NibbleArray.java
similarity index 62%
rename from connector/src/main/java/org/geysermc/connector/world/chunk/NibbleArray.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/NibbleArray.java
index 8da068f7..08303e18 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/NibbleArray.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/NibbleArray.java
@@ -1,14 +1,30 @@
/*
* 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.
+ * 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
*
- * 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;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/BitArray.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/BitArray.java
new file mode 100644
index 00000000..728fe237
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/BitArray.java
@@ -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();
+}
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/BitArrayVersion.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/BitArrayVersion.java
similarity index 60%
rename from connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/BitArrayVersion.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/BitArrayVersion.java
index f6e3ef5e..be91f13d 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/BitArrayVersion.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/BitArrayVersion.java
@@ -1,14 +1,30 @@
/*
* 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.
+ * 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
*
- * 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;
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/PaddedBitArray.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/PaddedBitArray.java
similarity index 65%
rename from connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/PaddedBitArray.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/PaddedBitArray.java
index d2f9393a..36a97a30 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/PaddedBitArray.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/PaddedBitArray.java
@@ -1,14 +1,30 @@
/*
* 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.
+ * 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
*
- * 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 org.geysermc.connector.utils.MathUtils;
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/Pow2BitArray.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/Pow2BitArray.java
similarity index 67%
rename from connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/Pow2BitArray.java
rename to connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/Pow2BitArray.java
index bcb878a7..c9bd2764 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/Pow2BitArray.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/chunk/bitarray/Pow2BitArray.java
@@ -1,14 +1,30 @@
/*
* 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.
+ * 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
*
- * 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 org.geysermc.connector.utils.MathUtils;
diff --git a/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java b/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java
index 0dcd13ad..2c04c205 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java
@@ -6,7 +6,7 @@ import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
import org.geysermc.connector.network.session.GeyserSession;
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 {
diff --git a/connector/src/main/java/org/geysermc/connector/utils/BlockUtils.java b/connector/src/main/java/org/geysermc/connector/utils/BlockUtils.java
index 34287073..3a9ecb86 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/BlockUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/BlockUtils.java
@@ -28,7 +28,7 @@ package org.geysermc.connector.utils;
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
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.ToolItemEntry;
diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java
index d496215a..3a3d1182 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java
@@ -42,16 +42,16 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.Getter;
import org.geysermc.connector.GeyserConnector;
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.block.BlockTranslator;
-import org.geysermc.connector.world.chunk.ChunkPosition;
-import org.geysermc.connector.world.chunk.ChunkSection;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
+import org.geysermc.connector.network.translators.world.chunk.ChunkSection;
import java.util.HashMap;
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 {
@@ -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) {
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java b/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java
deleted file mode 100644
index c45a7c94..00000000
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/BitArray.java b/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/BitArray.java
deleted file mode 100644
index 944cabd3..00000000
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/bitarray/BitArray.java
+++ /dev/null
@@ -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();
-}
\ No newline at end of file
diff --git a/connector/src/main/resources/config.yml b/connector/src/main/resources/config.yml
index ae0cbed8..b1e1e2f9 100644
--- a/connector/src/main/resources/config.yml
+++ b/connector/src/main/resources/config.yml
@@ -60,6 +60,15 @@ allow-third-party-capes: true
# The default locale if we dont have the one the client requested
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
# 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/.