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:
RednedEpic 2020-04-29 15:01:53 -05:00
parent efcf739973
commit 31be608038
74 changed files with 873 additions and 598 deletions

View file

@ -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>

View file

@ -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;
}

View file

@ -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

View file

@ -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;

View file

@ -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);