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