mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add block break sounds for blocks with 0 hardness, and refactor some things
The refactors in this commit go a bit beyond the scope of what the sound/effects branch was meant to accomplish, however most of these changes are necessary so chunk caching could be reintroduced for the standalone version. The chunk caching here allows for us to get the block ID before the block was broken, and in the future allow us to implement newer features. Chunk caching is optional (and disabled by default) as on non-Bukkit versions, it can eat up a lot of RAM with many players online.
This commit is contained in:
parent
efcf739973
commit
31be608038
74 changed files with 873 additions and 598 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Main-Class>org.geysermc.platform.standalone.GeyserBootstrap</Main-Class>
|
||||
<Main-Class>org.geysermc.platform.standalone.GeyserStandaloneBootstrap</Main-Class>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
|
@ -119,7 +119,7 @@
|
|||
</filters>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>org.geysermc.platform.standalone.GeyserBootstrap</mainClass>
|
||||
<mainClass>org.geysermc.platform.standalone.GeyserStandaloneBootstrap</mainClass>
|
||||
<manifestEntries>
|
||||
<Multi-Release>true</Multi-Release>
|
||||
</manifestEntries>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
|
@ -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;
|
||||
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.common;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IGeyserConfiguration {
|
||||
|
||||
IBedrockConfiguration getBedrock();
|
||||
|
||||
IRemoteConfiguration getRemote();
|
||||
|
||||
Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
|
||||
|
||||
boolean isPingPassthrough();
|
||||
|
||||
int getMaxPlayers();
|
||||
|
||||
boolean isDebugMode();
|
||||
|
||||
int getGeneralThreadPool();
|
||||
|
||||
boolean isAllowThirdPartyCapes();
|
||||
|
||||
String getDefaultLocale();
|
||||
|
||||
Path getFloodgateKeyFile();
|
||||
|
||||
IMetricsInfo getMetrics();
|
||||
|
||||
interface IBedrockConfiguration {
|
||||
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
|
||||
String getMotd1();
|
||||
|
||||
String getMotd2();
|
||||
}
|
||||
|
||||
interface IRemoteConfiguration {
|
||||
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
|
||||
String getAuthType();
|
||||
}
|
||||
|
||||
interface IUserAuthenticationInfo {
|
||||
String getEmail();
|
||||
|
||||
String getPassword();
|
||||
}
|
||||
|
||||
interface IMetricsInfo {
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
String getUniqueId();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.connector;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GeyserConfiguration {
|
||||
|
||||
IBedrockConfiguration getBedrock();
|
||||
|
||||
IRemoteConfiguration getRemote();
|
||||
|
||||
Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
|
||||
|
||||
boolean isPingPassthrough();
|
||||
|
||||
int getMaxPlayers();
|
||||
|
||||
boolean isDebugMode();
|
||||
|
||||
int getGeneralThreadPool();
|
||||
|
||||
boolean isAllowThirdPartyCapes();
|
||||
|
||||
String getDefaultLocale();
|
||||
|
||||
Path getFloodgateKeyFile();
|
||||
|
||||
boolean isCacheChunks();
|
||||
|
||||
IMetricsInfo getMetrics();
|
||||
|
||||
interface IBedrockConfiguration {
|
||||
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
|
||||
String getMotd1();
|
||||
|
||||
String getMotd2();
|
||||
}
|
||||
|
||||
interface IRemoteConfiguration {
|
||||
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
|
||||
String getAuthType();
|
||||
}
|
||||
|
||||
interface IUserAuthenticationInfo {
|
||||
String getEmail();
|
||||
|
||||
String getPassword();
|
||||
}
|
||||
|
||||
interface IMetricsInfo {
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
String getUniqueId();
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<String, GeyserCommand> 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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<ChunkPosition, Column> chunks;
|
||||
private Map<ChunkPosition, Column> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
||||
|
|
|
@ -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<PlayerActionPacket> {
|
||||
|
|
|
@ -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<Inve
|
|||
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
|
||||
false);
|
||||
session.getDownstream().getSession().send(blockPacket);
|
||||
Vector3i clickPos = packet.getBlockPosition();
|
||||
Vector3i blockPos = packet.getBlockPosition();
|
||||
// TODO: Find a better way to do this?
|
||||
switch (packet.getFace()) {
|
||||
case 0:
|
||||
clickPos = clickPos.sub(0, 1, 0);
|
||||
blockPos = blockPos.sub(0, 1, 0);
|
||||
break;
|
||||
case 1:
|
||||
clickPos = clickPos.add(0, 1, 0);
|
||||
blockPos = blockPos.add(0, 1, 0);
|
||||
break;
|
||||
case 2:
|
||||
clickPos = clickPos.sub(0, 0, 1);
|
||||
blockPos = blockPos.sub(0, 0, 1);
|
||||
break;
|
||||
case 3:
|
||||
clickPos = clickPos.add(0, 0, 1);
|
||||
blockPos = blockPos.add(0, 0, 1);
|
||||
break;
|
||||
case 4:
|
||||
clickPos = clickPos.sub(1, 0, 0);
|
||||
blockPos = blockPos.sub(1, 0, 0);
|
||||
break;
|
||||
case 5:
|
||||
clickPos = clickPos.add(1, 0, 0);
|
||||
blockPos = blockPos.add(1, 0, 0);
|
||||
break;
|
||||
}
|
||||
ItemEntry handItem = Translators.getItemTranslator().getItem(packet.getItemInHand());
|
||||
if (handItem.isBlock()) {
|
||||
session.setLastBlockPlacePosition(clickPos);
|
||||
session.setLastBlockPlacePosition(blockPos);
|
||||
session.setLastBlockPlacedId(handItem.getJavaIdentifier());
|
||||
}
|
||||
break;
|
||||
|
@ -112,6 +116,18 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
session.getDownstream().getSession().send(useItemPacket);
|
||||
break;
|
||||
case 2:
|
||||
BlockState blockState = session.getChunkCache().getBlockAt(new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()));
|
||||
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(blockState.getId());
|
||||
if (session.getGameMode() == GameMode.CREATIVE || blockHardness == 0) {
|
||||
session.setLastBlockPlacedId(null);
|
||||
session.setLastBlockPlacePosition(null);
|
||||
|
||||
LevelEventPacket blockBreakPacket = new LevelEventPacket();
|
||||
blockBreakPacket.setType(LevelEventType.DESTROY);
|
||||
blockBreakPacket.setPosition(packet.getBlockPosition().toFloat());
|
||||
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
|
||||
session.getUpstream().sendPacket(blockBreakPacket);
|
||||
}
|
||||
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
|
||||
Position pos = new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
|
||||
ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getFace()]);
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
|||
import com.nukkitx.protocol.bedrock.data.ContainerType;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.holder.BlockInventoryHolder;
|
||||
import org.geysermc.connector.network.translators.inventory.holder.InventoryHolder;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;
|
||||
|
|
|
@ -35,7 +35,7 @@ import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
|||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.ChestInventoryUpdater;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.InventoryUpdater;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
|||
import lombok.AllArgsConstructor;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
||||
|
||||
@AllArgsConstructor
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.particle.BlockParticleData;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -37,7 +36,7 @@ import org.geysermc.connector.inventory.PlayerInventory;
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translators;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||
import org.geysermc.connector.utils.BlockUtils;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
@ -49,13 +48,16 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
|||
@Override
|
||||
public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) {
|
||||
LevelEventPacket levelEvent = new LevelEventPacket();
|
||||
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState().getId());
|
||||
switch (packet.getAction()) {
|
||||
case FINISH_DIGGING:
|
||||
levelEvent.setType(LevelEventType.DESTROY);
|
||||
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
|
||||
session.getUpstream().sendPacket(levelEvent);
|
||||
session.setBreakingBlock(null);
|
||||
if (session.getGameMode() != GameMode.CREATIVE && blockHardness != 0) {
|
||||
levelEvent.setType(LevelEventType.DESTROY);
|
||||
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
|
||||
session.getUpstream().sendPacket(levelEvent);
|
||||
session.setBreakingBlock(null);
|
||||
}
|
||||
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
|
||||
break;
|
||||
case START_DIGGING:
|
||||
|
@ -65,7 +67,6 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
|||
packet.getPosition().getY(),
|
||||
packet.getPosition().getZ()
|
||||
));
|
||||
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState().getId());
|
||||
PlayerInventory inventory = session.getInventory();
|
||||
ItemStack item = inventory.getItemInHand();
|
||||
ItemEntry itemEntry = null;
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
||||
|
|
|
@ -44,9 +44,7 @@ import org.geysermc.connector.network.translators.BiomeTranslator;
|
|||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
import org.geysermc.connector.world.chunk.ChunkSection;
|
||||
|
||||
import java.util.Map;
|
||||
import org.geysermc.connector.network.translators.world.chunk.ChunkSection;
|
||||
|
||||
@Translator(packet = ServerChunkDataPacket.class)
|
||||
public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPacket> {
|
||||
|
@ -110,7 +108,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z));
|
||||
}
|
||||
chunkData.getLoadBlockEntitiesLater().clear();
|
||||
|
||||
session.getChunkCache().addToCache(packet.getColumn());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.geysermc.connector.GeyserConnector;
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.effect.Effect;
|
||||
import org.geysermc.connector.utils.EffectUtils;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.Translators;
|
||||
import org.geysermc.connector.network.translators.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.utils.EffectUtils;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket;
|
||||
|
|
|
@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.java.world;
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.world.chunk.ChunkPosition;
|
||||
import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket;
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdate
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.block.entity.BlockEntity;
|
||||
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.entity.BlockEntity;
|
||||
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
|
||||
import org.geysermc.connector.utils.BlockEntityUtils;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.world;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
public class CachedChunkManager extends WorldManager {
|
||||
|
||||
@Override
|
||||
public BlockState getBlockAt(GeyserSession session, int x, int y, int z) {
|
||||
return session.getChunkCache().getBlockAt(new Position(x, y, z));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.world;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
/**
|
||||
* Class that manages or retrieves various information
|
||||
* from the world. Everything in this class should be
|
||||
* safe to return null or an empty value in the event
|
||||
* that chunk caching or anything of the sort is disabled
|
||||
* on the standalone version of Geyser.
|
||||
*/
|
||||
public abstract class WorldManager {
|
||||
|
||||
/**
|
||||
* Gets the {@link BlockState} at the specified location
|
||||
*
|
||||
* @param session the session
|
||||
* @param x the x coordinate to get the block at
|
||||
* @param y the y coordinate to get the block at
|
||||
* @param z the z coordinate to get the block at
|
||||
* @return the block state at the specified location
|
||||
*/
|
||||
public abstract BlockState getBlockAt(GeyserSession session, int x, int y, int z);
|
||||
}
|
|
@ -23,7 +23,7 @@
|
|||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.block;
|
||||
package org.geysermc.connector.network.translators.world.block;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
|
@ -23,7 +23,7 @@
|
|||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.block;
|
||||
package org.geysermc.connector.network.translators.world.block;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
|
@ -47,7 +47,7 @@ import it.unimi.dsi.fastutil.ints.IntSet;
|
|||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.network.translators.block.entity.BlockEntity;
|
||||
import org.geysermc.connector.network.translators.world.block.entity.BlockEntity;
|
||||
import org.geysermc.connector.utils.Toolbox;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class BlockTranslator {
|
|||
addedStatesMap.defaultReturnValue(-1);
|
||||
List<CompoundTag> paletteList = new ArrayList<>();
|
||||
|
||||
Reflections ref = new Reflections("org.geysermc.connector.network.translators.block.entity");
|
||||
Reflections ref = new Reflections("org.geysermc.connector.network.translators.world.block.entity");
|
||||
ref.getTypesAnnotatedWith(BlockEntity.class);
|
||||
|
||||
int waterRuntimeId = -1;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
||||
|
|
@ -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;
|
|
@ -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<Tag<?>> translateTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag tag, BlockState blockState) {
|
||||
List<Tag<?>> 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<Tag<?>> translateTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag tag, BlockState blockState) {
|
||||
List<Tag<?>> 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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
||||
|
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
|
|
@ -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;
|
|
@ -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;
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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/.
|
||||
|
|
Loading…
Reference in a new issue