mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-19 14:59:27 +00:00
Address some "reviews"
This commit is contained in:
@@ -29,6 +29,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
@@ -92,8 +93,9 @@ public final class ConfigLoader {
|
||||
public ConfigLoader createFolder() {
|
||||
Path dataFolder = this.bootstrap.getConfigFolder();
|
||||
if (!dataFolder.toFile().exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
dataFolder.toFile().mkdir();
|
||||
if (!dataFolder.toFile().mkdir()) {
|
||||
GeyserImpl.getInstance().getLogger().warning("Failed to create config folder: " + dataFolder);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ public interface GeyserConfig {
|
||||
The IP address that Geyser will bind on to listen for incoming Bedrock connections.
|
||||
Generally, you should only change this if you want to limit what IPs can connect to your server.""")
|
||||
@NonNull
|
||||
@Override
|
||||
@DefaultString("0.0.0.0")
|
||||
@AsteriskSerializer.Asterisk
|
||||
String address();
|
||||
@@ -136,6 +137,7 @@ public interface GeyserConfig {
|
||||
@Comment("""
|
||||
The port that will Geyser will listen on for incoming Bedrock connections.
|
||||
Since Minecraft: Bedrock Edition uses UDP, this port must allow UDP traffic.""")
|
||||
@Override
|
||||
@DefaultNumeric(19132)
|
||||
@NumericRange(from = 0, to = 65535)
|
||||
int port();
|
||||
@@ -184,6 +186,7 @@ public interface GeyserConfig {
|
||||
What type of authentication Bedrock players will be checked against when logging into the Java server.
|
||||
Can be "floodgate" (see https://wiki.geysermc.org/floodgate/), "online", or "offline".""")
|
||||
@NonNull
|
||||
@Override
|
||||
default AuthType authType() {
|
||||
return AuthType.ONLINE;
|
||||
}
|
||||
@@ -191,16 +194,19 @@ public interface GeyserConfig {
|
||||
void authType(AuthType authType);
|
||||
boolean forwardHostname();
|
||||
|
||||
@Override
|
||||
@Exclude
|
||||
default String minecraftVersion() {
|
||||
return GameProtocol.getJavaMinecraftVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Exclude
|
||||
default int protocolVersion() {
|
||||
return GameProtocol.getJavaProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Exclude
|
||||
default boolean resolveSrv() {
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
package org.geysermc.geyser.event.type;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineResourcePacksEvent;
|
||||
@@ -42,7 +41,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePacksEvent implements GeyserIntegratedPackUtil {
|
||||
private final Map<UUID, ResourcePackHolder> packs;
|
||||
|
||||
@@ -126,4 +124,9 @@ public class GeyserDefineResourcePacksEventImpl extends GeyserDefineResourcePack
|
||||
|
||||
holder.optionHolder().validateAndAdd(holder.pack(), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, ResourcePackHolder> getPacks() {
|
||||
return packs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package org.geysermc.geyser.event.type;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.ResourcePackStackPacket;
|
||||
@@ -62,7 +61,6 @@ public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksE
|
||||
* The packs for this Session. A {@link ResourcePackHolder} may contain resource pack options registered
|
||||
* during the {@link org.geysermc.geyser.api.event.lifecycle.GeyserDefineResourcePacksEvent}.
|
||||
*/
|
||||
@Getter
|
||||
private final Map<UUID, ResourcePackHolder> packs;
|
||||
|
||||
/**
|
||||
@@ -252,4 +250,9 @@ public class SessionLoadResourcePacksEventImpl extends SessionLoadResourcePacksE
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, ResourcePackHolder> getPacks() {
|
||||
return packs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ import java.io.InputStreamReader;
|
||||
public abstract class EffectRegistryLoader<T> implements RegistryLoader<String, T> {
|
||||
|
||||
public JsonObject loadFile(String input) {
|
||||
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResourceOrThrow(input)) {
|
||||
return new JsonParser().parse(new InputStreamReader(stream)).getAsJsonObject();
|
||||
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResourceOrThrow(input);
|
||||
InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
//noinspection deprecation
|
||||
return new JsonParser().parse(reader).getAsJsonObject();
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError("Unable to load registrations for " + input, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,10 @@ public class SoundRegistryLoader implements RegistryLoader<String, Map<String, S
|
||||
@Override
|
||||
public Map<String, SoundMapping> load(String input) {
|
||||
JsonObject soundsJson;
|
||||
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResourceOrThrow(input)) {
|
||||
soundsJson = new JsonParser().parse(new InputStreamReader(stream)).getAsJsonObject();
|
||||
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResourceOrThrow(input);
|
||||
InputStreamReader isr = new InputStreamReader(stream)) {
|
||||
//noinspection deprecation
|
||||
soundsJson = new JsonParser().parse(isr).getAsJsonObject();
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError("Unable to load sound mappings", e);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,9 @@ public class WebUtils {
|
||||
con.setConnectTimeout(10000);
|
||||
con.setReadTimeout(10000);
|
||||
checkResponseCode(con);
|
||||
try (JsonReader reader = GeyserImpl.GSON.newJsonReader(new InputStreamReader(con.getInputStream()))) {
|
||||
try (InputStreamReader isr = new InputStreamReader(con.getInputStream());
|
||||
JsonReader reader = GeyserImpl.GSON.newJsonReader(isr)) {
|
||||
//noinspection deprecation
|
||||
return new JsonParser().parse(reader).getAsJsonObject();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user